Ver Fonte

礼品卡数据对接

chenrui há 4 anos atrás
pai
commit
2101aea531
2 ficheiros alterados com 31 adições e 2 exclusões
  1. 9 0
      api/coupon.js
  2. 22 2
      pagesA/giftCard/giftCard.vue

+ 9 - 0
api/coupon.js

@@ -35,3 +35,12 @@ export const couponEnable = (params) => {
 		data: params
 	})
 }
+
+//  礼品卡   立即充值
+export const giftCardUseCard = (params) => {
+	return axios.request({
+		url: `giftCard/useCard/${params.sequence}`,
+		method: 'post',
+		data: {}
+	})
+}

+ 22 - 2
pagesA/giftCard/giftCard.vue

@@ -15,7 +15,7 @@
 					<view class="inp-con">
 						<u-input v-model="rechargeCode" placeholder="请输入充值码" :maxlength="8" input-align="center" />
 					</view>
-					<u-button class="recharge-btn" shape="circle" :custom-style="customBtnStyle" hover-class="none" @click="messagePop=true">立即充值</u-button>
+					<u-button class="recharge-btn" shape="circle" :custom-style="customBtnStyle" hover-class="none" @click="goRecharge">立即充值</u-button>
 				</view>
 				<image class="module-footer-bg" src="/static/giftcard/module-footer-bg.png"></image>
 			</view>
@@ -58,6 +58,7 @@
 </template>
 
 <script>
+	import { giftCardUseCard } from '@/api/coupon'
 	export default{
 		data(){
 			return{
@@ -71,7 +72,26 @@
 			}
 		},
 		methods: {
-			
+			//  立即充值
+			goRecharge(){
+				if(!this.rechargeCode){
+					uni.showToast({
+						title:"请输入充值码",
+						icon:"none"
+					})
+					return
+				}
+				uni.showLoading({
+					mask: true,
+					title: "正在充值..."
+				})
+				giftCardUseCard({ sequence: this.rechargeCode }).then(res => {
+					uni.hideLoading()
+					if(res.status == 200){
+						this.messagePop = true
+					}
+				})
+			}
 		}
 	}
 </script>