Bladeren bron

8.15 修改个人信息

mym 1 jaar geleden
bovenliggende
commit
3a846056d8
2 gewijzigde bestanden met toevoegingen van 64 en 23 verwijderingen
  1. 1 1
      pages.json
  2. 63 22
      pages/personal/my.vue

+ 1 - 1
pages.json

@@ -381,7 +381,7 @@
 			}
 
 		}
-	],
+    ],
 	"tabBar": {
 		"color": "#7A7E83",
 		"selectedColor": "#4581fb",

+ 63 - 22
pages/personal/my.vue

@@ -1,34 +1,41 @@
 <template>
 	<view>
 		<view class="con">
-			<view class="flex item">
-				<view>用户名:</view>
-				<input v-model="person.name" />
+			<view class="item">
+				<view class="l">用户名:</view>
+				<input class="r" v-model="person.name" :disabled="enable" />
 			</view>
-			<view class="flex item">
-				<view>性别:</view>
-				<input v-model="person.name" />
+			<view class="item">
+				<view class="l">性别:</view>
+				<input class="r" v-model="person.genderName" :disabled="enable" />
 			</view>
-			<view class="flex item">
-				<view>年龄:</view>
-				<input v-model="person.name" />
+			<view class="item">
+				<view class="l">年龄:</view>
+				<input class="r" v-model="person.age" :disabled="enable" />
 			</view>
-			<view class="flex item">
-				<view>手机号:</view>
-				<input v-model="person.phone" />
+			<view class="item">
+				<view class="l">手机号:</view>
+				<input class="r" v-model="person.phone" :disabled="enable" />
 			</view>
-			<view class="flex item">
-				<view>互助组:</view>
-				<input v-model="person.name" />
+			<view class="item">
+				<view class="l">互助组:</view>
+				<input class="r" v-model="person.groupName" :disabled="enable" />
 			</view>
-			<view class="flex item">
-				<view>角色:</view>
-				<input v-model="person.name" />
+			<view class="item">
+				<view class="l">角色:</view>
+				<input class="r" v-model="person.roleName" :disabled="enable" />
 			</view>
-			<view class="flex item" style="border: none;">
-				<view>地址:</view>
-				<input v-model="person.name" />
+			<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" v-if="btnTitle=='编辑资料'" @click="edit">{{btnTitle}}</button>
 		</view>
 	</view>
 </template>
@@ -37,7 +44,10 @@
 	export default {
 		data() {
 			return {
-				person: {}
+				person: {},
+				enable: true,
+				btnTitle: '编辑资料',
+				name: ''
 			}
 		},
 		onLoad() {
@@ -53,10 +63,32 @@
 					}
 				});
 			},
+			edit(){
+				this.enable = false
+				this.btnTitle = '确认修改'
+				uni.showModal({
+					title: '请输入用户名',
+					editable: true,
+					placeholderText: '请输入用户名',
+					success: res => {
+						if(res.confirm){
+							this.name = res.content
+							this.updateUser()
+						}
+					}
+				})
+			},
 			// 修改个人信息
 			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: '修改成功',
@@ -87,5 +119,14 @@
 		display: flex;
 		align-items: center;
 		border-bottom: 1px #dcdcdc solid;
+		.l{
+			flex: 4;
+		}
+		.r{
+			flex: 10;
+		}
+	}
+	.btn{
+		width: 80%;
 	}
 </style>