App.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. console.log(this.$store.state.vuex_bizId,'---------')
  29. console.log(this.$store.state.vuex_token)
  30. },
  31. onShow: function() {
  32. const pages = getCurrentPages(); // 获取加载的页面
  33. const currentPage = pages[pages.length - 1]; // 获取当前页面的对象
  34. let url = currentPage ? currentPage.route :''; // 当前页面url
  35. // console.log(url,'App Show')
  36. // 用户扫描二维码后进入下单页面 未支付时,切换小程序至后台,再次显示时 进入首页
  37. if(this.$store.state.vuex_orderStatus != 'PAID'&&url=='pages/getOrder/getOrder') {
  38. uni.reLaunch({
  39. url: '/pages/index/index'
  40. })
  41. }
  42. console.log('App Show')
  43. },
  44. onHide: function() {
  45. console.log('App Hide')
  46. },
  47. }
  48. </script>
  49. <style lang="scss">
  50. @import "uview-ui/index.scss";
  51. /*每个页面公共css */
  52. page {
  53. min-height: 100%;
  54. display: flex;
  55. background: #fff;
  56. }
  57. /* #ifdef MP-BAIDU */
  58. page {
  59. width: 100%;
  60. height: 100%;
  61. display: block;
  62. }
  63. /* #endif */
  64. /* #ifdef MP-ALIPAY */
  65. page {
  66. min-height: 100vh;
  67. }
  68. /* #endif */
  69. /* 原生组件模式下需要注意组件外部样式 */
  70. m-input {
  71. width: 100%;
  72. min-height: 100%;
  73. display: flex;
  74. }
  75. .content {
  76. display: flex;
  77. flex: 1;
  78. flex-direction: column;
  79. background-color: #fff;
  80. padding: 20upx;
  81. }
  82. </style>