Ver código fonte

fix:报错修复

yangfeng 3 anos atrás
pai
commit
fb0627550f

+ 3 - 3
src/components/coupon/CouponGiftList.vue

@@ -62,9 +62,9 @@ export default {
       const { data } = await getGiftList(info)
       if (Array.isArray(data)) {
         this.giftList = data.map(item => {
-          item.preStartTime = item.preheatingTime.toString().length === 10 ? item.preheatingTime * 1000 : item.preheatingTime
-          item.startTime = item.beginDate.toString().length === 10 ? item.beginDate * 1000 : item.beginDate
-          item.endTime = item.endDate.toString().length === 10 ? item.endDate * 1000 : item.endDate
+          item.preStartTime = item.preheatingTime && item.preheatingTime.toString().length === 10 ? item.preheatingTime * 1000 : item.preheatingTime
+          item.startTime = item.beginDate && item.beginDate.toString().length === 10 ? item.beginDate * 1000 : item.beginDate
+          item.endTime = item.endDate && item.endDate.toString().length === 10 ? item.endDate * 1000 : item.endDate
           item.isReceive = item.IsReceive
           const giftInfo = this.sortGiftInfo(item)
           return {

+ 19 - 3
src/components/limited-banner/index.vue

@@ -67,7 +67,9 @@ export default {
       activityTime: this.startTime,
       startText: '开始倒计时:',
       getActivityName: this.activityName,
-      curTime: 0
+      curTime: 0,
+      isStart: false,
+      isEnd: false
     }
   },
   computed: {
@@ -85,10 +87,10 @@ export default {
     },
     unStatus () {
       // 当前时间小于活动开始时间且未预约状态且还有库存
-      return this.curTime < this.startTime && this.status === 0 && this.stockNumber > 0
+      return !this.isStart && this.status === 0 && this.stockNumber > 0
     },
     alreadyStatus () {
-      return this.curTime < this.startTime && this.status === 1 && this.stockNumber > 0
+      return this.isStart && !this.isEnd && this.status === 1 && this.stockNumber > 0
     },
     emptyStatus () {
       return this.stockNumber === 0
@@ -97,6 +99,20 @@ export default {
   watch: {
     activityName (val) {
       this.getActivityName = val
+    },
+    curTime (val) {
+      // console.log(val, 'val')
+      if (val < this.startTime) {
+        this.isStart = false
+      } else {
+        this.isStart = true
+        if (val < this.endTime) {
+          this.isEnd = false
+        } else {
+          this.isEnd = true
+        }
+      }
+      // console.log(this.isStart, '111')
     }
   },
   methods: {

+ 2 - 2
src/components/limited-countdown/index.vue

@@ -67,7 +67,7 @@ export default {
     document.addEventListener('visibilitychange', () => {
       if (document.visibilityState === 'visible') {
         // console.log('切出当前页')
-        this.initAdjustTime()
+        // this.initAdjustTime()
       }
     })
   },
@@ -111,7 +111,7 @@ export default {
           let sec = Math.floor((t / 1000) % 60)
           hour = hour < 10 && hour > 0 ? '0' + hour : hour
           min = min < 10 && min > 0 ? '0' + min : min
-          sec = sec < 10 && sec > 0 ? '0' + sec : sec
+          sec = sec < 10 ? '0' + sec : sec
           let format = ''
           if (this.placeholder) {
             format = `${day} 天 ${hour} 时 ${min} 分 ${sec} 秒`

+ 49 - 15
src/views/vipsubscribe/Buy.vue

@@ -200,7 +200,9 @@ export default {
       },
       isActivity: false,
       activity: {},
-      appointmentStatus: -1 // 预约状态
+      appointmentStatus: -1, // 预约状态
+      curTime: 0,
+      goodsBadge: false
     }
   },
   computed: {
@@ -282,6 +284,11 @@ export default {
         return false
       }
     }
+    // 商品规格上是否展示优惠信息、价格是否计算优惠(活动未开始前、库存为0不展示不计算优惠)
+    // isDiscounts () {
+    //   console.log(this.goodsBadge, JSON.stringify(this.activity))
+    //   return this.goodsBadge && this.activity && this.activity.stockNumber && this.activity.stockNumber > 0
+    // }
   },
   created () {
     this.getType()
@@ -395,7 +402,15 @@ export default {
       this.updatePrice()
     },
     specChange (spec) {
-      this.activity = {}
+      if (Object.keys(this.activity).length > 0) {
+        this.activity.reduce = 0
+        this.activity.promotionalPrice = 0
+        this.activity.discount = 0
+        this.activity.stockNumber = 0
+        this.activity.status = this.appointmentStatus
+      } else {
+        this.activity.stockNumber = 0
+      }
       if (this.buyType === 'upgrade') {
         spec.productionId = 1015
       }
@@ -428,7 +443,6 @@ export default {
         for (const key in activity) {
           this.activity[key] = activity[key]
         }
-        this.activity.status = this.appointmentStatus
         this.updatePrice()
         const gift = list[0]
         // this.specActiveItem.tipText = gift.giftInfo ? `加赠${gift.giftInfo}` : ''
@@ -494,13 +508,15 @@ export default {
       const params = this.getSubmitParam()
       const { data, success } = await getSelectPrice(params)
       if (success) {
-        const { reduce, promotionalPrice, discount } = this.activity
-        if (reduce) {
-          data.order_price = data.order_price - reduce
-        } else if (promotionalPrice) {
-          data.order_price = promotionalPrice
-        } else if (discount) {
-          data.order_price = data.order_price * (discount / 10)
+        const { reduce, promotionalPrice, discount, stockNumber } = this.activity
+        if (stockNumber > 0) {
+          if (reduce) {
+            data.order_price = data.order_price - reduce
+          } else if (promotionalPrice) {
+            data.order_price = promotionalPrice
+          } else if (discount) {
+            data.order_price = data.order_price * (discount / 10)
+          }
         }
         this.computedPrice.total = data.original_price
         this.computedPrice.pay = data.order_price
@@ -666,17 +682,32 @@ export default {
       })
       if (data) {
         this.appointmentStatus = data?.status
+        this.activity.status = data?.status
       } else {
-        this.appointmentStatus = -1
+        this.activity.status = -1
       }
     },
     getCurTime (data) {
-      if (data > this.activity.startTime && data < this.activity.endTime) {
+      this.curTime = data
+      if (data < this.activity.startTime) {
+        // 活动未开始
+        this.activity.reduce = 0
+        this.activity.promotionalPrice = 0
+        this.activity.discount = 0
+        this.$refs.buySubmitRef.changeBtnText(false)
+      } else if (data > this.activity.startTime && data < this.activity.endTime) {
+        // 活动进行中
+        const { stockNumber } = this.activity
         this.$nextTick(() => {
-          this.$refs.buySubmitRef.changeBtnText(true)
+          if (stockNumber > 0) {
+            this.$refs.buySubmitRef.changeBtnText(true)
+          } else {
+            this.$refs.buySubmitRef.changeBtnText(false)
+          }
+          this.goodsBadge = true
         })
-      }
-      if (data >= this.activity.endTime) {
+      } else if (data >= this.activity.endTime) {
+        // 活动结束
         // 会有毫秒延迟
         setTimeout(() => {
           this.isActivity = false
@@ -685,7 +716,10 @@ export default {
           this.updatePrice()
           this.$refs.buySubmitRef.changeBtnText(false)
         }, 300)
+        this.goodsBadge = false
         this.$forceUpdate()
+      } else {
+        this.goodsBadge = false
       }
     }
   }

+ 15 - 15
vue.config.js

@@ -28,8 +28,8 @@ module.exports = {
       //   logLevel: 'debug'
       // },
       '^/bigmember': {
-        target: 'https://jybx2-webtest.jydev.jianyu360.com',
-        // target: 'http://192.168.3.240:814',
+        // target: 'https://jybx2-webtest.jydev.jianyu360.com',
+        target: 'http://192.168.3.240:814',
         changeOrigin: true,
         logLevel: 'debug',
         pathRewrite: {
@@ -37,20 +37,20 @@ module.exports = {
         }
       },
       '^/jypay': {
-        target: 'https://jybx2-webtest.jydev.jianyu360.com',
-        // target: 'http://192.168.3.240:86',
+        // target: 'https://jybx2-webtest.jydev.jianyu360.com',
+        target: 'http://192.168.3.240:86',
         changeOrigin: true,
         logLevel: 'debug'
       },
       '^/publicapply': {
-        target: 'https://jybx2-webtest.jydev.jianyu360.com',
-        // target: 'http://192.168.3.240:828',
+        // target: 'https://jybx2-webtest.jydev.jianyu360.com',
+        target: 'http://192.168.3.240:828',
         changeOrigin: true,
         logLevel: 'debug'
       },
       '^/subscribepay': {
-        target: 'https://jybx2-webtest.jydev.jianyu360.com',
-        // target: 'http://192.168.3.240:86',
+        // target: 'https://jybx2-webtest.jydev.jianyu360.com',
+        target: 'http://192.168.3.240:86',
         changeOrigin: true,
         logLevel: 'debug'
       },
@@ -73,19 +73,19 @@ module.exports = {
         logLevel: 'debug'
       },
       '^/jyCoupon': {
-        target: 'https://jybx2-webtest.jydev.jianyu360.com',
-        // target: 'http://192.168.3.240:826',
+        // target: 'https://jybx2-webtest.jydev.jianyu360.com',
+        target: 'http://192.168.3.240:826',
         changeOrigin: true,
         logLevel: 'debug'
       },
       '^/marketing': {
-        target: 'https://jybx2-webtest.jydev.jianyu360.com',
-        // target: 'http://192.168.3.240:8077',
+        // target: 'https://jybx2-webtest.jydev.jianyu360.com',
+        target: 'http://192.168.3.240:8077',
         changeOrigin: true,
         logLevel: 'debug',
-        pathRewrite: {
-          '': '/jyapi'
-        }
+        // pathRewrite: {
+        //   '': '/jyapi'
+        // }
       }
     },
     headers: {