Browse Source

[bug][显示卡片刷新]

zhangwei 2 năm trước cách đây
mục cha
commit
9347e62161

+ 22 - 16
src/logic/content/twitter.js

@@ -1,5 +1,5 @@
 import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
-import { throttle, getQueryString, getCookie, nextTick } from '@/uilts/help'
+import { throttle, getQueryString, getCookie, nextTick ,getQueryStringByUrl} from '@/uilts/help'
 import { discordAuthRedirectUri } from '@/http/configAPI'
 import { reportSrcPublishEvent } from '@/http/publishApi'
 import Report from "@/log-center/log"
@@ -1193,7 +1193,7 @@ export function doTaskTwitterAPI({ task_data, task_type }) {
 export function showJoinDialog(data) {
     let iframe = document.querySelector('#nftProjectId')
     iframe.style.display = 'block'
-    iframe.src = chrome.runtime.getURL(`/iframe/buy-nft.html#/group?type=${data.type}&buy_nft_status=${data.buy_nft_status}&nft_group_Id=${data.nft_group_Id}&nftProjectId=${data.buyNftProjectId}`)
+    iframe.src = chrome.runtime.getURL(`/iframe/buy-nft.html#/group?params=${JSON.stringify(data)}`)
 }
 
 const TwitterFollowAPI = (item, tweet_Id) => {
@@ -1321,10 +1321,10 @@ export function publishNFTTweetEvent({ groupId, postId, srcContent }) {
             arr.forEach((item) => {
                 if (textContent.includes(item)) {
                     textContent = textContent.replaceAll(item, '')
-                }  
+                }
             })
-            text_content_arr.forEach((item)=>{
-                if(item.includes('#DNFT') || item.includes('⬇️')){
+            text_content_arr.forEach((item) => {
+                if (item.includes('#DNFT') || item.includes('⬇️')) {
                     textContent = textContent.replaceAll(item, '')
                 }
             })
@@ -1353,6 +1353,10 @@ export function publishNFTTweetEvent({ groupId, postId, srcContent }) {
                     groupFontWeight: '500',
                     lineDisplay: 'none'
                 });
+                chrome.runtime.sendMessage({
+                    actionType: "SWITCH_GROUP_BANNER_STATUS",
+                    data: { type: 'arrow' }
+                }, () => { });
             }, 2000);
         });
     }, 800)
@@ -1382,15 +1386,17 @@ export const setTwitterTextarea = (params) => {
 
 
 const initGroupTip = () => {
-    let dom_denet_group_tip = document.querySelector('#denet_group_tip')
-    if (dom_denet_group_tip) {
-        return
-    }
-
     let arr = window.location.pathname.split('/') || []
-    
     if (arr.length >= 2) {
         let twitterAccount = arr[1]
+        let iframe_banner = document.querySelector('#denet_group_tip')
+        if (iframe_banner) {
+            if (twitterAccount != getQueryStringByUrl(iframe_banner.src, 'twitterAccount')) {
+                iframe_banner.style.display = 'none'
+                iframe_banner.src = chrome.runtime.getURL(`/iframe/group-card.html?twitterAccount=${twitterAccount}`)
+            }
+            return
+        }
         try {
             let dom = document.querySelector('div[data-testid="ScrollSnap-SwipeableList"]').closest('nav')
             let iframe = document.createElement('iframe')
@@ -1674,8 +1680,8 @@ export const setPopupConfByPopupPage = () => {
 const addGroupTab = () => {
     let illegalPages = ['notifications', 'explore', 'followers', 'following'];
     let page = window.location.pathname.split('/');
-    if(page && page.length) {
-        if(illegalPages.indexOf(page[page.length - 1]) > -1) {
+    if (page && page.length) {
+        if (illegalPages.indexOf(page[page.length - 1]) > -1) {
             return;
         }
     }
@@ -1737,12 +1743,12 @@ const addGroupTab = () => {
 
             setTimeout(() => {
                 let tab = getMaskWeb3Tab();
-                if(tab) {
+                if (tab) {
                     tab.style.display = 'none'
                 } else {
                     setTimeout(() => {
                         tab = getMaskWeb3Tab();
-                        if(tab) {
+                        if (tab) {
                             tab.style.display = 'none'
                         }
                     }, 1500)
@@ -2008,7 +2014,7 @@ const getMaskWeb3Tab = () => {
 
 export const pageJumpHandler = (params) => {
     let { url } = params
-    if(url) {
+    if (url) {
         window.open(url)
     }
 }

+ 64 - 55
src/uilts/help.js

@@ -7,6 +7,15 @@ export function getQueryString(name) {
   return null
 }
 
+export function getQueryStringByUrl(url = '', name = '') {
+  let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i")
+  let r = url.split('?')[1].match(reg)
+  if (r != null) {
+    return window.decodeURIComponent(r[2])
+  }
+  return null
+}
+
 export function debounce(fn, delay) {
   let timer; // 定时器
   return function (...args) { // 形成闭包
@@ -63,84 +72,84 @@ export function guid() {
 }
 
 export function scaleNumber(num) {
-    let length = num.toString().split('.')[1].length;
-    
-    let scale = '1';
-    
-    for(let i = 0; i < length; i++) {
-        scale += '0';
-    }
+  let length = num.toString().split('.')[1].length;
+
+  let scale = '1';
+
+  for (let i = 0; i < length; i++) {
+    scale += '0';
+  }
 
-    let val = num * scale;
-    return {
-      val,
-      scale
-    };
+  let val = num * scale;
+  return {
+    val,
+    scale
+  };
 }
 
-export function getBit (value) {
+export function getBit(value) {
   const reg = /([0-9]+\.[0-9]{4})[0-9]*/;
-  if(value) {
+  if (value) {
     let str = value.toString();
-    str = str.replace(reg,"$1");
+    str = str.replace(reg, "$1");
     return str;
   } else {
     return value;
   }
 }
 
-export function getCookie(name){
+export function getCookie(name) {
   var strcookie = document.cookie;//获取cookie字符串
   var arrcookie = strcookie.split("; ");//分割
   //遍历匹配
-  for ( var i = 0; i < arrcookie.length; i++) {
-      var arr = arrcookie[i].split("=");
-      if (arr[0] == name){
-          return arr[1];
-      }
+  for (var i = 0; i < arrcookie.length; i++) {
+    var arr = arrcookie[i].split("=");
+    if (arr[0] == name) {
+      return arr[1];
+    }
   }
   return "";
 }
 
 export function nextTick(fn, time = 50) {
-    return new Promise((resolve, reject) => {
-        setTimeout(() => {
-            if (fn) fn();
-            resolve();
-        }, time)
-    })
+  return new Promise((resolve, reject) => {
+    setTimeout(() => {
+      if (fn) fn();
+      resolve();
+    }, time)
+  })
 }
 
 export function getBrowser() {
-    let browser;
-    let UserAgent = navigator.userAgent.toLowerCase();
-    if (UserAgent.indexOf('chrome') > -1 && UserAgent.indexOf('safari') > -1) {
-        browser = `Chrome`
-    } else if (UserAgent.indexOf('firefox') > -1) {
-        browser = `Firefox`
-    } else if (UserAgent.indexOf('opera') > -1) {
-        browser = `Opera`
-    } else if (UserAgent.indexOf('safari') > -1 && UserAgent.indexOf('chrome') == -1) {
-        browser = `Safari`
-    } else if (UserAgent.indexOf('edge') > -1) {
-        browser = `Edge`
-    } else {
-        browser = `Other`
-    }
-    return browser;
+  let browser;
+  let UserAgent = navigator.userAgent.toLowerCase();
+  if (UserAgent.indexOf('chrome') > -1 && UserAgent.indexOf('safari') > -1) {
+    browser = `Chrome`
+  } else if (UserAgent.indexOf('firefox') > -1) {
+    browser = `Firefox`
+  } else if (UserAgent.indexOf('opera') > -1) {
+    browser = `Opera`
+  } else if (UserAgent.indexOf('safari') > -1 && UserAgent.indexOf('chrome') == -1) {
+    browser = `Safari`
+  } else if (UserAgent.indexOf('edge') > -1) {
+    browser = `Edge`
+  } else {
+    browser = `Other`
+  }
+  return browser;
 }
 
 export function getOffsetRect(element) {
-    var oTop = element.offsetTop;
-    var oLeft = element.offsetLeft;
-    var current = element.offsetParent;
-    while (current !== null) {
-        oTop += current.offsetTop;
-        oLeft += current.offsetLeft;
-        current = current.offsetParent;
-    }
-    return {
-        top: oTop,
-        left: oLeft,
-    }
+  var oTop = element.offsetTop;
+  var oLeft = element.offsetLeft;
+  var current = element.offsetParent;
+  while (current !== null) {
+    oTop += current.offsetTop;
+    oLeft += current.offsetLeft;
+    current = current.offsetParent;
+  }
+  return {
+    top: oTop,
+    left: oLeft,
+  }
 }

+ 13 - 12
src/view/iframe/buy-nft/group/tip.vue

@@ -7,12 +7,11 @@
         <div class="area-content" v-show="state.show == 'tip'">
             <!--  -->
             <div class="logo">
-                <img :src="require('@/assets/svg/icon-denet-logo.svg')" />
-
+                <img :src="state.params.nftGroupIcon" />
             </div>
 
             <div class="title">
-                DeNet Core Member Group
+                {{ state.params.nftGroupName }}
             </div>
             <div class="tip">
                 Join to Get Posting Permissions and Badges
@@ -23,10 +22,10 @@
                 <span>Own this Group's NFT to Join</span>
                 <img :src="require('@/assets/svg/icon-line.svg')" />
             </div>
-            <div class="btn" v-if="state.type == 'buy' && state.buy_nft_status == 1" @click="clickBuy">
+            <div class="btn" v-if="state.params.type == 'buy' && state.params.buy_nft_status == 1" @click="clickBuy">
                 Buy NFT to Join
             </div>
-            <div class="btn" v-if="state.type == 'join'" @click="clickJoin">
+            <div class="btn" v-if="state.params.type == 'join'" @click="clickJoin">
                 Join Now
             </div>
         </div>
@@ -52,8 +51,10 @@
 import { reactive, onMounted } from 'vue'
 import { useRouter } from 'vue-router'
 import { setGroupJoin } from '@/http/group.js'
+import { sendChromeTabMessage } from '@/uilts/chromeExtension.js';
 let state = reactive({
     show: 'tip',
+    params:{}
 })
 const router = useRouter()
 
@@ -61,19 +62,20 @@ const clickJoin = () => {
     // 请求接口
     setGroupJoin({
         params: {
-            nftGroupId: state.nft_group_Id
+            nftGroupId: state.params.nft_group_Id
         }
     }).then((res) => {
         if (res.code == 0) {
             state.show = 'success'
-            state.type = 'buy'
+            state.params.type = 'buy'
+            sendChromeTabMessage({ actionType: "FINISH_GROUP_BANNNER" }, () => { })
         }
     })
 }
 
 const clickBuy = () => {
     // 传输参数
-    router.push(`/?nft_group_Id=${state.nft_group_Id}&nftProjectId=${state.buyNftProjectId}`)
+    router.push(`/?nft_group_Id=${state.params.nft_group_Id}&nftProjectId=${state.params.buyNftProjectId}`)
 }
 const clickClose = () => {
     chrome.tabs.getCurrent((tab) => {
@@ -88,10 +90,9 @@ const clickFinish = () => {
 }
 
 onMounted(() => {
-    state.type = router.currentRoute.value.query.type
-    state.buy_nft_status = router.currentRoute.value.query.buy_nft_status
-    state.nft_group_Id = router.currentRoute.value.query.nft_group_Id
-    state.buyNftProjectId = router.currentRoute.value.query.nftProjectId
+    let params = router.currentRoute.value.query.params || {}
+    debugger
+    state.params = JSON.parse(params)
 })
 
 </script>

+ 13 - 13
src/view/iframe/group-card/card.vue

@@ -2,7 +2,7 @@
     <div id="denet_group_tip" v-if="state.data" style="display: flex;z-index: 100; background-color: #356789;">
         <div style="flex:1; display: flex; align-items: center;">
             <div>
-                <img :src="state.data.linkImagePath" style="width:54px;height:54px; margin: 0 20px;" alt="" />
+                <img :src="state.data.nftGroupIcon" style="width:54px;height:54px; margin: 0 20px;" alt="" />
             </div>
             <div>
                 <p style="font-weight: 700; font-size: 18px; color: #fff; margin: 0; padding: 0; margin-bottom: 11px;">
@@ -48,7 +48,7 @@
 
 <script setup>
 import { reactive, onMounted } from 'vue'
-import { getTwitterNftGroupInfo, getTwitterNftPostPre } from "@/http/group";
+import { getTwitterNftGroupInfo } from "@/http/group";
 import { getQueryString } from '@/uilts/help.js';
 import { sendChromeTabMessage, checkIsLogin } from '@/uilts/chromeExtension.js';
 
@@ -60,13 +60,19 @@ let state = reactive({
 })
 
 // 显示加入小组弹框
-const clickJoin = () => {
+async function clickJoin() {
+    let _userInfo = await checkIsLogin()
+    if (!_userInfo) {
+        return
+    }
     sendChromeTabMessage({
         actionType: "IFRAME_SHOW_JOIN_DIALOG",
         data: {
             type: 'join',
             buy_nft_status: state.data.buyNftStatus,
-            nft_group_Id: state.data.nftGroupId
+            nft_group_Id: state.data.nftGroupId,
+            nftGroupIcon: state.data.nftGroupIcon,
+            nftGroupName: state.data.nftGroupName
         }
     })
 }
@@ -128,18 +134,10 @@ const clickArrow = () => {
 }
 
 async function clickPost() {
-    // getTwitterNftPostPre({
-    //     params:{
-    //         groupId:''
-    //     }
-    // }).then((res)=>{
-
-    // })
     let _userInfo = await checkIsLogin()
     if (!_userInfo) {
         return
     }
-    debugger
     // 没有购买过
     if (state.data.buyNftStatus == 0) {
         sendChromeTabMessage({
@@ -148,7 +146,9 @@ async function clickPost() {
                 type: 'buy',
                 buy_nft_status: state.data.buyNftStatus,
                 nft_group_Id: state.data.nftGroupId,
-                buyNftProjectId: state.data.buyNftProjectId
+                buyNftProjectId: state.data.buyNftProjectId,
+                nftGroupIcon: state.data.nftGroupIcon,
+                nftGroupName: state.data.nftGroupName
             }
         })
         // 购买过