Bladeren bron

[edit][登陆&宝箱进度&邀请人列表]

zhangwei 2 jaren geleden
bovenliggende
commit
bcd888f819

+ 1 - 1
src/logic/content/ParseCard.js

@@ -546,7 +546,7 @@ class ParseCard {
             if (post_Id.indexOf('luckdraw/') >= 0) {
                 post_Id = post_Id.replace('luckdraw/', '');
                 dom.appendChild(this.createIframe({ post_Id, tweet_author, page_type: '抽奖' }, true))
-            } else {
+            } else if (!post_Id.includes('/')) {
                 dom.appendChild(this.createIframe({ post_Id, tweet_author }, true))
             }
         }

+ 13 - 11
src/view/iframe/treasure-hunt/components/invite-friends.vue

@@ -5,9 +5,8 @@
             tasks.</div>
         <div class="area-url">
             <div class="url">{{ state.detail.inviteUrl }}</div>
-            <div class="btn copy-btn" @click="clickCopy"
-             v-click-log="state.log_invite_copy_btn_click"
-            :data-clipboard-text="state.detail.inviteCopyUrl">
+            <div class="btn copy-btn" @click="clickCopy" v-click-log="state.log_invite_copy_btn_click"
+                :data-clipboard-text="state.detail.inviteCopyUrl">
                 Copy
             </div>
         </div>
@@ -16,10 +15,8 @@
                 @click="clickShare(item)" class="share-item" />
         </div>
         <v-btn :txt="state.open_btn.txt" :font-size="'17px'" class="btn" :icon="false"
-            :disabled="state.open_btn.disabled"
-            v-show-log="state.log_invite_btn_show"
-            v-click-log="state.log_invite_btn_click"
-             @onClick="clickBtn" font-weight="600"></v-btn>
+            :disabled="state.open_btn.disabled" v-show-log="state.log_invite_btn_show"
+            v-click-log="state.log_invite_btn_click" @onClick="clickBtn" font-weight="600"></v-btn>
 
     </div>
 </template>
@@ -38,7 +35,7 @@ state.log_invite_btn_show = {
     pageSource: Report.pageSource.inviteFriendsPage,
     objectType: Report.objectType.openChestButton,
     redPacketType: Report.redPacketType.treasure,
-    shareLinkId:  state.invite_code,
+    shareLinkId: state.invite_code,
     myShareLinkId: state.detail.inviteCopyUrl,
     currentInvitedNum: state.detail.inviteCount,
     postId: state.postId
@@ -49,7 +46,7 @@ state.log_invite_btn_click = {
     pageSource: Report.pageSource.inviteFriendsPage,
     objectType: Report.objectType.openChestButton,
     redPacketType: Report.redPacketType.treasure,
-    shareLinkId:  state.invite_code,
+    shareLinkId: state.invite_code,
     myShareLinkId: state.detail.inviteCopyUrl,
     currentInvitedNum: state.detail.inviteCount,
     postId: state.postId
@@ -59,7 +56,7 @@ state.log_invite_copy_btn_click = {
     pageSource: Report.pageSource.inviteFriendsPage,
     objectType: Report.objectType.copyButton,
     redPacketType: Report.redPacketType.treasure,
-    shareLinkId:  state.invite_code,
+    shareLinkId: state.invite_code,
     myShareLinkId: state.detail.inviteCopyUrl,
     currentInvitedNum: state.detail.inviteCount,
     postId: state.postId
@@ -88,7 +85,12 @@ onMounted(() => {
 
 })
 
-const clickBtn = () => {
+async function clickBtn() {
+    let _userInfo = await state.checkIsLogin()
+    if (!_userInfo) {
+        return
+    }
+    state.btn_loading = true
     state.treasureOpen()
 }
 

+ 15 - 4
src/view/iframe/treasure-hunt/components/invite-list.vue

@@ -6,7 +6,7 @@
         <div class="list" v-else @scroll="handleScroll($event)">
             <div class="item" v-for="item in state.invited_list">
                 <div class="left">
-                    <img :src="item.userInfo.avatarUrl" alt="" />
+                    <img :src="item.userInfo.avatarUrl" alt="" @click="clickItem(item)" />
                 </div>
                 <div class="right">
                     <div>{{ item.userInfo.nickName }}</div>
@@ -49,6 +49,10 @@ onMounted(() => {
     list()
 })
 
+const clickItem = (item) => {
+    window.open(`https://twitter.com/${item.userInfo.nickName}`)
+}
+
 function handleScroll(e) {
     if (list_end) {
         return
@@ -56,7 +60,9 @@ function handleScroll(e) {
     e = e.target
     if ((e.clientHeight + e.scrollTop) / e.scrollHeight > .8) {
         list_end = true
-        page_num++
+        if (state.invited_list.length == page_num * page_size) {
+            page_num++
+        }
         list()
     }
 }
@@ -84,7 +90,7 @@ state.inviteList = () => {
                 })
                 list_end = false
             } else {
-                list_end = true
+                list_end = false
             }
         }
     })
@@ -116,7 +122,12 @@ const getTime = (timestamp) => {
     return plural(_s, 'sec')
 }
 
-const clickBtn = () => {
+async function clickBtn() {
+    let _userInfo = await state.checkIsLogin()
+    if (!_userInfo) {
+        return
+    }
+    state.btn_loading = true
     state.treasureOpen()
 }
 

+ 8 - 3
src/view/iframe/treasure-hunt/cover.vue

@@ -20,7 +20,7 @@
                     <span>${{ toLast(state.detail.amountUsdValue, 2) }}</span>
                 </component-zoom>
             </div>
-            <div class="gain" v-if="state.detail.upGainAmountValue == 0">
+            <div class="gain" v-if="Number(state.detail.upGainAmountValue) > 0">
                 <component-zoom width="335" fontSize="34" style="margin:0 auto;">
                     <span>Your Gain Up to</span>
                     <span>$</span>
@@ -38,7 +38,7 @@
             <img :src="require('@/assets/img/icon-gold-close-box.png')" alt="" v-if="state.cover_status == '奖励已被领光'" />
             <img :src="require('@/assets/img/icon-treasure-box.png')" alt="" v-else />
         </div>
-        <div class="mark">
+        <div class="mark" :style="{ 'opacity': state.cover_status == '奖励已被领光' ? '0' : '1' }">
             <img :src="require('@/assets/svg/icon-three-line.svg')" alt="" />
             <span>to Hunt Treasure</span>
         </div>
@@ -132,7 +132,11 @@ const toLast = (num, bit) => {
 }
 
 
-const clickBtn = () => {
+async function clickBtn() {
+    let _userInfo = await state.checkIsLogin()
+    if (!_userInfo) {
+        return
+    }
     if (state.cover_status == '奖励已被领光') {
         Report.reportLog({
             pageSource: Report.pageSource.pending_page,
@@ -144,6 +148,7 @@ const clickBtn = () => {
         return
     }
 
+
     Report.reportLog({
         businessType: Report.businessType.buttonClick,
         objectType: Report.objectType.open_button,

+ 22 - 2
src/view/iframe/treasure-hunt/index.vue

@@ -13,6 +13,7 @@ import VResult from '@/view/iframe/treasure-hunt/result.vue'
 import { inviteDetail, treasureDetail, treasureOpen } from '@/http/treasure.js'
 import { reSetBindTwtterId, reSetBindRepost } from '@/http/help.js'
 import { getQueryString } from '@/uilts/help'
+import { getChromeStorage } from '@/uilts/chromeExtension.js'
 import VToast from '@/view/iframe/treasure-hunt/components/toast.vue'
 import OpenBox from '@/view/iframe/treasure-hunt/components/open-box.vue'
 
@@ -46,6 +47,23 @@ onMounted(() => {
     state.init()
 })
 
+state.checkIsLogin = () => {
+    return new Promise((resolve) => {
+        getChromeStorage('userInfo', (_userInfo) => {
+            if (!_userInfo) {
+                state.btn_loading = true
+                setTimeout(() => {
+                    state.btn_loading = false
+                }, 3000)
+                chrome.runtime.sendMessage({ actionType: "POPUP_LOGIN", data: "" })
+                resolve(_userInfo)
+            } else {
+                resolve(_userInfo)
+            }
+        })
+    })
+}
+
 state.init = (callback) => {
     if (params.page_type == '邀请链接') {
         // 邀请链接
@@ -113,6 +131,7 @@ state.treasureOpen = () => {
             treasureId: state.treasureId,
         }
     }).then((res) => {
+        state.btn_loading = false
         if (res.code == 0) {
             // icon
             for (let i in state.boxs) {
@@ -133,7 +152,6 @@ state.treasureOpen = () => {
                 state.inviteList()
             })
         } else {
-            state.btn_loading = false
             switch (String(res.code)) {
                 case '2037':
                     state.dialog.show = true
@@ -161,6 +179,8 @@ state.treasureOpen = () => {
                 state.inviteList()
             })
         }
+    }).catch(() => {
+        state.btn_loading = false
     })
 }
 
@@ -200,9 +220,9 @@ const handleStatus = () => {
     }
     // 如果 夺宝状态 = 已结束
     else {
+        state.open_btn.txt = 'Look for more treasures'
         state.page = '封面页'
         state.cover_status = '奖励已被领光'
-        state.open_btn.txt = 'Look for more treasures'
         state.btn_loading = false
     }
 }

+ 13 - 10
src/view/iframe/treasure-hunt/invite.vue

@@ -15,7 +15,8 @@
         </div>
         <div class="area-success-message" @mouseover="mouseOver" @mouseleave="mouseLeave">
             <div class="content-success-message" ref="content_success_message">
-                <div class="success-message" v-for="item, index in state.success_message_list" :key="index">
+                <div class="success-message" v-for="item, index in state.success_message_list" :key="index"
+                    @click="clickItem(item)">
                     <img :src="item.userInfo.avatarUrl" alt="" />
                     <span>{{ item.userInfo.nickName }} </span> &nbsp;
                     <span>Opened Treasure Chest</span>
@@ -95,6 +96,9 @@ onMounted(() => {
     }, 30000)
 })
 
+const clickItem = (item) => {
+    window.open(`https://twitter.com/${item.userInfo.nickName}`)
+}
 state.inviteInit = () => {
     if (state.detail.inviteCount > 0) {
         state.tabs[1].txt = `invited(${state.detail.inviteCount})`
@@ -146,15 +150,16 @@ state.inviteInit = () => {
     btnStatus()
 
 }
-
+let line_width = 0
 const setLineFull = (box_num = 0, finishNeedInviteCount = 0, successInviteCount = 0) => {
     if (box_num == 0) {
-        line_full.value.style.width = (successInviteCount / finishNeedInviteCount) * 80 + 'px'
+        line_width = (successInviteCount / finishNeedInviteCount) * 80
     } else if (box_num == 1) {
-        line_full.value.style.width = ((successInviteCount / finishNeedInviteCount) * 100 + 80) + 'px'
+        line_width = (successInviteCount / finishNeedInviteCount) * 100 + line_width
     } else if (box_num == 2) {
-        line_full.value.style.width = ((successInviteCount / finishNeedInviteCount) * 100 + 180) + 'px'
+        line_width = (successInviteCount / finishNeedInviteCount) * 100 + line_width
     }
+    line_full.value.style.width = line_width + 'px'
 }
 
 const btnStatus = () => {
@@ -182,9 +187,7 @@ const btnStatus = () => {
                 state.treasureId = item.id
             }
         }
-        if (item.taskFinishStatus == 1) {
-            setLineFull(index, item.finishNeedInviteCount, item.successInviteCount)
-        }
+        setLineFull(index, item.finishNeedInviteCount, item.successInviteCount)
         // 三个箱子全部打开了
         if (item.openStatus == 1) {
             open_num++
@@ -304,14 +307,14 @@ const mouseLeave = () => {
         overflow: hidden;
 
         .content-success-message {
-
             width: fit-content;
             display: flex;
             animation: rolling 18s linear infinite;
             animation-duration: 10s;
+            animation-play-state: running;
 
             .success-message {
-                cursor: default;
+                cursor: pointer;
                 width: fit-content;
                 height: 30px;
                 padding: 0 9px;

+ 12 - 6
src/view/iframe/treasure-hunt/result.vue

@@ -1,7 +1,7 @@
 <template>
     <!-- 开奖页 -->
     <div class="content" v-show-log="state.log_result_show">
-        <img :src="require('@/assets/img/icon-silver-open-box.png')" alt="" />
+        <img :src="require('@/assets/img/icon-silver-open-box-big.png')" alt="" />
         <div class="mark">
 
             <!-- 新粉 -->
@@ -36,8 +36,10 @@
             </template>
         </div>
         <v-btn :txt="'Invite friends for more treasures'" :font-size="'16px'" class="btn"
-            v-if="Number(state.start_task.amountValue) > 0"  v-click-log="state.log_result_click" @onClick="clickBtn" :disabled="false"></v-btn>
-        <v-btn :txt="'Invite'" :font-size="'16px'" class="btn" v-else @onClick="clickBtn" :disabled="false"  v-click-log="state.log_result_click"></v-btn>
+            v-if="Number(state.start_task.amountValue) > 0" v-click-log="state.log_result_click" @onClick="clickBtn"
+            :disabled="false"></v-btn>
+        <v-btn :txt="'Invite'" :font-size="'16px'" class="btn" v-else @onClick="clickBtn" :disabled="false"
+            v-click-log="state.log_result_click"></v-btn>
     </div>
 </template>
 <script setup>
@@ -54,7 +56,7 @@ state.log_result_show = {
     shareLinkId: state.invite_code,
     postId: state.postId,
     extParams: {
-      isNewFans: Number(state.start_task.amountValue) > 0 ? true : false
+        isNewFans: Number(state.start_task.amountValue) > 0 ? true : false
     }
 }
 
@@ -66,11 +68,15 @@ state.log_result_click = {
     shareLinkId: state.invite_code,
     postId: state.postId,
     extParams: {
-      isNewFans: Number(state.start_task.amountValue) > 0 ? true : false
+        isNewFans: Number(state.start_task.amountValue) > 0 ? true : false
     }
 }
 
-const clickBtn = () => {
+async function clickBtn() {
+    let _userInfo = await state.checkIsLogin()
+    if (!_userInfo) {
+        return
+    }
     state.init(() => {
         state.page = '邀请页'
     })