App.vue 12 KB

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