rk
16 小时以前 fa4c7baec36d58b4bdca66159ece743b5a45a9c8
small-program/pages/mine/mine.vue
@@ -7,8 +7,7 @@
      </view>
      <view class="page-scroll">
         <view class="page-content">
            <view class="profile-card">
               <button open-type="getPhoneNumber" @getphonenumber="getphonenumber">授权手机号</button>
            <view class="profile-card" @click="handleProfileClick">
               <image class="avatar" :src="userInfo.fullCoverImage ? userInfo.fullCoverImage : '/static/image/tx@2x.png'" mode="widthFix"></image>
               <view class="profile-copy">
                  <text class="login-text">{{ userInfo.nickName || '点击登录' }}</text>
@@ -17,23 +16,23 @@
                  <view class="tool-item" @click="toSetting">
                     <image class="tool-icon" src="/static/icon/ic_option@2x.png" mode="aspectFit"></image>
                  </view>
                  <view class="tool-item has-badge">
                  <!-- <view class="tool-item has-badge">
                     <image class="tool-icon" src="/static/icon/ic_notice@2x.png" mode="aspectFit"></image>
                     <view class="tool-badge" v-if="userInfo.hasMessage"></view>
                  </view>
                  </view> -->
               </view>
            </view>
            <view class="order-card section-card">
               <view class="section-head">
                  <text class="section-title">我的订单</text>
                  <view class="more-wrap" @click="toAllOrders">
                  <view class="more-wrap" @click="toOrderDetail(-1)">
                     <text class="more-text">全部订单</text>
                     <u-icon name="arrow-right" size="13" color="#999999"></u-icon>
                  </view>
               </view>
               <view class="order-grid">
                  <view v-for="(item, index) in orderMenus" :key="index" class="order-item" @click="toOrderDetail(item.label)">
                  <view v-for="(item, index) in orderMenus" :key="index" class="order-item" @click="toOrderDetail(item.status)">
                     <image class="order-icon" :src="item.url" mode="widthFix"></image>
                     <view v-if="item.badge" class="order-badge">{{ item.badge }}</view>
                     <text class="order-label">{{ item.label }}</text>
@@ -49,81 +48,192 @@
               <view v-for="item in menuList" :key="item.label" class="menu-row" @click="handleMenuClick(item)">
                  <text class="menu-label">{{ item.label }}</text>
                  <view class="right-icon">
                     <text v-if="item.label === '门店入驻'" :class="{ 'status-red': userInfo.shopAuditStatus === 1 || userInfo.shopAuditStatus === 2 }">
                        {{ userInfo.shopAuditStatus === 0 ? '审核中' : userInfo.shopAuditStatus === 1 ? '审核通过,请支付押金' : userInfo.shopAuditStatus === 2 ? '审核未通过' : '申请入驻' }}
                     <text v-if="['门店入驻','门店信息'].includes(item.label)" :class="{ 'status-red': [1,2,5].includes(userInfo.shopAuditStatus), 'status-yellow': [4].includes(userInfo.shopAuditStatus) }">
                        {{userInfo.shopAuditStatus === 0 ? '审核中' : userInfo.shopAuditStatus === 1 ? '审核通过,请支付押金' : userInfo.shopAuditStatus === 2 ? '审核未通过' : userInfo.shopAuditStatus === 3 ? '门店已入驻' : userInfo.shopAuditStatus === 4 ? '变更中' : userInfo.shopAuditStatus === 5 ? '变更未通过' : '' }}
                     </text>
                     <u-icon name="arrow-right" size="18" color="#B5BBC5"></u-icon>
                     <button  v-if="item.label === '在线客服'" open-type="contact" type="default">    </button>
                     <u-icon   name="arrow-right" size="18" color="#B5BBC5"></u-icon>
                  </view>
               </view>
            </view>
         </view>
      </view>
      <u-popup :show="showPhone" round="15" mode="bottom" :safeAreaInsetBottom="true" @close="showPhone = false" :closeable="true" :closeOnClickOverlay="true">
         <view class="phone">
            <view class="phone-head">
               <view></view>
               <text>联系平台</text>
            </view>
             <view style="flex-direction: row;margin-bottom: 30rpx;" class="phone-item" v-for="(phone, index) in serverPhoneList" :key="index" @click="contactPhoneDo(phone)">
                  <image src="/static/icon/ic_call@2x.png" mode="widthFix"></image>
                  <text>{{ phone }}</text>
             </view>
             <view style="width: 100%; height: 30rpx;"></view>
         </view>
      </u-popup>
      <auth-login
         :show="showAuthLogin"
         :checked.sync="agreeChecked"
         @success="getOrderNum"
         @close="showAuthLogin = false" />
      <custom-tabbar></custom-tabbar>
   </view>
</template>
<script>
import { mapState } from 'vuex'
   import { mapState } from 'vuex'
   import CustomTabbar from '@/components/custom-tabbar/custom-tabbar.vue'
export default {
   computed: {
      ...mapState(['navHeight', 'statusbarHeight', 'openid', 'userInfo'])
   export default {
      components: {
         CustomTabbar
      },
      computed: {
      ...mapState(['navHeight', 'statusbarHeight', 'openid', 'userInfo', 'token']),
      serverPhoneList() {
         if (!this.serverPhone) return []
         return this.serverPhone.split(',')
      }
   },
   data() {
      return {
         showAuthLogin: false,
         agreeChecked: true,
         showPhone: false,
         userName: '',
         serverPhone: '',
         orderMenus: [
            { label: '待支付', url: '/static/icon/mine_ic_daifukuan@2x.png', badge: 0 },
            { label: '待收货', url: '/static/icon/mine_ic_daishouhuo@2x.png', badge: 0 },
            { label: '退款/售后', url: '/static/icon/mine_ic_tuikuan@2x.png', badge: 0 }
            { label: '待支付', url: '/static/icon/mine_ic_daifukuan@2x.png', badge: 0,status:0 },
            { label: '待收货', url: '/static/icon/mine_ic_daishouhuo@2x.png', badge: 0,status:3 },
            { label: '退款/售后', url: '/static/icon/mine_ic_tuikuan@2x.png', badge: 0 ,status:5}
         ],
         menuList: [
            { label: '门店入驻' },
            { label: '我的门店' },
            { label: '规范须知' },
            { label: '领券中心' },
            { label: '开票申请' },
            { label: '用户服务协议' },
            { label: '用户隐私政策' },
            { label: '在线客服' },
            { label: '联系平台' },
            { label: '关于我们' }
         ]
      }
   },
   onLoad() {
      this.getPlatformInfo()
      uni.$on('loginOut', () => {
         this.orderMenus = [
            { label: '待支付', url: '/static/icon/mine_ic_daifukuan@2x.png', badge: 0,status:0 },
            { label: '待收货', url: '/static/icon/mine_ic_daishouhuo@2x.png', badge: 0,status:3 },
            { label: '退款/售后', url: '/static/icon/mine_ic_tuikuan@2x.png', badge: 0 ,status:5}
         ]
      })
   },
   async onShow() {
      await this.$onLaunched
      if (this.userInfo) {
      await this.$onLaunched;
      if (this.token) {
         this.getOrderNum()
      }
      if (this.userInfo) {
         if (this.userInfo.shopAuditStatus === 3) {
            this.menuList[0].label = '门店信息'
         }
      } else {
         this.orderMenus = [
            { label: '待支付', url: '/static/icon/mine_ic_daifukuan@2x.png', badge: 0 },
            { label: '待收货', url: '/static/icon/mine_ic_daishouhuo@2x.png', badge: 0 },
            { label: '退款/售后', url: '/static/icon/mine_ic_tuikuan@2x.png', badge: 0 }
         ]
      }
   },
   methods: {
      contactPhoneDo(phone) {
         if (phone) {
            uni.makePhoneCall({
               phoneNumber: phone
            })
         }
      },
      async getPlatformInfo() {
         const res = await this.$u.api.getPlatformAboutUs({})
         if (res.code === 200 && res.data) {
            this.serverPhone = res.data.serverPhone || ''
         }
      },
      handleProfileClick() {
         if (this.token) {
            return
         }
         this.showAuthLogin = true
      },
      toAllOrders() {
         uni.navigateTo({
            url: '/pages/orders/orders'
         uni.switchTab({
            url: '/pages/itinerary/itinerary'
         })
      },
      handleMenuClick(item) {
         const urlMap = {
            '门店入驻': '/pages/store-apply/store-apply',
            '我的门店': '/pages/store-home/store-home',
            '规范须知': '/pages/rich-text/rich-text?type=serverIntroduce',
            '关于我们': '/pages/rich-text/rich-text?type=about'
            '我的门店': '/shop/pages/login/login',
            '领券中心': '/shop/pages/coupon-center/coupon-center',
            '开票申请': '/shop/pages/Invoice-application/Invoice-application',
            '用户服务协议': '/pages/rich-text/rich-text?type=0',
            '用户隐私政策': '/pages/rich-text/rich-text?type=1',
            '关于我们': '/pages/rich-text/rich-text?type=5'
         }
         if (item.label === '门店入驻' && [0,1,2].includes(this.userInfo.shopAuditStatus)) {
         if (item.label === '联系平台') {
            this.showPhone = true
            return
         }
         if (['门店入驻', '我的门店'].includes(item.label)) {
            if (!this.token) {
               this.showAuthLogin = true
               return
            }
         }
         if (['门店入驻','门店信息'].includes(item.label) && [0,1,2,3,4].includes(this.userInfo.shopAuditStatus)) {
            uni.navigateTo({
               url: '/pages/details-entry/details-entry'
            })
            return
         }
         if (urlMap[item.label]) {
         if (item.label!=='在线客服' && urlMap[item.label]) {
            uni.navigateTo({
               url: urlMap[item.label]
            })
         }
      },
      toOrderDetail(label) {
         uni.navigateTo({
            url: '/pages/orders/orders?status=' + label
         if (!this.token) {
            this.showAuthLogin = true
            return
         }
         // uni.$emit('shuaxin',label===0?-2:label)
         uni.setStorageSync("orderStatus",label===0?-2:label)
         uni.switchTab({
            url: '/pages/itinerary/itinerary'
         })
      },
      toSetting() {
         if (!this.token) {
            this.showAuthLogin = true
            return
         }
         uni.navigateTo({
            url: '/pages/settings/settings'
         })
      },
      goService() {
         uni.navigateTo({
            url: '/pages/rich-text/rich-text?type=userAgreement'
         })
      },
      goPrivacy() {
         uni.navigateTo({
            url: '/pages/rich-text/rich-text?type=privacyPolicy'
         })
      },
      getOrderNum() {
@@ -141,30 +251,6 @@
               })
            }
         })
      },
      // 授权手机号
      getphonenumber(e) {
         var that = this;
         if (e.detail.errMsg === 'getPhoneNumber:ok') {
            uni.login({
               provider: 'weixin',
               success: async function (loginRes) {
                  let { code } = loginRes;
                  let res = await that.$u.api.wxLogin({ code })
                  if (res.code === 200) {
                     that.$u.api.wxAuthPhone({
                        code: e.detail.code,
                        openid: res.data.openid
                     }).then(res => {
                        if (res.code === 200) {
                           that.$store.commit('setUserInfo', res.data.member)
                           that.$store.commit('setToken', res.data.token)
                        }
                     })
                  }
               }
            });
         }
      }
   }
}
@@ -394,5 +480,18 @@
      .status-red {
         color: #FF0000;
      }
      .status-yellow {
         color: #FFD700;
      }
      button {
         position: relative;
         top: 0;
         float:right;
         right:  0;
         width: 200rpx;
         height: 48rpx;
         opacity: 0;
         z-index: 9999;
      }
   }
</style>