Pārlūkot izejas kodu

完善扫码查看幸运数字

hwb0 3 gadi atpakaļ
vecāks
revīzija
a823d28287

+ 5 - 0
components/pay-popup/pay-popup.vue

@@ -100,8 +100,12 @@
 					uni.$u.toast('请同意《盲票购买须知》!');
 					return
 				}
+				uni.showLoading({
+					title: '支付中'
+				});
 				if (payIng) return
 				$http.post('/api/v1/mp/user/ticket/order/submit', {}).then(res => {
+					uni.hideLoading();
 					payIng = true
 					if (res.code == 0) {
 						if (res.data.needPay == 1) {
@@ -153,6 +157,7 @@
 						uni.$u.toast('支付失败!');
 					}
 				}).catch(() => {
+					uni.hideLoading();
 					payIng = false
 					uni.$u.toast('支付失败!');
 				})

+ 51 - 4
pages/choice/index.vue

@@ -2,8 +2,8 @@
 	<view>
 		<u-navbar title="选择奖品" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
 		<view class="choice">
-			<view class="choice-title">恭喜你获得</view>
-			<view class="choice-all" v-if="total > 1">以下奖品任选其一</view>
+			<view class="choice-title" v-if="!tipShow">恭喜你获得</view>
+			<view class="choice-all" v-if="total > 1 && !tipShow">以下奖品任选其一</view>
 			<view class="flex choice-list">
 				<view class="choice-list-item" v-for="(item, index) in prizeList" :key="index"
 					@click="selectPrize(item, index)">
@@ -18,9 +18,16 @@
 				</view>
 			</view>
 			<view class="flex btn">
-				<view class="confirm" @click="confirmPrize">确认</view>
+				<view class="confirm" @click="confirmPrize" v-if="!tipShow">确认</view>
 			</view>
 		</view>
+
+		<u-popup :show="tipShow" :round="10" mode="center">
+			<view class="null-prize">
+				<view class="title">该盲票已被他人买走了</view>
+				<view class="btn" @click="toIndex">确认</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -34,11 +41,14 @@
 				prizeList: [],
 				total: 0,
 				actionIndex: 0,
+				tipShow: false
 			};
 		},
 		onLoad(options) {
 			this.ticketId = options.id
 			this.orderId = options.orderId
+		},
+		onShow() {
 			this.getPrizeList()
 		},
 		methods: {
@@ -46,7 +56,11 @@
 				uni.showLoading({
 					title: '加载中'
 				});
-				let data = this.orderId ? { orderId: this.orderId } : { ticketId: this.ticketId }
+				let data = this.orderId ? {
+					orderId: this.orderId
+				} : {
+					ticketId: this.ticketId
+				}
 				$http.post('/api/v1/mp/user/ticket/queryHitPrizeList', data).then(res => {
 					uni.hideLoading();
 					if (res.code == 0) {
@@ -57,6 +71,10 @@
 						this.prizeList = res.data.prizeList
 						this.ticketId = res.data.ticketId
 						this.total = res.data.length
+					} else if (res.code == 1018) {
+						this.tipShow = true
+					}else{
+						this.tipShow = true
 					}
 				}).catch(() => {
 					uni.hideLoading();
@@ -98,6 +116,12 @@
 				})
 
 			},
+
+			toIndex() {
+				uni.switchTab({
+					url: '/pages/index/index'
+				})
+			},
 		}
 	}
 </script>
@@ -193,4 +217,27 @@
 			}
 		}
 	}
+
+	.null-prize {
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		justify-content: center;
+		width: 80vw;
+		height: 320rpx;
+		background-color: #FFFFFF;
+		border: 1px solid rgba(187, 187, 187, 100);
+
+		.btn {
+			margin-top: 60rpx;
+			width: 160rpx;
+			height: 60rpx;
+			line-height: 60rpx;
+			border-radius: 8rpx;
+			background-color: rgba(235, 112, 9, 100);
+			color: rgba(255, 255, 255, 100);
+			font-size: 28rpx;
+			text-align: center;
+		}
+	}
 </style>

+ 16 - 6
pages/goods/detail.vue

@@ -28,7 +28,7 @@
 			<view class="choiceShow-wrap">
 				<view class="flex goods">
 					<view class="flex image-wrap">
-						<image :src="picUrlArr[0]" mode="aspectFill"></image>
+						<image :src="payInfo.picUrl" mode="aspectFill"></image>
 					</view>
 					<view class="info">
 						<view class="info-title">{{ info.title }}</view>
@@ -189,7 +189,9 @@
 			valChange(e, item) {
 				let value = e.value
 				this.$set(item, 'value', value * item.exValue)
-				console.log(value, item);
+				if(this.payInfo.quantity < value){
+					uni.$u.toast('库存不足');
+				}
 			},
 
 			getSku(e, item, indexs) {
@@ -210,24 +212,32 @@
 			},
 
 			confirmPrize() {
-				uni.showLoading({
-					title: '兑换中'
-				});
 				let data = {
 					goodsId: this.payInfo.goodsId,
 					skuId: this.payInfo.skuId,
 					orderNum: this.orderNum,
 				}
-				console.log(data);
+				if(this.payInfo.quantity == 0){
+					uni.$u.toast('库存不足');
+					return
+				}
+				if(this.payInfo.quantity < this.orderNum){
+					uni.$u.toast('库存不足');
+					return
+				}
 				if (this.initData.coinNum < this.payInfo.value) {
 					uni.$u.toast('盲豆余额不足');
 					return
 				}
+				uni.showLoading({
+					title: '兑换中'
+				});
 				$http.post('/api/v1/mp/user/exchange/submit', data).then(res=>{
 					uni.hideLoading();
 					if(res.code == 0){
 						this.choiceShow = false
 						this.tipShow = true
+						this.getDetail()
 					}
 				}).catch(() => {
 					uni.hideLoading();

+ 5 - 1
pages/login/index.vue

@@ -3,7 +3,7 @@
 		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" title="微信授权"></u-navbar>
 		<view class="login">
 			<view class="flex login-image">
-				<view class="image"></view>
+				<view class="image">MP</view>
 			</view>
 			<view class="login-txt">盲票</view>
 			<view class="login-txt">盲票将为您提供</view>
@@ -97,6 +97,10 @@
 				border-radius: 10rpx;
 				margin-bottom: 14rpx;
 				background-color: $uni-bg-color;
+				color: #FFFFFF;
+				line-height: 164rpx;
+				font-size: 50rpx;
+				text-align: center;
 			}
 		}
 

+ 40 - 11
pages/lucky/index.vue

@@ -18,6 +18,7 @@
 				<view class="pay" @click="screen" v-else>保存至手机相册</view>
 			</view>
 			<view class="index" @click="toIndex">去首页</view>
+
 		</view>
 
 		<pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" />
@@ -45,15 +46,26 @@
 				info: '',
 				payInfo: {},
 				payShow: false,
-				showNull: false
+				showNull: false,
 			};
 		},
 
 		onLoad(options) {
-			this.serialNo = options.id
-			this.getDetail()
-		},
+			if (options.id) {
+				console.log(options);
+				this.serialNo = options.id
+			}
 
+			if (options.q) {
+				let url = JSON.stringify(options.q)
+				this.serialNo = url.substring(url.length - 22, url.length - 1)
+			}
+		},
+		onShow() {
+			if (this.serialNo) {
+				this.getDetail()
+			}
+		},
 		methods: {
 			getDetail() {
 				uni.showLoading({
@@ -68,18 +80,35 @@
 						if (res.data.status == 1) {
 							this.info = res.data
 						} else if (res.data.status == 2) {
-							uni.redirectTo({
-								url: `/pages/choice/index?id=${ res.data.ticketId }`
-							})
+							if (uni.getStorageSync('token')) {
+								uni.redirectTo({
+									url: `/pages/choice/index?id=${ res.data.ticketId }`
+								})
+							} else {
+								uni.showModal({
+									title: '提示',
+									content: '您未登录或登录失效!',
+									confirmText: '去登录',
+									showCancel: false,
+									success(res) {
+										if (res.confirm) {
+											uni.navigateTo({
+												url: "/pages/login/index"
+											})
+										}
+									}
+								})
+							}
 						} else {
 							this.showNull = true
 						}
 					} else {
+						uni.$u.toast('该盲票不存在!');
 						setTimeout(() => {
 							uni.switchTab({
 								url: '/pages/index/index'
 							})
-						}, 500)
+						}, 1000)
 					}
 				}).catch(() => {
 					uni.hideLoading();
@@ -214,13 +243,13 @@
 		flex-direction: column;
 		align-items: center;
 		justify-content: center;
-		width: 70vw;
-		height: 260rpx;
+		width: 80vw;
+		height: 320rpx;
 		background-color: #FFFFFF;
 		border: 1px solid rgba(187, 187, 187, 100);
 
 		.btn {
-			margin-top: 50rpx;
+			margin-top: 60rpx;
 			width: 160rpx;
 			height: 60rpx;
 			line-height: 60rpx;

+ 4 - 0
pages/prize/index.vue

@@ -183,7 +183,11 @@
 					uni.$u.toast('请选择商品');
 					return
 				}
+				uni.showLoading({
+					title: '提货中'
+				});
 				let ids = JSON.stringify(arr.map(item => item.storageId))
+				uni.hideLoading();
 				uni.navigateTo({
 					url: `/pages/order/settlement?ids=${ ids }`
 				})

+ 1 - 1
utils/request.js

@@ -47,7 +47,7 @@ const $http = (url, data, methods) => {
 							}
 						}
 					})
-				} else if (res.data && res.data.code !== 0 && res.data.code !== 1016) {
+				} else if (res.data && res.data.code !== 0 && res.data.code !== 1016 && res.data.code !== 1018) {
 					uni.showToast({
 						title: res.data.msg || '请求错误,请重试。',
 						icon: 'none',