Ver Fonte

修改头像

achao há 2 anos atrás
pai
commit
3d5c89db7d
1 ficheiros alterados com 81 adições e 32 exclusões
  1. 81 32
      xiaochengxu/pages/mySet/mySet.vue

+ 81 - 32
xiaochengxu/pages/mySet/mySet.vue

@@ -2,19 +2,21 @@
 	<view class="content">
 		<view class="content1 flex-between relative flex">
 			<view class="user flex">
-				<image :src="userInfo.head" mode="widthFix" class="img"></image>
+				<image :src="userInfo.head" mode="widthFix" class="img" @click="editHead"></image>
 				<view class="name">
 					{{userInfo.nickname}}
 				</view>
 			</view>
 			<view class="position">
-				<image v-if='list.length>1||list.length==0' @click='selectCard' src="../../static/imgs/mySet/share.png" mode="widthFix" class="right-img">
-				<button v-if='list.length==1' class="shareBtn" type="default" data-name="shareBtn" open-type="share">
-					<image src="../../static/imgs/mySet/share.png" mode="widthFix" class="right-img">
+				<image v-if='list.length>1||list.length==0' @click='selectCard' src="../../static/imgs/mySet/share.png"
+					mode="widthFix" class="right-img">
+					<button v-if='list.length==1' class="shareBtn" type="default" data-name="shareBtn"
+						open-type="share">
+						<image src="../../static/imgs/mySet/share.png" mode="widthFix" class="right-img">
+						</image>
+					</button>
+					<image @click='selectCard1' src="../../static/imgs/mySet/ewm.png" mode="widthFix" class="right-img">
 					</image>
-				</button>
-				<image @click='selectCard1' src="../../static/imgs/mySet/ewm.png" mode="widthFix" class="right-img">
-				</image>
 			</view>
 		</view>
 		<view class="content2">
@@ -46,6 +48,8 @@
 </template>
 
 <script>
+	var that;
+	import uploadImage from '@/components/ossutil/uploadFile.js';
 	import Poster from '../../components/zhangyuhao-poster/Poster.vue'
 	export default {
 		components: {
@@ -57,7 +61,7 @@
 				cardList: [],
 				canvasData: {},
 				currectData: {},
-				list:[],
+				list: [],
 				selectCode: '',
 				show: false,
 				clicknum: 0,
@@ -107,11 +111,12 @@
 				]
 			};
 		},
-		beforeDestroy(){
-			this.show=false
+		beforeDestroy() {
+			this.show = false
 		},
-		
+
 		onLoad() {
+			that = this
 			if (uni.getStorageSync("userInfo").phone) {
 				this.userInfo = uni.getStorageSync("userInfo")
 				this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
@@ -123,17 +128,17 @@
 					})
 					uni.hideLoading()
 				}).then(res => {
-					this.list=res.data.items
+					this.list = res.data.items
 					this.cardList = [res.data.items]
-					if(res.data.items.length>0){
-						if(!this.poster){
+					if (res.data.items.length > 0) {
+						if (!this.poster) {
 							this.cardChange({
 								value: this.cardList[[0]]
 							})
 						}
-						
+
 					}
-					
+
 				})
 			} else {
 				uni.switchTab({
@@ -161,33 +166,72 @@
 				return {
 					title: '名片Box',
 					path: '/pages/cardHolder/cardHolder',
-					imageUrl:''
+					imageUrl: ''
 				};
 			}
 		},
 		methods: {
+			editHead() {
+				uni.chooseImage({
+					count: 1,
+					sizeType: ['original', 'compressed'],
+					success: function(res) {
+						uploadImage(res.tempFilePaths[0], 'cardImages/',
+							result => {
+								that.userInfo.head = result
+								that.$request.baseRequest('commonUserApp', 'edit', {
+									commonUserInfo: JSON.stringify(that.userInfo)
+								}, failres => {
+									that.$refs.uToast.show({
+										type: 'error',
+										message: failres.errmsg,
+									})
+									uni.hideLoading()
+								}).then(res => {
+									uni.setStorageSync("userInfo", that.userInfo)
+									let params = {
+										type: 'success',
+										message: "修改成功",
+										url: '/pages/mySet/mySet'
+									}
+									that.$refs.uToast.show({
+										...params,
+										complete() {
+											params.url && uni.switchTab({
+												url: params.url
+											})
+										}
+									})
+								})
+							}
+						)
+					}
+				});
+			},
 			handleHiddenShare() {
 				this.popupshow = false
 			},
 			selectCard() {
-				if(this.cardList[0].length>0){
+				if (this.cardList[0].length > 0) {
 					this.show = true
-				}else if(this.cardList[0].length==0){
+				} else if (this.cardList[0].length == 0) {
 					this.$refs.uToast.show({
 						type: 'error',
 						message: '您还未创建名片',
 					})
 				}
-				
+
 			},
 			selectCard1() {
 				console.log(this.cardList[0])
-				if(this.cardList[0].length>1){
+				if (this.cardList[0].length > 1) {
 					this.show1 = true
-				}else if(this.cardList[0].length>0){
-					this.cardConfirm({value:this.cardList[[0]]})
+				} else if (this.cardList[0].length > 0) {
+					this.cardConfirm({
+						value: this.cardList[[0]]
+					})
 				}
-				
+
 			},
 			cardConfirm(e) {
 				console.log(e)
@@ -213,7 +257,8 @@
 					},
 					{
 						type: 'image',
-						path: this.currectData.headSculpture?this.currectData.headSculpture:'../../static/imgs/card/defaulthead.png',
+						path: this.currectData.headSculpture ? this.currectData.headSculpture :
+							'../../static/imgs/card/defaulthead.png',
 						shape: 'circle',
 						use: 'head',
 						x: 30,
@@ -506,7 +551,8 @@
 		}
 
 		.position {
-			display:flex;
+			display: flex;
+
 			.right-img {
 				width: 44rpx;
 				margin-left: 40rpx;
@@ -535,6 +581,7 @@
 
 			.row-right-img {
 				width: 12rpx;
+				height: auto;
 			}
 		}
 
@@ -556,13 +603,15 @@
 			border: none !important;
 		}
 	}
-	.shareBtn{
-		background:transparent;
+
+	.shareBtn {
+		background: transparent;
 		line-height: 1;
-		padding:0;
+		padding: 0;
 	}
-	.shareBtn::after{
-		border:none;
-		
+
+	.shareBtn::after {
+		border: none;
+
 	}
 </style>