فهرست منبع

fix: 阳光采购分享

cuiyalong 8 ماه پیش
والد
کامیت
702cd6efd4
2فایلهای تغییر یافته به همراه27 افزوده شده و 12 حذف شده
  1. 18 11
      apps/mobile/src/utils/mixins/modules/app-wx-share.js
  2. 9 1
      apps/mobile/src/views/article/content.vue

+ 18 - 11
apps/mobile/src/utils/mixins/modules/app-wx-share.js

@@ -28,7 +28,10 @@ export const appWxShareMixin = {
         wx: ''
       },
       shareEnableConf: {
+        // 是否进入页面立即初始化分享流程
         shareActionImmediate: true,
+        // 是否进入页面立即获取配置域名
+        getDomainImmediate: false,
         app: true, // 开启app分享
         wx: true // 开启wx分享
       },
@@ -46,6 +49,8 @@ export const appWxShareMixin = {
     console.log('app-wx-share')
     if (this.shareEnableConf.shareActionImmediate) {
       this.initShareMixin()
+    } else if (this.shareEnableConf.getDomainImmediate) {
+      this.getShareDomain()
     }
   },
   methods: {
@@ -55,7 +60,7 @@ export const appWxShareMixin = {
       } else {
         if (this.shareEnableConf.app) {
           if (this.shareConf.fetchDomain) {
-            this.getShareDomain()
+            this.getShareDomain(true)
           } else {
             this.refreshShareLink()
             this.registerWxShare()
@@ -63,22 +68,24 @@ export const appWxShareMixin = {
         }
       }
     },
-    refreshShareLink() {
+    refreshShareLink(origin) {
       if (!this.shareConf.pathname) return
-      this.shareConf.link = this.shareConf.origin + this.shareConf.pathname
+      const originLink = origin || this.shareConf.origin
+      this.shareConf.link = originLink + this.shareConf.pathname
     },
-    async getShareDomain() {
+    async getShareDomain(init = false) {
       const { data, error_code: code, error_msg: msg } = await getAppsDomain()
-      console.log(msg)
       if (code === 0 && data) {
         // app往微信分享会用到(app分享到微信,需要分享微信的域名)
         Object.assign(this.domainConf, data)
-        if (data.wx) {
-          this.shareConf.origin = data.wx
-          this.refreshShareLink()
-        }
-        if (this.isWeiXinBrowser) {
-          this.registerWxShare()
+        if (init) {
+          if (data.wx) {
+            this.shareConf.origin = data.wx
+            this.refreshShareLink()
+          }
+          if (this.isWeiXinBrowser) {
+            this.registerWxShare()
+          }
         }
       }
     },

+ 9 - 1
apps/mobile/src/views/article/content.vue

@@ -239,6 +239,7 @@ export default {
     OneClickBinding
   },
   data() {
+    const { inApp } = this.$envs
     return {
       pageLayoutConf: {
         actionRightStyle: {
@@ -252,6 +253,7 @@ export default {
       },
       shareEnableConf: {
         shareActionImmediate: false,
+        getDomainImmediate: inApp,
         app: true, // 开启app分享
         wx: true // 开启wx分享
       },
@@ -728,6 +730,8 @@ export default {
       contentList.push('向您推荐了剑鱼标讯')
       const content = contentList.join('')
 
+      const shareToWx = shareType === 1 || shareType === 3
+
       let link = `/swordfish/about?source=app_infocontentshare&from=${
         this.shareInfoRes.userId || ''
       }`
@@ -756,7 +760,11 @@ export default {
       this.shareConf.content = content
       this.shareConf.pathname = link
       // this.shareConf.link = link
-      this.refreshShareLink()
+      if (this.$envs.inApp && shareToWx) {
+        this.refreshShareLink(this.domainConf.wx)
+      } else {
+        this.refreshShareLink()
+      }
     },
     onScroll: throttle(function (e) {
       this.checkNpsView()