Преглед изворни кода

[add] 发布器逻辑、联调(差文案、输入单价交互)

wenliming пре 2 година
родитељ
комит
8beccc3333

+ 43 - 44
src/logic/content/twitter.js

@@ -276,47 +276,45 @@ function checkIsShowReSend(dom, params) {
  * @private
  */
 function _addDeNetEditBtn(params = {}) {
-    setTimeout(() => {
-        let toolElem = document.querySelector('div[data-testid="toolBar"]');
-        if (toolElem) {
-            Report.reportLog({
-                pageSource: Report.pageSource.mainPage,
-                businessType: Report.businessType.buttonView,
-                objectType: Report.objectType.buttonSecond
-            });
-            let innerDeIcon = document.getElementById('de-btn1');
-            if (!innerDeIcon) {
-                toolElem.firstChild.appendChild(createTweetToolbarDenet());
-                popupShowGiveawayDialog();
-            }
+    let toolElem = document.querySelector('div[data-testid="toolBar"]');
+    if (toolElem) {
+        Report.reportLog({
+            pageSource: Report.pageSource.mainPage,
+            businessType: Report.businessType.buttonView,
+            objectType: Report.objectType.buttonSecond
+        });
+        let innerDeIcon = toolElem.querySelector('#de-btn1');
+        if (!innerDeIcon) {
+            toolElem.firstChild.appendChild(createTweetToolbarDenet());
+            popupShowGiveawayDialog();
+        }
 
-            let innerToolBoxIcon = document.getElementById('de-tool-box-btn-01');
-            if (!innerToolBoxIcon) {
-                toolElem.firstChild.appendChild(createTweetToolbarToolBox())
-            }
-        } else {
-            setTimeout(() => {
-                let toolElem = document.querySelector('div[data-testid="toolBar"]');
-                if (toolElem) {
-                    Report.reportLog({
-                        pageSource: Report.pageSource.mainPage,
-                        businessType: Report.businessType.buttonView,
-                        objectType: Report.objectType.buttonSecond
-                    });
-                    let innerDeIcon = document.getElementById('de-btn1');
-                    if (!innerDeIcon) {
-                        toolElem.firstChild.appendChild(createTweetToolbarDenet());
-                        popupShowGiveawayDialog();
-                    }
+        let innerToolBoxIcon = toolElem.querySelector('#de-tool-box-btn-01');
+        if (!innerToolBoxIcon) {
+            toolElem.firstChild.appendChild(createTweetToolbarToolBox())
+        }
+    } else {
+        setTimeout(() => {
+            let toolElem = document.querySelector('div[data-testid="toolBar"]');
+            if (toolElem) {
+                Report.reportLog({
+                    pageSource: Report.pageSource.mainPage,
+                    businessType: Report.businessType.buttonView,
+                    objectType: Report.objectType.buttonSecond
+                });
+                let innerDeIcon = toolElem.querySelector('#de-btn1');
+                if (!innerDeIcon) {
+                    toolElem.firstChild.appendChild(createTweetToolbarDenet());
+                    popupShowGiveawayDialog();
+                }
 
-                    let innerToolBoxIcon = document.getElementById('de-tool-box-btn-01');
-                    if (!innerToolBoxIcon) {
-                        toolElem.firstChild.appendChild(createTweetToolbarToolBox())
-                    }
+                let innerToolBoxIcon = toolElem.querySelector('#de-tool-box-btn-01');
+                if (!innerToolBoxIcon) {
+                    toolElem.firstChild.appendChild(createTweetToolbarToolBox())
                 }
-            }, 1000)
-        }
-    })
+            }
+        }, 1000)
+    }
 }
 
 const popupShowGiveawayDialog = async () => {
@@ -689,8 +687,9 @@ function onWindowResize() {
 function checkHasDeBtn() {
     try {
         let toolBar = document.querySelector('div[data-testid="toolBar"]');
-        let innerDeIcon = document.getElementById('de-btn1');
-        if (toolBar && !innerDeIcon) {
+        let append = toolBar && !toolBar.querySelector('#de-btn1');
+
+        if (append) {
             _addDeNetEditBtn();
         }
     } catch (e) {
@@ -713,9 +712,9 @@ export function bindTwitterArtMethod() {
             }
         }).then((res) => {
             if (res.code == 0) {
-                Report.reportLog({
-                    objectType: Report.objectType.tweetPostBinded
-                });
+                // Report.reportLog({
+                //     objectType: Report.objectType.tweetPostBinded
+                // });
                 bindTwitterArt.needBind = false;
                 bindTwitterArt.postId = '';
                 bindTwitterArt.isBindIng = false;
@@ -874,6 +873,7 @@ function initParseCard() {
             clearInterval(timer)
             setInterval(() => {
                 onChangePageMain(inTwitterNode)
+                checkHasDeBtn()
                 twitterPinLogin()
                 showNFTGroupIcon()
                 if (queue_num <= 0) {
@@ -881,7 +881,6 @@ function initParseCard() {
                 }
                 initGroupTip()
                 setIframeRedPacket()
-                checkHasDeBtn()
                 checkHasSliderDeBtn();
                 changeQueueNum(-1)
                 showNFTCard()

+ 1 - 1
src/types/global.js

@@ -34,7 +34,7 @@ export const TaskType = {
   joinDiscord: 7,
   repostToFacebook: 8,
   twitterCommentAndTag: 9,
-  twitterMakePost: 10
+  twitterRePost: 10
 };
 
 /**

+ 2 - 2
src/view/components/custom-card-cover.vue

@@ -302,7 +302,7 @@ onMounted(() => {
             }
 
             .right {
-                 font-weight: 900;
+                font-weight: 900;
                 font-size: 25px;
             }
         }
@@ -321,7 +321,7 @@ onMounted(() => {
             .amount {
                 font-weight: 800;
                 font-size: 17px;
-                margin-top: -3px;
+                margin-top: -2px;
             }
         }
 

+ 2 - 2
src/view/components/custom-card-horizontal-cover.vue

@@ -28,10 +28,10 @@
                 <img :src="data.userInfo.avatarUrl" 
                 class="avatar"/> 
                 <template v-if="data.type != PlayType.treasure">
-                    {{data.userInfo.name}}
+                    {{data.userInfo.nickName}}
                 </template>
                 <span class="treasure-info" style="color: #fff; opacity: 0.7;font-weight: 300;" v-else>
-                    from @{{data.userInfo.name || ""}}
+                    from @{{data.userInfo.nickName || ""}}
                 </span>
             </div>
 

+ 1 - 1
src/view/iframe/publish/components/follow-input.vue

@@ -314,7 +314,7 @@ const onUserMouseLeave = (params, index) => {
                 overflow-y: auto;
                 background-color: #fff; 
                 top: 30px;
-                left: -150px;
+                left: 0px;
                 z-index: 1000;
                 border-radius: 10px;
 

+ 141 - 52
src/view/iframe/publish/give-dialog.vue

@@ -93,7 +93,7 @@
                         <template v-else>
                         <div class="form-wrapper"  v-if="showComType == 'default'">
                             <div class="form-left-sheet">
-                                <div class="form-cell-item base-form-wrapper">
+                                <div class="base-form-wrapper">
                                     <div class="form-cell-content">
                                         <div class="select-mode-ele">
                                             <template v-for="(item, index) in publishModeList" :key="index">
@@ -165,7 +165,7 @@
                                                         class="top-up" 
                                                         @click="goTopUp">Deposit</div>
                                                 </div>
-                                                <div class="usd-min-message" v-show="isShowUsdMinMessage" v-html="checkUsdMinNumber('inTemplate')"></div>
+                                                <div class="usd-min-message" v-show="isShowUsdMinMessage" v-html="selectModeInfo.type != PlayType.treasure ? checkUsdMinNumber('inTemplate') : checkTreasureAmountRange('inTemplate')"></div>
                                             </div>
                                             
                                             <!-- 人数 -->
@@ -216,8 +216,7 @@
                                                                 @blur="onUsdEstimateFansUnitAmountInput"/>
                                                         </template>
                                                     </form-input>
-                                                    <div style="color: #7E7E7E;font-weight: 400;
-font-size: 12px;margin-left: 10px;" v-if="treasureFormData.addFans">
+                                                    <div class="cost-txt" v-if="treasureFormData.addFans">
                                                         <div>Approximately</div>
                                                         {{treasureFormData.addFans}} New Follower
                                                     </div>
@@ -249,9 +248,9 @@ font-size: 12px;margin-left: 10px;" v-if="treasureFormData.addFans">
                                                     Follow
                                                 </div>
                                                 <div class="cell-content">
-                                                    <follow-input style="padding: 0" :isAddSelf="!isBack"
+                                                    <follow-input style="padding: 0"    
+                                                        :isAddSelf="!isBack"
                                                         :atUserList="atUserList"
-                                                        :isRequire = 'true'
                                                         @addUser="addFollowUser"
                                                         @setUser="setFollowUser"
                                                         @delUser="delFollowUser"></follow-input>
@@ -516,7 +515,7 @@ let timer = ref(null);
 let publishRes = reactive({});
 
 //弹窗是否展示
-let visible = ref(true);
+let visible = ref(false);
 let publishType = ref('REDPACKET');
 
 let userInfo = ref({})
@@ -660,6 +659,7 @@ let currentCurrencyInfo = ref(defaultCurrentCurrencyInfo);
 const discordIptErrTxt = 'Discord invite link is wrong';
 const discordIptEmptyErrTxt = 'Enter discord invite link';
 const discordIptNerverExpiresErrTxt = 'Make sure the Discord link never expires'
+const requireFollowTxt = '添加 follow 任务'
 let iptErrType = ''; //discord
 
 let formList = reactive([
@@ -944,10 +944,13 @@ const confirm = () => {
         return;
     }
     let { totalCount = 0 } = baseFormData;
-    if (!totalCount) {
-        return;
+    if(selectModeInfo.type != PlayType.treasure) {
+        if (!totalCount) {
+            return;
+        }
+        saveDiscordGuildInfo();
     }
-    saveDiscordGuildInfo();
+
     submitRequest();
 };
 
@@ -996,6 +999,10 @@ const resetFormIpt = (clearMode = true) => {
     baseFormData.validityDuration = "";
     baseFormData.rewardType = RewardType.money;
     baseFormData.customizedReward = "";
+    baseFormData.fansUnitAmountValue = "";
+    treasureFormData.addFans = "";
+    treasureFormData.usdEstimateOrderAmount = "";
+    treasureFormData.usdEstimateFansUnitAmount = "";
 
     if(clearMode) {
         selectModeInfo.index = 0;
@@ -1158,33 +1165,14 @@ const submitRequest = async () => {
     baseFormData.amountCurrencyCode = currentCurrencyInfo.value.currencyCode;
     // 组装提交参数
 
-    let finishConditions = [];
-    for (let i = 0; i < formList.length; i++) {
-        let item = {};
-        item.type = formList[i]["type"];
-        if (item.type == TaskType.twitterFollow && atUserList.value.length) {
-            // follow 参数
-            let relatedUsers = atUserList.value.filter(item => item.name);
-            item.relatedUsers = relatedUsers;
-            finishConditions.push(item);
-        } else  if (formList[i]["type"] == TaskType.joinDiscord) {
-            // join discord
-            if(formList[i]["checked"] && formList[i]["text"]) {
-                item.bizData = JSON.stringify({inviteUrl: formList[i]["text"]});
-                finishConditions.push(item);
-            }
-        } else  if (formList[i]["checked"]) {
-            // 其余任务
-            finishConditions.push(item);
-        }
-    }
+    let finishConditions = selectModeInfo.type != PlayType.treasure ? getFinishCondition() : getTreasureFinishCondition();
+ 
     let receiveConditions = openAntiBot.value ? "" : [];
 
     let validityDuration = '';
     if(baseFormData.type == PlayType.lottery) {
         //小时转毫秒
         let unit = process.env.NODE_ENV != 'production' ? 60 * 1000 : 60 * 60 * 1000;
-        // let unit = 60 * 60 * 1000
         validityDuration = baseFormData.validityDuration * unit;
     } else {
         validityDuration = '';
@@ -1193,13 +1181,14 @@ const submitRequest = async () => {
     // 提交参数
     let formData = {
         amountValue,
-        totalCount,
+        totalCount: selectModeInfo.type != PlayType.treasure ? totalCount : treasureFormData.addFans,
         finishConditions,
         receiveConditions,
         type: baseFormData.type,
         posterType: 1,
         validityDuration,
-        rewardType
+        rewardType,
+        fansUnitAmountValue: selectModeInfo.type == PlayType.treasure ? baseFormData.fansUnitAmountValue : ''
     };
     if(rewardType === RewardType.custom) {
         // 通用奖品 类型的活动,添加奖品名称
@@ -1260,6 +1249,49 @@ const submitRequest = async () => {
     });
 };
 
+const getFinishCondition = () => {
+    let finishConditions = [];
+    for (let i = 0; i < formList.length; i++) {
+        let item = {};
+        item.type = formList[i]["type"];
+        if (item.type == TaskType.twitterFollow && atUserList.value.length) {
+            // follow 参数
+            let relatedUsers = atUserList.value.filter(item => item.name);
+            item.relatedUsers = relatedUsers;
+            finishConditions.push(item);
+        } else  if (formList[i]["type"] == TaskType.joinDiscord) {
+            // join discord
+            if(formList[i]["checked"] && formList[i]["text"]) {
+                item.bizData = JSON.stringify({inviteUrl: formList[i]["text"]});
+                finishConditions.push(item);
+            }
+        } else  if (formList[i]["checked"]) {
+            // 其余任务
+            finishConditions.push(item);
+        }
+    }
+    return finishConditions;
+}
+
+const getTreasureFinishCondition = () => {
+    let finishConditions = [
+        {
+            type: TaskType.twitterLikeTweet
+        },
+        {
+            type: TaskType.twitterRePost
+        }
+    ];
+    if(atUserList.value.length) {
+        let relatedUsers = atUserList.value.filter(item => item.name);
+        finishConditions.push({
+            relatedUsers,
+            type: TaskType.twitterFollow
+        });
+    } 
+    return finishConditions;
+};
+
 const calcFontSize = (str, domWidth, maxSize) => {
     let lenstr = str.length;
     let num = parseInt(domWidth / lenstr);
@@ -1348,10 +1380,34 @@ const addFollowUser = (params) => {
 
 const setFollowUser = (params) => {
     atUserList.value[params.index]["name"] = params.name;
+    let userList = atUserList.value.filter(item => item.name);
+    if(selectModeInfo.type == PlayType.treasure) {
+        if(!userList.length) {
+            if(!iptErrMsgTxt.value) {
+                iptErrMsgTxt.value = requireFollowTxt;
+            }
+        } else {
+            if (iptErrMsgTxt.value == requireFollowTxt) {
+                iptErrMsgTxt.value = ""
+            }
+        }
+    }
 };
 
 const delFollowUser = (params) => {
     atUserList.value.splice(params.index, 1);
+    let userList = atUserList.value.filter(item => item.name);
+    if(selectModeInfo.type == PlayType.treasure) {
+        if(!userList.length) {
+            if(!iptErrMsgTxt.value) {
+                iptErrMsgTxt.value = requireFollowTxt;
+            }
+        } else {
+            if (iptErrMsgTxt.value == requireFollowTxt) {
+                iptErrMsgTxt.value = ""
+            }
+        }
+    }
 };
 
 const calcUsdEstimate = (params) => {
@@ -1394,14 +1450,20 @@ const calcTokenEstimate = (params) => {
     }
 }
 
+/**
+ * token 转 USD 估值
+ */
 const calcToken2UsdEstimate = (params) => {
     if(!params.amount) {
         return '';
     }
     let val = +math.format(math.evaluate(`${params.amount} * ${params.usdPrice}`));
-    return val.toFixed(2);
+    return Math.floor(val * 100) / 100;
 };
 
+/**
+ * USD 转 token 估值
+ */
 const calcUsd2TokenEstimate = (params) => {
     if(!params.amount) {
         return '';
@@ -1410,6 +1472,9 @@ const calcUsd2TokenEstimate = (params) => {
     return val;
 };
 
+/**
+ * 预计新增粉丝数
+ */
 const calcAddFans = (params = {}) => {
     let {totalAmount, unitPrice} = params;
     if (totalAmount > 0 && unitPrice > 0) {
@@ -1418,9 +1483,12 @@ const calcAddFans = (params = {}) => {
     }
 };
 
+/**
+ * 奖励总金额 美元估值
+ */
 const onUsdEstimateOrderAmountInput = () => {
     let val = treasureFormData.usdEstimateOrderAmount;
-    val = val.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
+    val = String(val).replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
     if(val == '00') {
         val = '0'
     }
@@ -1430,9 +1498,12 @@ const onUsdEstimateOrderAmountInput = () => {
     return val;
 };
 
+/**
+ * 粉丝单价 USD 输入
+ */
 const onUsdEstimateFansUnitAmountInput = () => {
     let val = treasureFormData.usdEstimateFansUnitAmount;
-    val = val.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
+    val = String(val).replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
     if(val == '00') {
         val = '0'
     }
@@ -1450,9 +1521,12 @@ const onUsdEstimateFansUnitAmountInput = () => {
     return val;
 }
 
+/**
+ * 粉丝单价输入
+ */
 const onFansUnitAmountInput = () => {
     let val = baseFormData.fansUnitAmountValue;
-    val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
+    val = String(val).replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
     if(val == '00') {
         val = '0'
     }
@@ -1473,7 +1547,7 @@ const onFansUnitAmountInput = () => {
 const onAmountInput = () => {
     let val = baseFormData.amountValue;
     // val = val.replace(/[^\d^\.]+/g, "");
-    val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
+    val = String(val).replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
 
     const maxCount = baseFormData.rewardType === RewardType.money ? Number.MAX_SAFE_INTEGER : 100000000;
 
@@ -1612,8 +1686,7 @@ const checkUsdMinNumber = (isInTemplate) => {
     return forbiddenText;
 };
 
-const checkTreasureAmountRange = (params = {}) => {
-    let {type, amount, maxAmount} = params;
+const checkTreasureAmountRange = (isInTemplate) => {
     let forbiddenText = '';
 
     const { usdPrice, minAmount, luckdropPostConfig = [] } = currentCurrencyInfo.value;
@@ -1624,34 +1697,41 @@ const checkTreasureAmountRange = (params = {}) => {
             // 当前token允许的usd最小金额为0 或单个红包最小金额为0,则无限制
             return forbiddenText;
         } else {
-            let amount2Usd = +math.format(math.evaluate(amount * usdPrice));
-            switch (type) {
-                case 'TOTAL_AMOUNT':
-                    forbiddenText = amount2Usd > currentLuckDropConfig?.minTotalUsdAmount ? '' : `要大于${currentLuckDropConfig?.minTotalUsdAmount}最小总金额`;
-                    break;
-                case 'FANS_UNIT_AMOUNT':
-                    forbiddenText = amount > minAmount && amount2Usd > currentLuckDropConfig?.minAvgUsdAmount ?  '' : `要大于${currentLuckDropConfig?.minAvgUsdAmount}最小平均金额`;
-                    break;
-            }
+
+            let txt =  `The prize pool must be above ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + currentLuckDropConfig.minTotalUsdAmount + '</span>') : ('$' + currentLuckDropConfig.minTotalUsdAmount)} 
+                            or the average prize must be above
+                            ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + currentLuckDropConfig.minAvgUsdAmount +' per person.</span>' ): ('$' + currentLuckDropConfig.minAvgUsdAmount + ' per person.') }`
+
+            const isAmountForbidden = currentLuckDropConfig?.minTotalUsdAmount ? +math.format(math.evaluate(baseFormData.amountValue * usdPrice)) < currentLuckDropConfig?.minTotalUsdAmount : false;
+            const isAvgForbidden = baseFormData.fansUnitAmountValue !== '' && currentLuckDropConfig?.minAvgUsdAmount ? baseFormData.fansUnitAmountValue < minAmount || +math.format(math.evaluate(baseFormData.fansUnitAmountValue * usdPrice)) < currentLuckDropConfig?.minAvgUsdAmount : false;
+
+            forbiddenText = isAmountForbidden || isAvgForbidden ? txt : '';
         }
     }
     return forbiddenText;
 };
 
 const treasureFormValidata = () => {
+    isShowUsdMinMessage.value = false;
+    let userList = atUserList.value.filter(item => item.name);
+
     if(!currentCurrencyInfo.value.currencyCode) {
         iptErrMsgTxt.value = "Select a reward"
     } else if (!baseFormData.amountValue || baseFormData.amountValue == '0') {
         iptErrMsgTxt.value = "Enter an amount";
-    } else if (iptErrMsgTxt.value = checkTreasureAmountRange({type: 'TOTAL_AMOUNT', amount: baseFormData.amountValue})) {
+    } else if (iptErrMsgTxt.value = checkTreasureAmountRange()) {
         //amount 是否大于 最小总金额
-
+        isShowUsdMinMessage.value = true;
     } else if (!baseFormData.fansUnitAmountValue) {
         // 输入粉丝单价
         iptErrMsgTxt.value = '请输入粉丝单价';
-    } else if(iptErrMsgTxt.value  = checkTreasureAmountRange({type: 'FANS_UNIT_AMOUNT', amount: baseFormData.fansUnitAmountValue, maxAmount: baseFormData.amountValue})) {
+    } else if(iptErrMsgTxt.value  = checkTreasureAmountRange()) {
         // 粉丝单价是否 小于总金额规则 大于最小粉丝单价 、大于币种最小精度
+        isShowUsdMinMessage.value = true;
+    } else if(!userList.length) {
+        iptErrMsgTxt.value = requireFollowTxt;
     } else {
+        isShowUsdMinMessage.value = false;
         iptErrMsgTxt.value = "";
     }
 };
@@ -2396,6 +2476,7 @@ onMounted(() => {
 
                     .base-form-wrapper {
                         margin-right: 30px;
+                        width: 100%;
 
                         .form-cell-content {
                             .select-mode-ele {
@@ -2415,6 +2496,7 @@ onMounted(() => {
                                 .img {
                                     width: 158px;
                                     height: 80px;
+                                    border-radius: 5px;
                                     margin-right: 13px;
                                 }
 
@@ -2470,6 +2552,13 @@ onMounted(() => {
                                             color: #B3B3B3;
                                             margin-top: 12px;
                                         }
+
+                                        .cost-txt {
+                                            color: #7E7E7E;
+                                            font-weight: 400;
+                                            font-size: 12px;
+                                            margin-left: 10px;
+                                        }
                                     }
                                 }