Browse Source

[edit][red-state]

zhangwei 3 years ago
parent
commit
430cc9d741
1 changed files with 57 additions and 35 deletions
  1. 57 35
      src/view/red-packet.vue

+ 57 - 35
src/view/red-packet.vue

@@ -373,7 +373,40 @@ async function clickFollowAll(item) {
     }
     }
   })
   })
 }
 }
+// 我领取了的状态
+function myReceivedState() {
+  data.status = 'opened'
+  data.money = data.detail.myReceived.amountValue
 
 
+  // 我的红包已经过期了 and 大红包可以领取
+  if (data.detail.myReceived.taskFinishStatus == 2 && !data.detail.receiveTimeExpired) {
+    data.status = 'not-open'
+  }
+  // 我领取未完成 and 大红包可以领取
+  if (data.detail.myReceived.taskFinishStatus == 0 && !data.detail.receiveTimeExpired) {
+    initTaskDetail()
+    getValidity()
+    data.detail.taskCondition = JSON.parse(data.detail.taskCondition)
+    data.detail.amountValue = showLastTwoPlace(data.detail.amountValue)
+    data.detail.receiveAmountValue = showLastTwoPlace(data.detail.receiveAmountValue)
+  }
+
+  // 大红包不能领取了
+  if (data.detail.receiveTimeExpired) {
+    data.status = 'close'
+    data.close_title = `This Giveways`
+    data.close_text = `expired on ${moment(data.detail.endTimestamp).format('MM-DD')}`
+  }
+  // 任务已经被领完了
+  if (data.detail.totalCount == data.detail.receiveCount) {
+    data.status = 'close'
+    data.close_title = 'Better luck next time!'
+  }
+  // 我领取成功了
+  if (data.detail.myReceived.taskFinishStatus == 1) {
+    data.status = 'success'
+  }
+}
 
 
 function showLastTwoPlace(n) {
 function showLastTwoPlace(n) {
   return n / 100
   return n / 100
@@ -399,48 +432,37 @@ function init() {
         // 红包未开始
         // 红包未开始
         if (data.detail.status == 0) {
         if (data.detail.status == 0) {
           data.status = 'not-open'
           data.status = 'not-open'
-          return
-        }
-        // 我领取了  
-        if (data.detail.myReceived) {
-          data.status = 'opened'
-          data.money = data.detail.myReceived.amountValue
-
-          // 我的红包已经过期了
-          if (data.detail.myReceived.taskFinishStatus == 2) {
-            data.status = 'not-open'
-          }
-          // 我领取成功了
-          if (data.detail.myReceived.taskFinishStatus == 1) {
-            data.status = 'success'
-          }
-          // 我领取未完成
-          if (data.detail.myReceived.taskFinishStatus == 0) {
-            initTaskDetail()
-            getValidity()
-            data.detail.taskCondition = JSON.parse(data.detail.taskCondition)
-            data.detail.amountValue = showLastTwoPlace(data.detail.amountValue)
-            data.detail.receiveAmountValue = showLastTwoPlace(data.detail.receiveAmountValue)
-          }
 
 
-          // 我没有领取
-        } else {
           // 任务进行中
           // 任务进行中
-          if (data.detail.status == 1) {
-            data.status = 'not-open'
+        } else if (data.detail.status == 1) {
+          data.status = 'not-open'
+          // 我领取过的状态
+          if (data.detail.myReceived) {
+            myReceivedState()
+          } else {
+            // 大红包不可以领取了
+            if (data.detail.receiveTimeExpired) {
+              data.status = 'close'
+              data.close_title = `This Giveways`
+              data.close_text = `expired on ${moment(data.detail.endTimestamp).format('MM-DD')}`
+            }
+            // 任务已经被领完了
+            if (data.detail.totalCount == data.detail.receiveCount) {
+              data.status = 'close'
+              data.close_title = 'Better luck next time!'
+            }
+          }
 
 
-            // 任务已经结束了
-          } else if (data.detail.status == 2) {
+          // 任务已经结束了
+        } else if (data.detail.status == 2) {
+          // 我领取过的状态
+          if (data.detail.myReceived) {
+            myReceivedState()
+          } else {
             data.status = 'close'
             data.status = 'close'
             data.close_title = `This Giveways`
             data.close_title = `This Giveways`
             data.close_text = `expired on ${moment(data.detail.endTimestamp).format('MM-DD')}`
             data.close_text = `expired on ${moment(data.detail.endTimestamp).format('MM-DD')}`
           }
           }
-
-          // 任务已经被领完了
-          if (data.detail.totalCount == data.detail.receiveCount) {
-            data.status = 'close'
-            data.close_title = 'Better luck next time!'
-          }
         }
         }
         break
         break
     }
     }