App.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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.setTabBarItem({
  187. index: 0,
  188. text: '订单',
  189. iconPath: 'static/images/common/dingdan@2x(1).png',
  190. selectedIconPath: 'static/images/common/dingdan@2x.png'
  191. })
  192. uni.navigateTo({
  193. url: '/pages/release/release'
  194. });
  195. }
  196. })
  197. }else{
  198. uni.$u.route('/pages/public/login');
  199. }
  200. })
  201. // #ifdef APP-PLUS
  202. let type = uni.getSystemInfoSync().platform
  203. console.log(type)
  204. if (type == "android") {
  205. console.log(111111111111111111111111111111111111111111111111111)
  206. appUpdate()
  207. }
  208. // var that = this
  209. // plus.push.getClientInfoAsync((info) => {
  210. // var name = 'clientId'
  211. // var value = info.clientid
  212. // that.$store.commit('$uStore', {
  213. // name,
  214. // value
  215. // });
  216. // uni.setStorageSync("clientId", info.clientid)
  217. // console.log("info.clientid", info.clientid)
  218. // }, err => {});
  219. // // 监听在线消息事件
  220. // plus.push.addEventListener("receive", function(msg) {
  221. // var title = msg.content.split(':')[0]
  222. // var content = msg.content.split(':')[1]
  223. // let params = {
  224. // inApp: true, // app内横幅提醒
  225. // voice: true, // 声音提醒
  226. // vibration: true, // 振动提醒
  227. // messageType: "",
  228. // messageTitle: title,
  229. // messageContent: content,
  230. // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
  231. // }
  232. // console.log("msg", msg)
  233. // // new app_push({
  234. // // ...params
  235. // // }).show();
  236. // var userInfo = uni.getStorageSync("userInfo")
  237. // var that = this
  238. // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
  239. // if (res.data.data) {
  240. // let name = 'myTip';
  241. // let value = res.data.data.task;
  242. // that.$store.commit('$uStore', {
  243. // name,
  244. // value
  245. // });
  246. // if (value != 0 && value) {
  247. // uni.setTabBarBadge({
  248. // index: 4,
  249. // text: value + ""
  250. // })
  251. // }
  252. // name = 'taskTip';
  253. // value = res.data.data.task;
  254. // that.$store.commit('$uStore', {
  255. // name,
  256. // value
  257. // });
  258. // // name = 'contractTip';
  259. // // value = res.data.data.contractTip;
  260. // // that.$store.commit('$uStore', {
  261. // // name,
  262. // // value
  263. // // });
  264. // }
  265. // })
  266. // //其它逻辑
  267. // }, false);
  268. // //监听系统通知栏消息点击事件
  269. // plus.push.addEventListener('click', function(msg) {
  270. // //处理点击消息的业务逻辑代码
  271. // if (msg.content && msg.content.contains("任务")) {
  272. // uni.navigateTo({
  273. // url: '/pages/task/my_task'
  274. // })
  275. // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
  276. // uni.navigateTo({
  277. // url: '/pageB/contract/contract'
  278. // })
  279. // }
  280. // }, false);
  281. // #endif
  282. this.$socket.initWebIM(this.$ws, true, true)
  283. let userInfo = uni.getStorageSync('userInfo') || '';
  284. if (userInfo.id) {
  285. //更新登陆状态
  286. uni.getStorage({
  287. key: 'userInfo',
  288. success: (res) => {
  289. this.login(res.data);
  290. }
  291. });
  292. }
  293. },
  294. onShow: function() {
  295. console.log('App Show')
  296. },
  297. onHide: function() {
  298. console.log('App Hide')
  299. },
  300. }
  301. </script>
  302. <style>
  303. /* #ifndef APP-PLUS */
  304. /* #endif */
  305. /*每个页面公共css */
  306. </style>