xxdezh преди 7 месеца
родител
ревизия
d773266294
променени са 2 файла, в които са добавени 276 реда и са изтрити 245 реда
  1. 1 1
      App.vue
  2. 275 244
      common/queue.js

+ 1 - 1
App.vue

@@ -535,7 +535,7 @@ export default {
           this.$Request
             .get("/app/Login/bindOpenId?userId=" + userId + "&openId=" + openid)
             .then((res) => {
-              // 省钱兄陪玩 https://pw.xianmxkj.com
+         
             });
         }
       }

+ 275 - 244
common/queue.js

@@ -198,8 +198,8 @@ module.exports = {
 		}
 		return 0;
 	},
-	uploadFile:function(path,callback){
-		const uploadTask=uni.uploadFile({ // 上传接口
+	uploadFile: function(path, callback) {
+		const uploadTask = uni.uploadFile({ // 上传接口
 			url: configdata.APIHOST1 + '/alioss/upload', //真实的接口地址
 			filePath: path,
 			name: 'file',
@@ -207,66 +207,67 @@ module.exports = {
 				let content = JSON.parse(uploadFileRes.data).data;
 				uni.hideLoading();
 				callback(content)
-			},fail:(err)=>{
+			},
+			fail: (err) => {
 				callback(false)
 				console.log(err)
 			}
 		});
 		uploadTask.onProgressUpdate((res) => {
-		  uni.showLoading({
-		    title: '上传进度' + res.progress+'%',
-		  })
-		  if(res.progress>=100){
-			  uni.hideLoading()
-		  }
+			uni.showLoading({
+				title: '上传进度' + res.progress + '%',
+			})
+			if (res.progress >= 100) {
+				uni.hideLoading()
+			}
 		})
 	},
-	array_column:function (arr, column_key, index_key = null) {
-	    if (index_key === null) {
-	        return arr.map(item => item[column_key]);
-	    }
-	    
-	    return arr.reduce((result, item) => {
-	        result[item[index_key]] = item[column_key];
-	        return result;
-	    }, {});
-	},
-	isCurrentMonth:function (date) {
-	  const now = new Date();
-	  return now.getFullYear() === date.getFullYear() && 
-	         now.getMonth() === date.getMonth();
-	},
-	getHighestEducation:function (educations) {
-	  // 定义学历等级映射(从低到高)
-	  const educationLevels = {
-	    '小学': 1,
-	    '初中': 2,
-	    '高中': 3,
-	    '中专': 4,
-	    '大专': 5,
-	    '本科': 6,
-	    '硕士': 7,
-	    '博士': 8,
-	    '博士后': 9
-	  };
-	
-	  let highestEducation = null;
-	  let highestLevel = -1;
-	
-	  educations.forEach(edu => {
-	    const level = educationLevels[edu.degree] || 0;
-	    if (level > highestLevel) {
-	      highestLevel = level;
-	      highestEducation = edu.degree;
-	    }
-	  });
-	
-	  return highestEducation;
-	},
-	
+	array_column: function(arr, column_key, index_key = null) {
+		if (index_key === null) {
+			return arr.map(item => item[column_key]);
+		}
+
+		return arr.reduce((result, item) => {
+			result[item[index_key]] = item[column_key];
+			return result;
+		}, {});
+	},
+	isCurrentMonth: function(date) {
+		const now = new Date();
+		return now.getFullYear() === date.getFullYear() &&
+			now.getMonth() === date.getMonth();
+	},
+	getHighestEducation: function(educations) {
+		// 定义学历等级映射(从低到高)
+		const educationLevels = {
+			'小学': 1,
+			'初中': 2,
+			'高中': 3,
+			'中专': 4,
+			'大专': 5,
+			'本科': 6,
+			'硕士': 7,
+			'博士': 8,
+			'博士后': 9
+		};
+
+		let highestEducation = null;
+		let highestLevel = -1;
+
+		educations.forEach(edu => {
+			const level = educationLevels[edu.degree] || 0;
+			if (level > highestLevel) {
+				highestLevel = level;
+				highestEducation = edu.degree;
+			}
+		});
+
+		return highestEducation;
+	},
+
 	//职业状态
-	resumesStatus(){
-		
+	resumesStatus() {
+
 		return [{
 				value: '0',
 				text: '离职-随时到岗',
@@ -289,8 +290,8 @@ module.exports = {
 			}
 		]
 	},
-	
-	appConfirm:function(content='请确认您的操作?',callback,title='操作提示',button=["继续","取消"]){
+
+	appConfirm: function(content = '请确认您的操作?', callback, title = '操作提示', button = ["继续", "取消"]) {
 		// #ifndef APP-PLUS 
 		uni.showModal({
 			title: title,
@@ -298,210 +299,240 @@ module.exports = {
 			success: function(res) {
 				if (res.confirm) {
 					callback(true)
-				}else
+				} else
 					callback(false)
 			}
 		});
 		return
 		//#endif
 		// #ifdef APP-PLUS 
-		plus.nativeUI.confirm(content, function(e){
-				if(e.index==0)
-					callback(true)
-				else
-					callback(false)
-			},title,button);
+		plus.nativeUI.confirm(content, function(e) {
+			if (e.index == 0)
+				callback(true)
+			else
+				callback(false)
+		}, title, button);
 		//#endif
 	},
-	isDateExpired:function (targetDate) {
-	    const currentTimestamp = new Date().getTime();
-	    const targetTimestamp = new Date(targetDate).getTime();
-		const rest=targetTimestamp < currentTimestamp
-		if(rest)
-			return [true,0]
-		    // 计算毫秒差
-		const diffInMs =  targetTimestamp -currentTimestamp; 
-		    
-		    // 转换为小时(向上取整确保显示完整小时)
-		const hours = Math.ceil(diffInMs / (1000 * 60 * 60));  
-		    
-		return [rest,hours > 0 ? hours : 0];  // 返回非负值
-	},
-	convert12to24:function (time12h) {
-	  // 使用正则表达式匹配12小时制格式
-	  const regex = /^(0?[1-9]|1[0-2]):([0-5]\d)\s?(AM|PM)$/i;
-	  const match = time12h.match(regex);
-	  
-	  if (!match) {
-	    throw new Error('无效的时间格式,请使用如 "2:00 PM" 或 "02:00 PM" 的格式');
-	  }
-	  
-	  let hour = parseInt(match[1], 10);
-	  const minute = match[2];
-	  const period = match[3].toUpperCase();
-	  
-	  // 处理AM/PM转换逻辑
-	  if (period === 'PM' && hour !== 12) {
-	    hour += 12;
-	  } else if (period === 'AM' && hour === 12) {
-	    hour = 0;
-	  }
-	  
-	  // 格式化为两位数
-	  const hour24 = hour.toString().padStart(2, '0');
-	  
-	  return `${hour24}:${minute}`;
-	},
-	changeTabbar:function(res){
+	isDateExpired: function(targetDate) {
+		const currentTimestamp = new Date().getTime();
+		const targetTimestamp = new Date(targetDate).getTime();
+		const rest = targetTimestamp < currentTimestamp
+		if (rest)
+			return [true, 0]
+		// 计算毫秒差
+		const diffInMs = targetTimestamp - currentTimestamp;
+
+		// 转换为小时(向上取整确保显示完整小时)
+		const hours = Math.ceil(diffInMs / (1000 * 60 * 60));
+
+		return [rest, hours > 0 ? hours : 0]; // 返回非负值
+	},
+	convert12to24: function(time12h) {
+		// 使用正则表达式匹配12小时制格式
+		const regex = /^(0?[1-9]|1[0-2]):([0-5]\d)\s?(AM|PM)$/i;
+		const match = time12h.match(regex);
+
+		if (!match) {
+			throw new Error('无效的时间格式,请使用如 "2:00 PM" 或 "02:00 PM" 的格式');
+		}
+
+		let hour = parseInt(match[1], 10);
+		const minute = match[2];
+		const period = match[3].toUpperCase();
+
+		// 处理AM/PM转换逻辑
+		if (period === 'PM' && hour !== 12) {
+			hour += 12;
+		} else if (period === 'AM' && hour === 12) {
+			hour = 0;
+		}
+
+		// 格式化为两位数
+		const hour24 = hour.toString().padStart(2, '0');
+
+		return `${hour24}:${minute}`;
+	},
+	changeTabbar: function(res) {
 		setTimeout(() => {
-			if(res==1){
-			uni.setTabBarItem({
-			  index: 0,
-			  text: '首页',
-			 iconPath: "/static/tabbar/Home.png",
-			 selectedIconPath: "/static/tabbar/Iconly_Bold_Home.png",
-			})
-			uni.setTabBarItem({
-			  index: 1,
-			  text: '急聘',
-			  "pagePath": "/pages/index/game/gameList",
-			  "iconPath": "/static/tabbar/jipin.png",
-			  "selectedIconPath": "/static/tabbar/ACjipin.png",
-			})
-			}else{
+			if (res == 1) {
+				uni.setTabBarItem({
+					index: 0,
+					text: '首页',
+					iconPath: "/static/tabbar/Home.png",
+					selectedIconPath: "/static/tabbar/Iconly_Bold_Home.png",
+				})
+				uni.setTabBarItem({
+					index: 1,
+					text: '急聘',
+					"pagePath": "/pages/index/game/gameList",
+					"iconPath": "/static/tabbar/jipin.png",
+					"selectedIconPath": "/static/tabbar/ACjipin.png",
+				})
+			} else {
 				uni.setTabBarItem({
-				  index: 0,
-				  text: '牛人',
-				 iconPath: "/static/tabbar/niu.png",
-				 selectedIconPath: "/static/tabbar/niu2.png",
+					index: 0,
+					text: '牛人',
+					iconPath: "/static/tabbar/niu.png",
+					selectedIconPath: "/static/tabbar/niu2.png",
 				})
 				uni.setTabBarItem({
-				  index: 1,
-				  "pagePath": "/pages/talentSearch/index",
-				   	"iconPath": "/static/tabbar/Hrsearch.png",
-				   	"selectedIconPath": "/static/tabbar/ACsearch.png",
-				   	"text": "搜索"
+					index: 1,
+					"pagePath": "/pages/talentSearch/index",
+					"iconPath": "/static/tabbar/Hrsearch.png",
+					"selectedIconPath": "/static/tabbar/ACsearch.png",
+					"text": "搜索"
 				})
 			}
-		    // 可以在这里添加 tabbar 更新后的后续操作
-		    console.log('tabbar 更新完成');
-		  },100);
+			// 可以在这里添加 tabbar 更新后的后续操作
+			console.log('tabbar 更新完成');
+		}, 100);
 	},
 	// 核心年龄计算函数
-	        calculateAgeFromBirthday:function(birthday) {
-	            const birthDate = new Date(birthday);
-	            const currentDate = new Date();
-	            
-	            // 验证日期有效性
-	            if (isNaN(birthDate.getTime())) {
-	                throw new Error('无效的生日日期');
-	            }
-	            
-	            if (birthDate > currentDate) {
-	                throw new Error('生日日期不能晚于当前日期');
-	            }
-	            
-	            let years = currentDate.getFullYear() - birthDate.getFullYear();
-	            let months = currentDate.getMonth() - birthDate.getMonth();
-	            let days = currentDate.getDate() - birthDate.getDate();
-	            
-	            // 处理天数负数情况
-	            if (days < 0) {
-	                months--;
-	                // 获取上个月的天数
-	                const lastMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
-	                days += lastMonth.getDate();
-	            }
-	            
-	            // 处理月份负数情况
-	            if (months < 0) {
-	                years--;
-	                months += 12;
-	            }
-	            
-	            return years;
-	        },
-			// 筛选求职列表
-			getFilterData:function(){
-				const condition={
-					education : '', //学历
-					experience : '', //经验
-					industry : '', //行业
-					salaryRange : '',//薪资
-					companyPeople : '' //公司规模
+	calculateAgeFromBirthday: function(birthday) {
+		const birthDate = new Date(birthday);
+		const currentDate = new Date();
+
+		// 验证日期有效性
+		if (isNaN(birthDate.getTime())) {
+			throw new Error('无效的生日日期');
+		}
+
+		if (birthDate > currentDate) {
+			throw new Error('生日日期不能晚于当前日期');
+		}
+
+		let years = currentDate.getFullYear() - birthDate.getFullYear();
+		let months = currentDate.getMonth() - birthDate.getMonth();
+		let days = currentDate.getDate() - birthDate.getDate();
+
+		// 处理天数负数情况
+		if (days < 0) {
+			months--;
+			// 获取上个月的天数
+			const lastMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
+			days += lastMonth.getDate();
+		}
+
+		// 处理月份负数情况
+		if (months < 0) {
+			years--;
+			months += 12;
+		}
+
+		return years;
+	},
+	// 筛选求职列表
+	getFilterData: function() {
+		const condition = {
+			education: '', //学历
+			experience: '', //经验
+			industry: '', //行业
+			salaryRange: '', //薪资
+			companyPeople: '' //公司规模
+		}
+		//获取选中的筛选条件
+		if (uni.getStorageSync('filter') && (uni.getStorageSync('filter')).length > 0) {
+			let filter = uni.getStorageSync('filter')
+			filter.map(item => {
+				let arr = []
+				item.list.map(ite => {
+					if (ite.value != '不限') {
+						arr.push(ite.value)
+					}
+				})
+				switch (item.name) {
+					case '学历要求':
+						condition.education = arr.join(',')
+						break;
+					case '薪资范围(单选)':
+						condition.salaryRange = arr.join(',')
+						break;
+					case '经验要求':
+						condition.experience = arr.join(',')
+						break;
+					case '公司规模':
+						condition.companyPeople = arr.join(',')
+						break;
+					case '行业':
+						condition.industry = arr.join(',')
+						break;
 				}
-				//获取选中的筛选条件
-				if (uni.getStorageSync('filter') && (uni.getStorageSync('filter')).length > 0) {
-					let filter = uni.getStorageSync('filter')
-					filter.map(item => {
-						let arr = []
-						item.list.map(ite => {
-							if (ite.value != '不限') {
-								arr.push(ite.value)
+
+			})
+			// console.log(filter)
+		}
+		return condition
+	},
+	//APP获取手机权限鉴权
+	// APP获取手机权限鉴权(优化版,兼容全权限+多系统)
+	checkPermission: function(permission, tip) {
+		return new Promise((resolve) => {
+			const permisionObj = uni.getAppAuthorizeSetting();
+			const system = uni.getSystemInfoSync().platform; // 获取系统类型(ios/android)
+
+			// 步骤1:统一权限scope映射(解决不同系统/权限的scope差异)
+			let realScope = permission;
+			const scopeMap = {
+				// 基础权限(双端通用)
+				'microphone': 'microphone', // 麦克风
+				'camera': 'camera', // 相机
+				'location': 'scope.userLocation', // 定位(小程序/APP通用)
+				// 相册权限(系统差异化处理)
+				'albumRead': system === 'ios' ? 'photos' : 'storage', // 读取相册
+				'albumWrite': system === 'ios' ? 'writePhotosAlbum' : 'storage', // 写入相册
+			};
+			// 兼容传入的permission别名(如传入'album'自动映射为对应系统的读取权限)
+			if (permission === 'album') realScope = scopeMap.albumRead;
+			else if (permission === 'albumWrite') realScope = scopeMap.albumWrite;
+			else if (scopeMap[permission]) realScope = scopeMap[permission];
+
+			// 步骤2:获取权限状态并校验
+			permisionObj.getSetting({
+				success: (res) => {
+					const authStatus = res.authSetting[realScope];
+					// 已授权
+					if (authStatus === true) {
+						resolve(true);
+					}
+					// 已拒绝(引导到设置页)
+					else if (authStatus === false) {
+						uni.showModal({
+							title: '权限不足',
+							content: `${tip},请前往设置开启权限`,
+							confirmText: '去设置',
+							cancelText: '取消',
+							success: (modalRes) => {
+								if (modalRes.confirm) {
+									permisionObj.openAppAuthorizeSetting({
+										success: () => resolve(
+										false), // 跳转设置页后不自动重试,需用户手动开启后返回
+										fail: () => resolve(false)
+									});
+								} else {
+									resolve(false);
+								}
 							}
-						})
-						switch (item.name) {
-							case '学历要求':
-								condition.education = arr.join(',')
-								break;
-							case '薪资范围(单选)':
-								condition.salaryRange = arr.join(',')
-								break;
-							case '经验要求':
-								condition.experience = arr.join(',')
-								break;
-							case '公司规模':
-								condition.companyPeople = arr.join(',')
-								break;
-							case '行业':
-								condition.industry = arr.join(',')
-								break;
-						}
-				
-					})
-					// console.log(filter)
+						});
+					}
+					// 未授权过(发起系统授权请求)
+					else {
+						permisionObj.authorize({
+							scope: realScope,
+							success: () => resolve(true),
+							fail: (err) => {
+								console.log(`权限授权失败:${permission}`, err);
+								resolve(false);
+							}
+						});
+					}
+				},
+				fail: (err) => {
+					console.log(`获取权限设置失败:${permission}`, err);
+					resolve(false);
 				}
-				return condition
-			},
-			//APP获取手机权限鉴权
-			checkPermission:function(permission, tip) {
-			  return new Promise((resolve) => {
-			    const permisionObj = uni.getAppAuthorizeSetting();
-			    permisionObj.getSetting({
-			      success: (res) => {
-			        const authStatus = res.authSetting[permission];
-			        if (authStatus === true) {
-			          resolve(true);
-			        } else if (authStatus === false) {
-			          // 已拒绝权限,引导去设置页
-			          uni.showModal({
-			            title: '权限不足',
-			            content: `${tip},请前往设置开启权限`,
-			            confirmText: '去设置',
-			            cancelText: '取消',
-			            success: (modalRes) => {
-			              if (modalRes.confirm) {
-			                permisionObj.openAppAuthorizeSetting({
-			                  success: () => resolve(false),
-			                  fail: () => resolve(false)
-			                });
-			              } else {
-			                resolve(false);
-			              }
-			            }
-			          });
-			        } else {
-			          // 未授权过,发起授权请求
-			          permisionObj.authorize({
-			            scope: permission,
-			            success: () => resolve(true),
-			            fail: () => resolve(false)
-			          });
-			        }
-			      },
-			      fail: () => resolve(false)
-			    });
-			  });
-			},
-			
-};
+			});
+		});
+	},
+
+};