Browse Source

[add][绑定推文id]

zhangwei 2 years ago
parent
commit
3913000c16
2 changed files with 31 additions and 0 deletions
  1. 24 0
      src/http/help.js
  2. 7 0
      src/view/iframe/tool-box/card.vue

+ 24 - 0
src/http/help.js

@@ -0,0 +1,24 @@
+import { getChromeStorage } from '@/uilts/chromeExtension.js'
+import { srcPublishSuccess } from '@/http/publishApi'
+
+// 重新绑定推文id
+export const reSetBindTwtterId = ({
+    postId = '',
+    tweetId = ''
+}, callback) => {
+    getChromeStorage('userInfo', (_userInfo = {}) => {
+        // if (_userInfo && _userInfo.uid == _params.uid) {
+        if (_userInfo.uid) {
+            srcPublishSuccess({
+                params: {
+                    postId,
+                    srcContentId: tweetId
+                }
+            }).then((res) => {
+                if (res.code == 0 || res.code == 3003) {
+                    callback && callback()
+                }
+            })
+        }
+    })
+}

+ 7 - 0
src/view/iframe/tool-box/card.vue

@@ -66,6 +66,7 @@ import { getChromeStorage, setChromeStorage, defineProps, sendChromeTabMessage }
 import { getPostDetail } from '@/http/redPacket.js'
 import { guid, getQueryString } from "@/uilts/help";
 import { onMounted, reactive, ref } from "vue";
+import { reSetBindTwtterId } from '@/http/help.js'
 let dom_iframe = ref(null)
 let state = reactive({
     status: '', //
@@ -160,6 +161,12 @@ const getDetail = () => {
     }).then((res) => {
         if (res && res.code == 0) {
             state.detail = JSON.parse(res.data.postBizData)
+            if (!res.data.srcContentId) {
+                reSetBindTwtterId({
+                    postId: state.postId,
+                    tweetId: state.tweetId
+                })
+            }
             console.log('postBizData', state.detail)
             // 加载iframe
             if (state.detail.viewBgImagePath) {