fix bug
This commit is contained in:
parent
81758accdc
commit
5d6abb0219
@ -1,6 +1,6 @@
|
|||||||
// isdev 为 true 表示开发环境 false 表示发布环境
|
// isdev 为 true 表示开发环境 false 表示发布环境
|
||||||
const isdev = false;
|
const isdev = false;
|
||||||
const baseUrl = isdev ? 'https://4571de69.r29.cpolar.top' : 'https://api.jimingyiliao.com';// 办公室接口 & 测试环境
|
const baseUrl = isdev ? 'http://318ca56c.r28.cpolar.top' : 'https://api.jimingyiliao.com';// 办公室接口 & 测试环境
|
||||||
// const baseUrl = isdev ? 'https://api.jimingyiliao.com' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
|
// const baseUrl = isdev ? 'https://api.jimingyiliao.com' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
|
||||||
// const baseUrl = isdev ? 'http://707788f2.r1.cpolar.top' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
|
// const baseUrl = isdev ? 'http://707788f2.r1.cpolar.top' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
|
||||||
// const baseUrl = isdev ? 'http://192.168.1.133:8899' : 'https://api.gwkjxb.com';// 办公室接口 & 正式环境
|
// const baseUrl = isdev ? 'http://192.168.1.133:8899' : 'https://api.gwkjxb.com';// 办公室接口 & 正式环境
|
||||||
|
@ -15,16 +15,21 @@
|
|||||||
onShow((e) => {
|
onShow((e) => {
|
||||||
getLbtList()
|
getLbtList()
|
||||||
// console.log("store:",store)
|
// console.log("store:",store)
|
||||||
// if(store.userInfo && !store.operation_info) { //登录过 且 未填写手术信息
|
// if(!store.userInfo && !store.operation_info) { //没登录过 且 未填写手术信息
|
||||||
// getHospitalList()
|
if(!store.userInfo) { //没登录过
|
||||||
// setTimeout(()=>{
|
// console.log("没有store.userInfo",store.userInfo)
|
||||||
// inputDialog.value.open()
|
// getHospitalList()
|
||||||
// },0)
|
setTimeout(()=>{
|
||||||
// }
|
inputDialog.value.open()
|
||||||
// let s = `$http({code:'1s'});if`
|
},0)
|
||||||
// // let arr = /\$http\((\S*)\)\;if/.exec(s);
|
// uni.navigateTo({
|
||||||
// let arr = s.match(/\$http\((.*)\)\;if/)
|
// url:'/pages/login/login'
|
||||||
// console.log(arr[1])
|
// })
|
||||||
|
} else {
|
||||||
|
setTimeout(()=>{
|
||||||
|
inputDialog.value.close()
|
||||||
|
},0)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 变量
|
// 变量
|
||||||
@ -176,9 +181,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bindPickerChange(e) {
|
function bindPickerChange(e) {
|
||||||
console.log(hospitals.value )
|
|
||||||
h_index.value = e.detail.value
|
h_index.value = e.detail.value
|
||||||
}
|
}
|
||||||
|
// 手机号登录
|
||||||
|
async function getPhoneNumber (e) {
|
||||||
|
await store.getAccess_token({code:e.detail.code})
|
||||||
|
toClose()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<view class="content page-box">
|
<view class="content page-box">
|
||||||
@ -251,9 +260,9 @@
|
|||||||
</view>
|
</view>
|
||||||
<uni-popup ref="inputDialog" @tap="toBlur" :is-mask-click='false'>
|
<uni-popup ref="inputDialog" @tap="toBlur" :is-mask-click='false'>
|
||||||
<view class="pop-box">
|
<view class="pop-box">
|
||||||
<view class="pb-title">完善手术信息</view>
|
<view class="pb-title">您好, 请先登录</view>
|
||||||
<view class="pb-content">
|
<view class="pb-content">
|
||||||
<view class="pb-item">
|
<!-- <view class="pb-item">
|
||||||
<view class="pb-item-left">已经手术</view>
|
<view class="pb-item-left">已经手术</view>
|
||||||
<view class="pb-item-right">
|
<view class="pb-item-right">
|
||||||
<radio-group @change="radioChange">
|
<radio-group @change="radioChange">
|
||||||
@ -265,38 +274,42 @@
|
|||||||
<view class="pb-item">
|
<view class="pb-item">
|
||||||
<view class="pb-item-left">手术时间</view>
|
<view class="pb-item-left">手术时间</view>
|
||||||
<view class="pb-item-right">
|
<view class="pb-item-right">
|
||||||
<!-- <uni-datetime-picker type="date" :clear-icon="false" v-model="single" @maskClick="maskClick" /> -->
|
|
||||||
<uniDatetimePicker type="date" :clear-icon="false" v-model="surgery_time" @maskClick="maskClick" ></uniDatetimePicker>
|
<uniDatetimePicker type="date" :clear-icon="false" v-model="surgery_time" @maskClick="maskClick" ></uniDatetimePicker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="pb-item">
|
<view class="pb-item">
|
||||||
<view class="pb-item-left">医院名称</view>
|
<view class="pb-item-left">医院名称</view>
|
||||||
<view class="pb-item-right">
|
<view class="pb-item-right">
|
||||||
<!-- <uniEasyinput @tap.stop="focusFunc" suffixIcon="search" v-model="hValue" focus placeholder="请输入内容" @iconClick="onClickH"></uniEasyinput>
|
|
||||||
<view class="h_res_show_aprt" v-if="hospitals">
|
|
||||||
<view v-for="(item,i) in hospitals" @tap.stop="toChooseH(item)" class="h_res_show_aprt_row text-ellipsis-1">
|
|
||||||
{{item.name}}
|
|
||||||
</view>
|
|
||||||
</view> -->
|
|
||||||
<!-- <uni-combox @input="onClickH" :candidates="hospitals" placeholder="请选择医院" @choosed="toChooseH" v-model="hValue"></uni-combox> -->
|
|
||||||
<picker @change="bindPickerChange" :value="h_index" :range="hospitals" range-key="name">
|
<picker @change="bindPickerChange" :value="h_index" :range="hospitals" range-key="name">
|
||||||
<view class="uni-input">{{hospitals[h_index]?.name}}</view>
|
<view class="uni-input">{{hospitals[h_index]?.name}}</view>
|
||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="pb-item pb-item-btn" @tap="toSave">提交</view>
|
<!-- <view class="pb-item pb-item-btn" @tap="toSave">提交</view> -->
|
||||||
|
<!-- <view class="pb-item pb-item-btn" @tap="toSave">获取手机号</view> -->
|
||||||
|
<button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">手机号登录</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="pop-close" @tap="toClose">
|
<!-- <view class="pop-close" @tap="toClose">
|
||||||
关闭
|
关闭
|
||||||
</view>
|
</view> -->
|
||||||
<!-- <uni-popup-dialog ref="inputClose" mode="input" title="输入内容" value="对话框预置提示内容!"
|
|
||||||
placeholder="请输入内容" @confirm="dialogInputConfirm"></uni-popup-dialog> -->
|
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
<aikefu />
|
<aikefu />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.buy-btn{
|
||||||
|
display: block;
|
||||||
|
margin-top:1rem;
|
||||||
|
background-color: #26758d;
|
||||||
|
color: white;
|
||||||
|
border-radius: 50rpx;
|
||||||
|
font-weight: 200;
|
||||||
|
font-size: 24rpx;
|
||||||
|
width: 80%;
|
||||||
|
padding: 10rpx 0;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
.test-card{
|
.test-card{
|
||||||
padding: 30rpx 20rpx;
|
padding: 30rpx 20rpx;
|
||||||
margin: 20rpx 0;
|
margin: 20rpx 0;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
// 引入依赖
|
// 引入依赖
|
||||||
import { onLoad } from "@dcloudio/uni-app"
|
import { onLoad, onBackPress } from "@dcloudio/uni-app"
|
||||||
// import mySwiper from "@/components/mySwiper.vue"
|
// import mySwiper from "@/components/mySwiper.vue"
|
||||||
import {ref,onMounted,nextTick,watch} from "vue"
|
import {ref,onMounted,nextTick,watch} from "vue"
|
||||||
import {useStore} from '@/store/index.js'
|
import {useStore} from '@/store/index.js'
|
||||||
@ -9,116 +9,37 @@
|
|||||||
import custom from "@/utils/index.js"
|
import custom from "@/utils/index.js"
|
||||||
onLoad((e) => {
|
onLoad((e) => {
|
||||||
token_info.value = JSON.parse(decodeURIComponent(e.token_info))
|
token_info.value = JSON.parse(decodeURIComponent(e.token_info))
|
||||||
// is_login.value = custom.checkLogin()
|
|
||||||
// console.log(is_login.value)
|
|
||||||
})
|
})
|
||||||
|
onBackPress(() => {
|
||||||
|
return false
|
||||||
|
})
|
||||||
// 变量
|
// 变量
|
||||||
const token_info = ref(null)
|
const token_info = ref(null)
|
||||||
const avatarUrl = ref(null)
|
const avatarUrl = ref(null)
|
||||||
const nickname = ref('')
|
const nickname = ref('')
|
||||||
const res_form = ref(null)
|
var isOperation = ref([ // 是否已手术
|
||||||
watch(nickname,(v1,v2)=> {
|
{
|
||||||
console.log("watch",v1)
|
index:0,
|
||||||
})
|
name:"否"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
name: "是"
|
||||||
|
}
|
||||||
|
])
|
||||||
// 函数
|
// 函数
|
||||||
function onChooseAvatar(e) {
|
function onChooseAvatar(e) {
|
||||||
// const { avatarUrl } = e.detail
|
|
||||||
// console.log(avatarUrl)
|
|
||||||
avatarUrl.value = e.detail.avatarUrl
|
avatarUrl.value = e.detail.avatarUrl
|
||||||
|
|
||||||
}
|
|
||||||
function getPhoneNumber (e) {
|
|
||||||
// tel_code.value = e.detail.code
|
|
||||||
// console.log(e)
|
|
||||||
getAccess_token({code:e.detail.code})
|
|
||||||
// console.log(e.detail.code) // 动态令牌
|
|
||||||
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
|
|
||||||
// console.log(e.detail.errno) // 错误码(失败时返回)
|
|
||||||
}
|
|
||||||
async function getAccess_token(code){//
|
|
||||||
//清除token缓存
|
|
||||||
// wx.clearStorageSync();
|
|
||||||
if(!avatarUrl.value) {
|
|
||||||
uni.showToast({
|
|
||||||
title:"请选择头像!",
|
|
||||||
icon:"error",
|
|
||||||
duration:1500
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if(!nickname.value) {
|
|
||||||
uni.showToast({
|
|
||||||
title:"请填写昵称!",
|
|
||||||
icon:"error",
|
|
||||||
duration:1500
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//访问接口
|
|
||||||
// console.log(code.value);return
|
|
||||||
// const data={
|
|
||||||
// username:code,//手机号按钮获取的code
|
|
||||||
// type:'wechat_mini_app',
|
|
||||||
// identity:'user',
|
|
||||||
// password:'111',
|
|
||||||
// avatarUrl:avatarUrl.value,
|
|
||||||
// nickName:nickname.value
|
|
||||||
// }
|
|
||||||
// console.log('登录参数:',data);return;
|
|
||||||
// const res = await api.getToken(data)
|
|
||||||
// if(res.code === 200) {
|
|
||||||
// uni.setStorageSync('avatarUrl', avatarUrl.value);//avatarUrl
|
|
||||||
// res_form.value = res.data
|
|
||||||
// res_form.value.access_token = 'Bearer '+res.data.access_token
|
|
||||||
// let userId = res.data.userId
|
|
||||||
// uni.setStorageSync('access_token',res_form.value.access_token);// token单独缓存一次
|
|
||||||
// wx_login(userId)
|
|
||||||
// }
|
|
||||||
uni.setStorageSync('avatarUrl', avatarUrl.value);//avatarUrl
|
|
||||||
wx_login(userId)
|
|
||||||
}
|
|
||||||
async function wx_login(userId){
|
|
||||||
let res=await new Promise(resolve=>{
|
|
||||||
uni.login({
|
|
||||||
provider: 'weixin', //使用微信登录
|
|
||||||
success: function (loginRes) {
|
|
||||||
resolve(loginRes);
|
|
||||||
console.log(loginRes,'微信登录返回信息');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
let res2=await api.wx_login({code:res.code},userId);
|
|
||||||
if(res2.code === 0) {
|
|
||||||
// for(let prop in res_form.value) {
|
|
||||||
// uni.setStorageSync(prop,res_form.value[prop])
|
|
||||||
// }
|
|
||||||
uni.setStorageSync('userInfo',JSON.stringify(res_form.value))
|
|
||||||
custom.uploadImage(avatarUrl.value,async (file)=>{
|
|
||||||
avatarUrl.value = file.data.file.url
|
|
||||||
uni.setStorageSync('avatarUrl', file.data.file.url);//头像链接
|
|
||||||
const up_res = await updateFunc() // 更新用户信息
|
|
||||||
// isInfo // 判断是否填过手术信息的字段(是否使用待定)
|
|
||||||
uni.switchTab({
|
|
||||||
url:"/pages/user/index"
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
uni.clearStorage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateFunc(){ // 更新用户信息,通过此接口获取用户是否填写手术信息
|
async function updateFunc(){ // 更新用户信息,通过此接口获取用户是否填写手术信息
|
||||||
let user_info = JSON.parse(uni.getStorageSync('userInfo'))
|
let user_info = JSON.parse(uni.getStorageSync('userInfo'))
|
||||||
user_info.avatar = avatarUrl.value
|
user_info.avatar = avatarUrl.value
|
||||||
user_info.id =user_info.userId
|
user_info.id =user_info.userId
|
||||||
// console.log(user_info)
|
|
||||||
return await api.userinfoUpdae(user_info)
|
return await api.userinfoUpdae(user_info)
|
||||||
}
|
}
|
||||||
function nameInput(e) {
|
function nameInput(e) {
|
||||||
nickname.value = e.detail.value
|
nickname.value = e.detail.value
|
||||||
// console.log('拿到的值:',e)
|
|
||||||
// console.log('nickname:',nickname.value)
|
|
||||||
}
|
}
|
||||||
async function updateInfoFunc() {
|
async function updateInfoFunc() {
|
||||||
if(!avatarUrl.value) {
|
if(!avatarUrl.value) {
|
||||||
@ -137,22 +58,24 @@
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// let user_info = JSON.parse(uni.getStorageSync('userInfo'))
|
|
||||||
await custom.uploadImage(avatarUrl.value,async (file)=>{
|
await custom.uploadImage(avatarUrl.value,async (file)=>{
|
||||||
avatarUrl.value = file.data.file.url
|
avatarUrl.value = file.data.file.url
|
||||||
uni.setStorageSync('avatarUrl', file.data.file.url);//头像链接
|
uni.setStorageSync('avatarUrl', file.data.file.url);//头像链接
|
||||||
token_info.value.nickname = nickname.value
|
token_info.value.nickname = nickname.value
|
||||||
token_info.value.avatar = avatarUrl.value
|
token_info.value.avatar = avatarUrl.value
|
||||||
uni.setStorageSync('userInfo',JSON.stringify(token_info.value))
|
uni.setStorageSync('userInfo',JSON.stringify(token_info.value))
|
||||||
|
uni.setStorageSync('access_token','Bearer '+token_info.value.access_token);// 为了保险,token单独缓存一次
|
||||||
const up_res = await updateFunc() // 更新用户信息
|
const up_res = await updateFunc() // 更新用户信息
|
||||||
|
store.checkLogin() // 检查一遍登录情况
|
||||||
uni.setStorageSync('access_token','Bearer '+token_info.value.access_token);// token单独缓存一次
|
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url:"/pages/user/index"
|
url:"/pages/user/index"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
function bindOperationPickerChange(e) {
|
||||||
|
token_info.value.IsSurgery = e.detail.value
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<view class="loginBox page-box img-part card-part" style="text-align:center">
|
<view class="loginBox page-box img-part card-part" style="text-align:center">
|
||||||
@ -163,16 +86,60 @@
|
|||||||
</button>
|
</button>
|
||||||
<input type="nickname" @blur="nameInput" class="weui-input" placeholder="请输入昵称" v-model="nickname" />
|
<input type="nickname" @blur="nameInput" class="weui-input" placeholder="请输入昵称" v-model="nickname" />
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="h_info_box">
|
<!-- <view class="row-box">
|
||||||
|
<view class="rb-card" @tap="toDetail(5)">
|
||||||
|
<view class="rbc-content">
|
||||||
|
<view class="rbc-content-row rbc-content-left rbc-content-left-box">
|
||||||
|
<uni-icons type="paperplane" color="gray" size="26"></uni-icons>
|
||||||
|
已经手术</view>
|
||||||
|
<view class="rbc-content-row rbc-content-right">
|
||||||
|
<picker @change="bindOperationPickerChange" :value="token_info?.IsSurgery" :range="isOperation" range-key="name" >
|
||||||
|
<view class="rbc-content-row rbc-content-right rbc-content-right-box">
|
||||||
|
<view class="uni-input">{{ isOperation[token_info?.IsSurgery]?.name }}</view>
|
||||||
|
<uni-icons type="forward" color="gray" size="20"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
<view class="btn-part">
|
<view class="btn-part">
|
||||||
<!-- <button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即登录</button> -->
|
|
||||||
<button class="buy-btn" @tap="updateInfoFunc">立即登录</button>
|
<button class="buy-btn" @tap="updateInfoFunc">立即登录</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.rbc-content-right-box,.rbc-content-left-box{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.row-box{
|
||||||
|
padding: 20rpx 0;
|
||||||
|
.rb-card{
|
||||||
|
padding: 20rpx;
|
||||||
|
background: white;
|
||||||
|
margin-bottom: 2rpx;
|
||||||
|
.rbc-title{
|
||||||
|
|
||||||
|
}
|
||||||
|
.rbc-content-box{
|
||||||
|
margin-top: 10rpx;
|
||||||
|
.rbc-content-row{
|
||||||
|
width: 50%;
|
||||||
|
text-align: center;
|
||||||
|
// padding: 40rpx 20rpx;
|
||||||
|
// box-shadow: 10rpx 10rpx 10rpx #cdcdcd;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.rbc-content{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.base-info{
|
.base-info{
|
||||||
padding: 50rpx 0;
|
padding: 50rpx 0;
|
||||||
}
|
}
|
||||||
@ -203,7 +170,7 @@
|
|||||||
border-radius: 50rpx;
|
border-radius: 50rpx;
|
||||||
font-weight: 200;
|
font-weight: 200;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
width: 50%;
|
width: 80%;
|
||||||
padding: 10rpx 0;
|
padding: 10rpx 0;
|
||||||
}
|
}
|
||||||
.title-part{
|
.title-part{
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
}
|
}
|
||||||
function getPhoneNumber (e) {
|
function getPhoneNumber (e) {
|
||||||
// tel_code.value = e.detail.code
|
// tel_code.value = e.detail.code
|
||||||
console.log(e)
|
// console.log(e)
|
||||||
getAccess_token({code:e.detail.code})
|
getAccess_token({code:e.detail.code})
|
||||||
// console.log(e.detail.code) // 动态令牌
|
// console.log(e.detail.code) // 动态令牌
|
||||||
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
|
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
|
||||||
@ -74,7 +74,7 @@
|
|||||||
}
|
}
|
||||||
async function getAccess_token(params={}){//获取token 获取手机号
|
async function getAccess_token(params={}){//获取token 获取手机号
|
||||||
//清除token缓存
|
//清除token缓存
|
||||||
// wx.clearStorageSync();
|
wx.clearStorageSync();
|
||||||
//访问接口
|
//访问接口
|
||||||
const data={
|
const data={
|
||||||
username:params.code,//手机号按钮获取的code
|
username:params.code,//手机号按钮获取的code
|
||||||
@ -94,7 +94,7 @@
|
|||||||
provider: 'weixin', //使用微信登录
|
provider: 'weixin', //使用微信登录
|
||||||
success: function (loginRes) {
|
success: function (loginRes) {
|
||||||
resolve(loginRes);
|
resolve(loginRes);
|
||||||
console.log(loginRes,'微信登录返回信息');
|
// console.log(loginRes,'微信登录返回信息');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -103,7 +103,8 @@
|
|||||||
let res2=await api.wx_login({code:res_p.code},userId);
|
let res2=await api.wx_login({code:res_p.code},userId);
|
||||||
if(res2.code === 0) {
|
if(res2.code === 0) {
|
||||||
store.checkLogin()
|
store.checkLogin()
|
||||||
toLogin(encodeURIComponent(JSON.stringify(res.data)))
|
// toLogin(encodeURIComponent(JSON.stringify(res.data)))
|
||||||
|
store.toProfile(encodeURIComponent(JSON.stringify(res.data)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -8,32 +8,26 @@
|
|||||||
import api from "@/api/index.js"
|
import api from "@/api/index.js"
|
||||||
import custom from "@/utils/index.js"
|
import custom from "@/utils/index.js"
|
||||||
const h_index = ref(0)
|
const h_index = ref(0)
|
||||||
onLoad(async () => {
|
onLoad(async (e) => {
|
||||||
await getHospitalList()
|
await getHospitalList()
|
||||||
// console.log(useStore.userInfo)
|
is_login.value = custom.checkLogin()
|
||||||
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
|
if(!is_login.value) { // 未登录
|
||||||
h_info.value = userinfo.value
|
userinfo.value = JSON.parse(decodeURIComponent(e.token_info))
|
||||||
h_info.value.surgery_time = h_info.value.SurgeryTime
|
} else { // 已登录
|
||||||
// console.log("userinfo is :",userinfo.value)
|
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
|
||||||
userinfo.value.avatar = uni.getStorageSync('avatarUrl')
|
h_info.value = userinfo.value
|
||||||
h_index.value = hospitals.value.findIndex((item,i) => {
|
h_info.value.surgery_time = h_info.value.SurgeryTime
|
||||||
return item.ID == userinfo.value.HospitalId
|
userinfo.value.avatar = uni.getStorageSync('avatarUrl')
|
||||||
})
|
h_index.value = hospitals.value.findIndex((item,i) => {
|
||||||
if(userinfo.value.HospitalId) {
|
return item.ID == userinfo.value.HospitalId
|
||||||
getHospital(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({
|
const h_queryParams = ref({
|
||||||
page:1,
|
page:1,
|
||||||
pageSize:1000,
|
pageSize:1000,
|
||||||
@ -57,7 +51,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onInputH() {
|
function onInputH() {
|
||||||
console.log(hValue.value)
|
|
||||||
h_queryParams.value.key = hValue.value
|
h_queryParams.value.key = hValue.value
|
||||||
getHospitalList()
|
getHospitalList()
|
||||||
|
|
||||||
@ -117,19 +110,16 @@
|
|||||||
return `${year}-${month}-${day}`;
|
return `${year}-${month}-${day}`;
|
||||||
}
|
}
|
||||||
function bindDateChange(e) {
|
function bindDateChange(e) {
|
||||||
console.log(e)
|
// console.log(e)
|
||||||
h_info.value.surgery_time = e.detail.value
|
h_info.value.surgery_time = e.detail.value
|
||||||
}
|
}
|
||||||
function toChooseH(item) {
|
function toChooseH(item) {
|
||||||
console.log(item)
|
// console.log(item)
|
||||||
choosed_h.value = item
|
choosed_h.value = item
|
||||||
hValue.value = item.name
|
hValue.value = item.name
|
||||||
// hospitals.value = null
|
// hospitals.value = null
|
||||||
}
|
}
|
||||||
async function sumbmitFunc() {
|
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) => {
|
await custom.uploadImage(userinfo.value.avatar, async (file) => {
|
||||||
userinfo.value.avatar = file.data.file.url
|
userinfo.value.avatar = file.data.file.url
|
||||||
})
|
})
|
||||||
@ -140,7 +130,6 @@
|
|||||||
nickname: userinfo.value.nickname,
|
nickname: userinfo.value.nickname,
|
||||||
avatar: userinfo.value.avatar,
|
avatar: userinfo.value.avatar,
|
||||||
phone: userinfo.value.phone,
|
phone: userinfo.value.phone,
|
||||||
// hospitalId:choosed_h.value?.ID
|
|
||||||
hospitalId:hospitals.value[h_index.value]?.ID
|
hospitalId:hospitals.value[h_index.value]?.ID
|
||||||
}
|
}
|
||||||
if(!obj.hospitalId) {
|
if(!obj.hospitalId) {
|
||||||
@ -152,8 +141,10 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
obj.isSurgery = parseInt(userinfo.value.IsSurgery)
|
obj.isSurgery = parseInt(userinfo.value.IsSurgery)
|
||||||
const res = await api.userinfoUpdae(obj)
|
// if(!is_login.value) { // 新用户 - 先登录
|
||||||
// console.log('res is ',res)
|
|
||||||
|
// }
|
||||||
|
const res = await api.userinfoUpdae(obj) // 更新用户信息
|
||||||
if(res.code === 0) {
|
if(res.code === 0) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title:res.msg,
|
title:res.msg,
|
||||||
@ -179,7 +170,6 @@
|
|||||||
provider: 'weixin', //使用微信登录
|
provider: 'weixin', //使用微信登录
|
||||||
success: function (loginRes) {
|
success: function (loginRes) {
|
||||||
resolve(loginRes);
|
resolve(loginRes);
|
||||||
console.log(loginRes,'微信登录返回信息');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -187,7 +177,6 @@
|
|||||||
if(res2.code === 0) {
|
if(res2.code === 0) {
|
||||||
userinfo.value.HospitalId = hospitals.value[h_index.value].ID
|
userinfo.value.HospitalId = hospitals.value[h_index.value].ID
|
||||||
h_info.value.hospitalId = userinfo.value.HospitalId
|
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('avatarUrl', userinfo.value.avatar);//avatarUrl
|
||||||
uni.setStorageSync('userInfo',JSON.stringify(userinfo.value))
|
uni.setStorageSync('userInfo',JSON.stringify(userinfo.value))
|
||||||
uni.setStorageSync('operation_info', JSON.stringify(h_info.value))
|
uni.setStorageSync('operation_info', JSON.stringify(h_info.value))
|
||||||
@ -199,7 +188,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function bindPickerChange(e) {
|
function bindPickerChange(e) {
|
||||||
console.log(hospitals.value )
|
// console.log(hospitals.value )
|
||||||
h_index.value = e.detail.value
|
h_index.value = e.detail.value
|
||||||
}
|
}
|
||||||
function onChooseAvatar(e) {
|
function onChooseAvatar(e) {
|
||||||
@ -219,7 +208,7 @@
|
|||||||
])
|
])
|
||||||
function bindOperationPickerChange(e) {
|
function bindOperationPickerChange(e) {
|
||||||
userinfo.value.IsSurgery = e.detail.value
|
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>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -57,11 +57,11 @@ export const useStore = defineStore('main2', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
checkLogin(){ // 检查是否登录
|
checkLogin(){ // 检查是否登录
|
||||||
let access_token = uni.getStorageSync('access_token')
|
// let access_token = uni.getStorageSync('access_token')
|
||||||
// let visitState = uni.getStorageSync('visitState')
|
let u_info = uni.getStorageSync('userInfo')
|
||||||
console.log(access_token)
|
// console.log("u_info is ",u_info)
|
||||||
if(access_token) {
|
if(u_info) {
|
||||||
this.access_token = access_token
|
this.access_token = uni.getStorageSync('access_token')
|
||||||
this.isLogin = true
|
this.isLogin = true
|
||||||
this.userInfo = uni.getStorageSync('userInfo')
|
this.userInfo = uni.getStorageSync('userInfo')
|
||||||
this.operation_info = uni.getStorageSync('operation_info')
|
this.operation_info = uni.getStorageSync('operation_info')
|
||||||
@ -181,6 +181,87 @@ export const useStore = defineStore('main2', {
|
|||||||
})
|
})
|
||||||
},duration)
|
},duration)
|
||||||
|
|
||||||
|
},
|
||||||
|
async getAccess_token(params={}) {
|
||||||
|
//清除token缓存
|
||||||
|
wx.clearStorageSync();
|
||||||
|
//访问接口
|
||||||
|
const data={
|
||||||
|
username:params.code,//手机号按钮获取的code
|
||||||
|
type:'wechat_mini_app',
|
||||||
|
identity:'user',
|
||||||
|
password:'111'
|
||||||
|
}
|
||||||
|
// console.log('登录参数:',data);return;
|
||||||
|
const res = await api.getToken(data)
|
||||||
|
if(res.code === 200) {
|
||||||
|
// newUser.value = res.data.newUser
|
||||||
|
// res.data.newUser = true // 开发阶段专用,正式版请删除或注释
|
||||||
|
if(res.data.newUser) { // 新用户,不做任何缓存动作,跳转登录页
|
||||||
|
let userId = res.data.userId
|
||||||
|
let res_p=await new Promise(resolve=>{
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin', //使用微信登录
|
||||||
|
success: function (loginRes) {
|
||||||
|
resolve(loginRes);
|
||||||
|
// console.log(loginRes,'微信登录返回信息');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// 正式版记住放开下面这行注释掉的代码
|
||||||
|
uni.setStorageSync('access_token','Bearer '+res.data.access_token);// 为了wx登录成功,必须token单独缓存一次
|
||||||
|
let res2= await api.wx_login({code:res_p.code},userId);
|
||||||
|
if(res2.code === 0) {
|
||||||
|
// this.checkLogin()
|
||||||
|
// this.toLogin(encodeURIComponent(JSON.stringify(res.data))) // 跳转登录页,但是我不想这么做
|
||||||
|
this.toProfile(encodeURIComponent(JSON.stringify(res.data)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
let res_form = {}
|
||||||
|
uni.setStorageSync('avatarUrl', res.data.avatar);//avatarUrl
|
||||||
|
res_form = res.data
|
||||||
|
res_form.access_token = 'Bearer '+res.data.access_token
|
||||||
|
let userId = res.data.userId
|
||||||
|
uni.setStorageSync('access_token',res_form.access_token);// token单独缓存一次
|
||||||
|
this.wx_login(userId, res_form)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
uni.showToast({
|
||||||
|
icon:"error",
|
||||||
|
title:res.msg,
|
||||||
|
duration:2000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async wx_login(userId, res_form) {
|
||||||
|
let res=await new Promise(resolve=>{
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin', //使用微信登录
|
||||||
|
success: function (loginRes) {
|
||||||
|
resolve(loginRes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
let res2 = await api.wx_login({code:res.code},userId);
|
||||||
|
if(res2.code === 0) {
|
||||||
|
uni.setStorageSync('userInfo',JSON.stringify(res_form))
|
||||||
|
this.checkLogin()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
uni.clearStorage();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toLogin(token_info) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url:"/pages/login/login?token_info="+token_info
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toProfile(token_info) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url:"/pages/user/userInfo?token_info="+token_info
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -103,9 +103,9 @@ export default {
|
|||||||
return { m: s * 1000, km: Number(s.toFixed(2)) }
|
return { m: s * 1000, km: Number(s.toFixed(2)) }
|
||||||
},
|
},
|
||||||
checkLogin(){
|
checkLogin(){
|
||||||
let token = uni.getStorageSync('access_token')
|
// let token = uni.getStorageSync('access_token')
|
||||||
console.log(token)
|
let u_info = uni.getStorageSync('userInfo')
|
||||||
if(token){
|
if(u_info){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
Loading…
Reference in New Issue
Block a user