App.vue 10 KB

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