App.vue 11 KB

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