|
@@ -196,11 +196,11 @@
|
|
|
<div v-if="showDiscordInvitePop"
|
|
|
class="discord-invite-info"
|
|
|
@click="showDiscordInvitePop = false">
|
|
|
- <img class="icon" :src="discordInviteInfo.icon" />
|
|
|
+ <img class="icon" :src="discordInviteInfo.icon || require('@/assets/svg/icon-discord-mini.svg')" />
|
|
|
<span class="name">{{discordInviteInfo.name}}</span>
|
|
|
</div>
|
|
|
<input v-model="item.text"
|
|
|
- placeholder="Enter link address"
|
|
|
+ placeholder="Enter discord invite link"
|
|
|
class="discord-address"
|
|
|
@input="onIptDiscordAddress($event, index)"
|
|
|
@blur="onBlurDiscordAddress($event, index)" />
|
|
@@ -209,7 +209,7 @@
|
|
|
<el-switch
|
|
|
v-if="item.type == 2 || item.type == 7"
|
|
|
v-model="item.checked"
|
|
|
- @change="formSwitchChange($event, item)"
|
|
|
+ @change="formSwitchChange($event, item, index)"
|
|
|
/>
|
|
|
<img
|
|
|
v-if="item.type == 3"
|
|
@@ -446,6 +446,10 @@ let currentCurrencyInfo = ref({
|
|
|
usdEstimateBalance: ""
|
|
|
});
|
|
|
|
|
|
+const discordIptErrTxt = 'Discord invite link is wrong';
|
|
|
+const discordIptEmptyErrTxt = 'Enter discord invite link';
|
|
|
+let iptErrType = ''; //discord
|
|
|
+
|
|
|
let formList = reactive([
|
|
|
{
|
|
|
label: "Follow",
|
|
@@ -820,8 +824,11 @@ const calcFontSize = (str, domWidth, maxSize) => {
|
|
|
*/
|
|
|
const initParams = () => {
|
|
|
resetFormIpt();
|
|
|
+
|
|
|
+ // clear follow value
|
|
|
formList[0].text = [];
|
|
|
atUserList.value = [];
|
|
|
+
|
|
|
submitIng.value = false;
|
|
|
isBack.value = false;
|
|
|
showCurrencyPop.value = false;
|
|
@@ -829,6 +836,9 @@ const initParams = () => {
|
|
|
|
|
|
tempCurrentCurrencyInfo.value = {};
|
|
|
currentCurrencyInfo.value = {};
|
|
|
+
|
|
|
+ // clear discord value
|
|
|
+ formList[3].text = '';
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -991,7 +1001,7 @@ const setInputErrorMsg = () => {
|
|
|
/**
|
|
|
* 输入时 检测设置错误信息
|
|
|
*/
|
|
|
-const onIptSetErrorTxt = () => {
|
|
|
+const onIptSetErrorTxt = (params = {}) => {
|
|
|
depositGuide.value = false;
|
|
|
if(!currentCurrencyInfo.value.currencyCode) {
|
|
|
iptErrMsgTxt.value = "Select a reward"
|
|
@@ -1005,6 +1015,9 @@ const onIptSetErrorTxt = () => {
|
|
|
iptErrMsgTxt.value = `${baseFormData.amountValue} ${currentCurrencyInfo.value.tokenSymbol} Can send up to ${res.count} winners`;
|
|
|
} else {
|
|
|
iptErrMsgTxt.value = "";
|
|
|
+ if(params.actionType != 'discord_blur') {
|
|
|
+ setDiscordErrTxt();
|
|
|
+ }
|
|
|
}
|
|
|
} else if(currentCurrencyInfo.value.currencyCode != 'USD') {
|
|
|
depositGuide.value = true;
|
|
@@ -1012,61 +1025,133 @@ const onIptSetErrorTxt = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const formSwitchChange = (val, params) => {
|
|
|
+/**
|
|
|
+ * 监听开关触发事件
|
|
|
+ */
|
|
|
+const formSwitchChange = (val, params, index) => {
|
|
|
+ console.log('formSwitchChange')
|
|
|
if(!val) {
|
|
|
if(params.type == 7) {
|
|
|
- // 清空discord错误校验
|
|
|
+ //错误类型 discord 清空discord错误校验
|
|
|
+ if(iptErrType == 'discord') {
|
|
|
+ iptErrMsgTxt.value = '';
|
|
|
+ formList[index]['text'] = '';
|
|
|
+ onIptSetErrorTxt();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/** 监听 discord 输入 */
|
|
|
const onIptDiscordAddress = (e, index) => {
|
|
|
let val = formList[index].text;
|
|
|
-
|
|
|
- onIptDiscordDebounce({value: val, checked: formList[index].checked})
|
|
|
+ let checked = formList[index].checked;
|
|
|
+ if(val && !checked) {
|
|
|
+ checked = true;
|
|
|
+ formList[index].checked = checked;
|
|
|
+ formList[index].text = formList[index].text.replace(/\s/g,'');
|
|
|
+ }
|
|
|
+ onIptDiscordDebounce()
|
|
|
}
|
|
|
|
|
|
const onBlurDiscordAddress = (e, index) => {
|
|
|
- let val = formList[index].text;
|
|
|
+ setDiscordErrTxt({fromType: 'discord', showPop: false, actionType: 'discord_blur'});
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
+const getDiscordIptData = () => {
|
|
|
+ let discordItem = formList.find(item => item.type == 7);
|
|
|
+ return discordItem;
|
|
|
}
|
|
|
|
|
|
-const onIptDiscordDebounce = debounce(function({value, checked}) {
|
|
|
- if(value && checked) {
|
|
|
- let validata = checkInviteUrl(value);
|
|
|
- if(validata) {
|
|
|
- getDiscordInviteInfo(value, (res) => {
|
|
|
- if(res.code != 0) {
|
|
|
- // 错误提示
|
|
|
- } else {
|
|
|
- showDiscordInvitePop.value = true;
|
|
|
- setTimeout(() => {
|
|
|
- showDiscordInvitePop.value = false;
|
|
|
- }, 2000)
|
|
|
- }
|
|
|
- });
|
|
|
+/**
|
|
|
+ * 设置输入discord错误提示信息
|
|
|
+ */
|
|
|
+const setDiscordErrTxt = (params = {showPop: false}) => {
|
|
|
+ let discordData = getDiscordIptData() || {};
|
|
|
+ if(discordData.checked) {
|
|
|
+ if(discordData.text) {
|
|
|
+ let validata = checkInviteUrl(discordData.text);
|
|
|
+ if(validata) {
|
|
|
+ getDiscordInviteInfo(discordData.text, (res) => {
|
|
|
+ if(res.code != 0) {
|
|
|
+ iptErrMsgTxt.value = discordIptErrTxt;
|
|
|
+ iptErrType = 'discord';
|
|
|
+ } else {
|
|
|
+ if(iptErrMsgTxt.value) {
|
|
|
+ iptErrMsgTxt.value = '';
|
|
|
+ iptErrType = '';
|
|
|
+ }
|
|
|
+ if(params.showPop) {
|
|
|
+ showDiscordInvitePop.value = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ showDiscordInvitePop.value = false;
|
|
|
+ }, 2000)
|
|
|
+ }
|
|
|
+ if(params.fromType == 'discord') {
|
|
|
+ onIptSetErrorTxt();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch((err) => {
|
|
|
+ if(iptErrMsgTxt.value) {
|
|
|
+ iptErrMsgTxt.value = '';
|
|
|
+ iptErrType = '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ iptErrMsgTxt.value = discordIptErrTxt;
|
|
|
+ iptErrType = 'discord';
|
|
|
+ }
|
|
|
} else {
|
|
|
- // 错误提示
|
|
|
-
|
|
|
+ if(params.actionType == 'discord_blur') {
|
|
|
+ onIptSetErrorTxt({acitonType: 'discord_blur'});
|
|
|
+ } else {
|
|
|
+ // 设置空提示
|
|
|
+ iptErrMsgTxt.value = discordIptEmptyErrTxt;
|
|
|
+ iptErrType = 'discord';
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+const onIptDiscordDebounce = debounce(function() {
|
|
|
+ setDiscordErrTxt({fromType: 'discord', showPop: true});
|
|
|
}, 800)
|
|
|
|
|
|
+/**
|
|
|
+ * 校验 discord邀请url
|
|
|
+ */
|
|
|
const checkInviteUrl = (inviteUrl) => {
|
|
|
- let flag = true;
|
|
|
- const INVITE_URL_PREFIX = 'https://discord.gg/';
|
|
|
- const INVITE_URL_PREFIX_OLD = 'https://discord.com/invite/';
|
|
|
+ let flag = false;
|
|
|
+ const INVITE_URL_PREFIX_1 = 'https://discord.gg/';
|
|
|
+ const INVITE_URL_PREFIX_2 = 'https://discord.com/invite/';
|
|
|
+ const INVITE_URL_PREFIX_3 = 'http://discord.gg/';
|
|
|
+ const INVITE_URL_PREFIX_4 = 'http://discord.com/invite/';
|
|
|
+ const INVITE_URL_PREFIX_5 = 'discord.gg/';
|
|
|
+ const INVITE_URL_PREFIX_6 = 'discord.com/invite/';
|
|
|
+
|
|
|
+ const arr = [INVITE_URL_PREFIX_1, INVITE_URL_PREFIX_2, INVITE_URL_PREFIX_3, INVITE_URL_PREFIX_4, INVITE_URL_PREFIX_5, INVITE_URL_PREFIX_6]
|
|
|
|
|
|
if(inviteUrl) {
|
|
|
- if(inviteUrl == INVITE_URL_PREFIX || inviteUrl == INVITE_URL_PREFIX_OLD ||
|
|
|
- (!inviteUrl.startsWith(INVITE_URL_PREFIX) && !inviteUrl.startsWith(INVITE_URL_PREFIX_OLD))) {
|
|
|
+ if(arr.indexOf(inviteUrl) > -1) {
|
|
|
flag = false;
|
|
|
+ } else {
|
|
|
+ let isPass = false;
|
|
|
+ for(let i = 0; i < arr.length; i++) {
|
|
|
+ let item = arr[i];
|
|
|
+ if(inviteUrl.startsWith(item)) {
|
|
|
+ isPass = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ flag = isPass;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
+/**获取discord 邀请信息 */
|
|
|
const getDiscordInviteInfo = (inviteUrl, cb) => {
|
|
|
if(!inviteUrl) return;
|
|
|
getInviteGuildInfo({
|
|
@@ -1588,6 +1673,8 @@ onMounted(() => {
|
|
|
box-sizing: border-box;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
.icon {
|
|
|
width: 40px;
|
|
|
height: 40px;
|