Bläddra i källkod

修改样式及校验

yangg 1 månad sedan
förälder
incheckning
6e625cfe22
2 ändrade filer med 206 tillägg och 8 borttagningar
  1. 99 4
      pages/Personal/Personal.vue
  2. 107 4
      pages/job-detail/job-detail.vue

+ 99 - 4
pages/Personal/Personal.vue

@@ -143,7 +143,15 @@
 					</view>
 					<view class="form-item">
 						<text class="label">期望薪资(元/月)</text>
-						<input type="digit" v-model="formData.expectedSalary" placeholder="请输入期望薪资" />
+						<input 
+							type="number" 
+							v-model="formData.expectedSalary" 
+							placeholder="请输入期望薪资" 
+							@change="validateExpectedSalary"
+							:class="{'input-error': formErrors.expectedSalary}"
+							max="100000"
+						/>
+						<text v-if="formErrors.expectedSalary" class="error-message">{{formErrors.expectedSalary}}</text>
 					</view>
 				</view>	
 			</view>
@@ -392,16 +400,18 @@
 						placeholder="请描述您的专业技能" 
 						class="skills-textarea"
 						:class="{'input-error': formErrors.skills}"
+						maxlength="500"
 					></textarea>
 					<text v-if="formErrors.skills" class="error-message">{{formErrors.skills}}</text>
 				</view>
-				<view class="section-title" v-if="showRequireProfessionalSkillsField"><text class="required" style="margin-right: 4rpx;color: #ff4d4f;">*</text>受过的培训</view>
+				<view class="section-title" v-if="showRequireProfessionalSkillsField"><text class="required" style="margin-right: 4rpx;color: #ff4d4f;">*</text>培训经历</view>
 				<view class="training-container" v-if="showRequireProfessionalSkillsField">
 					<textarea 
 						v-model="formData.training" 
-						placeholder="请描述您接受过的培训经历" 
+						placeholder="请描述您接培训经历" 
 						class="training-textarea"
 						:class="{'input-error': formErrors.training}"
+						maxlength="500"
 					></textarea>
 					<text v-if="formErrors.training" class="error-message">{{formErrors.training}}</text>
 				</view>
@@ -510,6 +520,8 @@
 								v-model="workForm.employeeCount" 
 								placeholder="请输入单位人数"
 								:class="{'input-error': workErrors.employeeCount}"
+								max="10000"
+								@change="validateEmployeeCount"
 							/>
 							<text v-if="workErrors.employeeCount" class="error-message">{{workErrors.employeeCount}}</text>
 						</view>
@@ -541,7 +553,15 @@
 					<view class="form-row">
 						<view class="form-item" >
 							<text class="label required">月总收入</text>
-							<input type="number" v-model="workForm.monthlySalary" placeholder="请输入月总收入" />
+							<input 
+								type="number" 
+								v-model="workForm.monthlySalary" 
+								placeholder="请输入月总收入"
+								:class="{'input-error': workErrors.monthlySalary}"
+								max="100000"
+								min="0"
+								@input="validateMonthlySalary"
+							/>
 							<text v-if="workErrors.monthlySalary" class="error-message">{{workErrors.monthlySalary}}</text>
 						</view>
 					</view>
@@ -2117,6 +2137,81 @@ import { apiBaseUrl } from '@/common/config.js';
 
 				return true;
 			},
+			validateExpectedSalary(e) {
+				const value = e.detail.value;
+				console.log(value);
+				if (value === '') {
+					this.formData.expectedSalary = '';
+					this.formErrors.expectedSalary = '';
+					return;
+				}
+				
+				let num = parseFloat(value);
+				if (isNaN(num)) {
+					this.formErrors.expectedSalary = '请输入有效的数字';
+					return;
+				}
+				
+				if (num < 0) {
+					num = 0;
+					this.formErrors.expectedSalary = '薪资不能小于0';
+				} else if (num > 100000) {
+					num = 100000;
+					this.formErrors.expectedSalary = '薪资不能超过100000';
+				}
+				
+				this.formData.expectedSalary = num.toString();
+			},
+			validateEmployeeCount(e) {
+				const value = e.detail.value;
+				if (value === '') {
+					this.workForm.employeeCount = '';
+					this.workErrors.employeeCount = '';
+					return;
+				}
+				
+				let num = parseInt(value);
+				if (isNaN(num)) {
+					this.workErrors.employeeCount = '请输入有效的数字';
+					return;
+				}
+				
+				if (num < 0) {
+					num = 0;
+					this.workErrors.employeeCount = '人数不能小于0';
+				} else if (num > 10000) {
+					num = 10000;
+					this.workErrors.employeeCount = '人数不能超过10000';
+				}
+				
+				this.workForm.employeeCount = num.toString();
+			},
+			validateMonthlySalary(e) {
+				const value = e.detail.value;
+				if (value === '') {
+					this.workForm.monthlySalary = '';
+					this.workErrors.monthlySalary = '';
+					return;
+				}
+				
+				let num = parseInt(value);
+				if (isNaN(num)) {
+					this.workErrors.monthlySalary = '请输入有效的数字';
+					return;
+				}
+				
+				if (num < 0) {
+					num = 0;
+					this.workErrors.monthlySalary = '月总收入不能小于0';
+				} else if (num > 100000) {
+					num = 100000;
+					this.workErrors.monthlySalary = '月总收入不能超过100000';
+				} else {
+					this.workErrors.monthlySalary = '';
+				}
+				
+				this.workForm.monthlySalary = num.toString();
+			}
 		},
 		// 添加监听器来清除错误信息
 		watch: {

+ 107 - 4
pages/job-detail/job-detail.vue

@@ -9,7 +9,7 @@
       <view class="job-requirements">
         <view class="requirement-item">
           <view class="dot"></view>
-          <text>{{ jobDetail.location }}</text>
+          <text>{{ formatLocation(jobDetail.location) }}</text>
         </view>
         <view class="requirement-item">
           <view class="time-icon"></view>
@@ -46,8 +46,12 @@
         <view class="description-content">
           <view class="description-item" v-for="(item, index) in jobDetail.description[0].items" :key="index">
             <view class="blue-dot"></view>
-            <text style="color: #333;">{{ item }}</text>
-            <!-- <view v-html="item"></view> -->
+            <template v-if="hasHtmlTags(item)">
+              <view class="description-text" v-html="item"></view>
+            </template>
+            <template v-else>
+              <text style="color: #333;">{{ item }}</text>
+            </template>
           </view>
         </view>
       </view>
@@ -185,6 +189,50 @@ export default {
       }
       return true;
     },
+	// 获取当前职位配置
+	getConfig(){
+		uni.request({
+			url: `${apiBaseUrl}/api/job/config/position/${this.selectedJobId}`,
+			method: 'GET',
+			data: {
+				openid: JSON.parse(uni.getStorageSync('userInfo')).openid
+			},
+			header: {
+				'content-type': 'application/x-www-form-urlencoded'
+			},
+			success: (res) => {
+				// 身份验证成功后,继续提交用户信息
+				console.log(res);
+				if (res.statusCode === 200) {
+					if (res.data.code === 2000) {
+						uni.setStorageSync('configData', JSON.stringify(res.data.data))
+						uni.navigateTo({
+							url: '/pages/Personal/Personal',
+							fail: (err) => {
+								console.error('页面跳转失败:', err);
+								uni.showToast({
+									title: '页面跳转失败',
+									icon: 'none'
+								});
+							}
+						});
+					} else {
+						
+					}
+				} else {
+					uni.hideLoading();
+					
+				}
+			},
+			fail: (err) => {
+				uni.hideLoading();
+				uni.showToast({
+					title: '网络错误,请稍后重试',
+					icon: 'none'
+				});
+			}
+		});
+	},
     async startInterview() {
       if (!this.checkLogin()) {
         return;
@@ -212,7 +260,7 @@ export default {
           } catch (e) {
             console.error('更新用户信息失败:', e);
           }
-
+		  this.getConfig()
           // 导航到摄像头页面
           uni.navigateTo({
             url: '/pages/Personal/Personal',
@@ -232,6 +280,41 @@ export default {
           icon: 'none'
         });
       }
+    },
+    hasHtmlTags(text) {
+      // 检查文本是否包含HTML标签
+      const htmlRegex = /<[^>]*>/;
+      return htmlRegex.test(text);
+    },
+    formatLocation(location) {
+      if (!location) return '';
+      
+      // 处理字符串形式的数组
+      if (typeof location === 'string' && location.startsWith('[')) {
+        try {
+          const locationArray = JSON.parse(location.replace(/'/g, '"'));
+          return locationArray.join(' ');
+        } catch (e) {
+          console.error('解析location失败:', e);
+          return location;
+        }
+      }
+      
+      // 处理数组格式
+      if (Array.isArray(location)) {
+        return location.join(' ');
+      }
+      
+      // 处理对象格式
+      if (typeof location === 'object' && location !== null) {
+        const { province, city, district } = location;
+        if (province && city) {
+          return province + ' ' + city + (district ? ' ' + district : '');
+        }
+      }
+      
+      // 处理普通字符串格式
+      return location;
     }
   }
 }
@@ -422,4 +505,24 @@ export default {
   border-top-left-radius: 16rpx;
   border-bottom-left-radius: 16rpx;
 }
+
+.description-text {
+  font-size: 26rpx;
+  color: #333;
+  line-height: 1.6;
+  flex: 1;
+
+  :deep(p) {
+    margin: 0;
+  }
+  
+  :deep(a) {
+    color: #0039b3;
+    text-decoration: none;
+  }
+  
+  :deep(strong) {
+    font-weight: bold;
+  }
+}
 </style>