wkw il y a 7 mois
Parent
commit
6b89e622b3
1 fichiers modifiés avec 174 ajouts et 160 suppressions
  1. 174 160
      package/jobIntention/basicInfo.vue

+ 174 - 160
package/jobIntention/basicInfo.vue

@@ -5,11 +5,12 @@
 		<view class="form-content">
 			<!-- 头像 -->
 			<view class="form-item">
-				<view class="form-label">头像(为了更换头像需要访问您的相册和摄像头)</view>
+				<view class="form-label">头像</view>
 				<view @click="chooseAvatar" class="avatar-container">
 					<image :src="avatar?avatar:'../../static/logo.png'" class="user-avatar" mode="aspectFill"></image>
 					<view class="edit-avatar-icon">
-						<image src="../../static/images/index/Combined-Shape.svg" style="width: 32rpx;height: 32rpx;" mode=""></image>
+						<image src="../../static/images/index/Combined-Shape.svg" style="width: 32rpx;height: 32rpx;"
+							mode=""></image>
 					</view>
 				</view>
 			</view>
@@ -44,7 +45,7 @@
 			<!-- 微信号码 -->
 			<view class="form-item">
 				<view class="form-label">微信号码</view>
-				<input class="form-input" type="text" placeholder="请输入微信号码,方便给求职者交换微信联系" v-model="weChatNum"/>
+				<input class="form-input" type="text" placeholder="请输入微信号码,方便给求职者交换微信联系" v-model="weChatNum" />
 			</view>
 
 			<!-- 出生年月 -->
@@ -57,14 +58,9 @@
 					<text class="date-text">{{ birthDateText }}</text>
 					<u-icon name="arrow-down" color="#999" size="24"></u-icon>
 				</view>
-				
-				<u-picker 
-					:default-time="birthDateText"
-					v-model="showDatePicker" 
-					mode="time" 
-					:params="dateParams"
-					@confirm="onDateConfirm"
-				></u-picker>
+
+				<u-picker :default-time="birthDateText" v-model="showDatePicker" mode="time" :params="dateParams"
+					@confirm="onDateConfirm"></u-picker>
 			</view>
 
 			<!-- 求职状态 -->
@@ -84,25 +80,22 @@
 		<view @click="messagebtn" class="save-button">
 			<text class="save-text">保存</text>
 		</view>
-		
+
 		<!-- 求职状态选择器 -->
-		<u-popup v-model="showJobStatusModal" mode="bottom" border-radius="42" height="auto" :safe-area-inset-bottom="true">
+		<u-popup v-model="showJobStatusModal" mode="bottom" border-radius="42" height="auto"
+			:safe-area-inset-bottom="true">
 			<view class="job-status-picker">
 				<view class="picker-header">
 					<text class="picker-title">求职状态</text>
 				</view>
-				
+
 				<view class="picker-content">
-					<view 
-						class="status-option" 
-						:class="{ active: selectedJobStatus == item.value }"
-						v-for="item in jobStatusList" 
-						:key="item.value"
-						@click="selectJobStatus(item)"
-					>
+					<view class="status-option" :class="{ active: selectedJobStatus == item.value }"
+						v-for="item in jobStatusList" :key="item.value" @click="selectJobStatus(item)">
 						<view class="option-left">
 							<view class="radio-btn" :class="{ checked: selectedJobStatus == item.value }">
-								<u-icon v-if="selectedJobStatus == item.value" name="checkmark" color="#ffffff" size="28"></u-icon>
+								<u-icon v-if="selectedJobStatus == item.value" name="checkmark" color="#ffffff"
+									size="28"></u-icon>
 							</view>
 							<text class="option-text">{{ item.text }}</text>
 							<view v-if="item.recommended" class="recommend-tag">
@@ -113,6 +106,12 @@
 				</view>
 			</view>
 		</u-popup>
+		<!-- 权限说明弹窗 -->
+		<u-popup mode="top" ref="permission">
+			<view class="popup-content">
+				<view class="popup-text" :style="{ paddingTop: 30 + BarHeight + 'px' }">选择/拍摄照片需要相机/相册权限,用于上传用户头像</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -120,18 +119,18 @@
 	import navBar from "@/components/nav-bar/index.vue";
 	export default {
 		components: {
-		  navBar,
+			navBar,
 		},
 		data() {
 			return {
-				statusBarHeight: 0, // 状态栏高度
-				weChatNum :''	,	
-				sex : '',
-				age :'',
-				phone :'',
-				avatar :'',
-				ifExp:0,
-				userName :'',
+				BarHeight: '',
+				weChatNum: '',
+				sex: '',
+				age: '',
+				phone: '',
+				avatar: '',
+				ifExp: 0,
+				userName: '',
 				birthDateText: '1991-11-29', // 显示的日期文本
 				showDatePicker: false, // 控制日期选择器显示
 				dateParams: {
@@ -142,8 +141,7 @@
 				// 求职状态相关
 				showJobStatusModal: false,
 				selectedJobStatus: 0,
-				jobStatusList: [
-					{
+				jobStatusList: [{
 						value: '0',
 						text: '离职-随时到岗',
 						recommended: true
@@ -166,17 +164,18 @@
 				]
 			}
 		},
-		onLoad(options){
-			// 获取状态栏高度
+		onLoad(options) {
+			// #ifdef APP-PLUS
 			let systemInfo = uni.getSystemInfoSync();
-			this.statusBarHeight = systemInfo.statusBarHeight || 0;
-			if(options&&options.resumesStatus)
-				this.selectedJobStatus=options.resumesStatus
-			if(options&&options.birthday)
-				this.birthDateText=options.birthday
-			if(options&&options.ifExp)
-				this.ifExp=options.ifExp
-			if(options&&options.resumesPhone)
+			this.BarHeight = systemInfo.statusBarHeight;
+			// #endif
+			if (options && options.resumesStatus)
+				this.selectedJobStatus = options.resumesStatus
+			if (options && options.birthday)
+				this.birthDateText = options.birthday
+			if (options && options.ifExp)
+				this.ifExp = options.ifExp
+			if (options && options.resumesPhone)
 				this.phone = options.resumesPhone
 			this.getUserInfo()
 		},
@@ -185,43 +184,45 @@
 				uni.navigateBack();
 			},
 			// 选择头像
-			chooseAvatar() {
-				var that=this
-				
-					// 1. 先判断系统类型,区分Android/iOS权限
-								const systemInfo = uni.getSystemInfoSync();
-								const isAndroid = systemInfo.system.includes('Android');
-								const permissionType = isAndroid ? 'storage' : 'photos'; // Android=存储,iOS=相册
-									  
-								// 2. 权限检查(复用之前封装的 checkPermission 函数)
-								const hasPermission = this.$queue.checkPermission(
-								  permissionType,
-								  isAndroid 
-								    ? '选择/拍摄照片需要相机/相册权限,用于上传用户头像' // Android 专属提示
-								    : '选择/拍摄照片需要相机/相册权限,用于上传消用户头像'
-								);
-									  
-								if (!hasPermission) {
-								  uni.showToast({ title: '未获取权限,无法选择照片', icon: 'none' });
-								  return;
-								}
-				
-			  uni.chooseImage({
-			    count: 1,
-			    sizeType: ["compressed"],
-			    sourceType: ["album", "camera"],
-			    success: (res) => {
-					console.log(res.tempFilePaths[0])
-				  that.$queue.uploadFile(res.tempFilePaths[0],function(path){
-					  if(path)
-						that.avatar = path;
-				  })
-			    },
-			  });
+			async chooseAvatar() {
+				// 1. 检查权限状态
+				const hasPermission = await this.$queue.checkPermission(
+					'camera',
+					'选择/拍摄照片需要相机/相册权限,用于上传用户头像',
+					this
+				);
+
+				// 2. 如果未授权或者用户拒绝,显示提示
+				if (!hasPermission) {
+					return;
+				}
+
+				// 3. 调用系统选择图片(系统弹框会出现,让用户授权)
+				uni.chooseImage({
+					count: 1,
+					sizeType: ['compressed'],
+					sourceType: ['album', 'camera'],
+					success: (res) => {
+						// 上传图片
+						this.$queue.uploadFile(res.tempFilePaths[0], (path) => {
+							if (path) this.avatar = path;
+						});
+						// 上传成功隐藏提示
+						this.$refs.permission.close();
+					},
+					fail: (err) => {
+						console.log('用户拒绝或取消选择', err);
+						// 用户拒绝仍然保持提示文字
+					}
+				});
 			},
 			// 日期选择确认
 			onDateConfirm(e) {
-				const { year, month, day } = e;
+				const {
+					year,
+					month,
+					day
+				} = e;
 				this.birthDateText = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
 				this.showDatePicker = false;
 			},
@@ -233,7 +234,7 @@
 			selectJobStatus(item) {
 				this.selectedJobStatus = item.value;
 				this.showJobStatusModal = false;
-				
+
 				// 可以在这里添加保存状态的逻辑
 				console.log('选择的求职状态:', item);
 			},
@@ -249,8 +250,8 @@
 					}
 					uni.hideLoading();
 				});
-			
-			
+
+
 			},
 			// 保存
 			messagebtn() {
@@ -266,13 +267,13 @@
 						title: "联系电话不能为空",
 						icon: "none"
 					})
-				} else if(!this.birthDateText){
+				} else if (!this.birthDateText) {
 					uni.showToast({
 						title: "生日不能为空",
 						icon: "none"
 					})
-				}else{
-					this.age=this.$queue.calculateAgeFromBirthday(this.birthDateText)||0
+				} else {
+					this.age = this.$queue.calculateAgeFromBirthday(this.birthDateText) || 0
 					let that = this
 					uni.showModal({
 						title: '温馨提示',
@@ -284,7 +285,7 @@
 									avatar: that.avatar,
 									sex: that.sex,
 									age: that.age,
-									weChatNum:that.weChatNum
+									weChatNum: that.weChatNum
 								}).then(res => {
 									if (res.code === 0) {
 										uni.showToast({
@@ -305,26 +306,26 @@
 				}
 			},
 			setResume() {
-				let data={
-					resumesStatus:this.selectedJobStatus,
+				let data = {
+					resumesStatus: this.selectedJobStatus,
 					resumesPhone: this.phone,
-					birthday:this.birthDateText,
-					ifExp:this.ifExp
+					birthday: this.birthDateText,
+					ifExp: this.ifExp
 				}
-			  this.$Request.postJson("/app/userFirst/regist", data).then((res) => {
-			    if (res.code == 0) {
-			        // 实际开发中可以在这里添加跳转逻辑
-					uni.$emit('updateResume')
-					setTimeout(function() {
-						uni.navigateBack()
-					}, 1000)
-			    } else {
-			      uni.showToast({
-			        title: res.msg,
-			        icon: "none",
-			      });
-			    }
-			  });
+				this.$Request.postJson("/app/userFirst/regist", data).then((res) => {
+					if (res.code == 0) {
+						// 实际开发中可以在这里添加跳转逻辑
+						uni.$emit('updateResume')
+						setTimeout(function() {
+							uni.navigateBack()
+						}, 1000)
+					} else {
+						uni.showToast({
+							title: res.msg,
+							icon: "none",
+						});
+					}
+				});
 			}
 		}
 	}
@@ -337,6 +338,7 @@
 		display: flex;
 		flex-direction: column;
 	}
+
 	// 表单内容
 	.form-content {
 		padding: 0 40rpx;
@@ -344,50 +346,51 @@
 		display: flex;
 		flex-direction: column;
 		overflow: auto;
+
 		.form-item {
 			margin-bottom: 30rpx;
-			
+
 			.form-label {
-                color: var(--Neutral/100, rgba(31, 44, 55, 1));
-                font-family: DM Sans;
-                font-size: 16px;
-                font-weight: 500;
-                line-height: 22px;
-                letter-spacing: 0.5%;
-                text-align: left;
+				color: var(--Neutral/100, rgba(31, 44, 55, 1));
+				font-family: DM Sans;
+				font-size: 16px;
+				font-weight: 500;
+				line-height: 22px;
+				letter-spacing: 0.5%;
+				text-align: left;
 				display: flex;
 				align-items: center;
 				margin-bottom: 20rpx;
-				
+
 				.required-mark {
 					color: #FF3B30;
 					font-size: 18px;
 					font-weight: 600;
 					margin-right: 8rpx;
 				}
-				
+
 				text {
-                    color: var(--Neutral/100, rgba(31, 44, 55, 1));
-                    font-family: DM Sans;
-                    font-size: 16px;
-                    font-weight: 500;
-                    line-height: 22px;
-                    letter-spacing: 0.5%;
-                    text-align: left;
+					color: var(--Neutral/100, rgba(31, 44, 55, 1));
+					font-family: DM Sans;
+					font-size: 16px;
+					font-weight: 500;
+					line-height: 22px;
+					letter-spacing: 0.5%;
+					text-align: left;
 				}
 			}
-			
+
 			.form-input {
 				width: 100%;
-                height: 75rpx;
+				height: 75rpx;
 				font-size: 14px;
-                border: 1px solid rgba(227, 231, 236, 1);
-                border-radius: 24px;
+				border: 1px solid rgba(227, 231, 236, 1);
+				border-radius: 24px;
 				color: rgba(23, 23, 37, 1);
-                padding: 0 16px;
+				padding: 0 16px;
 				box-sizing: border-box;
 			}
-			
+
 			.form-display {
 				color: rgba(23, 23, 37, 1);
 				font-family: DM Sans;
@@ -396,20 +399,20 @@
 				line-height: 22px;
 				letter-spacing: 0%;
 				text-align: left;
-                padding: 15px 0px;
+				padding: 15px 0px;
 			}
-			
+
 			// 头像样式
 			.avatar-container {
 				position: relative;
 				display: inline-block;
-				
+
 				.user-avatar {
 					width: 80rpx;
 					height: 80rpx;
 					border-radius: 50%;
 				}
-				
+
 				.edit-avatar-icon {
 					position: absolute;
 					bottom: 10rpx;
@@ -420,11 +423,11 @@
 					display: flex;
 					align-items: center;
 					justify-content: center;
-					box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
+					box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
 				}
 			}
-			
-			
+
+
 			// 日期选择器样式
 			.date-picker {
 				display: flex;
@@ -436,7 +439,7 @@
 				border-radius: 24px;
 				color: rgba(23, 23, 37, 1);
 				padding: 12px 16px;
-				
+
 				.date-text {
 					color: rgba(23, 23, 37, 1);
 					font-family: DM Sans;
@@ -447,7 +450,7 @@
 					text-align: left;
 				}
 			}
-			
+
 			// 下拉选择器样式
 			.select-picker {
 				display: flex;
@@ -459,7 +462,7 @@
 				border-radius: 24px;
 				color: rgba(23, 23, 37, 1);
 				padding: 12px 16px;
-				
+
 				.select-text {
 					color: rgba(23, 23, 37, 1);
 					font-family: DM Sans;
@@ -476,38 +479,38 @@
 	// 保存按钮
 	.save-button {
 		// position: fixed;
-		
+
 		// left: 0;
 		// right: 0;
 		height: 120rpx;
-        margin: 0 60rpx 60rpx;
-        border-radius: 24px;
+		margin: 0 60rpx 60rpx;
+		border-radius: 24px;
 		background: #007AFF;
 		display: flex;
 		align-items: center;
 		justify-content: center;
-		
+
 		.save-text {
-            color: rgba(255, 255, 255, 1);
-            font-family: DM Sans;
-            font-size: 18px;
-            font-weight: 400;
-            line-height: 24px;
-            letter-spacing: 0.5%;
-            text-align: left;
+			color: rgba(255, 255, 255, 1);
+			font-family: DM Sans;
+			font-size: 18px;
+			font-weight: 400;
+			line-height: 24px;
+			letter-spacing: 0.5%;
+			text-align: left;
 		}
 	}
-	
+
 	// 求职状态选择器样式
 	.job-status-picker {
 		background: #fff;
 		border-radius: 42rpx 42rpx 0 0;
-		
+
 		.picker-header {
 			padding: 40rpx 40rpx 20rpx 40rpx;
 			text-align: center;
 			border-bottom: 1px solid #f0f0f0;
-			
+
 			.picker-title {
 				color: rgba(23, 23, 37, 1);
 				font-family: DM Sans;
@@ -518,26 +521,26 @@
 				text-align: center;
 			}
 		}
-		
+
 		.picker-content {
 			padding: 20rpx 40rpx 40rpx 40rpx;
-			
+
 			.status-option {
 				padding: 30rpx 0;
 				border-bottom: 1px solid #f0f0f0;
-				
+
 				&:last-child {
 					border-bottom: none;
 				}
-				
+
 				&.active {
 					background-color: rgba(0, 122, 255, 0.05);
 				}
-				
+
 				.option-left {
 					display: flex;
 					align-items: center;
-					
+
 					.radio-btn {
 						width: 40rpx;
 						height: 40rpx;
@@ -547,13 +550,13 @@
 						align-items: center;
 						justify-content: center;
 						margin-right: 20rpx;
-						
+
 						&.checked {
 							background-color: #007AFF;
 							border-color: #007AFF;
 						}
 					}
-					
+
 					.option-text {
 						flex: 1;
 						color: rgba(23, 23, 37, 1);
@@ -564,13 +567,13 @@
 						letter-spacing: 0%;
 						text-align: left;
 					}
-					
+
 					.recommend-tag {
 						background-color: #007AFF;
 						border-radius: 8rpx;
 						padding: 4rpx 12rpx;
 						margin-left: 16rpx;
-						
+
 						text {
 							color: #fff;
 							font-family: DM Sans;
@@ -585,4 +588,15 @@
 			}
 		}
 	}
-</style>
+
+	// 权限弹窗页面
+	.popup-content {
+		height: 100vh;
+
+		.popup-text {
+			font-size: 32rpx;
+			padding-left: 32rpx;
+			padding-right: 32rpx;
+		}
+	}
+</style>