|
@@ -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()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|