Browse Source

聊天红包部分功能

bayi 2 years ago
parent
commit
ac83a4dcb0

+ 13 - 8
components/activityList/index.js

@@ -39,14 +39,13 @@ Component({
       this.setData({
         activityList
       })
-      // console.log(activityList);
       // 下面这个处理限时活动的,第一版先不上
-      // activityList.forEach((item, index) => {
-      //   if (item.bannerType == 4 && item.voucherType) {
-      //     // this.activityTimeOut(1677109150000, index)
-      //     this.activityTimeOut(item.endTime, index)
-      //   }
-      // })
+      activityList.forEach((item, index) => {
+        if (item.bannerType == 4 && item.voucherType) {
+          // this.activityTimeOut(1677109150000, index)
+          this.activityTimeOut(item.endTime, index)
+        }
+      })
     },
     jumpUserInfo({
       currentTarget
@@ -61,7 +60,7 @@ Component({
     activityTimeOut(oTime, index) {
       let inputTime = new Date(oTime)
       let dsq = setInterval(() => {
-        console.log('1');
+        // console.log(this.data.activityList[index]);
         var nowTime = new Date();
         //把剩余时间毫秒数转化为秒
         var times = (inputTime - nowTime) / 1000;
@@ -70,6 +69,7 @@ Component({
             [`activityList[${index}].hour`]: '00',
             [`activityList[${index}].minute`]: '00',
             [`activityList[${index}].second`]: '00',
+            [`activityList[${index}].finish`]: true,
           })
           return clearInterval(dsq)
         }
@@ -89,6 +89,7 @@ Component({
           [`activityList[${index}].hour`]: hour,
           [`activityList[${index}].minute`]: minute,
           [`activityList[${index}].second`]: second,
+          [`activityList[${index}].finish`]: false,
         })
         times = --times;
       }, 1000);
@@ -130,6 +131,10 @@ Component({
       currentTarget
     }) {
       let info = currentTarget.dataset.info
+      console.log(currentTarget.dataset.info);
+      if (info.finish) {
+        return
+      }
       this.selectComponent('#voucher').open({
         type: info.type,
         id: info.id,

+ 1 - 1
components/activityList/index.less

@@ -329,7 +329,7 @@
           font-size: 28rpx;
 
           .outNum {
-            width: 46rpx;
+            width: 42rpx;
             font-size: 26rpx;
             text-align: center;
             border-radius: 10rpx;

+ 3 - 3
components/activityList/index.wxml

@@ -91,12 +91,12 @@
             <view class="outNum">{{item.second}}</view>
           </view>
         </view>
-        <view class="btn {{item.second=='00'?'closingBtn':''}}" data-info='{{item}}' bindtap="drawVoucher">
-          {{item.second=='00'?
+        <view class="btn {{item.finish?'closingBtn':''}}" data-info='{{item}}' bindtap="drawVoucher">
+          {{item.finish?
           '已结束':item.voucherType?'立即使用':'立即领取'}}
         </view>
       </view>
     </view>
   </block>
 </view>
-<!-- <Voucher id="voucher" /> -->
+<Voucher id="voucher" bind:reload='getActivities' />

+ 1 - 1
components/activityList/index.wxss

@@ -270,7 +270,7 @@
   font-size: 28rpx;
 }
 .activityList .activityBox .footer .info .timeOut .outNum {
-  width: 46rpx;
+  width: 42rpx;
   font-size: 26rpx;
   text-align: center;
   border-radius: 10rpx;

+ 6 - 5
components/voucher/index.js

@@ -35,7 +35,6 @@ Component({
   methods: {
     open(data) {
       this.getProducts()
-
       let {
         type,
         id,
@@ -55,6 +54,7 @@ Component({
       this.setData({
         state: false
       })
+      this.triggerEvent('reload')
     },
     async getProducts() {
       let products = await getProducts()
@@ -72,15 +72,16 @@ Component({
     async getVoucher() {
       console.log('zz', this.data.voucherType);
       if (!this.data.voucherType) {
-        await getVoucher({
+        let res = await getVoucher({
           id: this.data.id
         })
+        this.toBuy(res.type == 1 ? '1001' : '1010')
+      } else {
+        this.toBuy(this.data.voucherType == 1 ? '1001' : '1010')
       }
-      this.toBuy(this.data.voucherType == 1 ? '1001' : '1010')
     },
     //购买vip和购买次数不是一个接口 type 1001是vip,1010是次数
     async toBuy(productId) {
-      console.log(productId);
       wx.showLoading({
         title: '提交中',
         mask: true
@@ -98,7 +99,6 @@ Component({
         }).finally(() => {
           wx.hideLoading()
         })
-        console.log(res);
       } else {
         wx.hideLoading()
         wx.showToast({
@@ -124,6 +124,7 @@ Component({
             title: "支付成功",
             duration: 2500
           })
+          this.close()
         },
         fail(res) {
           wx.showToast({

+ 7 - 7
utils/request.js

@@ -6,13 +6,13 @@ const {
     envVersion
   }
 } = wx.getAccountInfoSync();
-if (envVersion == 'develop') {
-  baseUrl = 'https://reader-api.efunbox.cn/wx'
-  oldUrl = 'https://reader-api.efunbox.cn'
-} else {
-  baseUrl = 'https://reader-api.ai160.com/wx'
-  oldUrl = 'https://reader-api.ai160.com'
-}
+// if (envVersion == 'develop') {
+baseUrl = 'https://reader-api.efunbox.cn/wx'
+oldUrl = 'https://reader-api.efunbox.cn'
+// } else {
+//   baseUrl = 'https://reader-api.ai160.com/wx'
+//   oldUrl = 'https://reader-api.ai160.com'
+// }
 
 function request(url, method, data, oldBaseUrl = false) {
   let header = {