浏览代码

支付 修复

lilei 4 年之前
父节点
当前提交
64ddeaeedd
共有 2 个文件被更改,包括 79 次插入12 次删除
  1. 8 0
      api/luckyDraw.js
  2. 71 12
      pagesA/luckDraw/luckDraw.vue

+ 8 - 0
api/luckyDraw.js

@@ -19,4 +19,12 @@ export const findCustomerTask = params => {
     url: `luckyDrawCust/findCustomerTask/${params.id}`,
     method: 'get',
   })
+};
+// 购买抽奖次数
+export const buyDrawTimes = params => {
+  return axios.request({
+    url: `luckyDrawCust/buyDrawTimes`,
+    method: 'post',
+	data: params
+  })
 };

+ 71 - 12
pagesA/luckDraw/luckDraw.vue

@@ -120,9 +120,9 @@
 			<view class="lottery-content win_4" v-if="winTypes == 'win_4'">
 				<view class="lottery-title">
 					<view>请输入支付密码</view>
-					<view class="pay-info">支付<text>10</text><image src="../../static/ledou.png"></image></view>
+					<view class="pay-info">支付<text>{{luckDraw.purchaseTimesGold}}</text><image src="../../static/ledou.png"></image></view>
 					<view>
-						<u-input v-model="payPws" trim type="password" :border="true" :password-icon="true" placeholder="请输入支付密码"></u-input>
+						<u-input v-model="payPws" :focus="focus" trim type="password" :border="true" :password-icon="true" placeholder="请输入支付密码"></u-input>
 					</view>
 				</view>
 				<view class="lottery-confrim-btn" @click="toPaySubmit">
@@ -130,13 +130,23 @@
 				</view>
 			</view>
 		</u-popup>
+		<!-- 提示用户设置支付密码 -->
+		<u-modal v-model="showSetPswModal" 
+		content="请先设置支付密码,才能使用乐豆" 
+		show-cancel-button 
+		confirm-text="去设置" 
+		cancel-text="暂时放弃"
+		@confirm="toSetPwd"
+		@cancel="showSetPswModal=false"
+		></u-modal>
 	</view>
 </template>
 
 <script>
 import AlmostLottery from '@/components/almost-lottery/almost-lottery.vue';
 import { clearCacheFile } from '@/almost-utils/almost-utils.js';
-import { findCustomerTimes } from '@/api/luckyDraw.js'
+import { findCustomerTimes, buyDrawTimes } from '@/api/luckyDraw.js'
+import { existPayPwd } from '@/api/order.js'
 export default {
 	name: 'Home',
 	components: {
@@ -161,6 +171,8 @@ export default {
 	},
 	data() {
 		return {
+			focus: false,
+			showSetPswModal: false,
 			animateUp: false,
 			timer: null,
 			scrollTextHeight: 400,
@@ -305,10 +317,22 @@ export default {
 		},
 		// 抽奖次数用完了
 		showPayWin(winTypes){
-			this.showLottery = true
-			this.winTypes = winTypes
-			this.prizeIndex = -1
-			clearCacheFile()
+			// 判断用户是否设置过支付密码
+			existPayPwd().then(res=>{
+				if(res.status == 200) {
+					// 设置过支付密码,输入密码
+					if(res.data) {
+						 this.payPws = ''
+						 this.showLottery = true
+						 this.winTypes = winTypes
+						 this.prizeIndex = -1
+						 clearCacheFile()
+					} else {
+						// 没设置过支付密码,提示设置密码
+						 this.showSetPswModal = true
+					}
+				} 
+			})
 		},
 		// 本次抽奖开始
 		handleDrawStart() {
@@ -393,14 +417,31 @@ export default {
 		},
 		// 支付乐豆继续抽奖
 		toPay(){
+			this.payPws = ''
 			this.winTypes = 'win_4'
 		},
 		// 支付确定
 		toPaySubmit(){
-			this.showLottery = false
-			uni.navigateTo({
-				url: '/pagesA/luckDraw/paySuccess'
-			})
+			if(this.payPws != ''){
+				let params = {
+					"payPwd": this.payPws,
+					"payGold": this.luckDraw.purchaseTimesGold,
+					"luckyDrawNo": this.luckDraw.luckyDrawNo
+				}
+				buyDrawTimes(params).then(res => {
+					if(res.status == 200){
+						this.showLottery = false
+						uni.navigateTo({
+							url: '/pagesA/luckDraw/paySuccess'
+						})
+					}
+				})
+			}else{
+				uni.showToast({
+					icon: 'none',
+					title: '请输入支付密码'
+				})
+			}
 		},
 		// 文字滚动
 		scrollAnimate() {
@@ -433,7 +474,22 @@ export default {
 			uni.navigateTo({
 				url: '/pagesA/taskList/taskList?id='+this.luckDraw.luckyDrawNo
 			})
-		}
+		},
+		// 跳转到设置支付密码页
+		toSetPwd () {
+			uni.navigateTo({
+				url:"/pages/userCenter/userInfo/smsVerification"
+			})
+		},
+		// 设置密码成功, 打开输入密码弹窗
+		setPsw (e) {
+			if (e.success) {
+				this.toPay()
+				setTimeout(()=>{
+					this.focus = true
+				},300)
+			}
+		},
 	},
 	onShow() {
 		this.timer = setInterval(this.scrollAnimate, 2000);
@@ -457,6 +513,9 @@ export default {
 			withShareTicket: true,
 			menus: ['shareAppMessage', 'shareTimeline']
 		})
+		
+		// 监听设置密码是否成功
+		uni.$once('setPswSuccess', this.setPsw)
 	},
 	onUnload() {
 		uni.hideLoading();