xiaoxin 8 meses atrás
pai
commit
515f72e7ac
2 arquivos alterados com 99 adições e 20 exclusões
  1. 35 9
      my/address/add.vue
  2. 64 11
      my/index/coupon/index.vue

+ 35 - 9
my/address/add.vue

@@ -305,7 +305,7 @@
 				if(this.form.isInner){
 					if (!this.form.address) {
 						uni.showToast({
-							title: '请选择骑手站点',
+							title: '请选择校区',
 							icon: 'none'
 						})
 						return
@@ -365,19 +365,45 @@
 					})
 					return
 				}
-				if (!this.form.address) {
+				let phonereg = /^1[3-9]\d{9}$/
+				if (!phonereg.test(this.form.userPhone)) {
 					uni.showToast({
-						title: '请选择所在地区',
+						title: '请输入正确联系电话',
 						icon: 'none'
 					})
 					return
 				}
-				if (!this.form.addressDetail) {
-					uni.showToast({
-						title: '请输入详细地址',
-						icon: 'none'
-					})
-					return
+				
+				if(this.form.isInner){
+					if (!this.form.address) {
+						uni.showToast({
+							title: '请选择校区',
+							icon: 'none'
+						})
+						return
+					}
+					if (!this.form.addressDetail) {
+						uni.showToast({
+							title: '请选择详细地址',
+							icon: 'none'
+						})
+						return
+					}
+				}else{
+					if (!this.form.address) {
+						uni.showToast({
+							title: '请选择所在地区',
+							icon: 'none'
+						})
+						return
+					}
+					if (!this.form.addressDetail) {
+						uni.showToast({
+							title: '请输入详细地址',
+							icon: 'none'
+						})
+						return
+					}
 				}
 
 				let data = {

+ 64 - 11
my/index/coupon/index.vue

@@ -2,14 +2,14 @@
 	<view class="container">
 		<!-- 优惠券信息 -->
 		<view class="info">
-			<view class="info_name">外卖满减券</view>
-			<view class="info_term">满25可用</view>
+			<view class="info_name">{{ info.couponName }}</view>
+			<view class="info_term" v-if="info.minMoney">满{{ info.minMoney || 0 }}可用</view>
 			<view class="info_box">
 				<text class="text">¥</text>
-				5
+				{{ info.money || 0 }}
 			</view>
-			<view class="info_btn">立即领取</view>
-			<view class="info_time">2025.09.22 23:59 到期</view>
+			<view class="info_btn" @click="handleFetch">立即领取</view>
+			<view class="info_time" v-if="info.expirationTime">{{ info.expirationTime }}到期</view>
 		</view>
 	</view>
 </template>
@@ -18,7 +18,9 @@
 export default {
 	data() {
 		return {
-			imgtype1: ''
+			shopId: '',
+			couponId: '',
+			info: {}
 		}
 	},
 	onLoad(option) {
@@ -34,14 +36,65 @@ export default {
 				params[key] = value
 			})
 
-			let shopId = params.shopId
-			let couponId = params.couponId
+			this.shopId = params.shopId
+			this.couponId = params.couponId
 
-			console.log(shopId)
-			console.log(couponId)
+			this.getInfo()
 		}
 	},
-	methods: {}
+	methods: {
+		getInfo() {
+			let data = {
+				couponId: this.couponId
+			}
+			this.$Request.get('/app/coupon/selectCoupon', data).then((res) => {
+				// console.log(res, 963)
+				if (res.code == 0) {
+					this.info = res.data
+				}
+			})
+		},
+		handleFetch() {
+			let userId = uni.getStorageSync('userId')
+
+			if (userId) {
+				let data = {
+					couponId: this.couponId,
+					shopId: this.shopId,
+					userId
+				}
+				this.$Request.get('/app/coupon/receiveCoupon', data).then((res) => {
+					// console.log(res, 888)
+					if (res.code == 0) {
+						uni.showToast({
+							title: '领取成功',
+							icon: 'success'
+						})
+						setTimeout(() => {
+							uni.reLaunch({
+								url: '/my/coupon/index'
+							})
+						}, 1500)
+					} else {
+						uni.showToast({
+							title: res.msg,
+							icon: 'none'
+						})
+					}
+				})
+			} else {
+				uni.showToast({
+					title: '请先登录',
+					icon: 'none'
+				})
+				setTimeout(() => {
+					uni.navigateTo({
+						url: '/pages/public/login'
+					})
+				}, 1500)
+			}
+		}
+	}
 }
 </script>