MrShi
2026-03-06 cdca21c0c12fa79ad4e85321d0f0960c0c4c3f33
mini-program/pages/mine/mine.vue
@@ -6,13 +6,13 @@
            <view class="head-bar-nav" :style="{ height: navHeight + 'px' }"></view>
         </view>
         <view class="user">
            <view class="user-left">
            <view class="user-left"  @click="jumpSettings">
               <view class="user-image">
                  <image :src="userInfo.imgFullUrl?userInfo.imgFullUrl:'/static/icon/default.png'" mode="widthFix"></image>
               </view>
               <view class="user-name">
                  <button open-type="getPhoneNumber" @getphonenumber="getphonenumber" v-if="!userInfo">获取手机号</button>
                  {{userInfo ? userInfo.nickname : '点击登录'}}
                  {{userInfo ? maskPhone(userInfo.phone) : '点击登录'}}
               </view>
            </view>
            <view class="user-right" v-if="userInfo">
@@ -53,18 +53,24 @@
            </view>
            <view class="func-list">
               <view class="func-list-item" @click="jumpOrder(1)">
                  <view class="func-list-item-num" v-if="orderNum && orderNum.waitPayOrders > 0">{{orderNum.waitPayOrders}}</view>
                  <image src="/static/icon/mine_ic_daifukuan@2x.png" mode="widthFix"></image>
                  <view class="func-list-item-image">
                     <image src="/static/icon/mine_ic_daifukuan@2x.png" mode="widthFix"></image>
                     <view class="func-list-item-num" v-if="orderNum && orderNum.waitPayOrders > 0">{{orderNum.waitPayOrders > 99 ? '99+' : orderNum.waitPayOrders}}</view>
                  </view>
                  <text>待支付</text>
               </view>
               <view class="func-list-item" @click="jumpOrder(2)">
                  <view class="func-list-item-num" v-if="orderNum && orderNum.waitOrders > 0">{{orderNum.waitOrders}}</view>
                  <image src="/static/icon/mine_ic_daifahuo@2x.png" mode="widthFix"></image>
                  <view class="func-list-item-image">
                     <view class="func-list-item-num" v-if="orderNum && orderNum.waitOrders > 0">{{orderNum.waitOrders > 99 ? '99+' : orderNum.waitOrders}}</view>
                     <image src="/static/icon/mine_ic_daifahuo@2x.png" mode="widthFix"></image>
                  </view>
                  <text>待发货/自提</text>
               </view>
               <view class="func-list-item" @click="jumpOrder(3)">
                  <view class="func-list-item-num" v-if="orderNum && orderNum.waitReceivedOrders > 0">{{orderNum.waitReceivedOrders}}</view>
                  <image src="/static/icon/mine_ic_daishouhuo@2x.png" mode="widthFix"></image>
                  <view class="func-list-item-image">
                     <view class="func-list-item-num" v-if="orderNum && orderNum.waitReceivedOrders > 0">{{orderNum.waitReceivedOrders > 99 ? '99+' : orderNum.waitReceivedOrders}}</view>
                     <image src="/static/icon/mine_ic_daishouhuo@2x.png" mode="widthFix"></image>
                  </view>
                  <text>待收货</text>
               </view>
            </view>
@@ -88,12 +94,15 @@
            </view>
         </view>
      </view>
      <Login ref="login" />
   </view>
</template>
<script>
   import { mapState } from 'vuex'
   import Login from '@/components/login/login.vue'
   export default {
      components: { Login },
      computed: {
         ...mapState(['navHeight', 'statusbarHeight', 'openid', 'userInfo','recshopid','recuserid'])
      },
@@ -109,16 +118,37 @@
         if (uni.getStorageSync('backgroundImage')) {
            this.share = uni.getStorageSync('backgroundImage').centerInviteBg
         }
         this.ordersStatistics()
         // 退出/注销清除数据
         uni.$on('loginOut', () => {
            this.objNum = null
            this.orderNum = null
         })
      },
      async onShow() {
         await this.$onLaunched;
         if (this.userInfo) {
            this.getMyInfo()
            this.ordersStatistics()
         }
      },
      methods: {
         maskPhone(phone) {
            if (!phone) return '';
            // 假设手机号为 11 位,保留前 3 位和后 4 位
            return phone.slice(0, 3) + '****' + phone.slice(-4);
         },
         jumpUser() {
            if (this.userInfo) {
               uni.navigateTo({
                  url: '/pages/settings/settings'
               })
            }
         },
         jumpTo(type) {
            if (!this.userInfo) {
               this.$refs.login.open()
               return
            }
            if (type === 1) {
               uni.navigateTo({
                  url: '/pages/shopping-cart/shopping-cart'
@@ -155,26 +185,41 @@
         },
         // 跳转设置
         jumpSettings() {
            if(!this.userInfo && !this.userInfo.id){
               return
            }
            uni.navigateTo({
               url: '/pages/settings/settings'
            })
         },
         // 授权手机号
         getphonenumber(e) {
            var that = this;
            if (e.detail.errMsg === 'getPhoneNumber:ok') {
               this.$u.api.wxPhone({
                  code: e.detail.code,
                  shopId:this.recshopid,
                  recId:this.recuserid,
                  openid: this.openid
               }).then(res => {
                  if (res.code === 200) {
                     this.$store.commit('setUserInfo', res.data.member)
                     this.$store.commit('setToken', res.data.token)
                      this.$store.commit('setRecShopId','')
                      this.$store.commit('setRecUserId','')
               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.wxPhone({
                           code: e.detail.code,
                           shopId:that.recshopid,
                           recId:that.recuserid,
                           openid: res.data.openid
                        }).then(res => {
                           if (res.code === 200) {
                              that.getMyInfo()
                              that.ordersStatistics()
                              that.$store.commit('setUserInfo', res.data.member)
                              that.$store.commit('setToken', res.data.token)
                              that.$store.commit('setRecShopId','')
                              that.$store.commit('setRecUserId','')
                           }
                        })
                     }
                  }
               })
               });
            }
         },
         // 获取收藏等数量
@@ -197,6 +242,10 @@
         },
         // 跳转订单列表
         jumpOrder(status) {
            if (!this.userInfo) {
               this.$refs.login.open()
               return
            }
            uni.navigateTo({
               url: '/pagesA/pages/order/order?userType=0&status=' + status
            })
@@ -319,24 +368,28 @@
                  flex-direction: column;
                  align-items: center;
                  justify-content: center;
                  position: relative;
                  .func-list-item-num {
                     position: absolute;
                     top: 0;
                     right: 0;
                     height: 32rpx;
                     line-height: 32rpx;
                     padding: 0 8rpx;
                     box-sizing: border-box;
                     border-radius: 50%;
                     background-color: #E4001D;
                     font-weight: 400;
                     font-size: 22rpx;
                     color: #FFFFFF;
                  }
                  image {
                  .func-list-item-image {
                     width: 60rpx;
                     height: 60rpx;
                     position: relative;
                     image {
                        width: 60rpx;
                        height: 60rpx;
                     }
                     .func-list-item-num {
                        position: absolute;
                        top: 0;
                        right: -10rpx;
                        width: 40rpx;
                        height: 40rpx;
                        line-height: 40rpx;
                        text-align: center;
                        border-radius: 50%;
                        background-color: #E4001D;
                        font-weight: 400;
                        font-size: 22rpx;
                        color: #FFFFFF;
                     }
                  }
                  text {
                     font-weight: 400;