lex 2 years ago
parent
commit
c249aa2666
4 changed files with 54 additions and 27 deletions
  1. 2 0
      src/common/vueFilters.js
  2. 33 18
      src/helpers/utils.js
  3. 7 6
      src/views/coupon/list.vue
  4. 12 3
      src/views/service/GoodsSale.vue

+ 2 - 0
src/common/vueFilters.js

@@ -150,3 +150,5 @@ Vue.filter("formatUnit", (value) => {
   };
   return template[value];
 });
+
+Vue.filter("coupontypeDetailType", (val) => constant.coupontypeDetail[val]);

+ 33 - 18
src/helpers/utils.js

@@ -1,28 +1,43 @@
-export const setTongjiTag = event => {
+import dayjs from "dayjs";
+
+export const setTongjiTag = (event) => {
   if (window._czc) {
-    window._czc.push(event)
+    window._czc.push(event);
   }
-}
+};
 
-export const sendUploadMessage = data => {
+export const sendUploadMessage = (data) => {
   return {
-    api: '',
+    api: "",
     payload: {}, // 参数
-    url: '', //提交url, 为空则app不提交数据仅上传视频,并返回视频url
-    callbackUrl: '', // 有就跳转没有就关闭
-    reload: false,  // 是否刷新当前页面,url为空时需要确保为false
-    ...data
-  }
-}
+    url: "", //提交url, 为空则app不提交数据仅上传视频,并返回视频url
+    callbackUrl: "", // 有就跳转没有就关闭
+    reload: false, // 是否刷新当前页面,url为空时需要确保为false
+    ...data,
+  };
+};
 
 // 身份证号(支持15位|18位)
-export const patternCard = /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/
+export const patternCard =
+  /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/;
 
 // 校验身份证号
-export function validateCardNo (value) {
-    let result = true
-    if(!patternCard.test(value)) {
-        result = false
-    }
-    return result
+export function validateCardNo(value) {
+  let result = true;
+  if (!patternCard.test(value)) {
+    result = false;
+  }
+  return result;
 }
+
+export const isDuringDate = (beginDateStr, endDateStr) => {
+  let curDate = dayjs().valueOf();
+  let beginDate = dayjs(beginDateStr).valueOf();
+  let endDate = dayjs(endDateStr).valueOf();
+  //  console.log(curDate,beginDate,endDate)
+  if (curDate >= beginDate && curDate <= endDate) {
+    return true;
+  } else {
+    return false;
+  }
+};

+ 7 - 6
src/views/coupon/list.vue

@@ -156,7 +156,7 @@ export default {
             fullAmountList[item.typeDetail] += item.fullAmount;
             faceValueList[item.typeDetail] += item.faceValue;
             nowMoneyList[item.typeDetail] =
-            shopObj[item.typeDetail] - faceValueList[item.typeDetail];
+              shopObj[item.typeDetail] - faceValueList[item.typeDetail];
             // shopObj[item.typeDetail] -= item.faceValue;
           } else {
             // 全类卷
@@ -180,7 +180,7 @@ export default {
               nowMoneyList[shopType[i]] = Number(
                 shopObj[shopType[i]] - faceValueList[shopType[i]]
               );
-                  fullAmountList[shopType[i]] = Number(
+              fullAmountList[shopType[i]] = Number(
                 fullAmountList[shopType[i]] + sclac * Number(item.fullAmount)
               );
             }
@@ -223,7 +223,7 @@ export default {
         allShopMoney,
         "allfaceValue:",
         allfaceValue,
-        'allFullMoney',
+        "allFullMoney",
         allFullMoney
       );
       this.faceValue = allfaceValue;
@@ -231,7 +231,8 @@ export default {
         if (
           item.typeDetail != "FULLCOUPON" &&
           shopObj[item.typeDetail] &&
-          item.fullAmount <=(shopObj[item.typeDetail]- fullAmountList[item.typeDetail]) &&
+          item.fullAmount <=
+            shopObj[item.typeDetail] - fullAmountList[item.typeDetail] &&
           isDuringDate(item.useStartDate, item.useDeadlineDate)
         ) {
           item.disabled = false;
@@ -239,7 +240,7 @@ export default {
         } else if (
           item.typeDetail == "FULLCOUPON" &&
           isDuringDate(item.useStartDate, item.useDeadlineDate) &&
-          item.fullAmount <= allShopMoney -allFullMoney
+          item.fullAmount <= allShopMoney - allFullMoney
         ) {
           item.disabled = false;
           flag = true;
@@ -287,7 +288,7 @@ export default {
 };
 </script>
 
-<style lang="less"  scoped>
+<style lang="less" scoped>
 .list {
   // background-color: #fff;
   width: 3.51rem;

+ 12 - 3
src/views/service/GoodsSale.vue

@@ -31,7 +31,12 @@
         <van-field
           label="选择商品"
           :readonly="true"
-          @click="goodsStatus = true"
+          @click="
+            () => {
+              goodsStatus = true;
+              hashState('goods');
+            }
+          "
           is-link
           placeholder="选择商品"
           input-align="right"
@@ -401,10 +406,12 @@ export default {
   methods: {
     onHash() {
       this.refundStatus = false;
+      this.goodsStatus = false;
     },
-    hashState() {
+    hashState(status) {
       // 打开弹窗
-      if (this.refundStatus) {
+      const type = status === "goods" ? this.goodsStatus : this.refundStatus;
+      if (type) {
         this.isDestroy = false;
         const splitUrl = window.location.hash.slice(1).split("?");
         const query = qs.parse(splitUrl[1]);
@@ -499,6 +506,7 @@ export default {
       this.goodsStatus = false;
       // this.resetCoupon();
       this.calcPrice();
+      this.hashState("goods");
     },
     onGoodDel(goodsList, item) {
       this.$dialog
@@ -910,6 +918,7 @@ export default {
   },
   destroyed() {
     // 销毁页面时
+    window.removeEventListener("hashchange", this.onHash, false);
     this.$toast.clear();
     this.qrCodeStatus = false;
   },