App.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <script>
  2. import { getTechnicianToken } from "@/api/newLogin";
  3. export default {
  4. globalData: {
  5. couponSelected: {}
  6. },
  7. data() {
  8. return {
  9. }
  10. },
  11. onLaunch() {
  12. this.getTechnicianTokenFun()
  13. console.log('App Launch')
  14. },
  15. onShow() {
  16. console.log('App Show')
  17. },
  18. methods: {
  19. //存入openid
  20. getTechnicianTokenFun() {
  21. let isWechat = navigator.userAgent.toLowerCase().includes('micromessenger');
  22. // 非微信环境直接跳过
  23. //if (!isWechat) return;//guo
  24. let openid = uni.getStorageSync('wx_copenid')
  25. const code = this.$utils.getQueryStr('code');
  26. if (openid) {
  27. this.checkMerchantStatus()
  28. } else {
  29. // // 1. 没有code → 跳转微信静默授权
  30. // if (!code && isWechat) {
  31. // let appid = 'wx9dc677bd41e82569'
  32. // //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx9dc677bd41e82569&redirect_uri=https://city.baoxianzhanggui.com/fragrance/wxcode/&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
  33. // let ruri = encodeURIComponent('https://city.baoxianzhanggui.com/fragrance/');
  34. // const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${ruri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`
  35. // window.location.href = authUrl
  36. // }
  37. let params = {
  38. //code: this.$utils.('code') //guo
  39. code: '031VMh000FD7zW1OwB200nJFjM1VMh0q'
  40. }
  41. getTechnicianToken(params).then(res => {
  42. if (res.data.code == 200) {
  43. uni.setStorageSync('wx_copenid', res.data.data.copenid);
  44. this.checkMerchantStatus()
  45. }
  46. })
  47. }
  48. },
  49. //查询商户注册和入驻信息 auditStatus 审核状态:-1-申请入住,0-待入驻,1-待审核,2-审核通过,3-审核驳回"
  50. async checkMerchantStatus() {
  51. const openid = uni.getStorageSync('wx_copenid')
  52. const merchantInfo = await this.$utils.checkMerchantStatus(openid)
  53. if (!merchantInfo) return
  54. //merchantInfo.merchant.auditStatus = 2 //guo
  55. if (merchantInfo.merchant.auditStatus == -1) {//未注册
  56. uni.navigateTo({
  57. url: '/pages/join/staff'
  58. })
  59. return
  60. } else if (merchantInfo.merchant.auditStatus == 0 || merchantInfo.merchant.auditStatus == 1 || merchantInfo.merchant.auditStatus == 2 || merchantInfo.merchant.auditStatus == 3) {
  61. if (merchantInfo.merchant.auditStatus == 0) { //待入驻
  62. if (!this.$utils.checkLogin({ type: 'navigate' })) return;
  63. uni.switchTab({
  64. url: '/pages/index/index'
  65. })
  66. return
  67. }
  68. if (merchantInfo.merchantAuditFile.length) {//已有入驻信息
  69. if (!this.$utils.checkLogin({ type: 'navigate' })) return;
  70. uni.switchTab({
  71. url: '/pages/index/index?merchantInfo=' + encodeURIComponent(JSON.stringify(merchantInfo))
  72. })
  73. } else {//无入驻信息
  74. if (merchantInfo.merchant.auditStatus == 1 || merchantInfo.merchant.auditStatus == 3) {
  75. uni.navigateTo({
  76. url: '/pages/join/staff?merchantInfo=' + encodeURIComponent(JSON.stringify(merchantInfo))
  77. })
  78. } if (merchantInfo.merchant.auditStatus == 2) {
  79. uni.switchTab({
  80. url: '/pages/index/index'
  81. })
  82. }
  83. }
  84. }
  85. },
  86. },
  87. onHide() {
  88. console.log('App Hide')
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. @import 'uview-ui/index.scss';
  94. @import "common/common.scss";
  95. html,
  96. body {
  97. height: 100vh;
  98. overflow-x: hidden;
  99. &::-webkit-scrollbar {
  100. display: none;
  101. }
  102. }
  103. page {
  104. --theme-color: #03C8BE;
  105. --theme-color-gradient: linear-gradient(131deg, #00DAAB 0%, #07CDC4 100%);
  106. ;
  107. }
  108. // 弹窗
  109. .modal-wrap {
  110. width: 590rpx;
  111. //height: 314rpx;
  112. background: #fff;
  113. border-radius: 16rpx;
  114. .title {
  115. font-weight: 600;
  116. font-size: 32rpx;
  117. color: #1D2129;
  118. text-align: center;
  119. margin-top: 32rpx;
  120. }
  121. .content {
  122. padding: 32rpx 48rpx;
  123. font-weight: 400;
  124. font-size: 30rpx;
  125. color: #4E5969;
  126. }
  127. .btn-box {
  128. display: flex;
  129. border-top: 1rpx solid #E7E7E7;
  130. }
  131. .btn {
  132. flex: 1;
  133. height: 90rpx;
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. font-size: 30rpx;
  138. color: #1D2129;
  139. font-weight: 400;
  140. }
  141. .left {
  142. font-weight: 400;
  143. font-size: 30rpx;
  144. color: #86909C;
  145. text-align: center;
  146. border-right: 1rpx solid #E7E7E7;
  147. }
  148. .right {
  149. font-weight: 400;
  150. font-size: 30rpx;
  151. color: #1D2129;
  152. text-align: center;
  153. }
  154. }
  155. </style>