|
|
@ -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{
|
|
|
|