App.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. uni.setStorageSync("region", region);
  36. uni.getSystemInfo({
  37. success:function(e){
  38. Vue.prototype.statusBar = e.statusBarHeight
  39. // #ifndef MP
  40. if(e.platform == 'android') {
  41. Vue.prototype.customBar = e.statusBarHeight + 50
  42. }else {
  43. Vue.prototype.customBar = e.statusBarHeight + 45
  44. }
  45. // #endif
  46. // #ifdef MP-WEIXIN
  47. let custom = wx.getMenuButtonBoundingClientRect()
  48. Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
  49. // #endif
  50. // #ifdef MP-ALIPAY
  51. Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
  52. // #endif
  53. }
  54. })
  55. // #ifdef APP-PLUS
  56. var that = this
  57. //判断该用户是否需要开启持续定位
  58. this.$helper.fUN_AmapLocation.stop({}, result => {
  59. console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  60. this.$helper.fUN_AmapLocation.start(
  61. {
  62. intervalTime: 1000*60,
  63. isReport: true,
  64. reportInterval: 5,
  65. url: 'http://192.168.0.66/fun/open/test_json.do',
  66. params: { a: 1, B: '测试', c: true },
  67. headers: { a: '123', B: 'abcd' }
  68. },
  69. res => {
  70. //见下方定位返回示例
  71. console.log('====确认装车开启连续定位====', JSON.stringify(res));
  72. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  73. }
  74. );
  75. });
  76. // fUN_AmapLocation.permission({}, result => {
  77. // console.log('====fUN_AmapLocation定位====');
  78. // });
  79. // fUN_AmapLocation.hasLocationPermissions(function(result) {
  80. // console.log('====fUN_AmapLocation定位权限===='+ result)
  81. // });
  82. // startLocation与start均可
  83. // this.$helper.fUN_AmapLocation.start(
  84. // {
  85. // intervalTime: 1000*10,
  86. // isReport: false,
  87. // },
  88. // result => {
  89. // //见下方定位返回示例
  90. // console.log('====fUN_AmapLocation定位====', JSON.stringify(result));
  91. // }
  92. // );
  93. // let isOpenLocation= permision.checkSystemEnableLocation()
  94. // console.log("isOpenLocation",isOpenLocation)
  95. // this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  96. let type = uni.getSystemInfoSync().platform
  97. console.log(type)
  98. if (type == "android") {
  99. appUpdate()
  100. }
  101. // plus.push.getClientInfoAsync((info) => {
  102. // var name = 'clientId'
  103. // var value = info.clientid
  104. // that.$store.commit('$uStore', {
  105. // name,
  106. // value
  107. // });
  108. // uni.setStorageSync("clientId", info.clientid)
  109. // console.log("info.clientid", info.clientid)
  110. // }, err => {});
  111. // 监听在线消息事件
  112. // plus.push.addEventListener("receive", function(msg) {
  113. // var title = msg.content.split(':')[0]
  114. // var content = msg.content.split(':')[1]
  115. // let params = {
  116. // inApp: true, // app内横幅提醒
  117. // voice: true, // 声音提醒
  118. // vibration: true, // 振动提醒
  119. // messageType: "",
  120. // messageTitle: title,
  121. // messageContent: content,
  122. // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  123. // }
  124. // console.log("msg", msg)
  125. // new app_push({
  126. // ...params
  127. // }).show();
  128. // var userInfo = uni.getStorageSync("userInfo")
  129. // var that = this
  130. // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  131. // if (res.data.data) {
  132. // let name = 'myTip';
  133. // let value = res.data.data.task;
  134. // that.$store.commit('$uStore', {
  135. // name,
  136. // value
  137. // });
  138. // if (value != 0 && value) {
  139. // uni.setTabBarBadge({
  140. // index: 4,
  141. // text: value + ""
  142. // })
  143. // }
  144. // name = 'taskTip';
  145. // value = res.data.data.task;
  146. // that.$store.commit('$uStore', {
  147. // name,
  148. // value
  149. // });
  150. // // name = 'contractTip';
  151. // // value = res.data.data.contractTip;
  152. // // that.$store.commit('$uStore', {
  153. // // name,
  154. // // value
  155. // // });
  156. // }
  157. // })
  158. // //其它逻辑
  159. // }, false);
  160. // //监听系统通知栏消息点击事件
  161. // plus.push.addEventListener('click', function(msg) {
  162. // //处理点击消息的业务逻辑代码
  163. // if (msg.content && msg.content.contains("任务")) {
  164. // uni.navigateTo({
  165. // url: '/pages/task/my_task'
  166. // })
  167. // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  168. // uni.navigateTo({
  169. // url: '/pageB/contract/contract'
  170. // })
  171. // }
  172. // }, false);
  173. // #endif
  174. this.$socket.initWebIM(this.$ws, true, true)
  175. let userInfo = uni.getStorageSync('userInfo') || '';
  176. if (userInfo.id) {
  177. //更新登陆状态
  178. uni.getStorage({
  179. key: 'userInfo',
  180. success: (res) => {
  181. this.login(res.data);
  182. }
  183. });
  184. }
  185. },
  186. onShow: function() {
  187. console.log('App Show')
  188. },
  189. onHide: function() {
  190. console.log('App Hide')
  191. },
  192. }
  193. </script>
  194. <style>
  195. /*每个页面公共css */
  196. </style>