Liuyi
2024-10-19 42e5ea86f7edc9361227edd979a8ae1952713161
pages/index/index.vue
@@ -13,7 +13,6 @@
   /**
    * 会员卡相关
    */
   const isLoss = ref(false)
   const cardInfo = ref({
      id:'',
      userName:'微信用户',
@@ -23,42 +22,42 @@
      waterCardNumber:'',
      balance:'',
      count:'',
      state:'',
      state:'',//state:true:挂失,false:正常
      userCardType:'',//userCardType:true:共享卡,false:正常卡
   })
   const isLoss = ref(false)
   const isVip = ref(false)
   const isShareCard = ref(false)
   //获取会员卡信息
    function getVipInfo(){
      return new Promise((resolve,reject) =>{
          getVipInfoApi().then((res) =>{
            if(res.code == 200){
               cardInfo.value.waterCardNumber = res.data.cardNumber
               cardInfo.value.state = res.data.state
               isLoss.value = cardInfo.value.state == 2 ? true : false
               if(res.data.cardType == 1){
                  cardInfo.value.balance = res.data.balance
               }else if(res.data.cardType == 2){
                  cardInfo.value.count = res.data.count
               }
               isVip.value = true
    async function getVipInfo(){
      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.userCardType = res.data.userCardType == 2 ? true : false //userCardType:2:共享卡,1:正常卡
            isLoss.value = cardInfo.value.state
            isShareCard.value = cardInfo.value.userCardType
            if(res.data.cardType == 1){
               cardInfo.value.balance = res.data.balance
            }else if(res.data.cardType == 2){
               cardInfo.value.count = res.data.count
            }
         })
            isVip.value = true
            console.log('cardInfo',cardInfo.value,'isShareCard.value',isShareCard.value)
         }
      })
   }
   //获取用户信息
   function getInfo(){
       getUserInfo().then((res) =>{
   async function getInfo(){
       await getUserInfo().then(async(res) =>{
         if(res.code == 200){
            cardInfo.value.userName = res.data.userInfo.userName ?  res.data.userInfo.userName : cardInfo.value.userName
            cardInfo.value.headImg = res.data.userInfo.headImg
            cardInfo.value.userPhone = res.data.userInfo.userPhone
            cardInfo.value.id = res.data.userInfo.id
            if(res.data.userInfo.waterCardNumber){
               getVipInfo()
               console.log('00000')
            }else{
               isVip.value = false
            }
            await getVipInfo()
            console.log('00000',cardInfo.value)
            uni.setStorageSync('userInfo',JSON.stringify(cardInfo.value))
         }
      })
@@ -82,10 +81,10 @@
    * 功能列表相关
    */
   const functionList = ref([
      {text:'余额记录',icon:'../../static/images/index/icon31.png',bgColor:'#16b387',bgColor:'',url:'/pages/functionList/balanceRecord/index',isUrl:1},
      {text:'余额记录',icon:'../../static/images/index/icon31.png',bgColor:'#16b387',url:'/pages/functionList/balanceRecord/index',isUrl:1},
      {text:'消费记录',icon:'../../static/images/index/icon32.png',bgColor:'#329ae8',url:'/pages/functionList/paymentRecord/index',isUrl:1},
      {text:'充值记录',icon:'../../static/images/index/icon33.png',bgColor:'#faaf0f',url:'/pages/functionList/rechargeRecord/index',isUrl:1},
      {text:'账户共享',icon:'../../static/images/index/icon34.png',bgColor:'#faaf0f',url:'',isUrl:4},
      {text:'充值记录',icon:'../../static/images/index/icon33.png',bgColor:'#f0a50e',url:'/pages/functionList/rechargeRecord/index',isUrl:1},
      {text:'水卡共享',icon:'../../static/images/index/icon34.png',bgColor:'#55ca8c',url:'/pages/functionList/share/cardShare/index',isUrl:1},
      {text:'故障上报',icon:'../../static/images/index/icon35.png',bgColor:'#a88ff1',url:'/pages/infoBreakdown/index',isUrl:1},
      {text:'优惠卷',icon:'../../static/images/index/icon36.png',bgColor:'#18bfc4',url:'',isUrl:4},
      {text:'会员卡挂失',icon:'../../static/images/index/icon37.png',bgColor:'#4875f0',url:'',isUrl:2},
@@ -103,62 +102,74 @@
      if(isUrl == 1){
         navTo(url)
      }else if(isUrl == 2){
         uni.showModal({
               title: '会员卡挂失',
               content: '确认挂失会员卡?',
               success: async function(res) {
               if (res.confirm) {
                  await reportLossApi(cardInfo.value.waterCardNumber).then(async(res) =>{
                     if(res.code == 200){
                        uni.showToast({
                           title: '已挂失',
                           duration: 2000,
                        });
                        await getVipInfoApi().then((res) =>{
                           if(res.code == 200){
                              if(res.data.state == 2){
                                 isLoss.value = true
         if(cardInfo.value.waterCardNumber){
            uni.showModal({
                  title: '会员卡挂失',
                  content: '确认挂失会员卡?',
                  success: async function(res) {
                  if (res.confirm) {
                     await reportLossApi(cardInfo.value.waterCardNumber).then(async(res) =>{
                        if(res.code == 200){
                           uni.showToast({
                              title: '已挂失',
                              duration: 2000,
                           });
                           await getVipInfoApi().then((res) =>{
                              if(res.code == 200){
                                 if(res.data.state == 2){
                                    isLoss.value = true
                                 }
                              }
                           }
                        })
                     }
                  })
               }else{
                  console.log('点击了取消7')
                           })
                        }
                     })
                  }
               }
            }
         })
            })
         }else{
            uni.showToast({
               title:'未绑定会员卡!',
               icon:'none'
            })
         }
      }else if(isUrl == 3){
         uni.showModal({
               title: '会员卡注销',
               content: '确认注销会员卡?',
               success: async function(res) {
               if (res.confirm) {
                  await removeCardApi(cardInfo.value.waterCardNumber).then(async(res) =>{
                     if(res.code == 200){
                        uni.showToast({
                           title: '已注销',
                           duration: 2000,
                           icon:'none',
                        });
                        await getVipInfoApi().then((res) =>{
                           if(res.code == 200){
                              if(!res.data.id){
                                 isVip.value = false
                                 cardInfo.value.balance = ''
                                 cardInfo.value.count = ''
                                 cardInfo.value.waterCardNumber = ''
                                 uni.setStorageSync('userInfo',JSON.stringify(cardInfo.value))
         if(cardInfo.value.waterCardNumber){
            uni.showModal({
                  title: '会员卡注销',
                  content: '确认注销会员卡?',
                  success: async function(res) {
                  if (res.confirm) {
                     await removeCardApi(cardInfo.value.waterCardNumber).then(async(res) =>{
                        if(res.code == 200){
                           uni.showToast({
                              title: '已注销',
                              duration: 2000,
                              icon:'none',
                           });
                           await getVipInfoApi().then((res) =>{
                              if(res.code == 200){
                                 if(!res.data.id){
                                    isVip.value = false
                                    cardInfo.value.balance = ''
                                    cardInfo.value.count = ''
                                    cardInfo.value.waterCardNumber = ''
                                    uni.setStorageSync('userInfo',JSON.stringify(cardInfo.value))
                                 }
                              }
                           }
                        })
                     }
                  })
               }else{
                  console.log('点击了取消8')
                           })
                        }
                     })
                  }else{
                     console.log('点击了取消8')
                  }
               }
            }
         })
            })
         }else{
               uni.showToast({
                  title:'未绑定会员卡!',
                  icon:'none'
               })
         }
      }else{
         uni.showToast({
            title: '该功能正在升级中!',
@@ -209,7 +220,8 @@
            </view>
            <view class="card">
               <image class="card-bg" src="../../static/images/index/card11.png" alt=""></image>
               <view class="card-content">
               <view v-if="isShareCard" class="share-card">共享卡号:{{cardInfo.waterCardNumber}}</view>
               <view v-if="!isShareCard" class="card-content">
                  <view class="card-left">
                     <view class="left-top">
                        <view>
@@ -367,6 +379,15 @@
                  top:0;
                  position: absolute;
                  z-index:1;
               }
               .share-card{
                  position:absolute;
                  top:16rpx;
                  left:28rpx;
                  z-index:100;
                  font-weight:400;
                  font-size: 36rpx;
                  color: #FFFFFF;
               }
               .card-content{
                  width: 100%;
@@ -577,7 +598,7 @@
                     display: flex;
                     justify-content: center;
                     align-items: center;
                     background: #65A7FD;
                     // background: #65A7FD;
                     border-radius:50%;
                     image{
                        width: 48rpx;