Explorar o código

新加个人资料

Qukatie hai 7 meses
pai
achega
6220936dfe
Modificáronse 6 ficheiros con 150 adicións e 23 borrados
  1. 4 4
      http/api.js
  2. 24 12
      pages/login/index.vue
  3. 6 1
      pages/me/index.vue
  4. 4 5
      pages/me/storeInfo.vue
  5. 112 0
      pages/me/userInfo.vue
  6. 0 1
      uni_modules/uni-scss/index.scss

+ 4 - 4
http/api.js

@@ -81,7 +81,7 @@ http.interceptors.response.use((response) => {
 		return response.data
 	}
 	// 服务端返回的状态码不等于200,则reject()
-	if (response.data.code !== 200 && response.data.code !== 601) {
+	if (response.data.code !== 200) {
 		console.log(response.data.code)
 
 		if (response.data.code === 400) {
@@ -112,7 +112,7 @@ http.interceptors.response.use((response) => {
 	}
 	return response.data;
 }, (response) => {
-	if (!response.statusCode ||response.statusCode === 0 ) {
+	if (response.statusCode === 0 || !response.statusCode) {
 		uni.showToast({
 			title: '网络连接中断,请检查网络设置',
 			icon: 'none',
@@ -121,7 +121,7 @@ http.interceptors.response.use((response) => {
 		return Promise.reject(response);
 	}
 	/*  对响应错误做点什么 (statusCode !== 200)*/
-	if (response.data.code === 401&& !isTokenExpireds) {
+	if (response.data.code === 401) {
 		isTokenExpired = true;
 		uni.showModal({
 			title: '提示',
@@ -166,4 +166,4 @@ http.interceptors.response.use((response) => {
 	}
 	return Promise.reject(response.data)
 })
-export default http;
+export default http;

+ 24 - 12
pages/login/index.vue

@@ -14,7 +14,7 @@
 			</view>
 
 			<view class="t-login">
-				<button  open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
+				<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
 					style="background-color:#0F974C;color:#ffffff ;">
 					授权手机号登录
 				</button>
@@ -22,11 +22,11 @@
 		</view>
 		<div style="margin-top: 20rpx;display: flex;justify-content: center;">
 			<view style="margin-top: 2px;">
-				<u-checkbox-group v-model="checkboxValue1" placement="column" >
-					<u-checkbox :customStyle="{marginBottom: '8px'}"  label="我已阅读" labelColor='#000000'></u-checkbox>
+				<u-checkbox-group v-model="checkboxValue1" placement="column">
+					<u-checkbox :customStyle="{marginBottom: '8px'}" label="我已阅读" labelColor='#000000'></u-checkbox>
 				</u-checkbox-group>
 			</view>
-			<view >
+			<view>
 				<text style="color: #73a8fc;" @click="tiaozhuanxieyi">《 用户协议 》</text>
 			</view>
 		</div>
@@ -52,12 +52,12 @@
 				checked: false,
 				lifeData: {},
 				checkboxValue1: [],
-        storeId: '',
+				storeId: '',
 			}
 		},
 		onLoad(options) {
-      this.storeId = options.scene
-      console.info('options----', options)
+			this.storeId = options.scene
+			console.info('options----', options)
 			if (options) {
 				uni.setStorageSync('QRcodeDate', options);
 			}
@@ -98,18 +98,30 @@
 											telCode: e.detail.code,
 											loginCode: res.code,
 										}).then(rest => {
-                      console.info('rest----', rest)
-											uni.setStorageSync('phoneInfo',rest.data.phoneNumber)
+											console.info('rest----', rest)
+											uni.setStorageSync('phoneInfo', rest.data
+												.phoneNumber)
 											uni.showLoading({
 												title: '登录中',
 												mask: true
 											});
+
+											console.log({
+												phone: rest.data.phoneNumber,
+												union_id: rest.data.unionid,
+												open_id: rest.data.openid,
+												storeId: this_.storeId,
+												applets_id: uni.getAccountInfoSync()
+													.miniProgram.appId,
+												// password: md5('123456')
+											}, 'login');
 											this_.$u.api.wechartToken({
 												phone: rest.data.phoneNumber,
 												union_id: rest.data.unionid,
 												open_id: rest.data.openid,
-												storeId: this.storeId,
-												applets_id: uni.getAccountInfoSync().miniProgram.appId,
+												storeId: this_.storeId,
+												applets_id: uni.getAccountInfoSync()
+													.miniProgram.appId,
 												// password: md5('123456')
 											}).then(data => {
 												uni.hideLoading();
@@ -305,4 +317,4 @@
 		height: 0;
 		content: '\20';
 	}
-</style>
+</style>

+ 6 - 1
pages/me/index.vue

@@ -14,7 +14,7 @@
 		</view>
 		<view class="card" style="margin-top: 20rpx;display: flex;align-items: center;">
 			<u-cell-group :border="false">
-				<u-cell title="个人资料" :clickable="true" @click="clickMeans">
+				<u-cell title="个人资料" :clickable="true" @click="allClick('个人资料')">
 					<view slot="icon">
 						<image src="/static/images/me/100.png" style="width:26rpx;height: 27rpx;margin-right: 10rpx;"
 							mode="scaleToFill">
@@ -156,6 +156,11 @@
 						url: '/pages/me/storeInfo'
 					});
 				}
+				if(name=='个人资料'){
+					uni.navigateTo({
+						url: '/pages/me/userInfo'
+					});
+				}
 			}
 		}
 	}

+ 4 - 5
pages/me/storeInfo.vue

@@ -8,22 +8,21 @@
 					<view class="tab-bar-item">
 						<view class="text">
 							<view class="text_content">
-								<text style="color: #03803B;width: 120rpx;">店铺名称:</text>
+								<text style="color: #03803B;width: 140rpx;">店铺名称:</text>
 								<text style="color: #6A6A6A">{{item.storeName||'暂无门店'}}</text>
 							</view>
 							<view class="text_content">
-								<text style="color: #03803B;width: 120rpx;">联系人:</text>
+								<text style="color: #03803B;width: 140rpx;">联系人:</text>
 								<text style="color: #6A6A6A">{{item.storeContact||'暂无联系人'}}</text>
-
 							</view>
 							<view class="text_content">
 								
-								<text style="color: #03803B;width: 120rpx;">地址:</text>
+								<text style="color: #03803B;width: 140rpx;">地址:</text>
 								<text style="color: #6A6A6A;text-align: right;">{{item.storeAddress||'暂无地址'}}</text>
 
 							</view>
 							<view class="text_content">
-								<text style="color: #03803B;width: 120rpx;">电话:</text>
+								<text style="color: #03803B;width: 140rpx;">电话:</text>
 								<text style="color: #6A6A6A">{{item.storePhone||'暂无电话'}}</text>
 							</view>
 						</view>

+ 112 - 0
pages/me/userInfo.vue

@@ -0,0 +1,112 @@
+<template>
+	<view>
+		<view style="padding: 0 62rpx;background-color: #ffffff;">
+			<uni-forms ref="form" :modelValue="form" :border="true" label-width="80">
+				<uni-forms-item name="consumerName" label="头像">
+					<view style="display: flex;justify-content: flex-end;">
+						<image :src="form.avatar||avatarUrl" style="width:100rpx;height: 100rpx;border-radius: 50%;"
+							mode="scaleToFill" @click="showActionSheet">
+						</image>
+					</view>
+				</uni-forms-item>
+				<uni-forms-item name="consumerName" label="用户名">
+					<uni-easyinput v-model="form.consumerName" class="right-align" placeholder-class="placeholder-right"
+						placeholder="请输入用户名" :inputBorder="false" :clearable="false"></uni-easyinput>
+				</uni-forms-item>
+				<uni-forms-item name="consumerPhone" label="手机号">
+					<uni-easyinput v-model="form.consumerPhone" class="right-align"
+						placeholder-class="placeholder-right" placeholder=" " :inputBorder="false" :disabled="true"
+						:clearable="false"></uni-easyinput>
+				</uni-forms-item>
+			</uni-forms>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				avatarUrl: '/static/images/me/head.png',
+				tempFilePaths: [],
+				form: {}
+			}
+		},
+		onLoad() {
+
+		},
+		methods: {
+			showActionSheet() {
+				uni.showActionSheet({
+					itemList: ['拍照', '从相册选择'],
+					success: (res) => {
+						if (res.tapIndex === 0) {
+							this.chooseMedia('camera')
+						} else {
+							this.chooseMedia('album')
+						}
+					}
+				})
+			},
+			chooseMedia(sourceType) {
+				uni.chooseMedia({
+					count: 1,
+					mediaType: ['image'],
+					sourceType: [sourceType],
+					sizeType: ['original', 'compressed'],
+					camera: 'front',
+					success: (res) => {
+						// this.avatarUrl = res.tempFiles[0].tempFilePath
+						this.tempFilePaths = res.tempFiles.map(file => file.tempFilePath)
+						this.uploadFiles()
+					},
+					fail: (err) => {
+						console.log(err)
+					},
+				})
+			},
+			uploadFiles() {
+				const uploadTasks = this.tempFilePaths.map((filePath, index) => {
+					return new Promise((resolve, reject) => {
+						uni.uploadFile({
+							url: 'https://lt.echepei.com/api/blade-resource/oss/endpoint/put-file',
+							filePath: filePath,
+							name: 'file',
+							header: {
+								'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken'),
+								appId: uni.getAccountInfoSync().miniProgram.appId
+							},
+							success: (uploadRes) => {
+								let obj = {
+									id: this.userData.userId,
+									avatar: JSON.parse(uploadRes.data).data.link
+								}
+								// updateUserAvatar(obj).then(res => {
+								// 	uni.showToast({
+								// 		title: "上传成功",
+								// 		icon: "none",
+								// 		mask: true
+								// 	});
+								// 	this.getUserData()
+								// })
+							},
+							fail: (err) => {
+								reject(err)
+							}
+						})
+					})
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	// ::v-deep .uni-section {
+	// 	padding: 0 62rpx;
+	// }
+	::v-deep .uni-forms-item.is-direction-left {
+
+		align-items: center !important;
+	}
+</style>

+ 0 - 1
uni_modules/uni-scss/index.scss

@@ -70,7 +70,6 @@
 	}
 	.uni-easyinput__content-input{
 		text-align: right !important;
-		color:#B5B4B4;
 	}
 	.uni-easyinput__content-textarea{
 		text-align: right !important;