فهرست منبع

[fix] self test bug

wenliming 2 سال پیش
والد
کامیت
8328c99c59

+ 21 - 11
src/logic/content/twitter.js

@@ -121,6 +121,15 @@ export function showPinTips() {
     })
 }
 
+export function hidePinTips() {
+    hidePopupPage();
+    hideNoticeBindTweet();
+    let pop = document.querySelector('#de-pin-pop');
+    if(pop) {
+        pop.style.display = 'none';
+    }
+}
+
 function addPinedPop() {
     let domPop = document.getElementById('de-pin-pop');
 
@@ -378,6 +387,8 @@ export function noticeBindTweet(params) {
 }
 
 export function hideNoticeBindTweet() {
+    hidePinTips();
+    hidePopupPage();
     let iframeContent = document.getElementById('de-notice-bind-tweet');
     if (iframeContent) {
         document.querySelector('body').removeChild(iframeContent)
@@ -789,8 +800,7 @@ export function init() {
     showNFTCard()
     renderDom();
     checkTwitterTaskState();
-    appendPopupPage();
-    
+
     onBodyClick();
     initBuyNFT()
 
@@ -1239,12 +1249,14 @@ export const showNFTSale = () => {
     document.querySelector('div[id="de-nft-node"]').style.display = 'block';
 }
 
-export const appendPopupPage = () => {
+export const appendPopupPage = (params) => {
+    let { path = '' } = params;
+
     let iframe = document.createElement('iframe');
     iframe.id = 'de-popup-page';
-    iframe.src = chrome.runtime.getURL('/iframe/popup-page.html');
+    iframe.src = chrome.runtime.getURL('/iframe/popup-page.html') + `#${path}`;
     iframe.style.cssText = `border: medium none; width: 375px;
-    height: 600px;position: fixed; right: 16px; top: 16px;background: #FFFFFF;border: 0.5px solid #919191;box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);box-sizing: border-box;display: none;z-index: 1000;`
+    height: 600px;position: fixed; right: 16px; top: 16px;background: #FFFFFF;border: 0.5px solid #919191;box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);box-sizing: border-box;z-index: 1000;`
     let iframeContent = document.getElementById('de-extension-popup');
     if (!iframeContent) {
         document.querySelector('body').appendChild(iframe);
@@ -1253,17 +1265,15 @@ export const appendPopupPage = () => {
 
 export const showPopupPage = (params) => {
     let { path = '' } = params;
-    let iframe = document.getElementById('de-popup-page');
-    if (iframe) {
-        iframe.src = chrome.runtime.getURL('/iframe/popup-page.html') + `#${path}`;
-        iframe.style.display = 'block';
-    }
+    appendPopupPage({path});
 }
 
 export const hidePopupPage = () => {
+    hidePinTips();
+    hideNoticeBindTweet();
     let iframe = document.getElementById('de-popup-page');
     if (iframe) {
-        iframe.style.display = 'none';
+        document.querySelector('body').removeChild(iframe);
     }
 }
 

+ 13 - 11
src/view/popup/components/tabbar.vue

@@ -91,15 +91,18 @@ const tabbarHandler = (params, index) => {
     emits("tabbarClick", params);
 };
 
-const setActiveTab = (path) => {
-    let list = tabbarData.value;
-    for (let i = 0; i < list.length; i++) {
-        if (path == list[i].path) {
-            currentTab.value.index = i;
-            currentTab.value.path = path;
-            break;
+const setActiveTab = () => {
+    nextTick(() => {
+        let path = router.currentRoute.value.path;
+        let list = tabbarData.value;
+        for (let i = 0; i < list.length; i++) {
+            if (path == list[i].path) {
+                currentTab.value.index = i;
+                currentTab.value.path = path;
+                break;
+            }
         }
-    }
+    })
 };
 
 const getNFTListMine = () => {
@@ -132,9 +135,8 @@ const setMessageCount = () => {
 }
 
 onMounted(() => {
-    let path = router.currentRoute.value.path;
-    setActiveTab(path);
-    // getNFTListMine();
+    setActiveTab();
+    getNFTListMine();
 });
 </script>
 

+ 7 - 2
src/view/popup/components/top-bar.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="top-bar-wrapper" :style="{background: bgColor, boxShadow: boxShadow}">
-        <div class="left">
+        <div class="left" @click="clickUserInfo">
             <img :src="userInfo.avatarUrl" class="icon-avatar">
             <span class="nick-name" :style="{color: color}">{{userInfo.nickName}}</span>
         </div>
@@ -13,7 +13,7 @@
 <script setup>
 import {defineProps} from 'vue';
 
-defineProps({
+const props = defineProps({
     userInfo: {
         type: Object,
         default: () => {
@@ -33,6 +33,10 @@ defineProps({
         default: '#fff'
     }
 })
+
+function clickUserInfo() {
+    window.open(`https://twitter.com/${props.userInfo.nickName}`);
+}
 </script>
 
 <style scoped lang='scss'>
@@ -48,6 +52,7 @@ defineProps({
     .left {
         display: flex;
         align-items: center;
+        cursor: pointer;
         .icon-avatar {
             width: 24px;
             height: 24px;

+ 42 - 28
src/view/popup/currency-detail.vue

@@ -10,8 +10,8 @@
         class="icon-currency"
         :src="currencyInfo.iconPath"/>
       <div class="amount">
-        {{currencyInfo.balance}} {{currencyInfo.currencyName}}
-        <div class="final">${{currencyInfo.usdEstimateBalance}}</div>
+        {{currencyInfo.totalBalance}} {{currencyInfo.currencyName}}
+        <div class="final">${{currencyInfo.totalUsdEstimateBalance}}</div>
       </div>
     </div>
     <div class="bottom">
@@ -29,7 +29,7 @@
                 @selectCurrency="selectCurrency">
             </currency-select>
         </div>
-        <div class="selectBg"></div>
+        <div class="selectBg" @click="showCurrencySelect = false"></div>
     </template>
   </div>
 </template>
@@ -50,17 +50,20 @@ let currenciesData = ref([]);
 let currencyInfo = ref({});
 let showCurrencySelect = ref(false);
 
+let currencyOpertionType = '';
+
+
+
 const selectCurrency = (params) => {
     showCurrencySelect.value = false;
-
-    currencyInfo.value = {
-      ...params,
-      totalBalance: currencyInfo.value.totalBalance,
-      totalUsdEstimateBalance: currencyInfo.value.totalUsdEstimateBalance
+    if(currencyOpertionType == 'WITHDRAW') {
+      withdrawHandle(params);
+    } else if(currencyOpertionType == 'DEPOSIT') {
+      depositHandle(params);
     }
-    console.log(currencyInfo.value)
 }
 
+let withdraw_info = inject('withdraw_info')
 // 点击提现
 const clickWithdraw = () => {
     Report.reportLog({
@@ -68,10 +71,15 @@ const clickWithdraw = () => {
         businessType: Report.businessType.buttonClick,
         objectType: Report.objectType.withdrawButton
     });
-    withdrawHandle(currencyInfo.value);
+
+    if(currenciesData.value.length > 1) {
+      showCurrencySelect.value = true;
+      currencyOpertionType = "WITHDRAW";
+    } else if(currenciesData.value.length == 1){
+      withdrawHandle(currenciesData.value[0]);
+    }
 }
 
-let withdraw_info = inject('withdraw_info')
 const withdrawHandle = (_params) => {
   withdraw_info.chainInfo = _params.chainInfo;
   if (_params.currencyCode == 'USD') {
@@ -91,6 +99,10 @@ const withdrawHandle = (_params) => {
   }
 }
 
+
+
+let top_up_info = inject('top_up_info');
+
 const clickDeposit = () => {
     Report.reportLog({
         pageSource: Report.pageSource.denetHomePage,
@@ -98,10 +110,14 @@ const clickDeposit = () => {
         objectType: Report.objectType.topupButton
     });
 
-    depositHandle(currencyInfo.value);
+    if(currenciesData.value.length > 1) {
+      showCurrencySelect.value = true;
+      currencyOpertionType = "DEPOSIT";
+    } else if(currenciesData.value.length == 1){
+      depositHandle(currenciesData.value[0]);
+    }
 }
 
-let top_up_info = inject('top_up_info');
 const depositHandle = (_params) => {
   top_up_info.token = _params.currencyName || ''
   top_up_info.token_chain = _params.tokenChain 
@@ -117,22 +133,24 @@ const depositHandle = (_params) => {
 };
 
 const onRefresh = () => {
-  // 刷新余额接口
-  asyncTokenRechRecord(currencyInfo.value, (res) => {
-    if(res.code == 0 && res.data && res.data.length) {
-        let currencyData = res.data[0];
-        if(currencyData.currencyCode == currencyInfo.value.currencyCode) {
-          currencyInfo.value.balance = currencyData.balance;
-          currencyInfo.value.usdEstimateBalance = currencyData.usdEstimateBalance;
-        }
-    }
-  })
+    asyncTokenRechRecord(currencyInfo.value, (res) => {
+      if(res.code == 0 && res.data && res.data.length) {
+          let currencyData = res.data[0];
+          if(currencyData.currencyCode == currencyInfo.value.currencyCode) {
+            currencyInfo.value.balance = currencyData.balance;
+            currencyInfo.value.usdEstimateBalance = currencyData.usdEstimateBalance;
+          }
+      }
+    })
 };
 
+
 const asyncTokenRechRecord = (_params, cb) => {
+    let { currencyCode = '' } = _params;
+    if(!currencyCode || !currencyOpertionType) return;
     syncChainTokenRechargeRecord({
         params: {
-            currencyCode: _params.currencyCode
+            currencyCode: currencyCode
         }
     }).then(res => {
         cb && cb(res)
@@ -153,10 +171,6 @@ onMounted(() => {
         totalUsdEstimateBalance
       };
     }
-
-    if(currenciesData.value.length > 1) {
-      showCurrencySelect.value = true;
-    }
 })
 </script>
 

+ 1 - 1
src/view/popup/withdraw/success.vue

@@ -17,7 +17,7 @@ let withdraw_info = inject('withdraw_info')
 
 let router = useRouter()
 const onDone = () => {
-    router.replace('/withdraw/home')
+    router.replace('/')
 }
 
 </script>