<template> <view> <view class="con"> <view class="item"> <view class="l">用户名:</view> <input class="r" v-model="person.name" :disabled="enable" /> </view> <view class="item"> <view class="l">性别:</view> <input class="r" v-model="person.genderName" :disabled="enable" /> </view> <view class="item"> <view class="l">年龄:</view> <input class="r" v-model="person.age" :disabled="enable" /> </view> <view class="item"> <view class="l">手机号:</view> <input class="r" v-model="person.phone" :disabled="enable" /> </view> <view class="item"> <view class="l">互助组:</view> <input class="r" v-model="person.groupName" :disabled="enable" /> </view> <view class="item"> <view class="l">角色:</view> <input class="r" v-model="person.roleName" :disabled="enable" /> </view> <view class="item"> <view class="l">贸易区域:</view> <input class="r" v-model="person.tradeAreaName" :disabled="enable" /> </view> <view class="item" style="border: none;"> <view class="l">地址:</view> <input class="r" v-model="person.address" :disabled="enable" /> </view> </view> <view> <button class="btn" @click="edit">编辑资料</button> </view> </view> </template> <script> export default { data() { return { person: {}, enable: true, name: '' } }, onLoad() { this.getSelfInfo() }, methods: { // 查看个人信息 getSelfInfo() { this.http.request({ url: '/sp-admin/app/AppUser/getSelfInfo', success: res => { this.person = res.data.data } }); }, edit(){ uni.showModal({ title: '请输入用户名', editable: true, placeholderText: '请输入新的用户名', success: res => { if(res.confirm){ this.name = res.content this.updateUser() // uni.navigateBack({delta: 1}) } } }) }, // 修改个人信息 updateUser(){ let userId = this.getUser().id let param = { id: userId, name: this.name } this.http.request({ url: '/sp-admin/app/AppUser/update', data: param, method: 'POST', success: res => { uni.showModal({ content: '修改成功', showCancel: false }), this.getSelfInfo() } }); } } } </script> <style lang="scss"> page { background-color: $pg; } .con{ background-color: #fff; margin: 20px; padding: 10px; border-radius: 10px; border: 1px #fff solid; } .item{ height: 50px; display: flex; align-items: center; border-bottom: 1px #dcdcdc solid; .l{ flex: 4; } .r{ flex: 10; } } .btn{ width: 80%; } </style>