App.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <script>
  2. const uat_URL = 'https://carwash.test.zyucgj.com/cw-wechat/' // 预发布
  3. // const uat_URL = 'http://192.168.16.103:8103/cw-wechat/' // 本地
  4. const pro_URL = 'https://carwash.zyucgj.com/saas/clz/' // 生产
  5. const buildType = 0 // 打包环境对应类型,1 生产 0 预发布
  6. const buildURL = buildType ? pro_URL : uat_URL // 打包后实际对应的url
  7. const envText = ['预发布环境','生产环境']
  8. const envTips = process.env.NODE_ENV == 'development' ? envText[0] : envText[buildType]
  9. export default {
  10. globalData: {
  11. baseUrl: process.env.NODE_ENV == 'development' ? uat_URL : buildURL,
  12. token: '',
  13. version: '', // 当前版本号
  14. buildType: buildType,
  15. envTips: envTips
  16. },
  17. mounted() {
  18. // 非V3模式
  19. if(this.$scope){
  20. this.$scope.globalData.token = this.$store.state.vuex_token
  21. }else{
  22. // V3模式
  23. getApp({allowDefault: true}).globalData.token = this.$store.state.vuex_token
  24. }
  25. },
  26. onLaunch: function() {
  27. console.log('App onLaunch')
  28. },
  29. onShow: function() {
  30. const pages = getCurrentPages(); // 获取加载的页面
  31. const currentPage = pages[pages.length - 1]; // 获取当前页面的对象
  32. let url = currentPage ? currentPage.route :''; // 当前页面url
  33. // console.log(url,'App Show')
  34. // 用户扫描二维码后进入下单页面 未支付时,切换小程序至后台,再次显示时 进入首页
  35. if(this.$store.state.vuex_orderInfo.orderStatus != 'PAID'&&url=='pages/getOrder/getOrder') {
  36. uni.reLaunch({
  37. url: '/pages/index/index'
  38. })
  39. }
  40. console.log('App Show')
  41. },
  42. onHide: function() {
  43. console.log('App Hide')
  44. }
  45. }
  46. </script>
  47. <style lang="scss">
  48. @import "uview-ui/index.scss";
  49. /*每个页面公共css */
  50. page {
  51. min-height: 100%;
  52. display: flex;
  53. background: #fff;
  54. }
  55. /* #ifdef MP-BAIDU */
  56. page {
  57. width: 100%;
  58. height: 100%;
  59. display: block;
  60. }
  61. /* #endif */
  62. /* #ifdef MP-ALIPAY */
  63. page {
  64. min-height: 100vh;
  65. }
  66. /* #endif */
  67. /* 原生组件模式下需要注意组件外部样式 */
  68. m-input {
  69. width: 100%;
  70. min-height: 100%;
  71. display: flex;
  72. }
  73. .content {
  74. display: flex;
  75. flex: 1;
  76. flex-direction: column;
  77. background-color: #fff;
  78. padding: 20upx;
  79. }
  80. </style>