wenliming преди 2 години
родител
ревизия
e656413498

+ 4 - 5
src/entry/background.js

@@ -148,19 +148,18 @@ function thenInstalledMethod() {
     try {
 
         onInstalledCreateTab()
-        onInstalledMid()
         onInstalledUserSet()
         // pingpang
         chrome.alarms.create('PingPong', {
-            //1分鐘之後開始(該值不能小於1) 
+            //1分鐘之後開始(該值不能小於1)
             delayInMinutes: 2,
-            //開始後每一分鐘執行一次(該值不能小于1) 
+            //開始後每一分鐘執行一次(該值不能小于1)
             periodInMinutes: 4
         });
         chrome.alarms.create('LuckMessage', {
-            //1分鐘之後開始(該值不能小於1) 
+            //1分鐘之後開始(該值不能小於1)
             delayInMinutes: 1,
-            //開始後每一分鐘執行一次(該值不能小于1) 
+            //開始後每一分鐘執行一次(該值不能小于1)
             periodInMinutes: 1
         });
     } catch (error) {

+ 5 - 2
src/http/fetch.js

@@ -1,5 +1,6 @@
 import { appVersionCode, baseAPIUrl } from '@/http/configAPI.js'
 import { getChromeStorage } from '@/uilts/chromeExtension.js'
+import { guid } from '@/uilts/help'
 
 export async function commonFetch({ url = '', method = 'POST', params = {}, baseInfo = {} }) {
     try {
@@ -17,8 +18,10 @@ export async function commonFetch({ url = '', method = 'POST', params = {}, base
         baseInfo.appType = 1
         baseInfo.loginUid = baseInfo.uid
 
-        baseInfo.deviceId1 = deviceInfo.deviceId1;
-        baseInfo.deviceId2 = deviceInfo.deviceId2;
+        baseInfo.fid = deviceInfo.deviceId1;
+        baseInfo.rid = deviceInfo.deviceId2;
+        baseInfo.clientTimestamp = new Date().getTime();
+        baseInfo.requestId = guid();
 
         return new Promise(function (resolve, reject) {
             let _url = baseAPIUrl + url

+ 10 - 2
src/http/request.js

@@ -1,6 +1,8 @@
 import axios from 'axios'
 import { getChromeStorage } from '@/uilts/chromeExtension.js'
 import { baseAPIUrl, appVersionCode } from '@/http/configAPI.js'
+import { guid } from '@/uilts/help'
+
 
 let userInfo = '';
 let storage_mid = ''
@@ -41,7 +43,10 @@ function checkParams(config) {
         appType: 1,
         machineCode: mid,
         pageSource: pageSource || '',
-        ...deviceInfo
+        fid: deviceInfo.deviceId1 || '',
+        rid: deviceInfo.deviceId2 || '',
+        clientTimestamp: new Date().getTime(),
+        requestId: guid()
       }
     }
     config['params'] = params;
@@ -67,7 +72,10 @@ function checkParams(config) {
         appType: 1,
         machineCode: mid,
         pageSource: pageSource || '',
-        ...deviceInfo
+        fid: deviceInfo.deviceId1 || '',
+        rid: deviceInfo.deviceId2 || '',
+        clientTimestamp: new Date().getTime(),
+        requestId: guid()
       }
     }
     config['data'] = data;

+ 2 - 2
src/http/treasure.js

@@ -27,7 +27,7 @@ export function inviteDetail(params) {
 
 export function inviteList(params) {
     return service({
-        url: `/post/treasure/invite/list/v2`,
+        url: `/post/treasure/invite/list/v3`,
         method: "post",
         data: params,
     });
@@ -91,4 +91,4 @@ export function bindPostContent(params) {
         method: "post",
         data: params,
     });
-}
+}

+ 23 - 15
src/logic/background/twitter.js

@@ -222,21 +222,26 @@ export function twitterShortUrl(sender, url) {
 
 
 // 安装插件后获取mid
-export function onInstalledMid() {
+export function onInstalledMid(cb) {
     try {
         getChromeCookie(LANDING_PAGE_MID, (res_arr) => {
             // 没有cookie
             if (res_arr && res_arr.length) {
-                setChromeStorage({ mid: JSON.stringify(res_arr[0]) })
+                setChromeStorage({ mid: JSON.stringify(res_arr[0]) }, () => {
+                  cb && cb()
+                })
             } else {
                 let _params = {
                     mid: guid()
                 }
                 setChromeCookie(LANDING_PAGE, { 'mid': _params.mid })
-                setChromeStorage({ mid: JSON.stringify(_params) })
+                setChromeStorage({ mid: JSON.stringify(_params) }, () => {
+                  cb && cb()
+                })
             }
         })
     } catch (error) {
+        cb && cb();
         Report.reportLog({
             objectType: Report.objectType.background_function_catch,
             funcName: 'onInstalledMid',
@@ -331,18 +336,21 @@ function sendActivetabMessage(message = {}) {
 export function onInstalledCreateTab() {
     try {
         getChromeCookie(LANDING_PAGE_JUMP_INFO, (res = {}) => {
-            setTimeout(() => {
-                if (!res) {
-                    res = {}
-                }
-                // 安装成功埋点
-                Report.reportLog({
-                    objectType: Report.objectType.chrome_extension_installed,
-                    funcName: 'onInstalledCreateTab',
-                    postId: res.postId || '',
-                    shareLinkId: res.shareLinkId || ''
-                })
-            }, 5000)
+            onInstalledMid(() => {
+              setTimeout(() => {
+                  if (!res) {
+                      res = {}
+                  }
+                  // 安装成功埋点
+                  Report.reportLog({
+                      objectType: Report.objectType.chrome_extension_installed,
+                      funcName: 'onInstalledCreateTab',
+                      postId: res.postId || '',
+                      shareLinkId: res.shareLinkId || ''
+                  })
+              }, 5000)
+            });
+
             let url = 'https://twitter.com/search?q=%23denet'
             // jump_info
             if (!res || !res.jump_type) {

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

@@ -343,7 +343,7 @@ class ParseCard {
         _iframe.style.cssText = 'border:medium none; width:505px; min-height:180px;'
         return _iframe
     }
-    createTreasureIframe(params = { page_type, tweet_Id, post_Id, invite_code }) {
+    createTreasureIframe(params = { page_type, tweet_Id, post_Id, invite_code, invite_channel }) {
         let _iframe = document.createElement('iframe')
         _iframe.id = params.post_Id
         _iframe.src = chromeExtensionUrl + ('iframe/treasure-hunt.html') + `?params=${JSON.stringify(params)}&iframeId=${guid()}`;
@@ -538,7 +538,7 @@ class ParseCard {
             dom.appendChild(this.createIframe({ post_Id, tweet_Id, page_type }))
         }
     }
-    replaceDOMTreasureCard({ invite_code, dom_card, tweet_Id, post_Id, time, short_url, page_type = '' }) {
+    replaceDOMTreasureCard({ invite_code, dom_card, tweet_Id, post_Id, time, short_url, page_type = '', invite_channel }) {
         if (!dom_card || !dom_card.parentElement) {
             return
         }
@@ -558,7 +558,7 @@ class ParseCard {
 
         dom.style = 'min-height:500px'
         if (dom) {
-            dom.appendChild(this.createTreasureIframe({ post_Id, tweet_Id, page_type, invite_code }))
+            dom.appendChild(this.createTreasureIframe({ post_Id, tweet_Id, page_type, invite_code, invite_channel }))
         }
     }
     replaceNftDomRedPacket({ dom_card, tweet_Id, post_Id, time, short_url }) {

+ 4 - 5
src/logic/content/help/twitter.js

@@ -1,4 +1,4 @@
-import { getStorage, setStorage, getVisitorId, setCookie, getCookie } from '@/uilts/help'
+import { getStorage, setStorage, getVisitorId, setCookie, getCookie, guid } from '@/uilts/help'
 import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
 
 // 根据提示dom 跳转到推文详情页面
@@ -71,10 +71,9 @@ export const setDeviceInfo = async () => {
 
   let cookieDeviceInfo = getCookie(deviceCookieParams.name);
   if(!cookieDeviceInfo) {
-    let res = await getVisitorId();
-    let id = res && res.visitorId || '';
-    setCookie(deviceCookieParams.name, id, 600);
-    deviceInfo.deviceId2 = id;
+    let rid = guid();
+    setCookie(deviceCookieParams.name, rid, 600);
+    deviceInfo.deviceId2 = rid;
   } else {
     deviceInfo.deviceId2 = cookieDeviceInfo;
   }

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

@@ -882,7 +882,12 @@ function setIframeCard(type = 'twitter') {
                         for (let i in arr) {
                             index = Number(i) + 1
                             if (arr[i] == 'invite' && arr.length >= index) {
-                                item.invite_code = arr[index]
+                                item.invite_code = arr[index];
+                                if(arr.length > index + 1) {
+                                  item.invite_channel = arr[index+1];
+                                } else {
+                                  item.invite_channel = '';
+                                }
                                 break
                             }
                         }

+ 5 - 3
src/view/iframe/treasure-hunt/components/invite-friends.vue

@@ -257,7 +257,7 @@ const clickCopy = () => {
 </script>
 <style lang="scss" scoped>
 .invite-friends {
-    padding: 9px 16px 16px 16px;
+    padding: 9px 14px 14px 14px;
     background: #fff;
     box-sizing: border-box;
 
@@ -265,11 +265,13 @@ const clickCopy = () => {
       max-height: 242px;
       overflow-y: auto;
       margin-bottom: 10px;
-      padding: 0 6px;
       box-sizing: border-box;
 
       .invite-friends-content-head {
         margin-bottom: 20px;
+        padding: 0 6px;
+        box-sizing: border-box;
+
         .title {
           font-weight: 900;
           font-size: 18px;
@@ -312,7 +314,7 @@ const clickCopy = () => {
             flex-direction: column;
             align-items: center;
             justify-content: center;
-            padding: 8px 4px;
+            padding: 8px 2px;
             box-sizing: border-box;
             border-radius: 12px;
 

+ 18 - 45
src/view/iframe/treasure-hunt/components/invite-list.vue

@@ -2,7 +2,7 @@
   <div class="content">
     <div class="horizontal-invited-wrapper" v-if="state.invited_list.length">
       invited({{ state.inviteCount }})
-      <div class="horizontal-invited-list" @mouseleave="invitedListMouseleave($event)">
+      <div class="horizontal-invited-list" v-show-log="state.log_invite_list_show " @mouseleave="invitedListMouseleave($event)">
         <template v-for="(item, index) in state.invited_list" :key="index">
           <div class="invited-item" v-if="index < 9" @mouseenter="invitedItemMouseenter(item)">
             <img :src="item.userInfo.avatarUrl" />
@@ -27,9 +27,9 @@
             {{ getTime(hoverInvitedUserInfo.timestamp) }}
           </div>
         </div>
-        <span class="channel">
-          <img class="app-icon" :src="hoverInvitedUserInfo.userInfo.avatarUrl" />
-          WhatsApp
+        <span class="channel" v-if="hoverInvitedUserInfo.channelName">
+          <img class="app-icon" :src="hoverInvitedUserInfo.channelIcon" />
+          {{hoverInvitedUserInfo.channelName}}
         </span>
       </div>
     </div>
@@ -49,34 +49,16 @@
               {{ getTime(item.timestamp) }}
             </div>
           </div>
-          <span class="channel">
-            <img class="app-icon" :src="item.userInfo.avatarUrl" />
-            WhatsApp
+          <span class="channel" v-if="item.channelName">
+            <img class="app-icon" :src="item.channelIcon" />
+            {{item.channelName}}
           </span>
         </div>
       </div>
     </div>
-
-    <!-- <div class="list" @scroll="handleScroll($event)">
-            <div class="item" v-for="item in state.invited_list" :key="item.userInfo.uid">
-                <div class="left">
-                    <img :src="item.userInfo.avatarUrl" alt="" @click="clickItem(item)" />
-                </div>
-                <div class="right">
-                    <div>{{ item.userInfo.nickName }}</div>
-                    <div>{{ getTime(item.timestamp) }}</div>
-                </div>
-            </div>
-        </div> -->
-    <!-- <div class="footer">
-            <v-btn :txt="state.open_btn.txt" :font-size="'17px'" class="btn" :icon="false" :loading="state.btn_loading"
-                :disabled="state.open_btn.disabled" v-click-log="state.log_invite_btn_click" @onClick="clickBtn"
-                font-weight="600"></v-btn>
-        </div>-->
   </div>
 </template>
 <script setup>
-import VBtn from '@/view/iframe/treasure-hunt/components/btn.vue'
 import { inviteList, inviteListRefresh } from '@/http/treasure'
 import { inject, onMounted, ref, watch } from 'vue'
 import Report from "@/log-center/log"
@@ -84,7 +66,7 @@ import Report from "@/log-center/log"
 var moment = require('moment')
 let state = inject('state')
 state.invited_list = []
-let page_num = 1
+
 let page_size = 100
 let list_end = false
 
@@ -93,17 +75,6 @@ let showVerticalInvitedList = ref(false);
 let timer = null;
 let timer1 = null;
 
-state.log_invite_btn_click = {
-  businessType: Report.businessType.buttonClick,
-  pageSource: Report.pageSource.inviteFriendsPage,
-  objectType: Report.objectType.openChestButton,
-  redPacketType: Report.redPacketType.treasure,
-  shareLinkId: state.invite_code,
-  myShareLinkId: state.detail.inviteCopyUrl,
-  currentInvitedNum: state.inviteCount,
-  postId: state.postId
-}
-
 state.log_invite_list_show = {
   businessType: Report.businessType.pageView,
   pageSource: Report.pageSource.beenInvitedPage,
@@ -116,13 +87,15 @@ state.log_invite_list_show = {
 
 watch(state, () => {
     if (state.refresh) {
-       list()
+      inviteListScroll({isRefresh: true});
+      //  list()
     }
 })
 
 onMounted(() => {
-  state.btn_loading = false
-  list()
+  state.btn_loading = false;
+  inviteListScroll({isRefresh: true})
+  // list()
 })
 
 const invitedItemMouseenter = (params) => {
@@ -199,9 +172,9 @@ const handleCommon = (data) => {
         state.invited_list.push(item)
       }
     })
-    state.invited_list = state.invited_list.sort((a, b) => {
-      return b.timestamp - a.timestamp
-    })
+    // state.invited_list = state.invited_list.sort((a, b) => {
+    //   return b.timestamp - a.timestamp
+    // })
 
     list_end = false
   } else {
@@ -210,11 +183,11 @@ const handleCommon = (data) => {
 }
 
 // 滚动
-let inviteListScroll = () => {
+let inviteListScroll = ({isRefresh = false}) => {
   // state.invited_list
   let last_timestamp = 0
   let len = state.invited_list.length
-  if (len > 0) {
+  if (!isRefresh && len > 0) {
     last_timestamp = state.invited_list[len - 1].timestamp
   }
 

+ 2 - 1
src/view/iframe/treasure-hunt/cover.vue

@@ -91,7 +91,8 @@ const toStart = (req) => {
             inviteCode: state.invite_code || '',
             frontFollowRelJSON: JSON.stringify(state.usersFollowStatusList),
             time: new Date().getTime(),
-            guid: guid()
+            guid: guid(),
+            channelCode: state.invite_channel
         }
     }).then((res) => {
         state.usersFollowStatusList = [];

+ 1 - 0
src/view/iframe/treasure-hunt/index.vue

@@ -58,6 +58,7 @@ onMounted(() => {
     state.tweetId = params.tweet_Id || ''
     state.invite_code = params.invite_code || ''
     state.page_type = params.page_type || ''
+    state.invite_channel = params.invite_channel ? window.atob(params.invite_channel) : '';
     state.init();
     onRuntimeMsg();
 })