10.25午夜修改

This commit is contained in:
阿怪 2023-10-25 23:45:00 +08:00
parent 6a45185641
commit a62eed8a22
4 changed files with 103 additions and 28 deletions

View File

@ -1,6 +1,6 @@
// isdev 为 true 表示开发环境 false 表示发布环境
const isdev = true;
const baseUrl = isdev ? 'http://eb467b6.r19.cpolar.top' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
const baseUrl = isdev ? 'http://3fc7c93a.r7.cpolar.top' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
// const baseUrl = isdev ? 'http://192.168.1.133:8899' : 'https://api.gwkjxb.com';// 办公室接口 & 正式环境
// const baseUrl = 'https://api.gwkjxb.com';// 正式环境(由于本地测试后台没有启动,暂时通用正式服)

View File

@ -121,11 +121,11 @@
isSurgery:isSurgery.value,
surgery_time:surgery_time.value,
userId:user_info.userId,
hospitalId:choosed_h.value.ID
hospitalId:choosed_h.value?.ID
})
console.log(res)
if(res.code == 0) {
toClose()
}
}
</script>

View File

@ -7,12 +7,14 @@
const store = useStore()
import api from "@/api/index"
import custom from "@/utils/index.js"
onLoad(() => {
onLoad((e) => {
token_info.value = JSON.parse(decodeURIComponent(e.token_info))
// is_login.value = custom.checkLogin()
// console.log(is_login.value)
})
//
const token_info = ref(null)
const avatarUrl = ref(null)
const nickname = ref('')
const res_form = ref(null)
@ -34,29 +36,48 @@
// console.log(e.detail.errMsg) //
// console.log(e.detail.errno) //
}
async function getAccess_token(params={}){//token
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
}
//访
const data={
username:params.code,//code
type:'wechat_mini_app',
identity:'user',
password:'111',
avatarUrl:avatarUrl.value,
nickName:nickname.value
}
// 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) {
// 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
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)
}
}
async function wx_login(userId){
let res=await new Promise(resolve=>{
uni.login({
@ -99,6 +120,39 @@
// console.log('',e)
// console.log('nickname:',nickname.value)
}
async function updateInfoFunc() {
if(!avatarUrl.value) {
uni.showToast({
title:"请选择头像!",
icon:"error",
duration:1500
})
return
}
if(!nickname.value) {
uni.showToast({
title:"请填写昵称!",
icon:"error",
duration:1500
})
return
}
// let user_info = JSON.parse(uni.getStorageSync('userInfo'))
await custom.uploadImage(avatarUrl.value,async (file)=>{
avatarUrl.value = file.data.file.url
uni.setStorageSync('avatarUrl', file.data.file.url);//
token_info.value.nickname = nickname.value
token_info.value.avatar = avatarUrl.value
uni.setStorageSync('userInfo',JSON.stringify(token_info.value))
const up_res = await updateFunc() //
uni.setStorageSync('access_token','Bearer '+token_info.value.access_token);// token
uni.switchTab({
url:"/pages/user/index"
})
})
}
</script>
<template>
<view class="loginBox page-box img-part card-part" style="text-align:center">
@ -110,7 +164,8 @@
<input type="nickname" @blur="nameInput" class="weui-input" placeholder="请输入昵称" v-model="nickname" />
</view>
<view class="btn-part">
<button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即登录</button>
<!-- <button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即登录</button> -->
<button class="buy-btn" @tap="updateInfoFunc">立即登录</button>
</view>
</view>
</template>

View File

@ -15,6 +15,7 @@
const res_form = ref(null)
const is_login = ref(null)
const userinfo = ref(null)
const newUser = ref(null)
// const avatarUrl = ref(null)
const nickname = ref('')
//
@ -26,9 +27,9 @@
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
}
}
function toLogin() {
function toLogin(token_info) {
uni.navigateTo({
url:"/pages/login/login"
url:"/pages/login/login?token_info="+token_info
})
}
function toDetail(type) {
@ -83,8 +84,24 @@
// console.log(':',data);return;
const res = await api.getToken(data)
if(res.code === 200) {
if(res.data.newUser) { //
toLogin()
// newUser.value = res.data.newUser
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);// token
let res2=await api.wx_login({code:res_p.code},userId);
if(res2.code === 0) {
toLogin(encodeURIComponent(JSON.stringify(res.data)))
}
}
else{
uni.setStorageSync('avatarUrl', res.data.avatar);//avatarUrl
@ -111,6 +128,9 @@
uni.setStorageSync('userInfo',JSON.stringify(res_form.value))
// is_login.value = custom.checkLogin()
getInfo()
// if(newUser.value) {
// toLogin()
// }
}
else{
uni.clearStorage();