App.vue 6.2 KB

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