tanyanfei 5 bulan lalu
induk
melakukan
767b5886c3
5 mengubah file dengan 50 tambahan dan 39 penghapusan
  1. 12 4
      src/App.vue
  2. 3 0
      src/api.js
  3. 27 32
      src/components/Index.vue
  4. 6 2
      src/components/PatBleedCount.vue
  5. 2 1
      src/components/PatGjBleedCount.vue

+ 12 - 4
src/App.vue

@@ -1,5 +1,6 @@
 <template>
   <div id="app">
+    <!-- <div><img  v-if='show' src="./assets/images/bg.jpg"   style="position: absolute;left: 0;top: 0;z-index: 999;" width="100%" /></div> -->
     <router-view />
   </div>
 </template>
@@ -10,7 +11,8 @@
     name: 'App',
     data() {
       return {
-        doctorInfo: {}
+        doctorInfo: {},
+        show:0
       }
     },
     methods: {
@@ -24,15 +26,21 @@
               this.goPage("/docindex")
             }else{
               this.goPage("/patindex")
-            }
+            } 
             localStorage.setItem("authinfo",JSON.stringify(res.data.data))
           }
         })
       }
     },
     created() {
-      
-      this.getData()
+
+      var tag=this.$route.query.tag
+      if(tag){
+        localStorage.setItem('tag',tag)
+      }
+      if(localStorage.getItem('authinfo')){
+        this.getData()
+      }
     }
   }
 

+ 3 - 0
src/api.js

@@ -63,6 +63,9 @@ export default {
   getInfo: params => {
     return axios.get(`${baseURL}/api/account/doctor/userinfo`, { params: params })
   },
+  getOpenid: params => {
+    return axios.get(`${baseURL}/api/account/wxmp/openid`, { params: params })
+  },
   // 病人注册
   regPatient: params => {
     return axios.post(`${baseURL}/api/doctor/patient/register`, params)

+ 27 - 32
src/components/Index.vue

@@ -1,9 +1,9 @@
 <template>
   <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="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>
 
     <img v-if='show' style="position: absolute;left: 0;top: 0;z-index: 999;" width="100%" src="../assets/images/bg.jpg" alt="">
@@ -24,10 +24,12 @@
     },
     methods: {
       goPage(path) {
+        if(localStorage.getItem('openid') && localStorage.getItem('tag')){
+           this.$router.push(path)
+           return
+        }
         var id=this.id
-
-        var url=encodeURIComponent(`http://bax.nalgin.com?path=${path}`)
-        // var url=encodeURIComponent(`http://xjctest.baianxi.com/?path=${path}&tag=${tag}`)
+        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`
 
         // this.$router.push(path)
@@ -37,15 +39,12 @@
         window.localStorage.removeItem('authinfo')
         window.location.reload()
       },
-  
-      getTag(openid,role){
+
+      getTag(openid){
         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")
-                 }
+              this.show=0
+              localStorage.setItem('tag',res.data.data.tag)
             }else{
               this.show=1
             }
@@ -53,29 +52,25 @@
       }
     },
     created(){
-      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)
+      //1.有openid 判断是否有返回tag
       if(localStorage.getItem('openid')){
-        var role=localStorage.getItem('role')
-        this.getTag(localStorage.getItem('openid'),role)
+        this.getTag(localStorage.getItem('openid'))
+        return
+      }
+      //2.没有openid 没有tag直接显示图片
+      if(!localStorage.getItem('tag')){
+        this.show=1
         return
       }
+      //3.授权回来获取openid
+      var code=this.$route.query.code
       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)
-              }
-              
-        });
-
+        this.$api.getOpenid({code:code}).then(res=>{
+          if(res.data.data.data.openid){
+            localStorage.setItem('openid',res.data.data.data.openid)
+            this.getTag(res.data.data.data.openid)
+          }
+        })
       }
 
     },

+ 6 - 2
src/components/PatBleedCount.vue

@@ -96,12 +96,15 @@
                        itemWidth:5,
                        itemHeight:5,
                        textStyle:{
-                         fontSize:10
+                         fontSize:14
                        }
                     },
                     xAxis: {
                       type: 'category',
-                      data: ['总出血次数', '关节出血', '其他部位出现']
+                      data: ['总出血次数', '关节出血', '其他部位出现'],
+                      axisLabel:{
+                            fontSize:14
+                      }
                     },
                     yAxis: {
                       type: 'value',
@@ -119,6 +122,7 @@
                         barWidth:30,
                         label:{
                           show:true,
+                          fontSize:14,
                           position:'inside',
                           formatter: function (value, index) {//隐藏 0
                             return value.data?value.data:'';

+ 2 - 1
src/components/PatGjBleedCount.vue

@@ -99,7 +99,7 @@
                        itemWidth:5,
                        itemHeight:5,
                        textStyle:{
-                         fontSize:10
+                         fontSize:14
                        }
                     },
                     grid:{
@@ -129,6 +129,7 @@
                         stack: '1',
                         label:{
                           show:true,
+                          fontSize:14,
                           position:'inside',
                           formatter: function (value, index) {//隐藏 0
                             return value.data?value.data:'';