|
@@ -318,7 +318,7 @@
|
|
|
<script setup>
|
|
|
import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick } from "vue";
|
|
|
import { postPublish, verifyPaypalResult, syncChainTokenRechargeRecord, getCurrencyInfoByCode } from "@/http/publishApi";
|
|
|
-import { getInviteGuildInfo } from "@/http/discordApi";
|
|
|
+import { getInviteGuildInfo, saveInviteGuildInfo } from "@/http/discordApi";
|
|
|
import { payCalcFee, getPayConfig } from "@/http/pay";
|
|
|
import { getFrontConfig } from "@/http/account";
|
|
|
import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
|
|
@@ -577,6 +577,19 @@ const getPayAmount = async (amountValue) => {
|
|
|
return res.data;
|
|
|
};
|
|
|
|
|
|
+const saveDiscordGuildInfo = () => {
|
|
|
+ let {guildId, inviteCode, inviteUrl} = discordInviteInfo.value;
|
|
|
+ if(guildId && inviteCode && inviteUrl) {
|
|
|
+ saveInviteGuildInfo({
|
|
|
+ params: {
|
|
|
+ guildId,
|
|
|
+ inviteCode,
|
|
|
+ inviteUrl
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
const confirm = () => {
|
|
|
if(depositGuide.value) { //余额不够去充值
|
|
@@ -590,6 +603,7 @@ const confirm = () => {
|
|
|
if (!totalCount) {
|
|
|
return;
|
|
|
}
|
|
|
+ saveDiscordGuildInfo();
|
|
|
submitRequest();
|
|
|
};
|
|
|
|
|
@@ -839,6 +853,8 @@ const initParams = () => {
|
|
|
|
|
|
// clear discord value
|
|
|
formList[3].text = '';
|
|
|
+
|
|
|
+ discordInviteInfo.value = {};
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -1074,8 +1090,9 @@ const setDiscordErrTxt = (params = {showPop: false}) => {
|
|
|
let validata = checkInviteUrl(discordData.text);
|
|
|
if(validata) {
|
|
|
getDiscordInviteInfo(discordData.text, (res) => {
|
|
|
- // 1012 openApi 超限
|
|
|
- if(res.code != 0 && res.code != 1012) {
|
|
|
+ console.log('discordData',res)
|
|
|
+ // 未知的邀请链接
|
|
|
+ if(res.inviteCode != res.data.code || !res.data.guildId) {
|
|
|
iptErrMsgTxt.value = discordIptErrTxt;
|
|
|
iptErrType = 'discord';
|
|
|
} else {
|
|
@@ -1150,15 +1167,36 @@ const checkInviteUrl = (inviteUrl) => {
|
|
|
/**获取discord 邀请信息 */
|
|
|
const getDiscordInviteInfo = (inviteUrl, cb) => {
|
|
|
if(!inviteUrl) return;
|
|
|
+ let inviteCode = '';
|
|
|
+ let arr = inviteUrl.split('/');
|
|
|
+ if(arr.length > 0) {
|
|
|
+ inviteCode = arr[arr.length - 1];
|
|
|
+ }
|
|
|
+ if(discordInviteInfo.value.guildId && discordInviteInfo.value.inviteCode == inviteCode) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
getInviteGuildInfo({
|
|
|
- params: {
|
|
|
- inviteUrl
|
|
|
- }
|
|
|
+ inviteCode
|
|
|
}).then(res => {
|
|
|
- cb && cb(res)
|
|
|
- if(res.code == 0) {
|
|
|
- discordInviteInfo.value = res.data;
|
|
|
+ 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,
|
|
|
+ name,
|
|
|
+ icon,
|
|
|
+ }
|
|
|
}
|
|
|
+ discordInviteInfo.value = resData.data;
|
|
|
+ cb && cb(resData);
|
|
|
}).catch((err) => {
|
|
|
if(iptErrMsgTxt.value && iptErrType == 'discord') {
|
|
|
iptErrMsgTxt.value = '';
|