Sfoglia il codice sorgente

[add][抽奖逻辑]

zhangwei 3 anni fa
parent
commit
eeeae478e3

+ 2 - 1
src/logic/content/twitter.js

@@ -726,7 +726,8 @@ function setIframeRedPacket(type = 'twitter') {
                         parseCard.replaceNftDomRedPacket(item)
                     } else if (item && item.post_Id && item.post_Id.indexOf('nft_group/') >= 0) {
                         parseCard.replaceNftGroupDomRedPacket(item)
-                    } else if (item && item.post_Id && item.post_Id.indexOf('luck/') >= 0) {
+                    } else if (item && item.post_Id && item.post_Id.indexOf('luckdraw/') >= 0) {
+                        item.post_Id = item.post_Id.split('luckdraw/')[1] || ''
                         item.page_type = '抽奖'
                         parseCard.replaceDOMRedPacket(item)
                     } else {

+ 35 - 5
src/view/iframe/publish/components/get-more.vue

@@ -1,14 +1,25 @@
 <template>
-    <div class="getMore" @click="jumpMore">
-        <img width="20" :src=" require('@/assets/svg/icon-big-give.svg') " />
+    <div class="getMore" @click="jumpMore" v-if="props.style_type == 1">
+        <img width="20" :src="require('@/assets/svg/icon-big-give.svg')" />
         <font>Get More Giveaway</font>
-        <img height="20" :src=" require('@/assets/svg/icon-cell-arrow-right.svg') " />
-      </div>
+        <img height="20" :src="require('@/assets/svg/icon-cell-arrow-right.svg')" />
+    </div>
+    <div class="get_more" v-if="props.style_type == 2" @click="jumpMore">
+        <img width="18" :src="require('@/assets/svg/icon-big-give.svg')" />
+        <span>Get More Giveaway</span>
+    </div>
 </template>
 
 <script setup>
 import { getFrontConfig } from "@/http/account";
-import { onBeforeMount, ref } from "vue";
+import { number } from "mathjs";
+import { onBeforeMount, ref, defineProps } from "vue";
+const props = defineProps({
+    style_type: {
+        type: Number,
+        default: 1,
+    },
+})
 
 // const
 const moreUrl = ref('');
@@ -38,9 +49,11 @@ const jumpMore = () => {
     align-items: center;
     justify-content: center;
     box-shadow: 0px -2px 10px rgba(0, 0, 0, 0.06);
+
     img {
         margin: 0 5px;
     }
+
     font {
         color: #000;
         font-size: 15px;
@@ -48,4 +61,21 @@ const jumpMore = () => {
         line-height: 18px;
     }
 }
+
+.get_more {
+    margin-top: 58px;
+    width: 240px;
+    height: 54px;
+    background: #FFFFFF;
+    border: 1px solid #E8E8E8;
+    border-radius: 100px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    cursor: pointer;
+
+    img {
+        margin-right: 8px;
+    }
+}
 </style>

+ 43 - 41
src/view/iframe/red-packet/luck-draw.vue

@@ -308,12 +308,9 @@
                 <p>Announcement Winner</p>
                 <div class="time">
                     <img :src="require('@/assets/svg/icon-win-time.svg')" alt />
-                    <span>20:22:33</span>
-                </div>
-                <div class="get_more">
-                    <img width="18" :src="require('@/assets/svg/icon-big-give.svg')" />
-                    <span>Get More Giveaway</span>
+                    <span>{{ moment(state.detail.endTimestamp).format('HH:mm:ss') || '' }}</span>
                 </div>
+                <get-more :style_type="2"></get-more>
                 <div class="notification_switch">
                     <span>Announcement Notification</span>
                     <a-switch v-model:checked="state.notification_switch" />
@@ -366,7 +363,7 @@
                     <img :src="require('@/assets/svg/icon-error.svg')" alt />
                 </div>
             </div>
-            <get-more v-show="state.close_status != '等待结果'"></get-more>
+            <get-more v-if="state.close_status != '等待结果'"></get-more>
         </div>
 
 
@@ -449,7 +446,8 @@ let state = reactive({
         repost_facebook: false,
         reply: false
     },
-    notification_switch: false
+    notification_switch: false,
+    open_timer_status: false
 })
 
 let fullName = '';
@@ -873,7 +871,7 @@ async function clickFollowAll(item, is_all) {
 // 重新绑定
 const reSetBindTwtterId = (_params) => {
     getChromeStorage('userInfo', (_userInfo) => {
-        if (_userInfo.uid == _params.uid) {
+        if (_userInfo && _userInfo.uid == _params.uid) {
             srcPublishSuccess({
                 params: {
                     postId: state.postId,
@@ -895,6 +893,7 @@ const showCloseEndTimePage = () => {
     state.status = 'close'
     state.close_status = '红包过期了'
     state.close_text = [`This Giveaways`, `expired on ${moment(state.detail.endTimestamp).format('MM-DD')}`]
+    state.open_timer_status = true
 }
 
 const showCloseEndTimePageReport = () => {
@@ -910,6 +909,7 @@ const showCloseEndTimePageReport = () => {
 
 const showSuccessPage = () => {
     state.status = 'success'
+    state.open_timer_status = true
     // 埋点
     Report.reportLog({
         pageSource: Report.pageSource.received_success_page,
@@ -948,8 +948,7 @@ const showOpenedPageReport = () => {
 const showRabbitPage = () => {
     state.status = 'close'
     state.close_status = '没有抽中'
-
-
+    state.open_timer_status = true
 }
 const showRabbitPageReport = () => {
     Report.reportLog({
@@ -960,22 +959,24 @@ const showRabbitPageReport = () => {
         senderId: state.userId,
     });
 }
-
 const handleStatusPage = () => {
     // status 红包状态(0:未开始,1:进行中,2:已结束,3:已终止,4:终止退款进行中)
     // myReceived 我是否领取过
     // taskFinishStatus 任务完成状态(0:未完成,1:已完成,2:已过期)
     // receiveTimeExpired 是否已经过了红包的领取截止时间
+    // endTimestamp 开奖时间
 
     // ---- 判断结构 ----
     // 如果 红包状态 = 未开始
     //    显示未打开页面 return
-    // 
+
     // 如果 我领取过了
     //    如果 任务完成状态 = 未完成
-    //        显示任务未完成页面
+    //         显示任务未完成页面
     //    如果 任务完成状态 = 已经完成
-    //        如果 领取到红包金额 = 0
+    //        如果 开奖时间 > 本地时间 & 红包状态 = 进行中
+    //            显示等待结果页面
+    //        否则如果 领取到红包金额 = 0 & 红包状态 = 已结束
     //            显示兔子页面
     //        否则 
     //            显示成功页面
@@ -1014,8 +1015,14 @@ const handleStatusPage = () => {
             }
             //如果 任务完成状态 = 已经完成
         } else if (state.detail.myReceived.taskFinishStatus == 1) {
-            // 领取到空红包
-            if (state.receiveAmount == 0) {
+            // 如果 开奖时间 >= 本地时间 & 红包状态 = 进行中
+            if (state.detail.endTimestamp >= new Date().getTime() && state.detail.status == 1) {
+                // 显示等待结果页面
+                showLoadResult()
+                open_timer()
+            }
+            // 领取到空红包 & 红包状态 = 已结束
+            else if (state.receiveAmount == 0 && state.status == 2) {
                 showRabbitPage()
                 showRabbitPageReport()
             } else {
@@ -1115,7 +1122,7 @@ function init(initParams) {
 
 function initTaskDetail() {
     getChromeStorage('userInfo', (_userInfo) => {
-        if (_userInfo.uid) {
+        if (_userInfo && _userInfo.uid) {
             // 任务详情
             getTaskDetail({
                 params: {
@@ -1235,13 +1242,24 @@ const open_timer = () => {
     let new_time
     let open_time
     let timer = setInterval(() => {
+        open_time = state.detail.endTimestamp || ''
+        if (!open_time || state.close_status == '没有抽中') {
+            return
+        }
         new_time = new Date().getTime()
         // 到时间了
         if (new_time >= open_time) {
             // 调用detail 查看结果
-            clearInterval(timer)
+            init()
+            if (state.open_timer_status == true) {
+                clearInterval(timer)
+            }
         }
-    })
+    }, 1000)
+}
+const showLoadResult = () => {
+    state.status = 'close'
+    state.close_status = '等待结果'
 }
 
 onMounted(() => {
@@ -1253,14 +1271,13 @@ onMounted(() => {
         state.tweet_author = getQueryString('tweet_author');
     }
 
-    getTweetAuthor();
-
-    //   init()
+    getTweetAuthor()
+    init()
     // state.loading_show = true
     // state.status = 'success'
-    state.status = 'close'
+    // state.status = 'close'
     // state.close_status = '等待结果'
-    state.close_status = '没有抽中'
+    // state.close_status = '没有抽中'
     // state.close_status = '已过期'
 
 })
@@ -2382,22 +2399,7 @@ body {
                 }
             }
 
-            .get_more {
-                margin-top: 58px;
-                width: 240px;
-                height: 54px;
-                background: #FFFFFF;
-                border: 1px solid #E8E8E8;
-                border-radius: 100px;
-                display: flex;
-                justify-content: center;
-                align-items: center;
-                cursor: pointer;
-
-                img {
-                    margin-right: 8px;
-                }
-            }
+        
 
             .notification_switch {
                 border-top: 1px solid #EFEFEF;
@@ -2824,7 +2826,7 @@ body {
             height: 200px;
             text-align: center;
             position: absolute;
-            bottom: 100px;
+            bottom: 80px;
             left: 50%;
             margin-left: -100px;
             z-index: 3;

+ 0 - 1
src/view/iframe/red-packet/red-packet.vue

@@ -1205,7 +1205,6 @@ onMounted(() => {
   }
 
   getTweetAuthor();
-
   init()
   // state.loading_show = true
   // state.status = 'opened'