Переглянути джерело

修改 搜索间距 添加头像编辑 昵称 编辑

achao 1 рік тому
батько
коміт
698e1f9d38

+ 10 - 1
uni_applet/pages.json

@@ -43,7 +43,16 @@
 
 		}
 
-	],
+	    ,{
+            "path" : "pages/my/editNickName",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "编辑昵称",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+    ],
 	"tabBar": {
 		"custom": false,
 		"color": "#656765",

+ 1 - 1
uni_applet/pages/food/food.vue

@@ -432,7 +432,7 @@
 			// color: #9199af;
 			// background: #f9d27d;
 			border-radius: 50rpx;
-			padding: 15rpx 0 15rpx 30rpx;
+			padding: 15rpx 0 15rpx 15rpx;
 			box-sizing: border-box;
 			margin-right: 20rpx;
 		

+ 84 - 0
uni_applet/pages/my/editNickName.vue

@@ -0,0 +1,84 @@
+<template>
+	<view class="content">
+		<view class="row1 flex">
+			<view class="left">
+				昵称
+			</view>
+			<u-input v-model="userInfo.nickname" :border="false" focus class="input" />
+		</view>
+		<view class="row2">
+			<view class="btn" @click="edit">
+				保存
+			</view>
+		</view>
+		<u-toast ref="uToast"></u-toast>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				value: '',
+				userInfo: {
+					nickname: ''
+				}
+			};
+		},
+		onLoad() {
+			this.userInfo = uni.getStorageSync("userInfo")
+		},
+		methods: {
+			edit() {
+				this.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
+					commonUserInfo: JSON.stringify(this.userInfo)
+				}, failres => {
+					uni.hideLoading()
+					uni.showToast({
+					  icon:"none",
+					  title: failres.errmsg,
+					  duration: 3000
+					});
+				}).then(res => {
+					this.userInfo = res.data
+					uni.setStorageSync("userInfo", this.userInfo)
+					uni.showToast({
+					  icon:"success",
+					  title: '修改成功!',
+					  duration: 2000,
+					  complete:function(){
+					    uni.switchTab({
+					      url: "/pages/my/my"
+					    })
+					  }
+					})
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.row1 {
+		background: #fff;
+		padding: 20rpx;
+	}
+
+	.input {
+		font-size: 28rpx;
+	}
+
+	.row2 {
+		padding: 20rpx;
+	}
+
+	.btn {
+		color: #fff;
+		padding: 20rpx;
+		border-radius: 8px;
+		background: #eaad1a;
+		text-align: center;
+		font-size: 36rpx;
+
+	}
+</style>

+ 54 - 9
uni_applet/pages/my/my.vue

@@ -4,19 +4,21 @@
 			<view class='flex userWrap justify-space-between'>
 				<view class='flex'>
 					<view style='margin-right:20rpx;'>
-						<u--image width='60' height='60' :src="userInfo.head" shape="circle"></u--image>
+						<u--image width='60' height='60' :src="userInfo.head" shape="circle" @click="editHead"></u--image>
 					</view>
 					<view>
 						<view class='flex'>
-							<view @click='login' v-if='!edit' style="font-weight: bold;font-size: 32rpx;">
+							<view @click='login' style="font-weight: bold;font-size: 32rpx;">
 								{{userInfo.nickname?userInfo.nickname:'请点击登录'}}
 							</view>
-							<view v-else> <u--input placeholder="请输入内容" border="bottom" v-model='userInfo.nickname'
-									clearable></u--input></view>
-							<u-icon v-if='!edit&&userInfo.phone' @click='edit = true' name="edit-pen-fill"
+						<!-- 	<view v-else>
+								<u--input placeholder="请输入内容" border="bottom" v-model='userInfo.nickname'
+									clearable></u--input>
+							</view> -->
+						<!-- 	<u-icon v-if='!edit&&userInfo.phone' @click='edit = true' name="edit-pen-fill"
 								color="#eaad1a" size="24"></u-icon>
 							<u-icon v-if='edit&&userInfo.phone' @click='editNickName' name="checkbox-mark"
-								color="#eaad1a" size="24"></u-icon>
+								color="#eaad1a" size="24"></u-icon> -->
 						</view>
 						<view>{{userInfo.phone1}}</view>
 					</view>
@@ -100,6 +102,8 @@
 </template>
 
 <script>
+	var that;
+		import uploadImage from '@/components/ossutil/uploadFile.js';
 	import loginPopUp from "@/components/loginPopUp/index.vue"
 	export default {
 		components: {
@@ -116,7 +120,7 @@
 			}
 		},
 		onLoad() {
-
+			that = this
 		},
 		onShow() {
 			if (!uni.getStorageSync("userInfo").phone) {
@@ -147,9 +151,50 @@
 				if (!uni.getStorageSync("userInfo").phone) {
 					this.$refs.loginpopup.open()
 				} else {
-
+					uni.navigateTo({
+						url: '/pages/my/editNickName'
+					})
 				}
-			}
+			},
+			editHead() {
+				if (this.userInfo.phone) {
+					uni.chooseImage({
+						count: 1,
+						sizeType: ['original', 'compressed'],
+						success: function(res) {
+							uploadImage(res.tempFilePaths[0], 'cardImages/',
+								result => {
+									that.userInfo.head = result
+									that.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
+										commonUserInfo: JSON.stringify(that.userInfo)
+									}, failres => {
+										uni.hideLoading()
+										uni.showToast({
+											icon: "none",
+											title: failres.errmsg,
+											duration: 3000
+										});
+									}).then(res => {
+										uni.setStorageSync("userInfo", that.userInfo)
+										uni.showToast({
+											icon: "success",
+											title: '修改成功!',
+											duration: 2000,
+											complete: function() {
+												uni.switchTab({
+													url: "/pages/my/my"
+												})
+											}
+										})
+									})
+								}
+							)
+						}
+					});
+				} else {
+					this.showAuthorizePhone = true
+				}
+			},
 		}
 	}
 </script>