App.vue 11 KB

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