App.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. // #ifdef APP-PLUS
  36. console.log(uni.getStorageSync('userInfo'))
  37. if(uni.getStorageSync('userInfo')){
  38. that.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', {
  39. phone: uni.getStorageSync('userInfo').phone,
  40. }).then(res => {
  41. if (res.data.authenticationStatus == '已禁用') {
  42. // this.isShowAlert = true
  43. // this.alertTitle = '账号审核中'
  44. // this.confirmText = '退出APP'
  45. // this.showCancelButton = false
  46. let options = {
  47. title: '提示',
  48. info:'账号审核中',
  49. okText: '退出程序',
  50. infoAlignment:'center',
  51. radius:10,
  52. // cancelText: '否',
  53. showCancel:false,
  54. okButtonColor:'#2772FB'
  55. };
  56. const native = uni.requireNativePlugin('AJ-Alert');
  57. native.showAction(options, result => {
  58. // #ifdef APP-PLUS
  59. if (uni.getSystemInfoSync().platform == 'ios') {
  60. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  61. } else if (uni.getSystemInfoSync().platform == 'android') {
  62. plus.runtime.quit();
  63. }
  64. // #endif
  65. // 点击是的回调, result暂时没有返回内容
  66. }, cancel => {
  67. // 点击否的回调
  68. });
  69. // uni.showModal({
  70. // title: '提示',
  71. // content: '这是一个模态弹窗',
  72. // showCancel:false,
  73. // confirmText:'退出app',
  74. // // confirmColor:'#317AFE',
  75. // confirmColor:'#F54E40',
  76. // success: function (res) {
  77. // if (res.confirm) {
  78. // // #ifdef APP-PLUS
  79. // if (uni.getSystemInfoSync().platform == 'ios') {
  80. // plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  81. // } else if (uni.getSystemInfoSync().platform == 'android') {
  82. // plus.runtime.quit();
  83. // }
  84. // // #endif
  85. // } else if (res.cancel) {
  86. // console.log('用户点击取消');
  87. // }
  88. // }
  89. // });
  90. } else {
  91. console.log(1231233212332312312213)
  92. }
  93. })
  94. }
  95. // #endif
  96. uni.setStorageSync("region", region);
  97. uni.getSystemInfo({
  98. success:function(e){
  99. Vue.prototype.statusBar = e.statusBarHeight
  100. // #ifndef MP
  101. if(e.platform == 'android') {
  102. Vue.prototype.customBar = e.statusBarHeight + 50
  103. }else {
  104. Vue.prototype.customBar = e.statusBarHeight + 45
  105. }
  106. // #endif
  107. // #ifdef MP-WEIXIN
  108. let custom = wx.getMenuButtonBoundingClientRect()
  109. Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
  110. // #endif
  111. // #ifdef MP-ALIPAY
  112. Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
  113. // #endif
  114. }
  115. })
  116. // #ifdef APP-PLUS
  117. var that=this
  118. //判断该用户是否需要开启持续定位
  119. if(uni.getStorageSync('userInfo')){
  120. this.$request.baseRequest('get', '/orderInfo/getData', {
  121. commonId:uni.getStorageSync('userInfo').id,
  122. }).then(res1 => {
  123. if(res1.data.length>0){
  124. that.$helper.fUN_AmapLocation.start({
  125. // intervalTime: 1000 * 60,
  126. intervalTime: 5000,
  127. // locationCacheEnable:true,
  128. isReport: false
  129. // url: 'http://192.168.0.66/fun/open/test_json.do',
  130. // params: {
  131. // a: 1,
  132. // B: '测试',
  133. // c: true
  134. // },
  135. // headers: {
  136. // a: '123',
  137. // B: 'abcd'
  138. // }
  139. },
  140. res => {
  141. // console.log('====确认装车开启连续定位====');
  142. // console.log(res)
  143. let _data = {
  144. orderId: res1.data[0].id,
  145. longitude: res.longitude,
  146. latitude: res.latitude,
  147. province: res.province,
  148. city: res.city,
  149. area: res.district
  150. }
  151. this.$helper.gjList.push(_data)
  152. uni.setStorageSync('mapGJ', this.$helper.gjList);
  153. // console.log('this.$helper.gjList')
  154. // console.log(this.$helper.gjList)
  155. // console.log("条数", uni.getStorageSync('mapGJ').length)
  156. if (uni.getStorageSync('mapGJ').length > 100) {
  157. console.log(JSON.stringify(uni.getStorageSync('mapGJ')) )
  158. this.$request.baseRequest('post', '/hyOrderTravelPath/api/addInfo', {
  159. orderId:"cdae6ec34c2349768c490a9fefa03fb3",
  160. longitudeLatitude:JSON.stringify(uni.getStorageSync('mapGJ'))
  161. }).then(res => {
  162. uni.removeStorageSync('mapGJ');
  163. this.$helper.gjList = []
  164. })
  165. .catch(res => {
  166. uni.$u.toast(res.message);
  167. });
  168. }
  169. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  170. }
  171. );
  172. }
  173. })
  174. }
  175. // this.$helper.fUN_AmapLocation.stop({}, result => {
  176. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  177. // this.$helper.fUN_AmapLocation.start(
  178. // {
  179. // intervalTime: 1000*60,
  180. // isReport: true,
  181. // reportInterval: 5,
  182. // url: 'http://192.168.0.66/fun/open/test_json.do',
  183. // params: { a: 1, B: '测试', c: true },
  184. // headers: { a: '123', B: 'abcd' }
  185. // },
  186. // res => {
  187. // //见下方定位返回示例
  188. // console.log('====确认装车开启连续定位====', JSON.stringify(res));
  189. // //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  190. // }
  191. // );
  192. // });
  193. // fUN_AmapLocation.permission({}, result => {
  194. // console.log('====fUN_AmapLocation定位====');
  195. // });
  196. // fUN_AmapLocation.hasLocationPermissions(function(result) {
  197. // console.log('====fUN_AmapLocation定位权限===='+ result)
  198. // });
  199. // startLocation与start均可
  200. // this.$helper.fUN_AmapLocation.start(
  201. // {
  202. // intervalTime: 1000*10,
  203. // isReport: false,
  204. // },
  205. // result => {
  206. // //见下方定位返回示例
  207. // console.log('====fUN_AmapLocation定位====', JSON.stringify(result));
  208. // }
  209. // );
  210. // let isOpenLocation= permision.checkSystemEnableLocation()
  211. // console.log("isOpenLocation",isOpenLocation)
  212. // this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  213. let type = uni.getSystemInfoSync().platform
  214. console.log(type)
  215. if (type == "android") {
  216. appUpdate()
  217. }
  218. // plus.push.getClientInfoAsync((info) => {
  219. // var name = 'clientId'
  220. // var value = info.clientid
  221. // that.$store.commit('$uStore', {
  222. // name,
  223. // value
  224. // });
  225. // uni.setStorageSync("clientId", info.clientid)
  226. // console.log("info.clientid", info.clientid)
  227. // }, err => {});
  228. // 监听在线消息事件
  229. // plus.push.addEventListener("receive", function(msg) {
  230. // var title = msg.content.split(':')[0]
  231. // var content = msg.content.split(':')[1]
  232. // let params = {
  233. // inApp: true, // app内横幅提醒
  234. // voice: true, // 声音提醒
  235. // vibration: true, // 振动提醒
  236. // messageType: "",
  237. // messageTitle: title,
  238. // messageContent: content,
  239. // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  240. // }
  241. // console.log("msg", msg)
  242. // new app_push({
  243. // ...params
  244. // }).show();
  245. // var userInfo = uni.getStorageSync("userInfo")
  246. // var that = this
  247. // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  248. // if (res.data.data) {
  249. // let name = 'myTip';
  250. // let value = res.data.data.task;
  251. // that.$store.commit('$uStore', {
  252. // name,
  253. // value
  254. // });
  255. // if (value != 0 && value) {
  256. // uni.setTabBarBadge({
  257. // index: 4,
  258. // text: value + ""
  259. // })
  260. // }
  261. // name = 'taskTip';
  262. // value = res.data.data.task;
  263. // that.$store.commit('$uStore', {
  264. // name,
  265. // value
  266. // });
  267. // // name = 'contractTip';
  268. // // value = res.data.data.contractTip;
  269. // // that.$store.commit('$uStore', {
  270. // // name,
  271. // // value
  272. // // });
  273. // }
  274. // })
  275. // //其它逻辑
  276. // }, false);
  277. // //监听系统通知栏消息点击事件
  278. // plus.push.addEventListener('click', function(msg) {
  279. // //处理点击消息的业务逻辑代码
  280. // if (msg.content && msg.content.contains("任务")) {
  281. // uni.navigateTo({
  282. // url: '/pages/task/my_task'
  283. // })
  284. // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  285. // uni.navigateTo({
  286. // url: '/pageB/contract/contract'
  287. // })
  288. // }
  289. // }, false);
  290. // #endif
  291. this.$socket.initWebIM(this.$ws, true, true)
  292. let userInfo = uni.getStorageSync('userInfo') || '';
  293. if (userInfo.id) {
  294. //更新登陆状态
  295. uni.getStorage({
  296. key: 'userInfo',
  297. success: (res) => {
  298. this.login(res.data);
  299. }
  300. });
  301. }
  302. },
  303. onShow: function() {
  304. console.log('App Show')
  305. },
  306. onHide: function() {
  307. console.log('App Hide')
  308. },
  309. }
  310. </script>
  311. <style>
  312. /*每个页面公共css */
  313. </style>