tanyanfei 5 months ago
parent
commit
f432b27f7b
6 changed files with 90 additions and 27 deletions
  1. 12 10
      src/App.vue
  2. 4 1
      src/api.js
  3. BIN
      src/assets/images/bg.jpg
  4. 7 3
      src/components/DocLogin.vue
  5. 63 13
      src/components/Index.vue
  6. 4 0
      src/components/PatRegister.vue

+ 12 - 10
src/App.vue

@@ -5,6 +5,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
+
   export default {
   export default {
     name: 'App',
     name: 'App',
     data() {
     data() {
@@ -17,19 +18,20 @@
         this.$router.push(path)
         this.$router.push(path)
       },
       },
       getData() {
       getData() {
-        // this.$api.getAccountInfo().then(res=>{
-        //   if(!res.data.code){
-        //     if(res.data.data.role=="1"){
-        //       this.goPage("/docindex")
-        //     }else{
-        //       this.goPage("/patindex")
-        //     }
-        //     localStorage.setItem("authinfo",JSON.stringify(res.data.data))
-        //   }
-        // })
+        this.$api.getAccountInfo().then(res=>{
+          if(res.data.code == 0){
+            if(res.data.data.role=="1"){
+              this.goPage("/docindex")
+            }else{
+              this.goPage("/patindex")
+            }
+            localStorage.setItem("authinfo",JSON.stringify(res.data.data))
+          }
+        })
       }
       }
     },
     },
     created() {
     created() {
+      
       this.getData()
       this.getData()
     }
     }
   }
   }

+ 4 - 1
src/api.js

@@ -1,6 +1,6 @@
 import axios from 'axios';
 import axios from 'axios';
 // var baseURL='http://118.190.145.217:8077'
 // var baseURL='http://118.190.145.217:8077'
-var baseURL='http://nj.scxjc.club'
+var baseURL='http://bax.nalgin.com'
 // var baseURL = '/'
 // var baseURL = '/'
 axios.interceptors.request.use(
 axios.interceptors.request.use(
   config => {
   config => {
@@ -60,6 +60,9 @@ export default {
   getAccountInfo: params => {
   getAccountInfo: params => {
     return axios.get(`${baseURL}/api/account/doctor/authinfo`)
     return axios.get(`${baseURL}/api/account/doctor/authinfo`)
   },
   },
+  getInfo: params => {
+    return axios.get(`${baseURL}/api/account/doctor/userinfo`, { params: params })
+  },
   // 病人注册
   // 病人注册
   regPatient: params => {
   regPatient: params => {
     return axios.post(`${baseURL}/api/doctor/patient/register`, params)
     return axios.post(`${baseURL}/api/doctor/patient/register`, params)

BIN
src/assets/images/bg.jpg


+ 7 - 3
src/components/DocLogin.vue

@@ -163,10 +163,14 @@
       }
       }
     },
     },
     created() {
     created() {
-      this.$api.getUserAgreementInfo({id:1}).then(res=>{
-        this.agreementInfo = res.data.data
-      })
+      // this.$api.getUserAgreementInfo({id:1}).then(res=>{
+      //   this.agreementInfo = res.data.data
+      // })
       var info=localStorage.getItem('doc_login_info')
       var info=localStorage.getItem('doc_login_info')
+      var tag=localStorage.getItem('tag')
+      var openid=localStorage.getItem('openid')
+      this.form.openid=openid?openid:''
+      this.form.tag=tag?tag:''
       if(info){
       if(info){
         info=JSON.parse(info)
         info=JSON.parse(info)
         this.form={
         this.form={

+ 63 - 13
src/components/Index.vue

@@ -2,44 +2,94 @@
   <div class="container">
   <div class="container">
     <img src="../assets/images/entrybg.jpg" alt="" width="100%" style="margin-top:4rem;">
     <img src="../assets/images/entrybg.jpg" alt="" width="100%" style="margin-top:4rem;">
     <div class="content">
     <div class="content">
-      <div class="csbtn" @click="goPage('/doclogin')" style="margin-top:0px;">医生端</div>
-      <div class="jbbtn" @click="goPage('/patregister')">个人端</div>
+      <div class="csbtn" @click="goPage('doclogin')" style="margin-top:0px;">医生端</div>
+      <div class="jbbtn" @click="goPage('patregister')">个人端</div>
     </div>
     </div>
+
+    <img v-if='show' style="position: absolute;left: 0;top: 0;z-index: 999;" width="100%" src="../assets/images/bg.jpg" alt="">
   </div>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
+  import axios from 'axios';
   export default {
   export default {
     name: 'Index',
     name: 'Index',
     data() {
     data() {
       return {
       return {
-        msg: 'Welcome to Your Vue.js App'
+        msg: 'Welcome to Your Vue.js App',
+        id:'wx84a42c807ed07198',
+        secret:'98cae7590d120457e861c4aa7169216c',
+        show:0
       }
       }
     },
     },
     methods: {
     methods: {
       goPage(path) {
       goPage(path) {
-        this.$router.push(path)
+        var id=this.id
+
+        var url=encodeURIComponent(`http://bax.nalgin.com?path=${path}`)
+        // var url=encodeURIComponent(`http://xjctest.baianxi.com/?path=${path}&tag=${tag}`)
+        window.location.href=`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${id}&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo#wechat_redirect`
+
+        // this.$router.push(path)
       },
       },
       logout(){
       logout(){
         window.localStorage.removeItem('token')
         window.localStorage.removeItem('token')
         window.localStorage.removeItem('authinfo')
         window.localStorage.removeItem('authinfo')
         window.location.reload()
         window.location.reload()
       },
       },
-      getData(){
-        this.$api.getAccountInfo().then(res=>{
-          if(!res.data.code){
-            if(res.data.data.role=="1"){
-              this.goPage("/docindex")
+  
+      getTag(openid,role){
+        this.$api.getInfo({openid:openid,role:role}).then(res=>{
+            if(res.data.data.tag){
+                 if(role=="1"){
+                   this.$router.push("/doclogin")
+                 }else{
+                   this.$router.push("/patregister")
+                 }
             }else{
             }else{
-              this.goPage("/patindex")
+              this.show=1
             }
             }
-            localStorage.setItem("authinfo",JSON.stringify(res.data.data))
-          }
         })
         })
       }
       }
     },
     },
     created(){
     created(){
-      this.getData()
+      var code=this.$route.query.code,tag=this.$route.query.tag,
+          path=this.$route.query.path
+          localStorage.setItem('tag',tag)
+          
+          localStorage.setItem('role',path=='doclogin'?1:2)
+      if(localStorage.getItem('openid')){
+        var role=localStorage.getItem('role')
+        this.getTag(localStorage.getItem('openid'),role)
+        return
+      }
+      if(code){
+        var id=this.id
+        var secret=this.secret
+        var that=this
+        axios.get(`https://api.weixin.qq.com/sns/oauth2/access_token?appid=${id}&secret=${secret}&code=${code}&grant_type=authorization_code`).then(res => {
+              if(res.data.openid){
+                localStorage.setItem('openid',res.data.openid)
+                var role= path=='doclogin'?1:2
+                this.getTag(res.data.openid,role)
+              }
+              
+        });
+
+      }
+
+    },
+    beforeRouteEnter(to,from,next){
+      next(vm =>{
+         var href = window.location.href;
+         if(href.includes("code=") && href.includes("=#/")){
+           // 授权回来
+           let url=window.location.href.replace('#/','').replace('?','#/?')
+           window.location.href=url
+         }else{
+           next()
+         }
+      })
     }
     }
   }
   }
 
 

+ 4 - 0
src/components/PatRegister.vue

@@ -167,6 +167,10 @@
         this.agreementInfo = res.data.data
         this.agreementInfo = res.data.data
       })
       })
       var info=localStorage.getItem('login_info')
       var info=localStorage.getItem('login_info')
+      var tag=localStorage.getItem('tag')
+      var openid=localStorage.getItem('openid')
+      this.form.openid=openid?openid:''
+      this.form.tag=tag?tag:''
       if(info){
       if(info){
         info=JSON.parse(info)
         info=JSON.parse(info)
         this.form={
         this.form={