瀏覽代碼

[edit][兼容版本]

zhangwei 2 年之前
父節點
當前提交
49ca606db3
共有 1 個文件被更改,包括 112 次插入104 次删除
  1. 112 104
      src/view/iframe/red-packet/red-packet.vue

+ 112 - 104
src/view/iframe/red-packet/red-packet.vue

@@ -23,8 +23,8 @@
       </div>
 
       <div class="list">
-        <div class="item" v-for="item, i in state.detail.taskCondition" v-bind:key="i">
-          <template v-if="item.type == 1 && item.relatedUsers && item.relatedUsers.length > 0">
+        <template v-for="item, i in state.detail.taskCondition" v-bind:key="i">
+          <div class="item" v-if="item.type == 1 && item.relatedUsers && item.relatedUsers.length > 0">
             <div class="item-content">
               <div class="item-follow-title">
                 <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
@@ -48,9 +48,9 @@
                 </template>
               </div>
             </div>
-          </template>
-          <template v-if="item.type == 2">
-          <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
+          </div>
+          <div class="item" v-if="item.type == 2">
+            <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
             <!-- <img :src="require('@/assets/svg/icon-like.svg')" alt /> -->
             <div class="item-content">
               <div class="item-title">Like</div>
@@ -59,8 +59,8 @@
               v-show="!state.done.like && state.done.like_red" />
             <img v-if="state.done.like" :src="require('@/assets/svg/icon-true.svg')" alt />
             <div v-else class="btn" @click="clickLikeBtn">Like</div>
-          </template>
-          <template v-if="item.type == 3">
+          </div>
+          <div class="item" v-if="item.type == 3">
             <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
             <!-- <img :src="require('@/assets/svg/icon-retweet.svg')" alt /> -->
             <div class="item-content">
@@ -70,9 +70,9 @@
               v-show="!state.done.retweet && state.done.retweet_red" />
             <img v-if="state.done.retweet" :src="require('@/assets/svg/icon-true.svg')" alt />
             <div v-else class="btn" @click="clickRetweetBtn">Retweet</div>
-          </template>
+          </div>
           <!-- Comment、艾特 friends -->
-          <template v-if="item.type == 9">
+          <div class="item" v-if="item.type == 9">
             <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
             <div class="item-content">
               <div class="item-title">Comment and Tag 3 friends</div>
@@ -81,9 +81,9 @@
               v-show="!state.done.reply && state.done.reply_red" />
             <img v-if="state.done.reply" :src="require('@/assets/svg/icon-true.svg')" alt />
             <div v-else class="btn" @click="clickReply(item)">Comment</div>
-          </template>
+          </div>
           <!-- repost feacebook -->
-          <template v-if="item.type == 8">
+          <div class="item" v-if="item.type == 8">
             <img :src="require('@/assets/svg/icon-task-facebook.svg')" alt />
             <div class="item-content">
               <div class="item-title">Repost to Facebook</div>
@@ -92,9 +92,9 @@
               v-show="!state.done.repost_facebook && state.done.repost_facebook_red" />
             <img v-if="state.done.repost_facebook" :src="require('@/assets/svg/icon-true.svg')" alt />
             <div v-else class="btn" @click="clickRepostFacebook(item)">Repost</div>
-          </template>
+          </div>
           <!-- join discord  -->
-          <template v-if="item.type == 7">
+          <div class="item" v-if="item.type == 7">
             <img :src="require('@/assets/svg/icon-discord-mini.svg')" alt />
             <div class="item-content">
               <div class="item-title">Join Discord</div>
@@ -110,8 +110,8 @@
                 Join
               </div>
             </template>
-          </template>
-        </div>
+          </div>
+        </template>
       </div>
       <!-- <div class="people" @click="clickRoad">
         <div class="txt">
@@ -374,7 +374,7 @@ import { setChromeStorage, getChromeStorage } from '@/uilts/chromeExtension.js'
 import Report from "@/log-center/log"
 import { srcPublishSuccess } from '@/http/publishApi'
 import { discordAuthUrl, checkGuildJoined } from '@/http/discordApi'
-import { discordAuthRedirectUri, faceShareRedirectUrl} from '@/http/configAPI'
+import { discordAuthRedirectUri, faceShareRedirectUrl } from '@/http/configAPI'
 import { getFrontConfig } from "@/http/account";
 import GlobalTip from '@/view/components/global-tip.vue'
 
@@ -425,8 +425,8 @@ async function clickLikeBtn() {
     return
   }
   state.detail.finishTaskTypeV2 = state.detail.finishTaskTypeV2.toString() || ''
-  if(state.window_origin.indexOf('facebook.com') >=0) {
-      state.detail.finishTaskTypeV2 = '2'
+  if (state.window_origin.indexOf('facebook.com') >= 0) {
+    state.detail.finishTaskTypeV2 = '2'
   }
   switch (state.detail.finishTaskTypeV2) {
     case '1':
@@ -529,8 +529,8 @@ async function clickRetweetBtn() {
   }
 
   state.detail.finishTaskTypeV2 = state.detail.finishTaskTypeV2.toString() || ''
-  if(state.window_origin.indexOf('facebook.com') >=0) {
-      state.detail.finishTaskTypeV2 = '2'
+  if (state.window_origin.indexOf('facebook.com') >= 0) {
+    state.detail.finishTaskTypeV2 = '2'
   }
   switch (state.detail.finishTaskTypeV2) {
     case '1':
@@ -581,67 +581,69 @@ async function clickRetweetBtn() {
 }
 
 function onTweetReplyClick(params) {
-    let replyData = {
-      postId: state.postId,
-      type: params.type,
-      taskLuckdropId: state.detail.taskLuckdropId
-    }
+  let replyData = {
+    postId: state.postId,
+    type: params.type,
+    taskLuckdropId: state.detail.taskLuckdropId
+  }
 
-     window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_ON_TWEET_REPLY_CLICK",  data: replyData}, "*");
+  window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_ON_TWEET_REPLY_CLICK", data: replyData }, "*");
 }
 
 async function clickReply(params) {
-    let _userInfo = await checkIsLogin()
-    if (!_userInfo) {
-      return
-    }
+  let _userInfo = await checkIsLogin()
+  if (!_userInfo) {
+    return
+  }
 
-    let replyData = {
-      postId: state.postId,
-      type: params.type,
-      taskLuckdropId: state.detail.taskLuckdropId
-    }
-    if(state.window_origin.indexOf('facebook.com') > -1) {
-      let url = `https://twitter.com/${state.tweet_author}/status/${state.tweetId}?actionType=denetFacebookToTwitterReply&deReplyParams=${JSON.stringify(replyData)}`
-      window.open(url)
-    } else {
-        window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_REPLY_CLICK",  data: replyData}, "*");
-    }
+  let replyData = {
+    postId: state.postId,
+    type: params.type,
+    taskLuckdropId: state.detail.taskLuckdropId
+  }
+  if (state.window_origin.indexOf('facebook.com') > -1) {
+    let url = `https://twitter.com/${state.tweet_author}/status/${state.tweetId}?actionType=denetFacebookToTwitterReply&deReplyParams=${JSON.stringify(replyData)}`
+    window.open(url)
+  } else {
+    window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_REPLY_CLICK", data: replyData }, "*");
+  }
 }
 
 /**
  * 点击repost facebook
  */
 async function clickRepostFacebook(params) {
-    let _userInfo = await checkIsLogin()
-    if (!_userInfo) {
-      return
-    }
+  let _userInfo = await checkIsLogin()
+  if (!_userInfo) {
+    return
+  }
 
-    let deUrlParams = {
-      fullName,
-      tweetId: state.tweetId
-    }
-    let href = `${state.postRedirectUrl}?deUrlParams=${JSON.stringify(deUrlParams)}`;
-    console.log(href);
-    let shareUrlparams = {
-      href, 
-      type: params.type,
-      taskLuckdropId: state.detail.taskLuckdropId
-    }
+  let deUrlParams = {
+    fullName,
+    tweetId: state.tweetId
+  }
+  let href = `${state.postRedirectUrl}?deUrlParams=${JSON.stringify(deUrlParams)}`;
+  console.log(href);
+  let shareUrlparams = {
+    href,
+    type: params.type,
+    taskLuckdropId: state.detail.taskLuckdropId
+  }
 
-    setChromeStorage({shareFacebookData : JSON.stringify({
+  setChromeStorage({
+    shareFacebookData: JSON.stringify({
       contentStr: state.srcContent
-    })}) 
+    })
+  })
 
-    let shareUrl = feacebookShareUrl(shareUrlparams);
-    openShareFacebookWindow({url: shareUrl});
+  let shareUrl = feacebookShareUrl(shareUrlparams);
+  openShareFacebookWindow({ url: shareUrl });
 }
 
 /**
  * 分享到facebook
  */
-function openShareFacebookWindow({url}) {
+function openShareFacebookWindow({ url }) {
   const width = 800;
   chrome.windows.create({
     width,
@@ -670,9 +672,9 @@ function feacebookShareUrl(params = {}) {
  * 分享成功
  */
 function facebookShareSuccess(params) {
-  let {taskLuckdropId} = params;
+  let { taskLuckdropId } = params;
 
-  if(taskLuckdropId == state.detail.taskLuckdropId) {
+  if (taskLuckdropId == state.detail.taskLuckdropId) {
     state.done.repost_facebook = true;
     state.done.repost_facebook_red = false;
   }
@@ -741,8 +743,8 @@ async function clickFollowAll(item, is_all) {
   }
   // ---- 
   state.detail.finishTaskTypeV2 = state.detail.finishTaskTypeV2.toString() || ''
-  if(state.window_origin.indexOf('facebook.com') >=0) {
-      state.detail.finishTaskTypeV2 = '2'
+  if (state.window_origin.indexOf('facebook.com') >= 0) {
+    state.detail.finishTaskTypeV2 = '2'
   }
   switch (state.detail.finishTaskTypeV2) {
     case '1':
@@ -822,7 +824,7 @@ const reSetBindTwtterId = (_params) => {
           Report.reportLog({
             objectType: Report.objectType.tweetPostBinded
           });
-          init({from: 'reSetBindTwtterId'})
+          init({ from: 'reSetBindTwtterId' })
         }
       })
     }
@@ -983,17 +985,17 @@ const handleStatusPage = () => {
 }
 
 function setFrontConfig() {
-    getFrontConfig({
-        params: {},
-    }).then((res) => {
-        if (res.code == 0) {
-            facebookAppConfig.facebookAppId = res.data.fbClientId;
-        }
-    });
+  getFrontConfig({
+    params: {},
+  }).then((res) => {
+    if (res.code == 0) {
+      facebookAppConfig.facebookAppId = res.data.fbClientId;
+    }
+  });
 };
 
 function init(initParams) {
-  let {type} = initParams || {};
+  let { type } = initParams || {};
   onRuntimeMsg();
   onPageVisbile();
   onWindowMessage();
@@ -1015,13 +1017,15 @@ function init(initParams) {
       // 判断推特id,绑定逻辑
       state.srcContentId = res.data.srcContentId
 
-      if(!res.data.srcContentId) {
-        if(type == 'reSetBindTwtterId') {
+      if (!res.data.srcContentId) {
+        if (type == 'reSetBindTwtterId') {
           // 显示提示
-          window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_SHOW_BIND_TWEET_NOTICE",  data: {
-            postId: state.postId,
-            taskLuckdropId: JSON.parse(res.data.postBizData).taskLuckdropId
-          }}, "*");
+          window.parent.postMessage({
+            actionType: "IFRAME_RED_PACKET_SHOW_BIND_TWEET_NOTICE", data: {
+              postId: state.postId,
+              taskLuckdropId: JSON.parse(res.data.postBizData).taskLuckdropId
+            }
+          }, "*");
         }
       }
 
@@ -1070,8 +1074,8 @@ function initTaskDetail() {
                 break;
               case 9:
                 state.done.reply = res.data[i].finished;
-                if(!state.done.reply) {
-                  onTweetReplyClick({type: 9});
+                if (!state.done.reply) {
+                  onTweetReplyClick({ type: 9 });
                 }
                 break;
             }
@@ -1172,20 +1176,24 @@ onMounted(() => {
 })
 
 function getTweetAuthor() {
-  if(state.window_origin.indexOf('twitter.com') > -1) {
-    window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_GET_TWEET_AUTHOR",  data: {
-      postId: state.postId,
-      taskLuckdropId: state.detail.taskLuckdropId
-    }}, "*");
+  if (state.window_origin.indexOf('twitter.com') > -1) {
+    window.parent.postMessage({
+      actionType: "IFRAME_RED_PACKET_GET_TWEET_AUTHOR", data: {
+        postId: state.postId,
+        taskLuckdropId: state.detail.taskLuckdropId
+      }
+    }, "*");
   }
 }
 
 function checkFacebookReply() {
   console.log('checkFacebookReply')
-  if(state.window_origin.indexOf('twitter.com') > -1) {
-    window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_CHECK_FACEBOOK_REPLY",  data: {
-      postId: state.postId
-    }}, "*");
+  if (state.window_origin.indexOf('twitter.com') > -1) {
+    window.parent.postMessage({
+      actionType: "IFRAME_RED_PACKET_CHECK_FACEBOOK_REPLY", data: {
+        postId: state.postId
+      }
+    }, "*");
   }
 }
 
@@ -1526,20 +1534,20 @@ function handleErrorCode(res) {
 // }
 function onWindowMessage() {
   window.addEventListener("message", function (event) {
-      if (event.data) {
-        switch(event.data.actionType) {
-          case 'CONTENT_RED_PACKET_REPLY_RASK_FINSH':
-            state.done.reply = true;
-            state.done.reply_red = false;
-            break;
-          case 'CONTENT_RED_PACKET_GET_TWEET_AUTHOR':
-            fullName = event.data.data.fullName
-            break;
-          case 'CONTENT_RED_PACKET_FACEBOOK_REPLY':
-            clickReply(event.data.data)
-            break;
-        }
+    if (event.data) {
+      switch (event.data.actionType) {
+        case 'CONTENT_RED_PACKET_REPLY_RASK_FINSH':
+          state.done.reply = true;
+          state.done.reply_red = false;
+          break;
+        case 'CONTENT_RED_PACKET_GET_TWEET_AUTHOR':
+          fullName = event.data.data.fullName
+          break;
+        case 'CONTENT_RED_PACKET_FACEBOOK_REPLY':
+          clickReply(event.data.data)
+          break;
       }
+    }
   });
 }