zhengkaixin 4 yıl önce
ebeveyn
işleme
6807feb8df
4 değiştirilmiş dosya ile 62 ekleme ve 3 silme
  1. 9 1
      apis/my.js
  2. 5 0
      pages/my/index.js
  3. 47 1
      pages/my/user/updateinfo.js
  4. 1 1
      pages/my/user/updateinfo.vue

+ 9 - 1
apis/my.js

@@ -4,11 +4,19 @@ import Qs from 'qs';
 export function passengerRecordList(data) {
 	return request({
 		method: 'post',
-	data: Qs.stringify(data),
+		data: Qs.stringify(data),
 		url: '/mobile/passengerApi/passengerRecordList'
 	})
 }
 
+export function updateUserInfo(data) {
+	return request({
+		method: 'post',
+		data: Qs.stringify(data),
+		url: '/mobile/passengerApi/updateUserInfo'
+	})
+}
+
 
 export function problemFeedback(data) {
 	return request({

+ 5 - 0
pages/my/index.js

@@ -39,5 +39,10 @@ export default {
 			if(this.user.faceImage){
 					this.pic=this.user.faceImage;
 			}
+		},onShow(){
+			this.user=this.carhelp.getPersonInfo();
+			if(this.user.faceImage){
+					this.pic=this.user.faceImage;
+			}
 		}
 	}

+ 47 - 1
pages/my/user/updateinfo.js

@@ -1,3 +1,6 @@
+ import * as API_Common from '@/apis/common'
+ import * as WxJsApi from '@/utils/wxJsApi.js'
+ import * as API from '@/apis/my.js'
 export default {
 		data() {
 			return {
@@ -10,7 +13,48 @@ export default {
 			
 		},
 		methods: {
-			 
+			upload(){
+				WxJsApi.chooseImage(1).then(res=>{
+					var formData = {
+						'photoName': '1.jpg',
+						'photoFile': res.localData
+					}
+					
+						API_Common.upload(formData).then(response => {
+							
+							this.pic=response.data
+						
+							this.$refs.common.showLoading(false,"上传成功!")
+							
+						}).catch(error => {
+							this.$refs.common.showLoading(false,error)
+								
+						})
+				})
+			},
+			 submit(){
+				 if(!this.user.name){
+					 this.$refs.common.alert('用户名不能为空')
+					return 
+				 }
+				 this.$refs.common.showLoading();
+				 this.user.faceImage=this.pic;
+				 this.user.acceptMessage=(this.user.acceptMessage?1:0)
+				 API.updateUserInfo(this.user).then((res) => {
+					 this.carhelp.setPersonInfo(this.user);
+					 
+				 	this.$refs.common.setFnc(function(){
+				 		uni.switchTab({
+				 		    url: '/pages/my/index'
+				 		});
+				 	})
+				 	this.$refs.common.alert2("操作成功!");
+				 
+				 }).catch(error => {
+				 	this.$refs.common.showLoading(false,error);
+				 	
+				 })
+			 },
 			gotoUrl(url){
 				uni.navigateTo({
 					url:url
@@ -33,6 +77,8 @@ export default {
 				})
 			}
 		},onReady(){
+			
+			 WxJsApi.getWxConfig()
 			this.user=this.carhelp.getPersonInfo();
 			if(this.user.faceImage){
 					this.pic=this.user.faceImage;

+ 1 - 1
pages/my/user/updateinfo.vue

@@ -23,7 +23,7 @@
 		
 			<u-cell-item title="手机号码"  :arrow="false" >{{showphone(user.phone)}}</u-cell-item>
 			<u-cell-item title="人脸识别照片"  >
-				<u-avatar :src="pic" size="50"></u-avatar>
+				<u-avatar :src="pic" size="50" @click="upload"></u-avatar>
 				</u-cell-item>
 			
 		</u-cell-group>