App.vue 4.7 KB

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