App.vue 4.3 KB

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