Browse Source

公众号首次进入限制功能完成

Your Name 1 year ago
parent
commit
1f78e3ce2c
1 changed files with 11 additions and 5 deletions
  1. 11 5
      src/components/Index.vue

+ 11 - 5
src/components/Index.vue

@@ -17,8 +17,8 @@
     data() {
       return {
         msg: 'Welcome to Your Vue.js App',
-        id:'wx84a42c807ed07198',
-        secret:'98cae7590d120457e861c4aa7169216c',
+        id:'wx3b167701e24d1ae9',
+        secret:'f446c97149a01c407e7e78be6e351fce',
         show:0
       }
     },
@@ -30,7 +30,7 @@
         }
         var id=this.id
         var url=encodeURIComponent(`http://bax.nalgin.com`)
-        window.location.href=`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${id}&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo#wechat_redirect`
+        window.location.href=`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${id}&redirect_uri=${url}&response_type=code&scope=snsapi_base#wechat_redirect`
 
         // this.$router.push(path)
       },
@@ -41,10 +41,16 @@
       },
 
       getTag(openid){
+        let that = this;
         this.$api.getInfo({openid:openid}).then(res=>{
             if(res.data.data.tag){
               this.show=0
               localStorage.setItem('tag',res.data.data.tag)
+            }else if(that.$route.query.tag){
+              this.show=0
+              localStorage.setItem('tag',that.$route.query.tag)
+            }else if(localStorage.getItem("tag")){
+              this.show=0
             }else{
               this.show=1
             }
@@ -53,12 +59,12 @@
     },
     created(){
       //1.有openid 判断是否有返回tag
-      if(localStorage.getItem('openid')){
+      if(localStorage.getItem('openid') && !localStorage.getItem("tag")){
         this.getTag(localStorage.getItem('openid'))
         return
       }
       //2.没有openid 没有tag直接显示图片
-      if(!localStorage.getItem('tag')){
+      if(!localStorage.getItem('tag') && !this.$route.query.tag){
         this.show=1
         return
       }