App.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. mapState
  10. } from 'vuex';
  11. import Vue from 'vue'
  12. import * as config from '@/config'
  13. import permision from "@/js_sdk/wa-permission/permission.js"
  14. import appUpdate from 'common/appUpdate.js'
  15. // import app_push from './components/APPPush/app_push.js'
  16. export default {
  17. methods: {
  18. ...mapMutations(['login']),
  19. },
  20. computed: {
  21. ...mapState(['hasLogin', 'userInfo']),
  22. },
  23. onLaunch: function() {
  24. // plus.android.requestPermissions(['android.permission.CAMERA'], function(e){
  25. // if(e.deniedAlways.length>0){ //权限被永久拒绝
  26. // // 弹出提示框解释为何需要权限,引导用户打开设置页面开启
  27. // console.log('权限被永久拒绝'+e.deniedAlways.toString());
  28. // }
  29. // if(e.deniedPresent.length>0){ //权限被临时拒绝
  30. // // 弹出提示框解释为何需要权限,可再次调用plus.android.requestPermissions申请权限
  31. // console.log('权限被临时拒绝'+e.deniedPresent.toString());
  32. // }
  33. // if(e.granted.length>0){ //权限被允许
  34. // console.log('权限被允许'+e.granted.toString());
  35. // }
  36. // }, function(e){
  37. // console.log('Request Permissions error:'+JSON.stringify(e));
  38. // });
  39. let that = this
  40. // uni.onTabBarMidButtonTap(() => {
  41. // console.log("点击发布")
  42. // if (!that.hasLogin) {
  43. // // uni.$u.route('/pages/public/login');
  44. // uni.navigateTo({
  45. // url: "/pages/public/login",
  46. // animationType: "slide-in-bottom", // 动画类型
  47. // animationDuration: 150, // 窗口动画持续时间,单位为 ms
  48. // fail(err) {
  49. // console.log(err)
  50. // },
  51. // success(res) {
  52. // console.log(res)
  53. // }
  54. // })
  55. // }
  56. // })
  57. uni.getSystemInfo({
  58. success: function(e) {
  59. Vue.prototype.statusBar = e.statusBarHeight
  60. // #ifndef MP
  61. if (e.platform == 'android') {
  62. Vue.prototype.customBar = e.statusBarHeight + 50
  63. } else {
  64. Vue.prototype.customBar = e.statusBarHeight + 45
  65. }
  66. // #endif
  67. // #ifdef MP-WEIXIN
  68. let custom = wx.getMenuButtonBoundingClientRect()
  69. Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
  70. // #endif
  71. // #ifdef MP-ALIPAY
  72. Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
  73. // #endif
  74. }
  75. })
  76. uni.onTabBarMidButtonTap(() => {
  77. uni.navigateTo({
  78. url: '/pages/release/release'
  79. });
  80. })
  81. // #ifdef APP-PLUS
  82. let type = uni.getSystemInfoSync().platform
  83. console.log(type)
  84. if (type == "android") {
  85. console.log(111111111111111111111111111111111111111111111111111)
  86. appUpdate()
  87. }
  88. // var that = this
  89. // plus.push.getClientInfoAsync((info) => {
  90. // var name = 'clientId'
  91. // var value = info.clientid
  92. // that.$store.commit('$uStore', {
  93. // name,
  94. // value
  95. // });
  96. // uni.setStorageSync("clientId", info.clientid)
  97. // console.log("info.clientid", info.clientid)
  98. // }, err => {});
  99. // // 监听在线消息事件
  100. // plus.push.addEventListener("receive", function(msg) {
  101. // var title = msg.content.split(':')[0]
  102. // var content = msg.content.split(':')[1]
  103. // let params = {
  104. // inApp: true, // app内横幅提醒
  105. // voice: true, // 声音提醒
  106. // vibration: true, // 振动提醒
  107. // messageType: "",
  108. // messageTitle: title,
  109. // messageContent: content,
  110. // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  111. // }
  112. // console.log("msg", msg)
  113. // // new app_push({
  114. // // ...params
  115. // // }).show();
  116. // var userInfo = uni.getStorageSync("userInfo")
  117. // var that = this
  118. // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  119. // if (res.data.data) {
  120. // let name = 'myTip';
  121. // let value = res.data.data.task;
  122. // that.$store.commit('$uStore', {
  123. // name,
  124. // value
  125. // });
  126. // if (value != 0 && value) {
  127. // uni.setTabBarBadge({
  128. // index: 4,
  129. // text: value + ""
  130. // })
  131. // }
  132. // name = 'taskTip';
  133. // value = res.data.data.task;
  134. // that.$store.commit('$uStore', {
  135. // name,
  136. // value
  137. // });
  138. // // name = 'contractTip';
  139. // // value = res.data.data.contractTip;
  140. // // that.$store.commit('$uStore', {
  141. // // name,
  142. // // value
  143. // // });
  144. // }
  145. // })
  146. // //其它逻辑
  147. // }, false);
  148. // //监听系统通知栏消息点击事件
  149. // plus.push.addEventListener('click', function(msg) {
  150. // //处理点击消息的业务逻辑代码
  151. // if (msg.content && msg.content.contains("任务")) {
  152. // uni.navigateTo({
  153. // url: '/pages/task/my_task'
  154. // })
  155. // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  156. // uni.navigateTo({
  157. // url: '/pageB/contract/contract'
  158. // })
  159. // }
  160. // }, false);
  161. // #endif
  162. this.$socket.initWebIM(this.$ws, true, true)
  163. let userInfo = uni.getStorageSync('userInfo') || '';
  164. if (userInfo.id) {
  165. //更新登陆状态
  166. uni.getStorage({
  167. key: 'userInfo',
  168. success: (res) => {
  169. this.login(res.data);
  170. }
  171. });
  172. }
  173. },
  174. onShow: function() {
  175. console.log('App Show')
  176. },
  177. onHide: function() {
  178. console.log('App Hide')
  179. },
  180. }
  181. </script>
  182. <style>
  183. /*每个页面公共css */
  184. </style>