Files
app-govern/pages/user/changeName.vue

79 lines
2.0 KiB
Vue
Raw Normal View History

2023-02-10 16:32:41 +08:00
<template>
2023-08-11 11:03:31 +08:00
<Cn-page :loading="loading">
<view slot="body">
<view class="change-name">
2023-02-10 16:32:41 +08:00
<view class="content">
<uni-easyinput type="text" v-model="name" placeholder="请输入昵称" />
</view>
<view class="btn-wrap">
2023-08-11 11:03:31 +08:00
<view class="btn-wrap-item" @click="submit"> 提交 </view>
2023-02-10 16:32:41 +08:00
</view>
</view>
</view>
</Cn-page>
</template>
<script>
2023-08-11 11:03:31 +08:00
import { apiUpdateUser } from '@/common/api/user'
2023-02-10 16:32:41 +08:00
export default {
2023-08-11 11:03:31 +08:00
data() {
2023-02-10 16:32:41 +08:00
return {
loading: false,
// 表单数据
name: '',
}
},
methods: {
2023-08-11 11:03:31 +08:00
submit() {
apiUpdateUser({
name: this.name,
}).then((res) => {
console.log(res)
uni.showToast({
title: '修改成功',
icon: 'none',
})
let userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
userInfo.nickname = this.name
uni.setStorageSync(this.$cacheKey.userInfo, userInfo)
setTimeout(() => {
uni.navigateBack()
}, 1500)
})
2023-02-10 16:32:41 +08:00
},
2023-08-11 11:03:31 +08:00
},
onLoad() {
this.name = uni.getStorageSync(this.$cacheKey.userInfo).nickname
},
2023-02-10 16:32:41 +08:00
}
</script>
2023-08-11 11:03:31 +08:00
<style lang="scss">
2023-02-10 16:32:41 +08:00
.change-name {
2023-08-11 11:03:31 +08:00
padding: 34rpx;
2023-02-10 16:32:41 +08:00
.content {
margin-bottom: 20rpx;
2023-08-11 11:03:31 +08:00
padding: 34rpx;
2023-02-10 16:32:41 +08:00
background: $uni-theme-white;
border-radius: 12rpx;
}
.btn-wrap {
margin-top: 40rpx;
display: flex;
align-items: center;
justify-content: space-between;
.btn-wrap-item {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
2023-08-03 14:51:36 +08:00
background: $uni-theme-color;
2023-02-10 16:32:41 +08:00
color: #fff;
height: 80rpx;
border-radius: 12rpx;
}
}
}
2023-08-11 11:03:31 +08:00
</style>