App.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. // #ifdef APP-PLUS
  35. // let isOpenLocation= permision.checkSystemEnableLocation()
  36. // console.log("isOpenLocation",isOpenLocation)
  37. // this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
  38. let type = uni.getSystemInfoSync().platform
  39. console.log(type)
  40. if (type == "android") {
  41. // appUpdate()
  42. }
  43. var that = this
  44. // plus.push.getClientInfoAsync((info) => {
  45. // var name = 'clientId'
  46. // var value = info.clientid
  47. // that.$store.commit('$uStore', {
  48. // name,
  49. // value
  50. // });
  51. // uni.setStorageSync("clientId", info.clientid)
  52. // console.log("info.clientid", info.clientid)
  53. // }, err => {});
  54. // 监听在线消息事件
  55. plus.push.addEventListener("receive", function(msg) {
  56. var title = msg.content.split(':')[0]
  57. var content = msg.content.split(':')[1]
  58. let params = {
  59. inApp: true, // app内横幅提醒
  60. voice: true, // 声音提醒
  61. vibration: true, // 振动提醒
  62. messageType: "",
  63. messageTitle: title,
  64. messageContent: content,
  65. messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  66. }
  67. console.log("msg", msg)
  68. new app_push({
  69. ...params
  70. }).show();
  71. var userInfo = uni.getStorageSync("userInfo")
  72. var that = this
  73. that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  74. if (res.data.data) {
  75. let name = 'myTip';
  76. let value = res.data.data.task;
  77. that.$store.commit('$uStore', {
  78. name,
  79. value
  80. });
  81. if (value != 0 && value) {
  82. uni.setTabBarBadge({
  83. index: 4,
  84. text: value + ""
  85. })
  86. }
  87. name = 'taskTip';
  88. value = res.data.data.task;
  89. that.$store.commit('$uStore', {
  90. name,
  91. value
  92. });
  93. // name = 'contractTip';
  94. // value = res.data.data.contractTip;
  95. // that.$store.commit('$uStore', {
  96. // name,
  97. // value
  98. // });
  99. }
  100. })
  101. //其它逻辑
  102. }, false);
  103. //监听系统通知栏消息点击事件
  104. plus.push.addEventListener('click', function(msg) {
  105. //处理点击消息的业务逻辑代码
  106. if (msg.content && msg.content.contains("任务")) {
  107. uni.navigateTo({
  108. url: '/pages/task/my_task'
  109. })
  110. } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  111. uni.navigateTo({
  112. url: '/pageB/contract/contract'
  113. })
  114. }
  115. }, false);
  116. // #endif
  117. this.$socket.initWebIM(this.$ws, true, true)
  118. let userInfo = uni.getStorageSync('userInfo') || '';
  119. if (userInfo.id) {
  120. //更新登陆状态
  121. uni.getStorage({
  122. key: 'userInfo',
  123. success: (res) => {
  124. this.login(res.data);
  125. }
  126. });
  127. }
  128. },
  129. onShow: function() {
  130. console.log('App Show')
  131. },
  132. onHide: function() {
  133. console.log('App Hide')
  134. },
  135. }
  136. </script>
  137. <style>
  138. /*每个页面公共css */
  139. </style>