Bladeren bron

修改信息

YY 2 jaren geleden
bovenliggende
commit
244d1d1572
2 gewijzigde bestanden met toevoegingen van 49 en 47 verwijderingen
  1. 0 1
      pagesMy/account/bindEmail.vue
  2. 49 46
      pagesMy/account/upBasic.vue

+ 0 - 1
pagesMy/account/bindEmail.vue

@@ -13,7 +13,6 @@
 				</uni-forms>
 				<view class="btn">
 					<button type="primary" @click="onSubmit('form')" size="small">立即绑定</button>
-					<view class="name">提示:为了您的账户安全,建议定期修改密码</view>
 				</view>
 			</view>
 		</view>

+ 49 - 46
pagesMy/account/upBasic.vue

@@ -6,8 +6,11 @@
 					<uni-forms-item label="头像" name="icon">
 						<upload :list="icon" name="icon" :count="1" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
 					</uni-forms-item>
-					<uni-forms-item label="真实姓名" name="name">
-						<uni-easyinput type="text" v-model="form.name" placeholder="请输入真实姓名" />
+					<uni-forms-item label="用户名" name="name">
+						<uni-easyinput type="text" v-model="form.name" placeholder="请输入用户名" />
+					</uni-forms-item>
+					<uni-forms-item label="手机号" name="phone">
+						<uni-easyinput type="text" v-model="form.phone" placeholder="请输入手机号" />
 					</uni-forms-item>
 					<uni-forms-item label="性别" name="gender">
 						<picker @change="genderChange" name="gender" :value="form.gender" :range="genderList"
@@ -15,19 +18,15 @@
 							<view class="uni-input">{{form.zhGender||'请选择性别'}}</view>
 						</picker>
 					</uni-forms-item>
-					<uni-forms-item label="生日" name="date">
-						<picker mode="date" :value="form.date" name="date" :start="startDate" :end="endDate"
+					<uni-forms-item label="生日" name="birth">
+						<picker mode="date" :value="form.birth" name="birth" :start="startDate" :end="endDate"
 							@change="bindDateChange">
-							<view class="uni-input">{{form.date||'请选择日期'}}</view>
+							<view class="uni-input">{{form.birth||'请选择日期'}}</view>
 						</picker>
 					</uni-forms-item>
-					<uni-forms-item label="昵称" name="Nname">
-						<uni-easyinput type="text" v-model="form.Nname" placeholder="请输入昵称" />
-					</uni-forms-item>
 				</uni-forms>
 				<view class="btn">
 					<button type="primary" @click="onSubmit('form')" size="small">提交</button>
-					<view class="name">提示:为了您的账户安全,建议定期修改密码</view>
 				</view>
 			</view>
 		</view>
@@ -51,13 +50,13 @@
 					name: {
 						rules: [{
 							required: true,
-							errorMessage: '请输入真实姓名',
+							errorMessage: '请输入用户名',
 						}]
 					},
-					num: {
+					phone: {
 						rules: [{
 							required: true,
-							errorMessage: '请输入邮箱验证码',
+							errorMessage: '请输入手机号',
 						}]
 					},
 				},
@@ -87,14 +86,23 @@
 				const that = this;
 				uni.getStorage({
 					key: 'token',
-					success: (res) => {
+					success: async (res) => {
 						let user = that.$jwt(res.data);
 						if (user) {
-							console.log(user);
-							// that.$set(that, `form`, {
-							// 	id: user.id,
-							// 	phone: user.phone
-							// })
+							const arr = await that.$api(`/user/${user.id}`, 'GET');
+							if (arr.errcode == '0') {
+								let gender = that.genderList.find(i => i.value == arr.data
+									.gender)
+								if (gender) arr.data.zhGender = gender.label;
+								that.$set(that, `form`, arr.data)
+								that.$set(that, `icon`, arr.data.icon)
+							} else {
+								uni.showToast({
+									title: arr.errmsg,
+									icon: 'error',
+									duration: 2000
+								});
+							}
 						}
 					},
 					fail: (err) => {}
@@ -128,38 +136,33 @@
 			},
 			// 选择日期
 			bindDateChange(e) {
-				// this.date = e.detail.value
 				const that = this;
-				that.$set(that.form, `date`, e.detail.value);
+				that.$set(that.form, `birth`, e.detail.value);
+			},
+			// 返回
+			back() {
+				uni.navigateBack({
+					delta: 1
+				})
 			},
 			// 提交保存
-			onSubmit() {
+			onSubmit(ref) {
 				const that = this;
-				let data = that.form;
-				data.logo = that.logo;
-				console.log(data);
-				// this.$refs.form.validate().then(async (res) => {
-				// let arr;
-				// if (data._id) {
-				// 	arr = await that.$api(``, 'POST', data)
-				// } else {
-				// 	arr = await that.$api(``, 'POST', data)
-				// }
-				// if (arr.errcode == '0') {
-				// 	uni.showToast({
-				// 		title: `维护信息成功`,
-				// 		icon: 'success',
-				// 		duration: 2000
-				// 	});
-				// 	that.back()
-				// } else {
-				// 	uni.showToast({
-				// 		title: arr.errmsg,
-				// 		icon: 'error',
-				// 		duration: 2000
-				// 	})
-				// }
-				// })
+				that.$refs[ref].validate().then(async params => {
+					params.icon = that.icon
+					const arr = await that.$api(`/user/${that.form.id}`, 'POST', params);
+					if (arr.errcode == '0') {
+						uni.showToast({
+							title: `维护信息成功`,
+							icon: 'success',
+						});
+						that.back();
+					} else {
+						uni.showToast({
+							title: arr.errmsg,
+						})
+					}
+				})
 			},
 		}
 	}