136 lines
2.8 KiB
Vue
136 lines
2.8 KiB
Vue
<template>
|
||
<view class="content">
|
||
<TopSafe></TopSafe>
|
||
<Header title="用户名称" />
|
||
<view class="setting-view">
|
||
<view class="name-box">
|
||
<text class="text-zu text-38">修改用户名称</text>
|
||
<text class="text-fu text-28 mt-24" >昵称为2~32位字符,支持中文、英文、数</text>
|
||
<view class="input-view">
|
||
<input v-model="inputText" maxlength="32" placeholder="请输入名称" />
|
||
</view>
|
||
</view>
|
||
|
||
</view>
|
||
<view class="bottom-btn">
|
||
<MyBtn text="保存" @ok="onSetName"></MyBtn>
|
||
</view>
|
||
<up-toast ref="uToastRef"></up-toast>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { getUserInfo,updateName } from '@/api/auth.js';
|
||
import Header from '@/components/common/header.vue';
|
||
import TopSafe from '@/components/common/top-safe.nvue'
|
||
import MyBtn from '@/components/common/my-btn.vue'
|
||
import func from '@/utils/func.js';
|
||
|
||
export default {
|
||
components: { Header, TopSafe,MyBtn },
|
||
data() {
|
||
return {
|
||
userInfo: null,
|
||
inputText:''
|
||
};
|
||
},
|
||
onShow() {
|
||
},
|
||
onLoad() {
|
||
this.init();
|
||
// this.userinfo();
|
||
},
|
||
methods: {
|
||
init() {
|
||
this.userinfo()
|
||
},
|
||
onSetName(){
|
||
if(!this.inputText){
|
||
return this.$refs.uToastRef.show({
|
||
type: 'error',
|
||
message: "请输入名称",
|
||
});
|
||
}
|
||
if(this.inputText.length < 2){
|
||
return this.$refs.uToastRef.show({
|
||
type: 'error',
|
||
message: "名称长度2-32",
|
||
});
|
||
}
|
||
|
||
updateName({name:this.inputText}).then(res=>{
|
||
if (res.bizcode === 100) {
|
||
this.$refs.uToastRef.show({
|
||
type: 'success',
|
||
message: "名称设置成功",
|
||
});
|
||
this.init();
|
||
} else {
|
||
this.$refs.uToastRef.show({
|
||
type: 'error',
|
||
message: "名称设置失败",
|
||
});
|
||
}
|
||
})
|
||
},
|
||
userinfo() {
|
||
getUserInfo().then(res => {
|
||
if (res.bizcode == 100) {
|
||
this.userInfo = res.data;
|
||
this.inputText = this.userInfo.nickname;
|
||
}
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.bottom-btn{
|
||
width: 100%;
|
||
margin-bottom:92rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
padding: 0 32rpx;
|
||
box-sizing: border-box;
|
||
position: relative;
|
||
|
||
}
|
||
.setting-view {
|
||
width: 100%;
|
||
height: calc(100% - 88rpx - 92rpx - 88rpx - var(--status-bar-height));
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
overflow-y: auto;
|
||
padding: 0 32rpx;
|
||
box-sizing: border-box;
|
||
position: relative;
|
||
.name-box{
|
||
width:100%;
|
||
border-radius: 16rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
background-color: #fff;
|
||
padding: 64rpx 32rpx;
|
||
box-sizing: border-box;
|
||
margin-top:24rpx;
|
||
.input-view{
|
||
border-radius: 20rpx;
|
||
margin-top:52rpx;
|
||
width:100%;
|
||
padding: 0 32rpx;
|
||
min-height:104rpx;
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
background-color: #f5f5f5;
|
||
box-sizing: border-box;
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
</style>
|