App.vue 5.1 KB

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