Преглед на файлове

修改公众号分享页自定义分享内容测试

xiebaomin преди 2 години
родител
ревизия
8c0ae2eb59
променени са 5 файла, в които са добавени 90 реда и са изтрити 1 реда
  1. 22 0
      pages/_template/app/index.vue
  2. 22 0
      pages/_template/hyt/index.vue
  3. 23 0
      pages/_template/ldm/index.vue
  4. 22 0
      pages/_template/ph/index.vue
  5. 1 1
      pages/_template/ross/index.vue

+ 22 - 0
pages/_template/app/index.vue

@@ -161,6 +161,7 @@ export default {
     }
   },
   mounted() {
+    this.initAppMessageShareData() // 公众号分享授权页面
     window.addEventListener('scroll', () => {
       this.scrollTop = document.documentElement.scrollTop
     })
@@ -222,6 +223,27 @@ export default {
         this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
       }
     },
+
+    // 分享当前页面
+    initAppMessageShareData() {
+      console.log(window.location.href, window.location.origin)
+      //  重试次数
+      let retryCount = 1
+      this.$wxReady((wx) => {
+        //需在用户可能点击分享按钮前就先调用
+        wx.updateAppMessageShareData({
+          title: '官方正品授权查询', // 分享标题
+          desc: '官方正品授权', // 分享描述
+          link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
+          imgUrl: this.banner.headAppBanner, // 分享图标
+          fail: () => {
+            if (retryCount === 0) return
+            this.initAppMessageShareData()
+            retryCount--
+          },
+        })
+      })
+    },
   },
 }
 </script>

+ 22 - 0
pages/_template/hyt/index.vue

@@ -158,6 +158,7 @@ export default {
     }
   },
   mounted() {
+    this.initAppMessageShareData() // 公众号分享授权页面
     window.addEventListener('scroll', () => {
       this.scrollTop = document.documentElement.scrollTop
     })
@@ -222,6 +223,27 @@ export default {
         this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
       }
     },
+
+    // 分享当前页面
+    initAppMessageShareData() {
+      console.log(window.location.href, window.location.origin)
+      //  重试次数
+      let retryCount = 1
+      this.$wxReady((wx) => {
+        //需在用户可能点击分享按钮前就先调用
+        wx.updateAppMessageShareData({
+          title: '官方正品授权查询', // 分享标题
+          desc: '官方正品授权', // 分享描述
+          link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
+          imgUrl: this.banner.headAppBanner, // 分享图标
+          fail: () => {
+            if (retryCount === 0) return
+            this.initAppMessageShareData()
+            retryCount--
+          },
+        })
+      })
+    },
   },
 }
 </script>

+ 23 - 0
pages/_template/ldm/index.vue

@@ -87,6 +87,7 @@ export default {
     ...mapGetters(['authUserId', 'appId', 'routePrefix', 'accountType']),
   },
   mounted() {
+    this.initAppMessageShareData() // 公众号分享授权页面
     window.addEventListener('scroll', () => {
       this.scrollTop = document.documentElement.scrollTop
     })
@@ -153,6 +154,28 @@ export default {
         this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
       }
     },
+
+
+    // 分享当前页面
+    initAppMessageShareData() {
+      console.log(window.location.href, window.location.origin)
+      //  重试次数
+      let retryCount = 1
+      this.$wxReady((wx) => {
+        //需在用户可能点击分享按钮前就先调用
+        wx.updateAppMessageShareData({
+          title: '官方正品授权查询', // 分享标题
+          desc: '官方正品授权', // 分享描述
+          link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
+          imgUrl: this.banner.headAppBanner, // 分享图标
+          fail: () => {
+            if (retryCount === 0) return
+            this.initAppMessageShareData()
+            retryCount--
+          },
+        })
+      })
+    },
   },
 }
 </script>

+ 22 - 0
pages/_template/ph/index.vue

@@ -71,6 +71,7 @@ export default {
     document.title = '官方正品授权查询'
   },
   mounted() {
+    this.initAppMessageShareData() // 公众号分享授权页面
     window.addEventListener('scroll', () => {
       this.scrollTop = document.documentElement.scrollTop
     })
@@ -178,6 +179,27 @@ export default {
         this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
       }
     },
+
+    // 分享当前页面
+    initAppMessageShareData() {
+      console.log(window.location.href, window.location.origin)
+      //  重试次数
+      let retryCount = 1
+      this.$wxReady((wx) => {
+        //需在用户可能点击分享按钮前就先调用
+        wx.updateAppMessageShareData({
+          title: '官方正品授权查询', // 分享标题
+          desc: '官方正品授权', // 分享描述
+          link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
+          imgUrl: this.banner.headAppBanner, // 分享图标
+          fail: () => {
+            if (retryCount === 0) return
+            this.initAppMessageShareData()
+            retryCount--
+          },
+        })
+      })
+    },
   },
 }
 </script>

+ 1 - 1
pages/_template/ross/index.vue

@@ -214,7 +214,7 @@ export default {
           title: '官方正品授权查询', // 分享标题
           desc: '官方正品授权', // 分享描述
           link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
-          imgUrl: window.location.origin + '/activity.png', // 分享图标
+          imgUrl: this.banner.headAppBanner, // 分享图标
           fail: () => {
             if (retryCount === 0) return
             this.initAppMessageShareData()