192 lines
4.8 KiB
Vue
192 lines
4.8 KiB
Vue
<template>
|
|
<view class="app">
|
|
<view class="user" v-if="appPersonallist">
|
|
<image class="img" src="../../static/user.png" mode=""></image>
|
|
<image class="bjimg" src="https://hekou-nurse-api.xinyilu.cn/profile/weChatPicture/background.png" mode="">
|
|
</image>
|
|
<!-- <view class="service" @tap="remove">
|
|
<image src="../../static/tuichu.png" mode=""></image>
|
|
</view> -->
|
|
<view class="phone">
|
|
{{appPersonallist.patientName?appPersonallist.patientName:'用户'}}
|
|
</view>
|
|
<view class="nickname" style="top:250rpx">
|
|
{{phone?phone:''}}
|
|
</view>
|
|
<view class="nickname">
|
|
<span style='padding-right: 10rpx;' v-if="appPersonallist.age">
|
|
{{appPersonallist.age}}
|
|
</span>
|
|
<span style='padding-right: 30rpx;' v-if="appPersonallist.age">
|
|
岁
|
|
</span>
|
|
{{appPersonallist.sex=='MALE'?'男':""}}
|
|
{{appPersonallist.sex=='FEMALE'?'女':""}}
|
|
</span>
|
|
</view>
|
|
</view>
|
|
<view class="user" v-else>
|
|
<image class="img" src="../../static/user.png" mode=""></image>
|
|
<image class="bjimg" src="https://hekou-nurse-api.xinyilu.cn/profile/weChatPicture/background.png" mode="">
|
|
<view class="login" @tap='gologin'>
|
|
登录
|
|
</view>
|
|
</view>
|
|
<view class="center">
|
|
<view class="home" @tap='gomodify'>
|
|
<image src="@/static/person.png" mode=""></image>
|
|
<view class="name">
|
|
个人信息
|
|
</view>
|
|
</view>
|
|
<view class="home" @tap='goHealthrecords'>
|
|
<image src="@/static/health.png" mode=""></image>
|
|
<view class="name">
|
|
健康档案
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- <view class="service">
|
|
<view class="serviceorder">退出账号</view>
|
|
<image src="../../static/huijiantou.png" mode=""></image>
|
|
</view> -->
|
|
<u-toast ref="uToast" />
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import {
|
|
getAge
|
|
} from "@/api/age.js";
|
|
import baseurl from '@/api/baseurl.js'
|
|
import {
|
|
appletLoginV1,
|
|
getResidentInfoById
|
|
} from '@/api/personal/index.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
appPersonallist: null, //获取个人信息
|
|
phone: undefined,
|
|
}
|
|
},
|
|
onShow() {
|
|
this.phone = uni.getStorageSync('phone')
|
|
if (uni.getStorageSync('patientId') && uni.getStorageSync('openid')) {
|
|
this.info();
|
|
} else {
|
|
this.appPersonallist = null
|
|
}
|
|
},
|
|
methods: {
|
|
// 退出登录
|
|
remove() {
|
|
let that = this
|
|
const value = uni.getStorageSync('patientId');
|
|
if (value) {
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '确认要退出此账号吗',
|
|
success: function(res) {
|
|
if (res.confirm) {
|
|
that.$refs.uToast.show({
|
|
title: '退出账号成功',
|
|
type: 'success',
|
|
duration: '2000'
|
|
})
|
|
that.removes()
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
that.$refs.uToast.show({
|
|
title: '您未登录,请先登录',
|
|
type: 'error',
|
|
duration: '1000'
|
|
})
|
|
}
|
|
},
|
|
removes() {
|
|
this.appPersonallist = null
|
|
uni.removeStorageSync('patientId');
|
|
uni.removeStorageSync('openid');
|
|
uni.removeStorageSync('phone');
|
|
},
|
|
info() {
|
|
getResidentInfoById(uni.getStorageSync('patientId')).then(res => {
|
|
if (res.data) {
|
|
this.phone = res.data.patientPhone
|
|
res.data.birthDate ? res.data.age = getAge(res.data.birthDate) : ''
|
|
this.appPersonallist = res.data
|
|
} else {
|
|
this.removes();
|
|
}
|
|
})
|
|
},
|
|
//去登陆
|
|
gologin() {
|
|
let that = this
|
|
wx.login({
|
|
provider: 'weixin',
|
|
success: function(loginRes) {
|
|
appletLoginV1(loginRes.code).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.msg == '已注册') {
|
|
uni.setStorageSync("openid", res.data.openId)
|
|
uni.setStorageSync("patientId", res.data.id)
|
|
uni.setStorageSync("phone", res.data.patientPhone)
|
|
that.phone = res.data.patientPhone
|
|
that.info();
|
|
} else {
|
|
uni.setStorageSync("openid", res.data)
|
|
that.$refs.uToast.show({
|
|
title: '您未注册,前往注册',
|
|
type: 'error',
|
|
duration: '1500',
|
|
url: '/pages/login/login'
|
|
})
|
|
}
|
|
} else {
|
|
that.$refs.uToast.show({
|
|
title: '登录失败',
|
|
type: 'error',
|
|
duration: '1500',
|
|
})
|
|
}
|
|
})
|
|
}
|
|
});
|
|
},
|
|
//未登录
|
|
nologin() {
|
|
this.$refs.uToast.show({
|
|
title: '您未登录,请先登录',
|
|
type: 'error',
|
|
duration: '1500',
|
|
})
|
|
},
|
|
//健康档案
|
|
goHealthrecords() {
|
|
if (uni.getStorageSync('patientId') && uni.getStorageSync('openid')) {
|
|
uni.navigateTo({
|
|
url: '/pages/healthRecords/healthRecords'
|
|
})
|
|
} else {
|
|
this.nologin()
|
|
}
|
|
},
|
|
//个人信息
|
|
gomodify() {
|
|
if (uni.getStorageSync('patientId') && uni.getStorageSync('openid')) {
|
|
uni.navigateTo({
|
|
url: '/pages/modify/modify'
|
|
})
|
|
} else {
|
|
this.nologin()
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
<style lang="scss">
|
|
@import "./personal.scss";
|
|
</style> |