wenliming пре 2 година
родитељ
комит
48274e0aa1
3 измењених фајлова са 80 додато и 23 уклоњено
  1. 9 1
      src/http/discordApi.js
  2. 20 0
      src/view/iframe/popup/index.vue
  3. 51 22
      src/view/iframe/publish/give-dialog.vue

+ 9 - 1
src/http/discordApi.js

@@ -15,11 +15,19 @@ export function discordAuthUrl(params) {
  */
 export function getInviteGuildInfo(params) {
     return service({
-        url: `https://discord.com/api/invites/${params.inviteCode}`,
+        url: `https://discord.com/api/v9/invites/${params.inviteCode}?with_counts=true&with_expiration=true`,
         method: "get",
     });
 }
 
+export function getInviteGuildInfoByOpenApi(params) {
+    return service({
+        url: `https://discord.com/api/invites/${params.inviteCode}?with_counts=true&with_expiration=true`,
+        method: "get",
+    });
+}
+
+
 export function checkGuildJoined(params) {
     return service({
         url: `/openapi/discord/checkGuildJoined`,

+ 20 - 0
src/view/iframe/popup/index.vue

@@ -0,0 +1,20 @@
+<template>
+    <div class="main_app">
+        <div class="content" :style="contentStyle">
+            <popup></popup>
+        </div>
+    </div>
+</template>
+
+
+<script setup>
+import { onMounted } from "vue";
+import popup from '@/view/popup/index.vue'
+
+onMounted(() => {
+});
+
+</script>
+
+<style lang='scss' scoped>
+</style>

+ 51 - 22
src/view/iframe/publish/give-dialog.vue

@@ -446,7 +446,7 @@
 <script setup>
 import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick, provide } from "vue";
 import { postPublish, verifyPaypalResult, syncChainTokenRechargeRecord, getCurrencyInfoByCode } from "@/http/publishApi";
-import { getInviteGuildInfo, saveInviteGuildInfo } from "@/http/discordApi";
+import { getInviteGuildInfo, getInviteGuildInfoByOpenApi, saveInviteGuildInfo } from "@/http/discordApi";
 import { payCalcFee, getPayConfig } from "@/http/pay";
 import { getFrontConfig } from "@/http/account";
 import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
@@ -668,7 +668,7 @@ watch(
             // 更新余额
             clearInterval(timer.value);
             timer.value = setInterval(() => {
-                getCurrencyInfo();
+                getCurrencyInfo({loop: true});
             }, 10000)
         } else {
             clearInterval(timer.value);
@@ -1403,26 +1403,27 @@ const getDiscordInviteInfo = ({inviteUrl, getDuildId}, cb) => {
     getInviteGuildInfo({
         inviteCode
     }).then(res => {
-        if(!res) {
-            res = {};
+        let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
+        if(resData.data.guildId) {
+            cb && cb(resData);
+        } else {
+            getGuildInfoByOpenApi({inviteCode}, cb);
         }
-        let {name, icon, id} = res.guild || {};
+    }).catch((err) => {
+        getGuildInfoByOpenApi({inviteCode}, cb);
+    });
+}
 
-        icon = icon && id ? `https://cdn.discordapp.com/icons/${id}/${icon}.png` : '';
-        let resData = {
-            inviteCode,
-            data: {
-                code: res.code,
-                guildId: id,
-                inviteUrl,
-                inviteCode,
-                expires: res.expires_at,
-                name,
-                icon,
-            }
-        }
-        discordInviteInfo.value = resData.data;
-        cb && cb(resData);
+const getGuildInfoByOpenApi = (params, cb) => {
+    let { inviteCode } = params;
+
+    getInviteGuildInfoByOpenApi({
+        inviteCode
+    }).then(res => {
+        let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
+        if(resData.data.guildId) {
+            cb && cb(resData);
+        } 
     }).catch((err) => {
         if(iptErrMsgTxt.value && iptErrType == 'discord') {
             iptErrMsgTxt.value = '';
@@ -1431,6 +1432,31 @@ const getDiscordInviteInfo = ({inviteUrl, getDuildId}, cb) => {
     });
 }
 
+const inviteGuildResHandler = (res, params) => {
+    let {inviteCode, inviteUrl} = params;
+    if(!res) {
+        res = {};
+    }
+    let {name, icon, id} = res.guild || {};
+
+    icon = icon && id ? `https://cdn.discordapp.com/icons/${id}/${icon}.png` : '';
+    let resData = {
+        inviteCode,
+        data: {
+            code: res.code,
+            guildId: id,
+            inviteUrl,
+            inviteCode,
+            expires: res.expires_at,
+            name,
+            icon,
+        }
+    }
+    discordInviteInfo.value = resData.data;
+
+    return resData;
+};
+
 /**
  * 获取支付配置(paypalClientId)
  */
@@ -1472,7 +1498,8 @@ const getLocalCurrencyInfoByCode = () => {
     }
 }
 
-const getCurrencyInfo = async () => {
+const getCurrencyInfo = async (_params) => {
+    let { loop = false} = _params || {};
     let {accessToken = ''} = await getChromeStorage('userInfo') || {};
     if (accessToken) {
         getChromeStorage('selectCurrencyInfo', (res) => {
@@ -1485,7 +1512,9 @@ const getCurrencyInfo = async () => {
                     if(res.code == 0 && res.data) {
                         currentCurrencyInfo.value = res.data;
                         tempCurrentCurrencyInfo.value = res.data;
-                        onIptSetErrorTxt();
+                        if(!loop) {
+                            onIptSetErrorTxt();
+                        }
                     }
                 });
             }