Browse Source

修改提交订单优惠券显示

zs 1 year ago
parent
commit
de7f05605a

+ 42 - 8
pagesIndex/order/order.vue

@@ -24,7 +24,7 @@
 						<view class="one_4" v-if="couponList.length>0">
 							<view class="left">优惠券</view>
 							<view class="right" @tap="toCoupon">
-								<text v-if="discountInfo.name">{{discountInfo.name}}</text>
+								<text class="text" v-if="discountInfo.name">{{discountInfo.name}}</text>
 								<text class="iconfont icon-dayuhao"></text>
 							</view>
 						</view>
@@ -92,7 +92,8 @@
 							<uni-easyinput v-model="form.card" minlength="18" maxlength="18" placeholder="必填,请输入证件号" />
 						</uni-forms-item>
 						<uni-forms-item label="手机号" name="phone" required>
-							<uni-easyinput v-model="form.phone" minlength="11" maxlength="11" placeholder="必填,请输入联系人手机号" />
+							<uni-easyinput v-model="form.phone" minlength="11" maxlength="11"
+								placeholder="必填,请输入联系人手机号" />
 						</uni-forms-item>
 					</uni-forms>
 					<button class="button" type="primary" @click="submit">保存</button>
@@ -123,8 +124,7 @@
 									</view>
 									<view class="center">
 										<view class="name textOver">{{item.name}}</view>
-										<view class="content">有效日期:({{item.expire_type_label}}) {{item.expire_time}}
-										</view>
+										<view class="content">有效日期:{{item.time}}</view>
 									</view>
 									<view class="right">
 										<button class="button_1" type="primary" @tap="toUser(item)">使用</button>
@@ -192,7 +192,8 @@
 							errorMessage: '请填写手机号码',
 						}, {
 							validateFunction: function(rule, value, data, callback) {
-								let iphoneReg =  /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
+								let iphoneReg =
+									/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
 								if (!iphoneReg.test(value)) {
 									callback('手机号码格式不正确,请重新填写')
 								}
@@ -359,7 +360,27 @@
 						icon: 'none',
 						duration: 2000
 					});
-				} else that.$set(that, `discountInfo`, item);
+				} else {
+					const date = moment().format('YYYY-MM-DD HH:mm:ss');
+					const time = item.time.split('至');
+					// 判断日期是否在开始日期和结束日期中间,并且可能是开始日期或者结束日期
+					const startDate = time[0];
+					const endDate = time[1];
+					const format = 'YYYY-MM-DD HH:mm:ss';
+					const diffStart =
+						moment(startDate, format).diff(moment(date, format), 'days') <= 0;
+					const diffEnd =
+						moment(endDate, format).diff(moment(date, format), 'days') >= 0;
+					const diffDtate = diffStart && diffEnd;
+					if (diffDtate) that.$set(that, `discountInfo`, item);
+					else {
+						uni.showToast({
+							title: '该优惠券过期了 无法使用!',
+							icon: 'none',
+							duration: 2000
+						});
+					}
+				}
 				that.toCouponClose();
 			},
 			// 关闭弹框
@@ -502,10 +523,23 @@
 				.one_4 {
 					display: flex;
 					justify-content: space-between;
-					font-size: var(--font18Size);
-					font-weight: bold;
 					padding: 2vw;
 					border-bottom: 1px solid var(--f9Color);
+
+					.left {
+						font-size: var(--font18Size);
+						font-weight: bold;
+					}
+
+					.right {
+						.text {
+							padding: 4px;
+							font-size: var(--font12Size);
+							color: var(--mainColor);
+							border-radius: 5px;
+							background: linear-gradient(to right, #FFA500, #FF0000);
+						}
+					}
 				}
 			}
 

File diff suppressed because it is too large
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesIndex/order/order.js.map


+ 18 - 1
unpackage/dist/dev/mp-weixin/pagesIndex/order/order.js

@@ -499,7 +499,24 @@ var _default = {
           icon: 'none',
           duration: 2000
         });
-      } else that.$set(that, "discountInfo", item);
+      } else {
+        var date = (0, _moment.default)().format('YYYY-MM-DD HH:mm:ss');
+        var time = item.time.split('至');
+        // 判断日期是否在开始日期和结束日期中间,并且可能是开始日期或者结束日期
+        var startDate = time[0];
+        var endDate = time[1];
+        var format = 'YYYY-MM-DD HH:mm:ss';
+        var diffStart = (0, _moment.default)(startDate, format).diff((0, _moment.default)(date, format), 'days') <= 0;
+        var diffEnd = (0, _moment.default)(endDate, format).diff((0, _moment.default)(date, format), 'days') >= 0;
+        var diffDtate = diffStart && diffEnd;
+        if (diffDtate) that.$set(that, "discountInfo", item);else {
+          uni.showToast({
+            title: '该优惠券过期了 无法使用!',
+            icon: 'none',
+            duration: 2000
+          });
+        }
+      }
       that.toCouponClose();
     },
     // 关闭弹框

File diff suppressed because it is too large
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesIndex/order/order.wxml


+ 11 - 2
unpackage/dist/dev/mp-weixin/pagesIndex/order/order.wxss

@@ -70,11 +70,20 @@
 .main .info .one .one_4.data-v-0ce3258c {
   display: flex;
   justify-content: space-between;
-  font-size: var(--font18Size);
-  font-weight: bold;
   padding: 2vw;
   border-bottom: 1px solid var(--f9Color);
 }
+.main .info .one .one_4 .left.data-v-0ce3258c {
+  font-size: var(--font18Size);
+  font-weight: bold;
+}
+.main .info .one .one_4 .right .text.data-v-0ce3258c {
+  padding: 4px;
+  font-size: var(--font12Size);
+  color: var(--mainColor);
+  border-radius: 5px;
+  background: linear-gradient(to right, #FFA500, #FF0000);
+}
 .main .info .two.data-v-0ce3258c {
   margin: 0 2vw;
   padding: 2vw;