Kaynağa Gözat

表单数据验证处理与过期红包展示修改

shizhongqi 4 ay önce
ebeveyn
işleme
326c96af14

+ 14 - 0
hdApp/src/admin/hb/send.vue

@@ -98,6 +98,20 @@ export default {
         this.$msg('请输入最低消费');
         return;
       }
+      // form.amount 小数点后只能两位
+      if (this.form.amount.split('.')[1] && this.form.amount.split('.')[1].length > 2) {
+        this.$msg('红包金额最小到分');
+        return;
+      }
+      if (this.form.minConsume.split('.')[1] && this.form.minConsume.split('.')[1].length > 2) {
+        this.$msg('最低消费最小到分');
+        return;
+      }
+      // 有效时长只能是正整数
+      if (isNaN(this.form.days) || this.form.days % 1 !== 0 || this.form.days < 0) {
+        this.$msg('有效时长必须为正整数');
+        return;
+      }
       this.$util.confirmModal({content:'确认发放?'},() => {
         createHb({ userId: this.userId, customId: this.customId, ...this.form, }).then(res => {
           if (res.code == 1) {

+ 17 - 0
hdApp/src/admin/hb/sendHb.vue

@@ -216,6 +216,11 @@ export default {
             this.$msg('请输入充值金额');
             return;
         }
+        // 金额小数点后只能两位
+        if (this.amount.split('.')[1] && this.amount.split('.')[1].length > 2) {
+            this.$msg('充值金额最小到分');
+            return;
+        }
         for (let i = 0; i < this.rules.length; i++) {
             const rule = this.rules[i];
             
@@ -235,6 +240,18 @@ export default {
                 this.$msg(`请输入第${i+1}项最低消费`);
                 return;
             }
+            if (rule.hbAmount.split('.')[1] && rule.hbAmount.split('.')[1].length > 2) {
+                this.$msg('红包金额最小到分');
+                return;
+            }
+            if (rule.miniCost.split('.')[1] && rule.miniCost.split('.')[1].length > 2) {
+                this.$msg('最低消费最小到分');
+                return;
+            }
+            if (isNaN(rule.duration) || rule.duration % 1 !== 0 || rule.duration < 0) {
+                this.$msg('有效时长必须为正整数');
+                return;
+            }
         }
 
         sendHbRule({id: this.id, amount: this.amount, rules: this.rules}).then(res => {

+ 5 - 4
mallApp/src/pages/hb/list.vue

@@ -27,10 +27,11 @@
 							<view class="coupon-message">
 								<view class="title">{{ item.name }}</view>
 								<view class="shop">所属门店:{{ item.merchantName }}</view>
-								<!-- 开始生效时间点 -->
-								<view class="date" v-if="item.beginTime * 1000 > Date.now()">生效时间:{{ item.beginTime | formatTime('YYYY-MM-DD') }}</view>
-								<view class="date" v-if="item.endTime == 4102416000">有效期:永久可用</view>
-								<view class="date" v-else>有效期至:{{ item.endTime | formatTime('YYYY-MM-DD') }}</view>
+								<template v-if="item.status != -1">
+									<view class="date" v-if="item.beginTime * 1000 > Date.now()">生效时间:{{ item.beginTime | formatTime('YYYY-MM-DD') }}</view>
+									<view class="date" v-if="item.endTime == 4102416000">有效期:永久可用</view>
+									<view class="date" v-else>有效期至:{{ item.endTime | formatTime('YYYY-MM-DD') }}</view>
+								</template>
 							</view>
 							<!-- 未使用 -->
 							<template v-if="item.status == 0">