Browse Source

[edit] add

A\An 2 years ago
parent
commit
bde4d30612

+ 5 - 1
src/entry/content.js

@@ -12,7 +12,8 @@ import {
     init,
     initExecuteScript,
     changeQueueNum,
-    replyHandle
+    replyHandle,
+    noticeBindTweet
 } from "@/logic/content/twitter.js";
 
 import {
@@ -44,6 +45,9 @@ window.onmessage = (res) => {
             case "IFRAME_RED_PACKET_REPLY_CLICK":
                 replyHandle(res.data.data || {});
                 break;
+            case "IFRAME_RED_PACKET_SHOW_BIND_TWEET_NOTICE":
+                noticeBindTweet(res.data.data || {});
+                break;
             // case "IFRAME_DO_TASK":
             //     findTweetByIdDoTask(res.data.task_data, res.data.task_type)
             //     break

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

@@ -307,6 +307,17 @@ function addPublishTipsIframe({srcContent}) {
     }, 1000)
 }
 
+export function noticeBindTweet(params) {
+    let iframe = document.createElement('iframe');
+    iframe.id = 'de-notice-bind-tweet';
+    iframe.src = chrome.runtime.getURL('/iframe/bind-tweet.html') + `?params=${JSON.stringify(params)}`;
+    iframe.style.cssText = `border: medium none; width:400px;min-height:280px;position: fixed; right: 16px; top: 16px;`
+    let iframeContent = document.getElementById('de-notice-bind-tweet');
+    if(!iframeContent) {
+        document.querySelector('body').appendChild(iframe)
+    }
+}
+
 /**
  * 点击deNet按钮处理
  * @private

+ 2 - 1
src/manifest.json

@@ -55,7 +55,8 @@
                 "/iframe/publish.html",
                 "/iframe/red-packet.html",
                 "/iframe/home.html",
-                "/iframe/publish-tips.html"
+                "/iframe/publish-tips.html",
+                "/iframe/bind-tweet.html"
             ],
             "matches": [
                 "<all_urls>"

+ 146 - 0
src/view/iframe/bind-tweet/bind-tweet.vue

@@ -0,0 +1,146 @@
+<template>
+    <div class="bind-tips-wrapper">
+        <img src="" class="icon-close" @click="close">
+        <div class="top">
+            <img src="" class="icon-give-box">
+            <div class="text">
+                oops, you failed to send giveaway
+            </div>
+        </div>
+        <div class="button-wrapper">
+            <div class="re-send" @click="seSend">Resend</div>
+            <div class="terminate" @click="terminate">Terminate for a refund</div>
+        </div>
+    </div>
+</template>
+
+<script setup>
+/* eslint-disable */
+import { onMounted, ref } from "vue";
+import { ElMessage } from 'element-plus'
+import { getChromeStorage } from '@/uilts/chromeExtension.js'
+import { getQueryString } from '@/uilts/help.js'
+
+let submitData = ref({});
+
+const close = () => {
+    window.parent.postMessage({ actionType: "IFRAME_CLOSE_BIND_TWEET",  data: {
+    }}, "*");
+}
+
+const seSend = async () => {
+    let publishData = await getChromeStorage('publishData');
+    callEventPageMethod(
+        "POPUP_PUBLISH_TWITTER_RED_PACK",
+        { 
+            srcContent: publishData.srcContent, 
+            postId: publishData.postId 
+        },
+        function (response) {
+            console.log("res", response);
+        }
+    );
+}
+
+const terminate = () => {
+    terminatedLuckdrop({
+        params: {
+            luckdropId: submitData.id
+        }
+    }).then(res => {
+        if(res.code == 0) {
+            close();
+        }
+    });
+    // window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_REPLY_CLICK",  data: {
+    //   postId: state.postId,
+    //   type: params.type,
+    //   taskLuckdropId: state.detail.taskLuckdropId
+    // }}, "*");
+}
+
+/**
+ * sendMessage
+ */
+const callEventPageMethod = (actionType, data, callback) => {
+    chrome.runtime.sendMessage(
+        { 
+            actionType: actionType, 
+            data: data 
+        },
+        function (response) {
+            if (typeof callback === "function") callback(response);
+        }
+    );
+};
+
+
+onMounted(() => {
+    let params = getQueryString('params');
+    submitData.value = params;
+}) 
+
+</script>
+
+<style scoped lang="scss">
+.bind-tips-wrapper {
+    width: 100%;
+    height: 100%;
+    box-sizing: border-box;
+    background: #FFFFFF;
+    border-radius: 20px;
+    padding: 15px;
+    position: relative;
+
+    .icon-close {
+        position: absolute;
+        left: 14px;
+        top: 14px;
+        width: 24px;
+        height: 24px;
+    }
+
+    .top {
+        display: flex;
+        align-items: center;
+        flex-direction: column;
+        margin-top: 35px;
+
+        .icon-give-box {
+            width: 60px;
+            height: 60px;
+            margin-bottom: 20px;
+        }
+
+        .text {
+            font-weight: 590;
+            font-size: 18px;
+        }
+    }
+
+    .button-wrapper {
+        margin-top: 26px;
+
+        .re-send, .terminate {
+            width: 360px;
+            height: 43px;
+            border-radius: 100px;
+            font-weight: 500;
+            font-size: 17px;
+            display: flex;
+            align-items: center;
+            justify-content: center;
+        }
+        
+        .re-send {
+            background: #1D9BF0;
+            margin-bottom: 12px;
+            color: #FFFFFF;
+        }
+
+        .terminate {
+            color: #1D9BF0;
+        }
+    }
+}
+</style>

+ 15 - 9
src/view/iframe/publish/give-dialog.vue

@@ -1203,7 +1203,21 @@ const onIptSetErrorTxt = (params = {}) => {
  * 监听开关触发事件
  */
 const formSwitchChange = (val, params, index) => {
-    console.log('formSwitchChange')
+    closeDiscordTask(val, params, index);
+}
+
+
+const hideTask = (params, index) => {
+    formList[index]['checked'] = false;
+    formList[index]['show'] = false;
+    closeDiscordTask(false, {type: 7, index})
+}
+
+const clickDropdown = (params, index) => {
+    formList[index]['show'] = true;
+}
+
+const closeDiscordTask = (val, params) => {
     if(params.type == 7) {
         if(!val) {
             //错误类型 discord 清空discord错误校验
@@ -1218,14 +1232,6 @@ const formSwitchChange = (val, params, index) => {
     }
 }
 
-const hideTask = (params, index) => {
-    formList[index]['show'] = false;
-}
-
-const clickDropdown = (params, index) => {
-    formList[index]['show'] = true;
-}
-
 
 /** 监听 discord 输入 */
 const onIptDiscordAddress = (e, index) => {

+ 10 - 2
src/view/iframe/red-packet/red-packet.vue

@@ -724,7 +724,7 @@ const reSetBindTwtterId = (_params) => {
           Report.reportLog({
             objectType: Report.objectType.tweetPostBinded
           });
-          init()
+          init({from: 'reSetBindTwtterId'})
         }
       })
     }
@@ -901,7 +901,8 @@ function setFrontConfig() {
     });
 };
 
-function init() {
+function init(initParams) {
+  let {type} = initParams || {};
   onRuntimeMsg();
   onPageVisbile();
   onWindowMessage();
@@ -923,6 +924,13 @@ function init() {
       // 判断推特id,绑定逻辑
       state.srcContentId = res.data.srcContentId
       if (!state.srcContentId) {
+        if(type != 'reSetBindTwtterId') {
+          // 显示提示
+          window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_SHOW_BIND_TWEET_NOTICE",  data: {
+            postId: state.postId,
+            taskLuckdropId: state.detail.taskLuckdropId
+          }}, "*");
+        }
         reSetBindTwtterId(res.data)
         return
       }