Prechádzať zdrojové kódy

cps:微信内二次分享

panyong 3 rokov pred
rodič
commit
212921e253
1 zmenil súbory, kde vykonal 15 pridanie a 0 odobranie
  1. 15 0
      htmldev/cps/src/main.js

+ 15 - 0
htmldev/cps/src/main.js

@@ -31,5 +31,20 @@ new Vue({
   created () {
     // 保存整站vuex本地储存初始状态
     window.SITE_CONFIG.storeState = cloneDeep(store.state)
+    this.reloadInWX()
+  },
+  methods: {
+    /**
+     * 处理微信内二次分享
+     */
+    reloadInWX () {
+      let href = decodeURIComponent(window.location.href)
+      // 微信环境二次分享
+      if (href.indexOf('groupmessage') > -1 || href.indexOf('singlemessage') > -1 || href.indexOf('timeline') > -1 || href.indexOf('isappinstalled') > -1) {
+        href = href.replace(/from=(groupmessage|singlemessage|timeline|isappinstalled)(\S*)/, '')
+        location.replace(href)
+        location.reload(true)
+      }
+    }
   }
 }).$mount('#app')