From 67d71d2b5d5445e2532b16d2b7bc84b3b96fb938 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期四, 20 十月 2022 16:00:50 +0800
Subject: [PATCH] 34
---
src/stores/userInfo.ts | 4 ++--
src/views/login/index.vue | 19 +++++++++++++++----
src/utils/axios.ts | 1 -
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/stores/userInfo.ts b/src/stores/userInfo.ts
index 1e043bc..a40a6f6 100644
--- a/src/stores/userInfo.ts
+++ b/src/stores/userInfo.ts
@@ -8,8 +8,8 @@
headimgurl:'',
nickname:''
})
- function setUserInfo(userInfo:{openud:string, headimgurl:string,nickname:string}) {
- info.value.openid=userInfo.openud
+ function setUserInfo(userInfo:{openid:string, headimgurl:string,nickname:string}) {
+ info.value.openid=userInfo.openid
info.value.headimgurl=userInfo.headimgurl
info.value.nickname=userInfo.nickname
}
diff --git a/src/utils/axios.ts b/src/utils/axios.ts
index 18bf3ed..fd34165 100644
--- a/src/utils/axios.ts
+++ b/src/utils/axios.ts
@@ -69,7 +69,6 @@
instance.interceptors.response.use(
(response: AxiosResponse) => {
const { data, status } = response
- console.log('返回结果',data)
const { message } = data
// 请求正常时,仅返回需要用到的 data 信息即可
if (message==='SUCCESS') return data.data
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 19823e3..e1b5a1d 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -1,13 +1,14 @@
<script lang="ts" setup>
- import { Dialog } from 'vant'
import { ref,onMounted } from 'vue'
import {useRoute,useRouter} from 'vue-router'
import { ajaxGet } from '@/utils/axios'
// import { Session } from '@/utils/storage'
- import { Toast } from 'vant'
+ import { Dialog } from 'vant'
+ import { userInfoStore } from '@/stores/userInfo'
import logo from 'assets/logo.png'
import shoujiLogin from 'assets/yijianLogin.png'
import pswdLogin from 'assets/pswdLogin.png'
+ const userInfo = userInfoStore()
const route = useRoute()
const router=useRouter()
const username = ref('')
@@ -97,6 +98,14 @@
if (code){
ajaxGet('wechat/code',{code}).then((re:any)=>{
console.log(re)
+ userInfo.setUserInfo({openid:re.openid,nickname:re.nickname,headimgurl:re.headimgurl})
+ const openid = re.openid
+ if (openid) {
+ ajaxGet('patient/info/wechatLogin',{openid}).then((re:any)=>{
+ console.log('openid换的accesstoken=',re)
+ })
+ }
+
})
}
else {
@@ -112,9 +121,11 @@
}
} else {
console.log('不是微信浏览器')
- Toast({
+ Dialog.alert({
+ title: '提示',
message: '请在微信中打开浏览',
- position: 'top',
+ }).then(() => {
+ // on close
})
}
})
--
Gitblit v1.8.0