瀏覽代碼

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
优惠券

1004749546@qq.com 4 年之前
父節點
當前提交
ccad7cfdde
共有 8 個文件被更改,包括 79 次插入32 次删除
  1. 9 1
      api/coupon.js
  2. 46 10
      pages/coupon/getCoupon/getCoupon.vue
  3. 16 15
      pages/coupon/index/index.vue
  4. 5 5
      pages/store/storeList.vue
  5. 二進制
      static/img/dky.jpg
  6. 二進制
      static/img/yyz.jpg
  7. 二進制
      static/img/ztyy.jpg
  8. 3 1
      store/index.js

+ 9 - 1
api/coupon.js

@@ -7,8 +7,16 @@ export const receivesCoupon = (params) => {
   })
 }
 
+// 查询要领取的优惠券
+export const couponData = (params) => {
+  return axios.request({
+    url: `couponReceives/receivesCoupon/${params.couponCode}`,
+    method: 'get'
+  })
+}
+
 // 优惠券领取明细查询
-export const couponList = (params) => {
+export const couponListFind = (params) => {
   return axios.request({
     url: `couponReceives/findPage`,
     method: 'post',

+ 46 - 10
pages/coupon/getCoupon/getCoupon.vue

@@ -20,25 +20,61 @@
 </template>
 
 <script>
+	import {couponData, receivesCoupon} from '@/api/coupon.js'
 	export default{
 		name: 'getCoupon',
 		data () {
 			return {
-				
+				couponInfo: {}, // 领取优惠券信息
+			}
+		},
+		onLoad(options) {
+			// 存储当前扫码的券码
+			if (options.scene) {
+				let scene = decodeURIComponent(options.scene);
+				//&是我们定义的参数链接方式
+				let couponCode = scene;
+				//其他逻辑处理。。。。。
+				this.$store.state.vuex_couponCode = couponCode
+				// 获取要领取的优惠券
+				this.getCoupon(couponCode)
+			} else {
+				// 判断是否扫码过
+				if (this.$store.state.vuex_couponCode != '') {
+					let couponCode = this.$store.state.vuex_couponCode
+					this.getCoupon(couponCode)
+				} else {
+					// 返回首页
+					uni.reLaunch({
+						url: "/pages/index/index"
+					})
+				}
 			}
 		},
 		methods: {
-			// 选中优惠卷
-			checked(item) {
-				if(this.showCheck){
-					let has = this.list.find(item=>item.checked)
-					if(has){
-						has.checked = false
+			// 获取要领取的优惠券
+			getCoupon (code) {
+				couponData({couponCode:code}).then(res=>{
+					if (res.status == 200) {
+						this.couponInfo = res.data
 					}
-					item.checked = true
-					this.$emit('checkOk',item)
-				}
+				})
 			},
+			// 确认领取优惠券
+			handleSubmit () {
+				let couponCode = this.$store.state.vuex_couponCode
+				receivesCoupon({couponCode:couponCode}).then(res =>{
+					if (res.status == 200) {
+						this.toashMsg('领取成功')
+						setTimeout(()=>{
+							uni.navigateTo({
+								url: '/pages/coupon/index/index'
+							})
+						},500)
+					}
+				})
+			}
+			
 		},
 	}
 </script>

+ 16 - 15
pages/coupon/index/index.vue

@@ -20,6 +20,7 @@
 
 <script>
 	import couponTpl from '@/pages/coupon/couponTpl.vue'
+	import {couponListFind} from '@/api/coupon.js'
 	export default {
 		components: {
 			couponTpl
@@ -37,41 +38,41 @@
 				}],
 				couponList: [{
 						id: 23432445,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 					},
 					{
 						id: 3544355,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 					},
 					{
 						id: 234234234,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 					},
 					{
 						id: 66264646,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 					},
 					{
 						id: 9794694698,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 					}

+ 5 - 5
pages/store/storeList.vue

@@ -24,7 +24,7 @@
 					</view>
 				</view>
 				<view class="list-right">
-					<u-image width="100rpx" height="44rpx" :border-radius="10" :src="getStoreStatus(item)"></u-image>
+					<u-image width="180rpx" height="120rpx" :border-radius="10" mode="aspectFit" :src="getStoreStatus(item)"></u-image>
 					<u-icon size="30" color="#999" name="arrow-right"></u-icon>
 				</view>
 			</view>
@@ -131,18 +131,18 @@
 				endTimeStamp = endTimeStamp <=beginTimeStamp ? (endTimeStamp+24*60*60*1000) : endTimeStamp
 				switch (item.businessStatus) {
 					case 'CLOSED':
-						return '/static/img/ygb.png'
+						return '/static/img/ztyy.jpg'
 						break;
 					case 'OPEN':
 						// 根据当前时间判断目前是否在营业时间范围内
 						if (nowTimeStamp>=beginTimeStamp && nowTimeStamp<=endTimeStamp) {
-							return '/static/img/yyz.png'
+							return '/static/img/yyz.jpg'
 						} else {
-							return '/static/img/ygb.png'
+							return '/static/img/ztyy.jpg'
 						}
 						break;
 					case 'TO_BE_OPENED':
-						return '/static/img/dky.png'
+						return '/static/img/dky.jpg'
 						break;
 					default:
 						break;

二進制
static/img/dky.jpg


二進制
static/img/yyz.jpg


二進制
static/img/ztyy.jpg


+ 3 - 1
store/index.js

@@ -52,7 +52,9 @@ const store = new Vuex.Store({
 			duration: 0, // 不同服务的机器运行时间
 			orderNo: '',// 订单编号
 			orderStatus: '' // 订单状态
-		}
+		},
+		// 优惠券码
+		vuex_couponCode: ''
 	},
 	mutations: {
 		$uStore(state, payload) {