This commit is contained in:
2024-03-20 14:44:01 +08:00
parent 81758accdc
commit 5d6abb0219
7 changed files with 227 additions and 176 deletions

View File

@@ -66,7 +66,7 @@
}
function getPhoneNumber (e) {
// tel_code.value = e.detail.code
console.log(e)
// console.log(e)
getAccess_token({code:e.detail.code})
// console.log(e.detail.code) // 动态令牌
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
@@ -74,7 +74,7 @@
}
async function getAccess_token(params={}){//获取token 获取手机号
//清除token缓存
// wx.clearStorageSync();
wx.clearStorageSync();
//访问接口
const data={
username:params.code,//手机号按钮获取的code
@@ -94,7 +94,7 @@
provider: 'weixin', //使用微信登录
success: function (loginRes) {
resolve(loginRes);
console.log(loginRes,'微信登录返回信息');
// console.log(loginRes,'微信登录返回信息');
}
});
});
@@ -103,7 +103,8 @@
let res2=await api.wx_login({code:res_p.code},userId);
if(res2.code === 0) {
store.checkLogin()
toLogin(encodeURIComponent(JSON.stringify(res.data)))
// toLogin(encodeURIComponent(JSON.stringify(res.data)))
store.toProfile(encodeURIComponent(JSON.stringify(res.data)))
}
}
else{

View File

@@ -8,32 +8,26 @@
import api from "@/api/index.js"
import custom from "@/utils/index.js"
const h_index = ref(0)
onLoad(async () => {
onLoad(async (e) => {
await getHospitalList()
// console.log(useStore.userInfo)
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
h_info.value = userinfo.value
h_info.value.surgery_time = h_info.value.SurgeryTime
// console.log("userinfo is :",userinfo.value)
userinfo.value.avatar = uni.getStorageSync('avatarUrl')
h_index.value = hospitals.value.findIndex((item,i) => {
return item.ID == userinfo.value.HospitalId
})
if(userinfo.value.HospitalId) {
getHospital(userinfo.value.HospitalId)
is_login.value = custom.checkLogin()
if(!is_login.value) { // 未登录
userinfo.value = JSON.parse(decodeURIComponent(e.token_info))
} else { // 已登录
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
h_info.value = userinfo.value
h_info.value.surgery_time = h_info.value.SurgeryTime
userinfo.value.avatar = uni.getStorageSync('avatarUrl')
h_index.value = hospitals.value.findIndex((item,i) => {
return item.ID == userinfo.value.HospitalId
})
if(userinfo.value.HospitalId) {
getHospital(userinfo.value.HospitalId)
}
}
// if(uni.getStorageSync('operation_info')) {
// h_info.value = JSON.parse(uni.getStorageSync('operation_info'))
// if(h_info.value) {
// h_index.value = hospitals.value.findIndex((item,i) => {
// return item.ID == h_info.value.hospitalId
// })
// getHospital(h_info.value.hospitalId)
// }
// }
})
// 变量
const is_login = ref(false)
const h_queryParams = ref({
page:1,
pageSize:1000,
@@ -57,7 +51,6 @@
}
}
function onInputH() {
console.log(hValue.value)
h_queryParams.value.key = hValue.value
getHospitalList()
@@ -117,19 +110,16 @@
return `${year}-${month}-${day}`;
}
function bindDateChange(e) {
console.log(e)
// console.log(e)
h_info.value.surgery_time = e.detail.value
}
function toChooseH(item) {
console.log(item)
// console.log(item)
choosed_h.value = item
hValue.value = item.name
// hospitals.value = null
}
async function sumbmitFunc() {
// console.log(h_index.value)
// console.log(hospitals.value)
// console.log(hospitals.value[h_index.value])
await custom.uploadImage(userinfo.value.avatar, async (file) => {
userinfo.value.avatar = file.data.file.url
})
@@ -140,7 +130,6 @@
nickname: userinfo.value.nickname,
avatar: userinfo.value.avatar,
phone: userinfo.value.phone,
// hospitalId:choosed_h.value?.ID
hospitalId:hospitals.value[h_index.value]?.ID
}
if(!obj.hospitalId) {
@@ -152,8 +141,10 @@
return
}
obj.isSurgery = parseInt(userinfo.value.IsSurgery)
const res = await api.userinfoUpdae(obj)
// console.log('res is ',res)
// if(!is_login.value) { // 新用户 - 先登录
// }
const res = await api.userinfoUpdae(obj) // 更新用户信息
if(res.code === 0) {
uni.showToast({
title:res.msg,
@@ -179,7 +170,6 @@
provider: 'weixin', //使用微信登录
success: function (loginRes) {
resolve(loginRes);
console.log(loginRes,'微信登录返回信息');
}
});
});
@@ -187,7 +177,6 @@
if(res2.code === 0) {
userinfo.value.HospitalId = hospitals.value[h_index.value].ID
h_info.value.hospitalId = userinfo.value.HospitalId
// console.log("h_info.value is:", h_info.value)
uni.setStorageSync('avatarUrl', userinfo.value.avatar);//avatarUrl
uni.setStorageSync('userInfo',JSON.stringify(userinfo.value))
uni.setStorageSync('operation_info', JSON.stringify(h_info.value))
@@ -199,7 +188,7 @@
}
}
function bindPickerChange(e) {
console.log(hospitals.value )
// console.log(hospitals.value )
h_index.value = e.detail.value
}
function onChooseAvatar(e) {
@@ -219,7 +208,7 @@
])
function bindOperationPickerChange(e) {
userinfo.value.IsSurgery = e.detail.value
console.log("userinfo.value.IsSurgery is :",userinfo.value.IsSurgery)
// console.log("userinfo.value.IsSurgery is :",userinfo.value.IsSurgery)
}
</script>
<template>