Преглед изворни кода

feat:亲情卡赠送次数判断

zhanghui пре 2 година
родитељ
комит
ff23e87712
2 измењених фајлова са 32 додато и 3 уклоњено
  1. 7 1
      common/js/api.js
  2. 25 2
      myPages/familyCard/giveFamilyCard/giveFamilyCard.vue

+ 7 - 1
common/js/api.js

@@ -849,6 +849,12 @@ export default {
         })
     },
 
-
+    //查询剩余可赠送次数
+    presentCount(){
+        return request({
+            url: '/member/loveCard/presentCount',
+            method: 'GET'
+        })
+    }
 
 }

+ 25 - 2
myPages/familyCard/giveFamilyCard/giveFamilyCard.vue

@@ -12,8 +12,12 @@
     </u--form>
     <view class="op-btn-wrap">
       <view class="h-btn" @click="handleGive">
-        <text>确定</text>
+        <text>确定
+          <text class="presentCount" v-if="count !== null">(剩余可赠送{{count}}次)</text>
+        </text>
       </view>
+
+
     </view>
   </view>
 </template>
@@ -24,11 +28,21 @@ export default {
   data() {
     return {
       userInfo: {},
-      giveUser: {}
+      giveUser: {},
+      count:null
     }
   },
+  onShow(){
+    this.presentCount()
+  },
   methods: {
     handleGive() {
+
+      if (this.count == 0){
+        uni.$u.toast('可赠送次数不足!')
+        return
+      }
+
       this.giveUser.memberNo = "Vip." + this.userInfo.memberNo
       this.giveUser.memberPhone = this.userInfo.memberPhone
       this.$api.giveFamilyCard(this.giveUser).then((res) => {
@@ -40,6 +54,11 @@ export default {
               uni.navigateBack({delta : 1})
           }
       )
+    },
+    presentCount(){
+      this.$api.presentCount().then(res=>{
+        this.count = res.data.data
+      })
     }
   }
 }
@@ -59,4 +78,8 @@ export default {
   border-radius: 27px;
   line-height: 42px;
 }
+.presentCount{
+  font-size: 24rpx;
+  color: #666666;
+}
 </style>