App.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import "@/uni_modules/uview-ui/index.scss";
  4. @import 'static/css/common.scss';
  5. uni-modal {
  6. .uni-modal {
  7. border-radius:30px;
  8. font-size:20rpx;
  9. }
  10. }
  11. </style>
  12. <script>
  13. import {
  14. mapMutations,
  15. mapState
  16. } from 'vuex';
  17. import Vue from 'vue'
  18. import * as config from '@/config'
  19. import permision from "@/js_sdk/wa-permission/permission.js"
  20. import appUpdate from 'common/appUpdate.js'
  21. // import app_push from './components/APPPush/app_push.js'
  22. export default {
  23. methods: {
  24. ...mapMutations(['login']),
  25. },
  26. computed: {
  27. ...mapState(['hasLogin', 'userInfo']),
  28. },
  29. onLaunch: function() {
  30. // plus.android.requestPermissions(['android.permission.CAMERA'], function(e){
  31. // if(e.deniedAlways.length>0){ //权限被永久拒绝
  32. // // 弹出提示框解释为何需要权限,引导用户打开设置页面开启
  33. // console.log('权限被永久拒绝'+e.deniedAlways.toString());
  34. // }
  35. // if(e.deniedPresent.length>0){ //权限被临时拒绝
  36. // // 弹出提示框解释为何需要权限,可再次调用plus.android.requestPermissions申请权限
  37. // console.log('权限被临时拒绝'+e.deniedPresent.toString());
  38. // }
  39. // if(e.granted.length>0){ //权限被允许
  40. // console.log('权限被允许'+e.granted.toString());
  41. // }
  42. // }, function(e){
  43. // console.log('Request Permissions error:'+JSON.stringify(e));
  44. // });
  45. let that = this
  46. // uni.onTabBarMidButtonTap(() => {
  47. // console.log("点击发布")
  48. // if (!that.hasLogin) {
  49. // // uni.$u.route('/pages/public/login');
  50. // uni.navigateTo({
  51. // url: "/pages/public/login",
  52. // animationType: "slide-in-bottom", // 动画类型
  53. // animationDuration: 150, // 窗口动画持续时间,单位为 ms
  54. // fail(err) {
  55. // console.log(err)
  56. // },
  57. // success(res) {
  58. // console.log(res)
  59. // }
  60. // })
  61. // }
  62. // })
  63. // #ifdef APP-PLUS
  64. console.log(uni.getStorageSync('userInfo'))
  65. if(uni.getStorageSync('userInfo')){
  66. that.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', {
  67. phone: uni.getStorageSync('userInfo').phone,
  68. }).then(res => {
  69. if (res.data.authenticationStatus == '已禁用') {
  70. // this.isShowAlert = true
  71. // this.alertTitle = '账号审核中'
  72. // this.confirmText = '退出APP'
  73. // this.showCancelButton = false
  74. let options = {
  75. title: '提示',
  76. info:'账号审核中',
  77. okText: '退出程序',
  78. infoAlignment:'center',
  79. radius:10,
  80. // cancelText: '否',
  81. showCancel:false,
  82. okColor:'#2772FB',
  83. okButtonColor:'#fff'
  84. };
  85. const native = uni.requireNativePlugin('AJ-Alert');
  86. native.showAction(options, result => {
  87. // #ifdef APP-PLUS
  88. if (uni.getSystemInfoSync().platform == 'ios') {
  89. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  90. } else if (uni.getSystemInfoSync().platform == 'android') {
  91. plus.runtime.quit();
  92. }
  93. // #endif
  94. // 点击是的回调, result暂时没有返回内容
  95. }, cancel => {
  96. // 点击否的回调
  97. });
  98. // uni.showModal({
  99. // title: '提示',
  100. // content: '这是一个模态弹窗',
  101. // showCancel:false,
  102. // confirmText:'退出app',
  103. // // confirmColor:'#317AFE',
  104. // confirmColor:'#F54E40',
  105. // success: function (res) {
  106. // if (res.confirm) {
  107. // // #ifdef APP-PLUS
  108. // if (uni.getSystemInfoSync().platform == 'ios') {
  109. // plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  110. // } else if (uni.getSystemInfoSync().platform == 'android') {
  111. // plus.runtime.quit();
  112. // }
  113. // // #endif
  114. // } else if (res.cancel) {
  115. // console.log('用户点击取消');
  116. // }
  117. // }
  118. // });
  119. } else {
  120. console.log(1231233212332312312213)
  121. }
  122. })
  123. }
  124. // #endif
  125. uni.getSystemInfo({
  126. success: function(e) {
  127. Vue.prototype.statusBar = e.statusBarHeight
  128. // #ifndef MP
  129. if (e.platform == 'android') {
  130. Vue.prototype.customBar = e.statusBarHeight + 50
  131. } else {
  132. Vue.prototype.customBar = e.statusBarHeight + 45
  133. }
  134. // #endif
  135. // #ifdef MP-WEIXIN
  136. let custom = wx.getMenuButtonBoundingClientRect()
  137. Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
  138. // #endif
  139. // #ifdef MP-ALIPAY
  140. Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
  141. // #endif
  142. }
  143. })
  144. uni.onTabBarMidButtonTap(() => {
  145. if(uni.getStorageSync('userInfo')){
  146. this.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', {
  147. phone: uni.getStorageSync('userInfo').phone
  148. }).then(res => {
  149. if(res.data.authenticationStatus!='已认证'){
  150. if(res.data.authenticationStatus=='审核中'){
  151. uni.showToast({
  152. icon:'none',
  153. title: '身份信息审核中'
  154. })
  155. }else if(res.data.authenticationStatus=='已过期'||res.data.authenticationStatus=='未认证'){
  156. var content='',confirmtext=''
  157. if(res.data.authenticationStatus=='已过期'){
  158. content='身份信息已过期!'
  159. confirmtext='立即修改'
  160. }else{
  161. content='身份信息未认证!'
  162. confirmtext='去认证'
  163. }
  164. let options = {
  165. title: '提示',
  166. info:content,
  167. okText: confirmtext,
  168. infoAlignment:'center',
  169. radius:10,
  170. // cancelText: '否',
  171. showCancel:false,
  172. okColor:'#2772FB',
  173. okButtonColor:'#ffffff'
  174. };
  175. const native = uni.requireNativePlugin('AJ-Alert');
  176. native.showAction(options, result => {
  177. uni.switchTab({
  178. url: '/pages/mine/index'
  179. })
  180. // 点击是的回调, result暂时没有返回内容
  181. }, cancel => {
  182. // 点击否的回调
  183. });
  184. }
  185. }else{
  186. uni.navigateTo({
  187. url: '/pages/release/release'
  188. });
  189. }
  190. })
  191. }else{
  192. uni.$u.route('/pages/public/login');
  193. }
  194. })
  195. // #ifdef APP-PLUS
  196. let type = uni.getSystemInfoSync().platform
  197. console.log(type)
  198. if (type == "android") {
  199. console.log(111111111111111111111111111111111111111111111111111)
  200. appUpdate()
  201. }
  202. // var that = this
  203. // plus.push.getClientInfoAsync((info) => {
  204. // var name = 'clientId'
  205. // var value = info.clientid
  206. // that.$store.commit('$uStore', {
  207. // name,
  208. // value
  209. // });
  210. // uni.setStorageSync("clientId", info.clientid)
  211. // console.log("info.clientid", info.clientid)
  212. // }, err => {});
  213. // // 监听在线消息事件
  214. // plus.push.addEventListener("receive", function(msg) {
  215. // var title = msg.content.split(':')[0]
  216. // var content = msg.content.split(':')[1]
  217. // let params = {
  218. // inApp: true, // app内横幅提醒
  219. // voice: true, // 声音提醒
  220. // vibration: true, // 振动提醒
  221. // messageType: "",
  222. // messageTitle: title,
  223. // messageContent: content,
  224. // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  225. // }
  226. // console.log("msg", msg)
  227. // // new app_push({
  228. // // ...params
  229. // // }).show();
  230. // var userInfo = uni.getStorageSync("userInfo")
  231. // var that = this
  232. // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  233. // if (res.data.data) {
  234. // let name = 'myTip';
  235. // let value = res.data.data.task;
  236. // that.$store.commit('$uStore', {
  237. // name,
  238. // value
  239. // });
  240. // if (value != 0 && value) {
  241. // uni.setTabBarBadge({
  242. // index: 4,
  243. // text: value + ""
  244. // })
  245. // }
  246. // name = 'taskTip';
  247. // value = res.data.data.task;
  248. // that.$store.commit('$uStore', {
  249. // name,
  250. // value
  251. // });
  252. // // name = 'contractTip';
  253. // // value = res.data.data.contractTip;
  254. // // that.$store.commit('$uStore', {
  255. // // name,
  256. // // value
  257. // // });
  258. // }
  259. // })
  260. // //其它逻辑
  261. // }, false);
  262. // //监听系统通知栏消息点击事件
  263. // plus.push.addEventListener('click', function(msg) {
  264. // //处理点击消息的业务逻辑代码
  265. // if (msg.content && msg.content.contains("任务")) {
  266. // uni.navigateTo({
  267. // url: '/pages/task/my_task'
  268. // })
  269. // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  270. // uni.navigateTo({
  271. // url: '/pageB/contract/contract'
  272. // })
  273. // }
  274. // }, false);
  275. // #endif
  276. this.$socket.initWebIM(this.$ws, true, true)
  277. let userInfo = uni.getStorageSync('userInfo') || '';
  278. if (userInfo.id) {
  279. //更新登陆状态
  280. uni.getStorage({
  281. key: 'userInfo',
  282. success: (res) => {
  283. this.login(res.data);
  284. }
  285. });
  286. }
  287. },
  288. onShow: function() {
  289. console.log('App Show')
  290. },
  291. onHide: function() {
  292. console.log('App Hide')
  293. },
  294. }
  295. </script>
  296. <style>
  297. /* #ifndef APP-PLUS */
  298. /* #endif */
  299. /*每个页面公共css */
  300. </style>