App.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import "@/uni_modules/uview-ui/index.scss";
  4. @import 'static/css/common.scss';
  5. </style>
  6. <script>
  7. import region from "@/components/region/data";
  8. import {
  9. mapMutations
  10. } from 'vuex';
  11. import * as config from '@/config'
  12. import appUpdate from 'common/appUpdate.js'
  13. import app_push from './components/APPPush/app_push.js'
  14. import permision from "@/js_sdk/wa-permission/permission.js"
  15. export default {
  16. methods: {
  17. ...mapMutations(['login']),
  18. // vue的method里编写如下代码
  19. // async requestAndroidPermission(permisionID) {
  20. // var result = await permision.requestAndroidPermission(permisionID)
  21. // var strStatus
  22. // if (result == 1) {
  23. // strStatus = "已获得授权"
  24. // } else if (result == 0) {
  25. // strStatus = "未获得授权"
  26. // // permision.gotoAppPermissionSetting()
  27. // // 引导设置,判断是否有运输中订单,有订单,必须授权
  28. // } else {
  29. // strStatus = "被永久拒绝权限"
  30. // // permision.gotoAppPermissionSetting()
  31. // }
  32. // },
  33. },
  34. onLaunch: function() {
  35. uni.setStorageSync("region", region);
  36. uni.getSystemInfo({
  37. success:function(e){
  38. Vue.prototype.statusBar = e.statusBarHeight
  39. // #ifndef MP
  40. if(e.platform == 'android') {
  41. Vue.prototype.customBar = e.statusBarHeight + 50
  42. }else {
  43. Vue.prototype.customBar = e.statusBarHeight + 45
  44. }
  45. // #endif
  46. // #ifdef MP-WEIXIN
  47. let custom = wx.getMenuButtonBoundingClientRect()
  48. Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
  49. // #endif
  50. // #ifdef MP-ALIPAY
  51. Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
  52. // #endif
  53. }
  54. })
  55. // #ifdef APP-PLUS
  56. var that=this
  57. //判断该用户是否需要开启持续定位
  58. if(uni.getStorageSync('userInfo')){
  59. this.$request.baseRequest('get', '/orderInfo/getData', {
  60. commonId:uni.getStorageSync('userInfo').id,
  61. }).then(res1 => {
  62. if(res1.data.length>0){
  63. that.$helper.fUN_AmapLocation.start({
  64. // intervalTime: 1000 * 60,
  65. intervalTime: 5000,
  66. // locationCacheEnable:true,
  67. isReport: false
  68. // url: 'http://192.168.0.66/fun/open/test_json.do',
  69. // params: {
  70. // a: 1,
  71. // B: '测试',
  72. // c: true
  73. // },
  74. // headers: {
  75. // a: '123',
  76. // B: 'abcd'
  77. // }
  78. },
  79. res => {
  80. // console.log('====确认装车开启连续定位====');
  81. // console.log(res)
  82. let _data = {
  83. orderId: res1.data[0].id,
  84. longitude: res.longitude,
  85. latitude: res.latitude,
  86. province: res.province,
  87. city: res.city,
  88. area: res.district
  89. }
  90. this.$helper.gjList.push(_data)
  91. uni.setStorageSync('mapGJ', this.$helper.gjList);
  92. // console.log('this.$helper.gjList')
  93. // console.log(this.$helper.gjList)
  94. // console.log("条数", uni.getStorageSync('mapGJ').length)
  95. if (uni.getStorageSync('mapGJ').length > 100) {
  96. console.log(JSON.stringify(uni.getStorageSync('mapGJ')) )
  97. this.$request.baseRequest('post', '/hyOrderTravelPath/api/addInfo', {
  98. orderId:"cdae6ec34c2349768c490a9fefa03fb3",
  99. longitudeLatitude:JSON.stringify(uni.getStorageSync('mapGJ'))
  100. }).then(res => {
  101. uni.removeStorageSync('mapGJ');
  102. this.$helper.gjList = []
  103. })
  104. .catch(res => {
  105. uni.$u.toast(res.message);
  106. });
  107. }
  108. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  109. }
  110. );
  111. }
  112. })
  113. }
  114. // this.$helper.fUN_AmapLocation.stop({}, result => {
  115. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  116. // this.$helper.fUN_AmapLocation.start(
  117. // {
  118. // intervalTime: 1000*60,
  119. // isReport: true,
  120. // reportInterval: 5,
  121. // url: 'http://192.168.0.66/fun/open/test_json.do',
  122. // params: { a: 1, B: '测试', c: true },
  123. // headers: { a: '123', B: 'abcd' }
  124. // },
  125. // res => {
  126. // //见下方定位返回示例
  127. // console.log('====确认装车开启连续定位====', JSON.stringify(res));
  128. // //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  129. // }
  130. // );
  131. // });
  132. // fUN_AmapLocation.permission({}, result => {
  133. // console.log('====fUN_AmapLocation定位====');
  134. // });
  135. // fUN_AmapLocation.hasLocationPermissions(function(result) {
  136. // console.log('====fUN_AmapLocation定位权限===='+ result)
  137. // });
  138. // startLocation与start均可
  139. // this.$helper.fUN_AmapLocation.start(
  140. // {
  141. // intervalTime: 1000*10,
  142. // isReport: false,
  143. // },
  144. // result => {
  145. // //见下方定位返回示例
  146. // console.log('====fUN_AmapLocation定位====', JSON.stringify(result));
  147. // }
  148. // );
  149. // let isOpenLocation= permision.checkSystemEnableLocation()
  150. // console.log("isOpenLocation",isOpenLocation)
  151. // this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  152. let type = uni.getSystemInfoSync().platform
  153. console.log(type)
  154. if (type == "android") {
  155. appUpdate()
  156. }
  157. // plus.push.getClientInfoAsync((info) => {
  158. // var name = 'clientId'
  159. // var value = info.clientid
  160. // that.$store.commit('$uStore', {
  161. // name,
  162. // value
  163. // });
  164. // uni.setStorageSync("clientId", info.clientid)
  165. // console.log("info.clientid", info.clientid)
  166. // }, err => {});
  167. // 监听在线消息事件
  168. // plus.push.addEventListener("receive", function(msg) {
  169. // var title = msg.content.split(':')[0]
  170. // var content = msg.content.split(':')[1]
  171. // let params = {
  172. // inApp: true, // app内横幅提醒
  173. // voice: true, // 声音提醒
  174. // vibration: true, // 振动提醒
  175. // messageType: "",
  176. // messageTitle: title,
  177. // messageContent: content,
  178. // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  179. // }
  180. // console.log("msg", msg)
  181. // new app_push({
  182. // ...params
  183. // }).show();
  184. // var userInfo = uni.getStorageSync("userInfo")
  185. // var that = this
  186. // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  187. // if (res.data.data) {
  188. // let name = 'myTip';
  189. // let value = res.data.data.task;
  190. // that.$store.commit('$uStore', {
  191. // name,
  192. // value
  193. // });
  194. // if (value != 0 && value) {
  195. // uni.setTabBarBadge({
  196. // index: 4,
  197. // text: value + ""
  198. // })
  199. // }
  200. // name = 'taskTip';
  201. // value = res.data.data.task;
  202. // that.$store.commit('$uStore', {
  203. // name,
  204. // value
  205. // });
  206. // // name = 'contractTip';
  207. // // value = res.data.data.contractTip;
  208. // // that.$store.commit('$uStore', {
  209. // // name,
  210. // // value
  211. // // });
  212. // }
  213. // })
  214. // //其它逻辑
  215. // }, false);
  216. // //监听系统通知栏消息点击事件
  217. // plus.push.addEventListener('click', function(msg) {
  218. // //处理点击消息的业务逻辑代码
  219. // if (msg.content && msg.content.contains("任务")) {
  220. // uni.navigateTo({
  221. // url: '/pages/task/my_task'
  222. // })
  223. // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  224. // uni.navigateTo({
  225. // url: '/pageB/contract/contract'
  226. // })
  227. // }
  228. // }, false);
  229. // #endif
  230. this.$socket.initWebIM(this.$ws, true, true)
  231. let userInfo = uni.getStorageSync('userInfo') || '';
  232. if (userInfo.id) {
  233. //更新登陆状态
  234. uni.getStorage({
  235. key: 'userInfo',
  236. success: (res) => {
  237. this.login(res.data);
  238. }
  239. });
  240. }
  241. },
  242. onShow: function() {
  243. console.log('App Show')
  244. },
  245. onHide: function() {
  246. console.log('App Hide')
  247. },
  248. }
  249. </script>
  250. <style>
  251. /*每个页面公共css */
  252. </style>