|
- <template>
- <view style="padding: 0 30rpx;">
- <view class="header">
- <view style="padding-top: 44rpx;" class="headerContent">
- <u-avatar :src="userInfo.avatar" size="180rpx"></u-avatar>
- <view class="right">
- <view class="name">
- {{userInfo.name}}
- </view>
- <view class="des">
- <image src="/static/image/school.png" mode=""></image>
- {{userInfo.orgNames}} | {{userInfo.positionName}}
- </view>
- </view>
- </view>
- </view>
- <view class="whiteCard">
- <view class="title">
- 个人信息
- </view>
- <u-cell title="账号" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false">
- <view slot="value" class="valueBox disabled">
- {{userInfo.account}}
- </view>
- </u-cell>
- <u-cell title="姓名" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink
- @click="cellClick('修改姓名')">
- <view slot="value" class="valueBox">
- {{userInfo.name}}
- </view>
- </u-cell>
- <u-cell title="手机" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink
- @click="cellClick('修改手机号')">
- <view slot="value" class="valueBox">
- {{userInfo.phone}}
- </view>
- </u-cell>
- <u-cell title="昵称" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink
- @click="cellClick('设置昵称')">
- <view slot="value" class="valueBox">
- {{userInfo.nickname||'未设置'}}
- </view>
- </u-cell>
- <picker mode="date" :value="userInfo.birthday" @change="dateChange">
- <u-cell title="出生日期" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink>
- <view slot="value" class="valueBox">
- {{userInfo.birthday}}
- </view>
- </u-cell>
- </picker>
- </view>
- <view class="btn" @click="loginOut">
- 退出登录
- </view>
- <u-popup :show="show" mode="center" :round="10">
- <view class="popupInfo">
- <view class="title">
- {{this.action}}
- </view>
- <u--input v-model="inputValue" :customStyle="{height: '84rpx',boxSizing:'border-box'}" placeholder="请输入" border="surround" clearable></u--input>
- <view class="bottom">
- <view class="cancel" @click="cancel">
- 取消
- </view>
- <view class="confirm" @click="confirm">
- 确定
- </view>
- </view>
- </view>
- </u-popup>
-
- </view>
- </template>
-
- <script>
- import {updateUserInfo} from '@/api/user.js'
- export default {
- data() {
- return {
- show: false,
- action: '',
- inputValue: '',
- }
- },
- onShow() {
- this.$store.dispatch('getUserInfo')
- },
- methods: {
- cellClick(action) {
- this.action = action
- this.inputValue = ''
- this.show = true
- },
- confirm() {
- switch (this.action) {
- case '修改姓名':
- if (!this.inputValue) {
- this.TOAST('请输入姓名')
- return
- }
- this.LOADING()
- updateUserInfo({...this.userInfo,name:this.inputValue}).then(res=>{
- this.HIDE_LOADING()
- if(res.code != 200)return
- this.$store.dispatch('getUserInfo')
- this.cancel()
- })
- break
- case '修改手机号':
- if (!this.inputValue) {
- this.TOAST('请输入手机号')
- return
- }
- if (!
- /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/
- .test(this.inputValue)) {
- this.TOAST('请输入正确的手机号')
- return
- }
- this.LOADING()
- updateUserInfo({...this.userInfo,phone:this.inputValue}).then(res=>{
- this.HIDE_LOADING()
- if(res.code != 200)return
- this.$store.dispatch('getUserInfo')
- this.cancel()
- })
- break
- case '设置昵称':
- // if (!this.inputValue) {
- // this.TOAST('请输入昵称')
- // return
- // }
- this.LOADING()
- updateUserInfo({...this.userInfo,nickname:this.inputValue}).then(res=>{
- this.HIDE_LOADING()
- if(res.code != 200)return
- this.$store.dispatch('getUserInfo')
- this.cancel()
- })
- break
- }
- },
- cancel() {
- this.show = false
- },
- dateChange(e) {
- this.LOADING()
- updateUserInfo({...this.userInfo,birthday:e.detail.value}).then(res=>{
- this.HIDE_LOADING()
- if(res.code != 200)return
- this.$store.dispatch('getUserInfo')
- this.cancel()
- })
- },
- loginOut() {
- this.CONFIRM('您是否确认退出登录?').then(res=>{
- if(!res)return
- this.CLEAR_STORAGE()
- this.JUMP_TO('/pages/login')
- })
- }
- }
- }
- </script>
-
- <style scoped lang="scss">
- uni-page-body {
- /* #ifdef H5*/
- background-image: url('/static/image/mybgh5.png');
- /* #endif */
- /* #ifndef H5*/
- background-image: url('/static/image/mybg.png');
- /* #endif */
- background-position: top;
- background-size: 100% auto;
- background-repeat: no-repeat;
- }
-
- .header {
- /* #ifdef H5*/
- padding-top: 40rpx;
- /* #endif */
- /* #ifndef H5*/
- padding-top: 88rpx;
- /* #endif */
- color: #333;
-
- .headerContent {
- display: flex;
- }
-
- .right {
- flex: 1;
- padding-top: 24rpx;
- padding-left: 36rpx;
-
- .name {
- font-size: 46rpx;
- font-weight: 700;
- }
-
- .des {
- display: flex;
- font-size: 28rpx;
- margin-top: 30rpx;
-
- uni-image {
- width: 34rpx;
- height: 34rpx;
- margin-right: 12rpx;
- }
- }
- }
- }
-
- .whiteCard {
- background-color: #fff;
- border-radius: 20rpx;
- margin-top: 50rpx;
-
- // padding: 0 30rpx;
- .title {
- font-family: 'Alimama ShuHeiTi';
- font-weight: 700;
- color: #2388FF;
- font-size: 42rpx;
- line-height: 42rpx;
- padding: 60rpx 30rpx 30rpx;
- }
- }
-
- .u-cell {
- height: 90rpx;
- position: relative;
-
- &:not(&:last-child)::after {
- content: '';
- display: block;
- position: absolute;
- height: 1rpx;
- background-color: rgba(0, 0, 0, 0.1);
- width: calc(100% - 60rpx);
- left: 30rpx;
- bottom: 0rpx;
- }
-
- .valueBox {
- color: #333;
- font-size: 30rpx;
- font-weight: 700;
-
- &.disabled {
- font-weight: unset;
- }
- }
- }
-
- .btn {
- height: 98rpx;
- background-color: #fff;
- line-height: 98rpx;
- border-radius: 20rpx;
- text-align: center;
- color: #333;
- margin-top: 30rpx;
- font-size: 32rpx;
- }
-
- .popupInfo {
- padding: 30rpx 30rpx 0rpx;
- width: 540rpx;
- box-sizing: border-box;
-
- .title {
- font-size: 34rpx;
- font-weight: 700;
- text-align: center;
- margin-bottom: 30rpx;
- margin-top: 16rpx;
- }
-
- .bottom {
- margin-top: 30rpx;
- display: flex;
- line-height: 88rpx;
- border-top: 1rpx solid rgba(0, 0, 0, 0.1);
- margin-left: -30rpx;
- margin-right: -30rpx;
- position: relative;
-
- &::after {
- content: '';
- background-color: rgba(0, 0, 0, 0.1);
- display: block;
- position: absolute;
- width: 1rpx;
- height: 100%;
- left: 50%;
- top: 0;
- }
-
- &>* {
- width: 50%;
- text-align: center;
- color: #165DFF;
- font-weight: 32rpx;
- }
- }
- }
- </style>
|