Liuyi
2024-10-21 15a55f79a84e5dab670d54a9dc0c6b9133a18441
pages/index/index.vue
@@ -1,6 +1,6 @@
<script setup>
    import { onMounted, ref } from "vue";
   import { getVipInfoApi,getUserInfo,reportLossApi,removeCardApi } from '../../api/index.js'
   import { getVipInfoApi,getUserInfo,reportLossApi,removeCardApi,buyWaterApi } from '../../api/index.js'
   import { onShow,getCurrentPages } from '@dcloudio/uni-app'
   //状态栏高度
   const topHeight = ref(0)
@@ -33,7 +33,9 @@
      await getVipInfoApi().then((res) =>{
         if(res.code == 200 && res.data.id){
            cardInfo.value.waterCardNumber = res.data.cardNumber
            cardInfo.value.state = res.data.state == 2 ? true : false//state:2:挂失,1:正常
            cardInfo.value.cardType = res.data.cardType
            //用户信息处理存储
            cardInfo.value.state = res.data.state == 2 ? true : false//state:2:挂失,1:正常 是否挂失
            cardInfo.value.userCardType = res.data.userCardType == 2 ? true : false //userCardType:2:共享卡,1:正常卡
            
            isLoss.value = cardInfo.value.state 
@@ -69,10 +71,24 @@
      //调用二维码扫描接口
      uni.scanCode({
         scanType: ['qrCode'],
         success: function (res) {
         success: async function (res) {
            console.log('条码内容:' + res.result);
            let data = {
               cardType:cardInfo.value.cardType,
               card:cardInfo.value.waterCardNumber,
               sn:res.result
            }
            await buyWaterApi(data).then((res) =>{
               if(res.code == 200){
            uni.navigateTo({
               url:'/pages/scanWater/index'
                  })
               }else{
                  uni.showToast({
                     title:'扫码失败!',
                     icon:'none'
                  })
               }
            })
         }
      });
@@ -103,6 +119,8 @@
         navTo(url)
      }else if(isUrl == 2){
         if(cardInfo.value.waterCardNumber){
            //不是共享卡且未挂失
            if(!isShareCard.value && !cardInfo.value.state){
            uni.showModal({
                  title: '会员卡挂失',
                  content: '确认挂失会员卡?',
@@ -126,6 +144,17 @@
                  }
               }
            })
            }else if(isShareCard.value){
               uni.showToast({
                  title:'共享卡无权限',
                  icon:'none'
               })
            }else if(cardInfo.value.state){
               uni.showToast({
                  title:'已挂失',
                  icon:'none'
               })
            }
         }else{
            uni.showToast({
               title:'未绑定会员卡!',
@@ -134,6 +163,7 @@
         }
      }else if(isUrl == 3){
         if(cardInfo.value.waterCardNumber){
            if(!isShareCard.value){
            uni.showModal({
                  title: '会员卡注销',
                  content: '确认注销会员卡?',
@@ -159,11 +189,15 @@
                           })
                        }
                     })
                  }else{
                     console.log('点击了取消8')
                  }
               }
            })
            }else{
               uni.showToast({
                  title:'共享卡无权限',
                  icon:'none'
               })
            }
         }else{
               uni.showToast({
                  title:'未绑定会员卡!',
@@ -171,11 +205,7 @@
               })
         }
      }else{
         uni.showToast({
            title: '该功能正在升级中!',
            duration: 2000,
            icon:'none',
         });
         upGrade()
      }
   }
   function upGrade(){
@@ -187,8 +217,10 @@
   }
   onMounted( async() =>{
      getTopHeight()
      await getInfo()
   })
   onShow(async() =>{
      getTopHeight()
      await getInfo()
   })
   uni.showShareMenu({
@@ -210,7 +242,8 @@
      <view class="content">
         <view class="card-box" :style="{paddingTop:topHeight + 'rpx'}">
            <view class="user-info" >
               <image class="user-img" src='../../static/images/index/head.png' alt=''></image>
               <image v-if="cardInfo.headImg" class="user-img" :src='cardInfo.headImg' alt=''></image>
               <image v-else class="user-img" src='../../static/images/index/head.png' alt=''></image>
               <text @click="navTo('/pages/userInfo/index')">{{cardInfo.userName}}</text>
               <image @click="navTo('/pages/userInfo/index')" class="user-more"src="../../static/images/index/back.png"></image>
               <view class="user-add-card" @click="navTo('/pages/addCard/index')">
@@ -341,6 +374,7 @@
               .user-img{
                  width:90rpx;
                  height:90rpx;
                  border-radius:50%;
                  margin-right:20rpx;
               }
               text{