App.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. //插件对象
  16. var sdkwx = uni.requireNativePlugin('Hdgq-LocSdkWX');
  17. export default {
  18. data() {
  19. return {
  20. shippingNoteInfos: [{
  21. shippingNoteNumber: '',
  22. serialNumber: "",
  23. startCountrySubdivisionCode: "",
  24. endCountrySubdivisionCode: "",
  25. startLongitude: "",
  26. startLatitude: "",
  27. endLongitude: "",
  28. endLatitude: "",
  29. startLocationText: "",
  30. endLocationText: "",
  31. vehicleNumber: "",
  32. driverName: "",
  33. interval: "",
  34. }],
  35. }},
  36. methods: {
  37. ...mapMutations(['login',"firstAuthentication"]),
  38. // vue的method里编写如下代码
  39. // async requestAndroidPermission(permisionID) {
  40. // var result = await permision.requestAndroidPermission(permisionID)
  41. // var strStatus
  42. // if (result == 1) {
  43. // strStatus = "已获得授权"
  44. // } else if (result == 0) {
  45. // strStatus = "未获得授权"
  46. // // permision.gotoAppPermissionSetting()
  47. // // 引导设置,判断是否有运输中订单,有订单,必须授权
  48. // } else {
  49. // strStatus = "被永久拒绝权限"
  50. // // permision.gotoAppPermissionSetting()
  51. // }
  52. // },
  53. send(_obj){//发送定位
  54. var remark = ""
  55. var that = this
  56. console.log("send参数",this.shippingNoteInfos)
  57. sdkwx.send(this.shippingNoteInfos[0].vehicleNumber, this.shippingNoteInfos[0].driverName,remark, this.shippingNoteInfos, function(res){
  58. console.log(res)
  59. if (res.type == "onSuccess") {
  60. console.log("App.vue发送定位成功")
  61. console.log(res);
  62. //成功
  63. var shippingNoteInfos = res.data;//运单信息列表
  64. if(shippingNoteInfos&&shippingNoteInfos.length >0 ){
  65. that.timer = setInterval(() => {
  66. //TODO
  67. that.send()
  68. }, shippingNoteInfos[0].interval+1000);
  69. }
  70. } else if (res.type == "onFailure"){
  71. console.log("App.vue发送定位失败",res)
  72. //失败
  73. var errorCode = res.data.errorCode;//错误码
  74. var errorMsg = res.data.errorMsg;//错误描述
  75. }
  76. });
  77. },
  78. },
  79. onLaunch: function() {
  80. var that = this
  81. // #ifdef APP-PLUS
  82. // this.$tabbarView.init()
  83. // uni.getNetworkType({
  84. // success: function (res) {
  85. // if(res.networkType=='none'){
  86. // let options = {
  87. // title: '提示',
  88. // info:'当前没有网络中',
  89. // okText: '连接Wifi',
  90. // cancelText:'开启流量',
  91. // infoAlignment:'center',
  92. // radius:10,
  93. // // cancelText: '否',
  94. // // showCancel:false,
  95. // okButtonColor:'#2772FB'
  96. // };
  97. // const native = uni.requireNativePlugin('AJ-Alert');
  98. // native.showAction(options, result => {
  99. // // #ifdef APP-PLUS
  100. // if (uni.getSystemInfoSync().platform == 'ios') {
  101. // plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  102. // } else if (uni.getSystemInfoSync().platform == 'android') {
  103. // plus.runtime.quit();
  104. // }
  105. // // #endif
  106. // // 点击是的回调, result暂时没有返回内容
  107. // }, cancel => {
  108. // // 点击否的回调
  109. // });
  110. // }
  111. // console.log(res.networkType);
  112. // }
  113. // });
  114. console.log(uni.getStorageSync('userInfo'))
  115. if(uni.getStorageSync('userInfo')){
  116. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  117. driverPhone:uni.getStorageSync('userInfo').phone,
  118. }).then(res => {
  119. if (res.data.authenticationStatus == '已禁用') {
  120. // this.isShowAlert = true
  121. // this.alertTitle = '账号审核中'
  122. // this.confirmText = '退出APP'
  123. // this.showCancelButton = false
  124. let options = {
  125. title: '提示',
  126. info:'账号审核中',
  127. okText: '退出程序',
  128. infoAlignment:'center',
  129. radius:10,
  130. // cancelText: '否',
  131. showCancel:false,
  132. okButtonColor:'#2772FB'
  133. };
  134. const native = uni.requireNativePlugin('AJ-Alert');
  135. native.showAction(options, result => {
  136. // #ifdef APP-PLUS
  137. if (uni.getSystemInfoSync().platform == 'ios') {
  138. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  139. } else if (uni.getSystemInfoSync().platform == 'android') {
  140. plus.runtime.quit();
  141. }
  142. // #endif
  143. // 点击是的回调, result暂时没有返回内容
  144. }, cancel => {
  145. // 点击否的回调
  146. });
  147. // uni.showModal({
  148. // title: '提示',
  149. // content: '这是一个模态弹窗',
  150. // showCancel:false,
  151. // confirmText:'退出app',
  152. // // confirmColor:'#317AFE',
  153. // confirmColor:'#F54E40',
  154. // success: function (res) {
  155. // if (res.confirm) {
  156. // // #ifdef APP-PLUS
  157. // if (uni.getSystemInfoSync().platform == 'ios') {
  158. // plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  159. // } else if (uni.getSystemInfoSync().platform == 'android') {
  160. // plus.runtime.quit();
  161. // }
  162. // // #endif
  163. // } else if (res.cancel) {
  164. // console.log('用户点击取消');
  165. // }
  166. // }
  167. // });
  168. } else {
  169. console.log(1231233212332312312213)
  170. }
  171. })
  172. }
  173. // #endif
  174. uni.setStorageSync("region", region);
  175. uni.getSystemInfo({
  176. success:function(e){
  177. Vue.prototype.statusBar = e.statusBarHeight
  178. // #ifndef MP
  179. if(e.platform == 'android') {
  180. Vue.prototype.customBar = e.statusBarHeight + 50
  181. }else {
  182. Vue.prototype.customBar = e.statusBarHeight + 45
  183. }
  184. // #endif
  185. // #ifdef MP-WEIXIN
  186. let custom = wx.getMenuButtonBoundingClientRect()
  187. Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
  188. // #endif
  189. // #ifdef MP-ALIPAY
  190. Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
  191. // #endif
  192. }
  193. })
  194. // #ifdef APP-PLUS
  195. var that=this
  196. //判断该用户是否需要开启持续定位
  197. if(uni.getStorageSync('userInfo')){
  198. this.$request.baseRequest('get', '/orderInfo/getData', {
  199. commonId:uni.getStorageSync('userInfo').id,
  200. }).then(res1 => {
  201. console.log("/orderInfo/getData",res1.data)
  202. this.shippingNoteInfos[0].shippingNoteNumber = res1.data[0].orderNo //运单号
  203. this.shippingNoteInfos[0].serialNumber = "0000" //分单号
  204. this.shippingNoteInfos[0].startCountrySubdivisionCode = res1.data[0].sendAdCode //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  205. this.shippingNoteInfos[0].endCountrySubdivisionCode = res1.data[0].unsendAdCode //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  206. this.shippingNoteInfos[0].startLongitude = res1.data[0].sendLongitude //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  207. this.shippingNoteInfos[0].startLatitude = res1.data[0].sendLatitude //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  208. this.shippingNoteInfos[0].endLongitude = res1.data[0].unsendLongitude //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  209. this.shippingNoteInfos[0].endLatitude = res1.data[0].unsendLatitude //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  210. this.shippingNoteInfos[0].driverName = res1.data[0].driverName //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  211. this.shippingNoteInfos[0].vehicleNumber = res1.data[0].carNumber //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  212. this.shippingNoteInfos[0].startLocationText = res1.data[0].sendCity //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  213. this.shippingNoteInfos[0].endLocationText = res1.data[0].unloadCity //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  214. this.shippingNoteInfos[0].interval = "5000"
  215. // for(let i = 0; i < res1.data.length ; i++){
  216. // this.shippingNoteInfos[i].push({'shippingNoteNumber':res1.data[i].orderNo})
  217. // this.shippingNoteInfos[i].push({'serialNumber':"0000"})
  218. // this.shippingNoteInfos[i].push({'interval':'5000'})
  219. // // this.shippingNoteInfos[i].shippingNoteNumber = res1.data[i].orderNo,
  220. // // this.shippingNoteInfos[i].serialNumber = "0000", //分单号
  221. // // this.shippingNoteInfos[i].startCountrySubdivisionCode = this.detailData.publishTaskInfo.sendAdCode, //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  222. // // this.shippingNoteInfos[i].endCountrySubdivisionCode = this.detailData.publishTaskInfo.unsendAdCode, //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  223. // // this.shippingNoteInfos[i].startLongitude = this.detailData.loadingLatitude, //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  224. // // this.shippingNoteInfos[i].startLatitude = this.detailData.loadingLatitude, //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  225. // // this.shippingNoteInfos[i].endLongitude = this.detailData.publishTaskInfo.unsendLongitude, //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  226. // // this.shippingNoteInfos[i].endLatitude = this.detailData.publishTaskInfo.unsendLatitude, //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  227. // // this.shippingNoteInfos[i].startLocationText = res1.data.sendCity, //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  228. // // this.shippingNoteInfos[i].endLocationText = res1.data.unloadCity, //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  229. // // this.shippingNoteInfos[i].vehicleNumber = res1.data.carNumber, //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  230. // // this.shippingNoteInfos[i].driverName = res.data.driverName, //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  231. // // this.shippingNoteInfos[i].interval = "5000" //请求时间间隔,SDK 回调返 回(单位 ms)
  232. // }
  233. console.log("查看参数",this.shippingNoteInfos)
  234. that.send(res1.data)
  235. if(res1.data.length>0){
  236. that.$helper.fUN_AmapLocation.start({
  237. // intervalTime: 1000 * 60,
  238. intervalTime: 5000,
  239. // locationCacheEnable:true,
  240. isReport: false
  241. // url: 'http://192.168.0.66/fun/open/test_json.do',
  242. // params: {
  243. // a: 1,
  244. // B: '测试',
  245. // c: true
  246. // },
  247. // headers: {
  248. // a: '123',
  249. // B: 'abcd'
  250. // }
  251. },
  252. res => {
  253. // console.log('====确认装车开启连续定位====');
  254. // console.log(res)
  255. let _data = {
  256. orderId: res1.data[0].id,
  257. longitude: res.longitude,
  258. latitude: res.latitude,
  259. province: res.province,
  260. city: res.city,
  261. area: res.district
  262. }
  263. this.$helper.gjList.push(_data)
  264. uni.setStorageSync('mapGJ', this.$helper.gjList);
  265. // console.log('this.$helper.gjList')
  266. // console.log(this.$helper.gjList)
  267. // console.log("条数", uni.getStorageSync('mapGJ').length)
  268. if (uni.getStorageSync('mapGJ').length > 100) {
  269. console.log(JSON.stringify(uni.getStorageSync('mapGJ')))
  270. this.$request.baseRequest('post', '/hyOrderTravelPath/api/addInfo', {
  271. orderId:"cdae6ec34c2349768c490a9fefa03fb3",
  272. longitudeLatitude:JSON.stringify(uni.getStorageSync('mapGJ'))
  273. }).then(res => {
  274. uni.removeStorageSync('mapGJ');
  275. this.$helper.gjList = []
  276. })
  277. .catch(res => {
  278. uni.$u.toast(res.message);
  279. });
  280. }
  281. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  282. }
  283. );
  284. }
  285. })
  286. }
  287. // this.$helper.fUN_AmapLocation.stop({}, result => {
  288. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  289. // this.$helper.fUN_AmapLocation.start(
  290. // {
  291. // intervalTime: 1000*60,
  292. // isReport: true,
  293. // reportInterval: 5,
  294. // url: 'http://192.168.0.66/fun/open/test_json.do',
  295. // params: { a: 1, B: '测试', c: true },
  296. // headers: { a: '123', B: 'abcd' }
  297. // },
  298. // res => {
  299. // //见下方定位返回示例
  300. // console.log('====确认装车开启连续定位====', JSON.stringify(res));
  301. // //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  302. // }
  303. // );
  304. // });
  305. // fUN_AmapLocation.permission({}, result => {
  306. // console.log('====fUN_AmapLocation定位====');
  307. // });
  308. // fUN_AmapLocation.hasLocationPermissions(function(result) {
  309. // console.log('====fUN_AmapLocation定位权限===='+ result)
  310. // });
  311. // startLocation与start均可
  312. // this.$helper.fUN_AmapLocation.start(
  313. // {
  314. // intervalTime: 1000*10,
  315. // isReport: false,
  316. // },
  317. // result => {
  318. // //见下方定位返回示例
  319. // console.log('====fUN_AmapLocation定位====', JSON.stringify(result));
  320. // }
  321. // );
  322. // let isOpenLocation= permision.checkSystemEnableLocation()
  323. // console.log("isOpenLocation",isOpenLocation)
  324. // this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  325. let type = uni.getSystemInfoSync().platform
  326. console.log(type)
  327. if (type == "android") {
  328. appUpdate()
  329. }
  330. // plus.push.getClientInfoAsync((info) => {
  331. // var name = 'clientId'
  332. // var value = info.clientid
  333. // that.$store.commit('$uStore', {
  334. // name,
  335. // value
  336. // });
  337. // uni.setStorageSync("clientId", info.clientid)
  338. // console.log("info.clientid", info.clientid)
  339. // }, err => {});
  340. // 监听在线消息事件
  341. // plus.push.addEventListener("receive", function(msg) {
  342. // var title = msg.content.split(':')[0]
  343. // var content = msg.content.split(':')[1]
  344. // let params = {
  345. // inApp: true, // app内横幅提醒
  346. // voice: true, // 声音提醒
  347. // vibration: true, // 振动提醒
  348. // messageType: "",
  349. // messageTitle: title,
  350. // messageContent: content,
  351. // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  352. // }
  353. // console.log("msg", msg)
  354. // new app_push({
  355. // ...params
  356. // }).show();
  357. // var userInfo = uni.getStorageSync("userInfo")
  358. // var that = this
  359. // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  360. // if (res.data.data) {
  361. // let name = 'myTip';
  362. // let value = res.data.data.task;
  363. // that.$store.commit('$uStore', {
  364. // name,
  365. // value
  366. // });
  367. // if (value != 0 && value) {
  368. // uni.setTabBarBadge({
  369. // index: 4,
  370. // text: value + ""
  371. // })
  372. // }
  373. // name = 'taskTip';
  374. // value = res.data.data.task;
  375. // that.$store.commit('$uStore', {
  376. // name,
  377. // value
  378. // });
  379. // // name = 'contractTip';
  380. // // value = res.data.data.contractTip;
  381. // // that.$store.commit('$uStore', {
  382. // // name,
  383. // // value
  384. // // });
  385. // }
  386. // })
  387. // //其它逻辑
  388. // }, false);
  389. // //监听系统通知栏消息点击事件
  390. // plus.push.addEventListener('click', function(msg) {
  391. // //处理点击消息的业务逻辑代码
  392. // if (msg.content && msg.content.contains("任务")) {
  393. // uni.navigateTo({
  394. // url: '/pages/task/my_task'
  395. // })
  396. // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  397. // uni.navigateTo({
  398. // url: '/pageB/contract/contract'
  399. // })
  400. // }
  401. // }, false);
  402. // #endif
  403. // this.$socket.initWebIM(this.$ws, true, true)
  404. let userInfo = uni.getStorageSync('userInfo') || '';
  405. if (userInfo.id) {
  406. //更新登陆状态
  407. uni.getStorage({
  408. key: 'userInfo',
  409. success: (res) => {
  410. this.login(res.data);
  411. }
  412. });
  413. }
  414. },
  415. onShow: function() {
  416. console.log('App Show')
  417. },
  418. onHide: function() {
  419. console.log('App Hide')
  420. },
  421. }
  422. </script>
  423. <style>
  424. /*每个页面公共css */
  425. </style>