<template>
	<!-- :style="{ minHeight: `calc(100vh - ${navbarHeight}px)` }" --> 
	<view class="p-home-inedx g_w_all g_kuaishou" :class="computeCode == -1 ? 'g_flex_column_center' : ''" :style="{ minHeight: `calc(100vh)`, paddingBottom: 'calc(50px + env(safe-area-inset-bottom))', backgroundColor: '#ededed', opacity: 0, animation: 'fadeIn 0.2s ease forwards' }">
		<div class="navContainer" :style="computeCode == -1 ? { backgroundColor: '#ededed' } : { backgroundImage: `linear-gradient(to bottom, ${themeColor}, ${themeColorRgba(0.98)})` }">
			<u-navbar :is-back="false" :is-fixed="true" :borderBottom="false" background="transparent" :title-bold="false">
				<view class="g_flex_row_start flex_center g_fs_20 g_pl_12">
					<view><img :src="appInfo.logo" alt="" class="g_w_32 g_h_32 g_radius_50" /></view>
					<view class="g_ml_8 g_mr_8 g_fw_600 g_ell_1 webfont" :style="{ maxWidth: '150px', color: appNameColor }">{{ appInfo.appName }}</view>
					<!-- <view class="g_mr_6">|</view>
					<view>信息真·价格高</view> -->
				</view>
			</u-navbar>
		</div>
		<view v-show="computeCode == -1" class="g_flex_column_center">
			<rh-loading marginBottom="g_mb_130" />
		</view>
		<view v-show="computeCode > -1">
			<view class="g_position_rela g_flex_row_center toudom" :style="{ backgroundImage: `linear-gradient(to bottom, ${themeColorRgba(0.98)}, #ededed)` }">
				<view class="the_city g_flex_column_center" style hover-class="thover" @click="goCity">
					<view class="g_flex_row_center">
						<view class="g_fs_16 g_fw_600 g_ml_10" style="width: 36px; display: inline-block">
                            <view v-if="cityLoading" class="g_flex_column_center">
                                <view class="loading-dot">
                                    <view class="dot dot1"></view>
                                    <view class="dot dot2"></view>
                                    <view class="dot dot3"></view>
                                </view>
                            </view>
                            <text v-else>{{ selectedCity }}</text>
                        </view>
						<view class="g_flex_column_center">
							<view class="iconfont icon-zhankai g_fs_12" style="display: inline-block"></view>
						</view>
					</view>
				</view>
				<!-- 搜索区 -->
				<view class="m-search g_p_10 g_pt_8 g_position_abso bg_shawdoc g_flex_1" style="top: 0" id="searchInputBox">
					<u-search height="80" v-model="keyword" class="g_flex_1" placeholder="搜索职位名称" bg-color="#fff" :show-action="false" placeholder-class="g_c_c" search-icon-color="#999999" :maxlength="20" @clear="getSearch" @search="getSearch"></u-search>
				</view>
			</view>
			<scroll-view class="m-list" id="listBox" :scroll-into-view="scrollTo" refresher-default-style="none" refresher-background="#ededed" :refresher-enabled="true" :refresher-triggered="isTrigger" @refresherrefresh="refreshJobList" :style="{ height: `calc(100vh - ${navbarHeight + 40}px - 50px - env(safe-area-inset-bottom))` }" :scroll-y="true" @scrolltolower="reachBottom" @scroll="checkScroll">
				<div>
					<div class="g_text_c g_c_c g_fs_12" style="width: 100vw; position: absolute; top: -32px; z-index: 9999999">{{ "最近更新" + (jobNum || "-") + "条信息" }}</div>
					<!-- <div class="g_h_10"></div> -->

					<view>
						<div>
							<!-- <div v-if="appid == 'wxb0c590fd696b79be'">
							<promotion cusType="image"></promotion>
						</div> -->
							<div>
								<promotion cusType="image"></promotion>
							</div>
						</div>
						<!--为最外层的大盒子-->
						<view class="g_flex_row_start flex_center g_bg_f g_ml_10 g_mr_10 g_radius_8" style="overflow: hidden;margin-top: 8px;"
									@click="getMore"
						>
							<view class="g_flex_c g_h_48 g_w_40 g_flex_none">
								<!-- <image class="g_w_48 g_h_48" :src="noticeImg" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload=""> </image> -->
								<i class="iconfont icon-sound" style="font-size: 24px;color: #666;"></i>
							</view>
							<view :style="{
											'width':'calc(100vw - ' + (isJm ? 90 : 80) + 'px)'
										}"
							>
								<u-notice-bar ref="noticeBar"
															:color="noticeColor" 
															padding="0rpx" 
															font-size="32" 
															style="width: calc(100% - 54px)" 
															:speed="100" 
															:volume-icon="false" 
															type="none" 
														 :list="noticList"
														 class="g_flex_1"
								></u-notice-bar>
							</view>
							<view class="g_flex_c g_h_48 g_flex_none" style="width: 30px;" v-if="isJm">
								<i class="iconfont icon-gengduo11 g_c_c" style="font-size: 16px;"></i>
							</view>
						</view>
						<view class="sticky g_flex_row_between flex_center" :class="toTop ? 'g_bg_f defaultShadow' : 'g_bg_f_5'" ref="tttop" id="tttop">
							<view class="" style="">
								<g-tabs bg-color="transparent" from="index" gutter="20" :list="tabInfo.list" :current="tabInfo.active" :active-color="themeColor" bar-width="64" bar-height="6" @change="handleUpdateTab" font-size="34" duration="0.05" height="76"></g-tabs>
							</view>
							<!-- <view v-if="isMember && hasPermission" class="g_mr_8" @click="goShare"> 批量分享 </view> -->
							<view class="g_flex_row_end g_flex_1">
								<view class="csbf" @click="chooseNl('sort')" :class="toTop ? 'g_bg_f_5 ' : 'g_bg_f'">
									{{ sortList.list[sortList.active].showName }}
									<span class="iconfont icon-shouqi g_fs_12 g_c_9 fst g_ml_4" v-if="whichOneShow == 'sort'"></span>
									<span class="iconfont icon-zhankai g_fs_12 g_c_9 fst g_ml_4" v-if="whichOneShow != 'sort'"></span>
									<view class="sortMask" v-if="whichOneShow == 'sort'">
										<view class="sortContainer" style="overflow: hidden" @click.stop>
											<view v-for="(item, index) in sortList.list" @click="sortJob(index)" :key="index" :class="sortList.active == index ? 'g_border_f' : 'g_border_f'" class="g_fs_16 g_fw_600 g_mt_16 g_bg_f" :style="sortList.active == index ? {color: themeColor, borderColor: themeColor, border: '1px solid ' + themeColor} : {}" style="border-radius: 30px; padding: 8px 16px">{{ item.name }}</view>
										</view>
									</view>
								</view>
								<view class="g_flex_column_center">
									<view class="csbf" :class="toTop ? 'g_bg_f_5 ' : 'g_bg_f'" @click="chooseNl('special')" data-type="special">
										筛选
										<span class="iconfont icon-shouqi g_fs_12 g_c_9 fst g_ml_4" v-if="whichOneShow == 'special'"></span>
										<span class="iconfont icon-zhankai g_fs_12 g_c_9 fst g_ml_4" v-if="whichOneShow != 'special'"></span>
										<mfilter :show="whichOneShow" ref="filterChild" top="43px" :getFilterDataNew="getFilterData" @filterObj="receiveFromChild"></mfilter>
									</view>
								</view>
							</view>
							<scroll-view class="filterTag bt1 g_h_44" v-if="getFilterData.jobCategoryLabelObjects.length > 0 || getFilterData.jobSpecialLabelObjects.length > 0 || getFilterData.sex != '-1' || (getFilterData.ageRangeStr && getFilterData.ageRangeStr != '16-16')" :scroll-x="true" :scroll-y="false" scroll-top="0" scroll-left="0" scroll-into-view scroll-with-animation="false" enable-flex enable-back-to-top="false">
								<div class="g_flex_row_between flex_center flex_nw g_w_all">
									<div class="g_flex_row_start flex_nw" style="line-height: 44px">
										<div class="tc genderTag f14 por" style="min-width: 60px" v-if="getFilterData.ageRangeStr != '' && getFilterData.ageRangeStr != '16-16'">
											<div class="por bg_main" @click.stop="deleteAge">
												{{ getFilterData.ageRangeStr }}
												<div class="clear_icon iconfont icon-dianji"></div>
											</div>
										</div>

										<div class="tc genderTag f14 por" style="min-width: 60px" v-if="getFilterData.sex != '-1'">
											<div class="por bg_main" @click.stop="deleteSex">
												{{ getFilterData.sex == 1 ? "收男工" : getFilterData.sex == 2 ? "收女工" : getFilterData.sex == 3 ? "男女都收" : "" }}
												<!-- {{getFilterData.jobCategoryLabelObjects.length > 0}} {{getFilterData.jobSpecialLabelObjects.length > 0}} -->
												<div class="clear_icon iconfont icon-dianji"></div>
											</div>
										</div>
										<div class="brandTag ml8" v-if="getFilterData.jobCategoryLabelObjects.length > 0">
											<block v-for="(item, index) in getFilterData.jobCategoryLabelObjects" :key="index">
												<div class="por bg_main" @click.stop="deleteJobCategoryLabel(item.id)">
													{{ item.name }}
													<div class="clear_icon iconfont icon-dianji"></div>
												</div>
											</block>
										</div>

										<div class="specialTag ml8">
											<block v-for="(item, index) in getFilterData.jobSpecialLabelObjects" :key="index">
												<div class="por bg_main" @click.stop="deleteJobSpecialLabel(item.id)">
													{{ item.name }}
													<div class="clear_icon iconfont icon-dianji"></div>
												</div>
											</block>
										</div>
										<!-- <div class="specialTag" wx:if="{{selectJobList.length > 0}}">
                  <block wx:for="{{selectJobList}}" wx:key="index">
                    <div class="por" catchtap="deleteMark" data-item="{{item}}">
                      {{item.name}}
                      <div class="clear_icon iconfont icon-qingchu"></div>
                    </div>
                  </block>
                </div> -->
									</div>
									<div class="clear" @click.stop="clearFilter1" data-type="outerClear">
										<span class="iconfont icon-shanchu f14"></span>
										清除
									</div>
								</div>
							</scroll-view>
						</view>
						<g-yi-list-job :tabactive='tabInfo.active'
												 :hrtext="hrtext" 
												 :isshowskit="isshowskit" 
												 :pt="tabInfo.active == 0 ? 0 : 120" 
												 style="padding-bottom: 10px" 
												 from="home" 
												 class="g_h_all" 
												 :list="query.list" 
												 @clickCard="goDetail" 
												 @successLogin="successLogin" 
												 :loading="loading" 
												 :speed="speed" 
												 :query="query" 
												 :isShowLoginBtn="isLogin ? false : true" 
												 :emptyText="isLogin ? (tabInfo.list[tabInfo.active].classify == 2 ? '您还未收藏职位，快去试试收藏职位吧' : '嘿，这里还没有数据呢') : '您还有没有登录，请登录后查看职位'"
						/>
					</view>
				</div>
			</scroll-view>

			<u-popup v-model="popSelect.isShow" mode="bottom" uZindex="9999" border-radius="12" :closeable="true" :mask-close-able="true">
				<view class="g_pt_32" style="height: calc(100vh - 300rpx)">
					<selectPanel />
				</view>
			</u-popup>
		</view>
		<!-- v-if="isMember && hasPermission" -->
		<!-- <div class="g_fs_12 g_text_c g_flex_column_center g_c_f g_bg_main g_boeder_e g_radius_50 g_p_4 g_w_48 g_h_48" style="position: fixed; right: 20px; bottom: 120px" @click="goShare">
			<div class="">批量</div>
			<div>分享</div>
		</div> -->
	</view>
	<custom-tabbar :current="0" />
</template>

<script>
import selectPanel from "./child/select.vue";
import mfilter from "./child/filter.vue";
import promotion from "./child/promotion.vue";

export default {
	components: {
		selectPanel,
		mfilter,
		promotion,
	},
	mounted() {
		// console.log("mountedmountedmountedmountedmountedmounted");
		const query = uni.createSelectorQuery().in(this);
		// console.log("query", query);
		// 选择指定的 DOM 元素
		query
			.select(".navContainer")
			.boundingClientRect((res) => {
				this.navbarHeight = res.height;
			})
			.exec();
	},
	onShareAppMessage() {
		let that = this;
		let path;
		console.log("getFilterData", this.getFilterData);
		path = `/pages/home/index?filterInfo=${JSON.stringify(that.getFilterData)}&cityInfo=${that.selectedCity}`;
		let appInfo = uni.getStorageSync("miniApp-info");
		return {
			// title: "你想找的厂都有，立即查看",
			title: appInfo.slogan || "为劳动者创造价值",
			imageUrl: appInfo.sharePoster,
			path,
		};
	},
	onShareTimeline() {
		let that = this;
		let appInfo = uni.getStorageSync("miniApp-info");
		console.log("appInfo", appInfo);
		return {
			title: appInfo.slogan || "为劳动者创造价值",
			imageUrl: appInfo.logo,
			query:`filterInfo=${JSON.stringify(that.getFilterData)}&cityInfo=${that.selectedCity}`
		};
	},
	onLoad(options) {
		console.log("首页 onload", options);
		let that = this;
		that.navInfo = that.G.getNavInfo();
		let sceneInfo = uni.getLaunchOptionsSync();
		// console.log("scenescene", sceneInfo);
		if ((sceneInfo.scene == 1007 || sceneInfo.scene == 1008) && sceneInfo.query.filterInfo) {
			// that.getFilterData = that.getFilterData. {...JSON.parse(sceneInfo.query.filterInfo)};
			Object.assign(that.getFilterData, JSON.parse(sceneInfo.query.filterInfo));
			if (sceneInfo.query.cityInfo) {
				uni.setStorageSync("selectedCity", sceneInfo.query.cityInfo);
			}
			// console.log("that.getFilterData", that.getFilterData);
		}
		uni.setNavigationBarTitle({
			title: that.pageTitle,
		});
		if (options.userId) {
			this.userId = options.userId;
			uni.setStorageSync("AGENCY_USER_ID", this.userId);
		}
		// console.log("options.scene", options.scene);
		// console.log("options.scene", options.scene);
		// console.log("options.scene", options.scene);
		// console.log("options.scene", options.scene);
		// console.log("options.scene", options.scene);
		// console.log("options.scene", options.scene);
		// // console.log("options.scene", decodeURIComponent(options.scene));

		if (options.scene) {
			// // 	// console.log("XXXXXXXXXXXX");
			// // 	//扫小程序码携带参数
			var sceneStr = decodeURIComponent(options.scene);
			var sceneJson = this.G.sceneToJson(sceneStr);
			// // 	// console.log("sceneJson===", sceneJson);

			// // 	if (sceneJson.tk) {
			// // 		uni.setStorageSync("apply-token", sceneJson.tk);
			// // 	}

			// console.log("options.scene",sceneJson);
			// console.log("options.scene", sceneJson);
			if (sceneJson.i) {
				this.userId = sceneJson.i.split("_")[0];
				uni.setStorageSync("AGENCY_USER_ID", this.userId);
			}
		}

		// #ifdef MP-WEIXIN
		this.searchAnimate();
		// #endif
		let appId = getApp().globalData.appId;
		that.isshowskit = false;
		// console.log("=========", that);
		that.usetype = "share";
		that.useshare = true;
		that.query.page = 1;
		this.isLogin = uni.getStorageSync("apply-userinfo") ? true : false;
		this.query.size = this.isLogin ? 50 : 20;
		that.isCheckShare(() => {
			that.getList().then(() => {
				that.showNotic = "paused";
				console.log("that.showNotic1", that.showNotic);
				that.getJobNum();
				setTimeout(() => {
					let _notice = uni.getStorageSync("miniApp-info").notice || '愿祖国繁荣富强，山河锦绣如画；盼华夏儿女同心，共筑盛世中华！';
					if (_notice) {
						var reg = /[\r\n]/g;
						_notice = _notice.replace(reg, "");
						that.noticList = [_notice];
						that.noticeColor = uni.getStorageSync("miniApp-info").noticeColor;
						that.showNotic = "play";
					}
				}, 100);
			});
			that.isShowTab = true;
		});
	},
	onShow() {
		let that = this;
		that.themeColor = getApp().globalData.themeColor;
		let skipRefresh = uni.getStorageSync("HOME_SKIP_REFRESH");
		if (skipRefresh) {
			uni.removeStorageSync("HOME_SKIP_REFRESH");
			that.cityLoading = false;
			return;
		}
		that.cityLoading = true;

		// 判断是否需要弹出申请加入弹窗（isAgency为false，且每天只弹一次）
		// that.checkShowApplyModal();

		let locationUpdated = uni.getStorageSync("LOCATION_SETTING_UPDATED");
		if (locationUpdated) {
			uni.removeStorageSync("LOCATION_SETTING_UPDATED");
			// 直接执行更新逻辑，去掉弹窗确认
			let agencyInfo = uni.getStorageSync("agencyInfo");
			that.cityLoading = true;
			if (agencyInfo && agencyInfo.fdbHomeCity == 1) {
				uni.removeStorageSync("selectedCity");
			}
			that.initSelectedCityByAgencyInfo().then(() => {
				that.loadSelectedCityFromCache().then(() => {
					that.restoreActiveTab();
					that.getList();
				});
			});
		} else {
			that.initSelectedCityByAgencyInfo().then(() => {
				that.loadSelectedCityFromCache().then(() => {
					that.restoreActiveTab();
					this.getList();
				});
			});
		}

		// 尝试从缓存获取miniApp-info，如果不存在则请求API获取
		let miniAppInfo = uni.getStorageSync("miniApp-info");
		if (!miniAppInfo || Object.keys(miniAppInfo).length === 0) {
			// 如果缓存中没有数据，则请求API获取
			this.G.Get("/yishoudan/agency/getInfo", {}, (res) => {
				let obj = { ...res.agency, ...res.weixinConfig };
				for (let key in obj) {
					if (typeof obj[key] == "string" && obj[key].indexOf("http://") > -1) {
						obj[key] = obj[key].replace("http:", "https:");
					}
				}
				uni.setStorageSync("miniApp-info", obj);
				this.appInfo = obj;
				let demoEnabled = uni.getStorageSync("DEMO_MODE_ENABLED");
				let demoConfig = uni.getStorageSync("DEMO_MODE_CONFIG");
				if (demoEnabled && demoConfig) {
					this.$set(this.appInfo, 'logo', demoConfig.logo);
					this.$set(this.appInfo, 'appName', demoConfig.appName);
					if (demoConfig.themeColor) {
						getApp().globalData.themeColor = demoConfig.themeColor;
						this.themeColor = demoConfig.themeColor;
					}
				} else {
					let originalThemeColor = uni.getStorageSync("ORIGINAL_THEME_COLOR") || getApp().globalData.themeColor;
					getApp().globalData.themeColor = originalThemeColor;
					this.themeColor = originalThemeColor;
				}
				if (this.appInfo.noticeImg) {
					this.noticeImg = this.appInfo.noticeImg;
				} else {
					this.noticeImg = "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/notice/noticeDefault.png";
				}

				uni.setStorageSync("pgy-agency-id", res.agency.id);
				uni.setStorageSync("ai-name", res.agency.aiRobotName);
				uni.setStorageSync("ai-logo", res.agency.aiLogo);
				that.initData(obj);
			});
		} else {
			// 如果缓存中有数据，则直接使用
			this.appInfo = miniAppInfo;
			that.initData(miniAppInfo);
			if (this.appInfo.noticeImg) {
				this.noticeImg = this.appInfo.noticeImg;
			} else {
				this.noticeImg = "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/notice/noticeDefault.png";
			}
		}

		
		setTimeout(() => {
			let _notice = (uni.getStorageSync("miniApp-info") || {}).notice || '愿祖国繁荣富强，山河锦绣如画；盼华夏儿女同心，共筑盛世中华！';
			if (_notice) {
				var reg = /[\r\n]/g;
				_notice = _notice.replace(reg, "");
				that.noticList = [_notice];
				that.noticeColor = (uni.getStorageSync("miniApp-info") || {}).noticeColor;
				that.showNotic = "play";
			}
		}, 100);

		let demoEnabled = uni.getStorageSync("DEMO_MODE_ENABLED");
		let demoConfig = uni.getStorageSync("DEMO_MODE_CONFIG");
		if (demoEnabled && demoConfig) {
			that.$set(that.appInfo, 'logo', demoConfig.logo);
			that.$set(that.appInfo, 'appName', demoConfig.appName);
			if (demoConfig.themeColor) {
				getApp().globalData.themeColor = demoConfig.themeColor;
				that.themeColor = demoConfig.themeColor;
			}
		} else {
			let originalThemeColor = uni.getStorageSync("ORIGINAL_THEME_COLOR") || getApp().globalData.themeColor;
			getApp().globalData.themeColor = originalThemeColor;
			that.themeColor = originalThemeColor;
		}
	},
	data() {
		return {
			isSelf: false,
			themeColor: getApp().globalData.themeColor,
			noticeColor: "#333",
			isAgency: uni.getStorageSync("apply-userinfo") && uni.getStorageSync("apply-userinfo").agencyId,
			isJm:uni.getStorageSync("apply-userinfo") && uni.getStorageSync("apply-userinfo").agencyId && uni.getStorageSync("apply-userinfo").agencyId == '114827',
			hrtext: 2,
			tabbarShow: true,
			navbarHeight: 0, // navbar高度
			tabbarHeight: 0, // tabbar高度
			isTrigger: false, // 职位刷新状态
			jobNum: 0, // 职位刷新数
			globalData: getApp().globalData,
			isUseNewJob: getApp().globalData.isUseNewJob,
			appid: getApp().globalData.appId,
			selectedCity: "全国",
			cityLoading: true,
			currentInfo: {},
			currentCity: "",
			themeColor: getApp().globalData.themeColor,
			envVersion: uni.getStorageSync("ENV_VERSION"), // 小程序环境判断
			isMember: uni.getStorageSync("IS_MINIAPP_MEMBER"), // 登陆者是否当前小程序成员的判断
			hasPermission: uni.getStorageSync("HAS_PERMISSION") == 1 ? true : false, // 登陆者是否有权限查看
			noticeImg: "",
			getFilterData: {
				sex: "-1",
				ageRangeStr: "",
				jobCategoryLabelIds: "",
				jobRequestLabelIds: "",
				jobSpecialLabelObjects: [],
				jobCategoryLabelObjects: [],
			},
			getFilterDataNew: {
				sex: "-1",
				jobCategoryLabelIds: "",
				jobRequestLabelIds: "",
				jobSpecialLabelObjects: [],
				jobCategoryLabelObjects: [],
			},
			scrollTo: "",
			whichOneShow: "",
			pageTitle: getApp().globalData.title,
			background: {
				backgroundColor: "#3578f6",
			},
			isShowTab: false,
			showPop: false, // 显示关注邀请弹窗显示
			attentionList: [], // 关注列表
			subAttentionList: [],
			attentionConfig: {
				num: 1,
				size: 12,
			},
			checkAll: false, // 全选
			upInfo: {
				num: 0,
				list: [],
			},
			computeCode: -1,
			isLogin: true,
			navInfo: {},
			cdnBaseImg: this.G.store().cdnBaseImg,
			localBaseImg: this.G.store().cdnBaseImg,
			loading: true,
			speed: -1,
			query: {
				page: 1,
				size: 50,
				list: [],
				isFinish: -1,
				ujc: 0, // 0 全部 1收藏
				sortTag: 0,
			},
			keyword: "",
			// 排序的配置
			sortList: {
				list: [
					{
						name: "按时间排序",
						key: 0,
						showName: "排序",
					},
					{
						name: "按工价排序",
						key: 1,
						showName: "排序",
					},
					// {
					// 	name: "按佣金",
					// 	key: 3,
					// 	showName: "按佣金",
					// },

					{
						name: "按距离排序",
						key: 2,
						showName: "排序",
					},
				],
				active: 0,
			},
			tabInfo: {
				list: uni.getStorageSync("apply-userinfo")
					? [
							{
								name: "全部",
								classify: 0,
							},
							{
								name: "推荐",
								classify: 1,
							},
							// {
							// 	name: "收藏",
							// 	classify: 2,
							// },
						]
					: [
							{
								name: "全部",
								classify: 0,
							},
							{
								name: "推荐",
								classify: 1,
							},
						],
				active: 0,
			},
			popSelect: {
				isShow: false,
			},
			noticList: [],
			showNotic: "paused",
			userId: 0,
			currentInfo: {},
			appInfo: {},
			toTop: false,
			usetype: "share",
			useshare: true,
			isshowskit: false,
		};
	},

	onReachBottom() {
		let that = this;
		if (!uni.getStorageSync("apply-token") && that.tabInfo.active == 1) {
			return false;
		}
		if (that.query.isFinish == -1 || that.query.isFinish == that.query.size) {
			that.query.page++;
			that.getList("concat");
		}
	},
	computed: {
		appNameColor() {
			const darkThemes = ['#D81010', '#002470'];
			return darkThemes.includes(this.themeColor) ? '#ffffff' : '';
		}
	},
	methods: {
		themeColorRgba(alpha) {
			if (!this.themeColor) return `rgba(0,0,0,${alpha})`;
			let hex = this.themeColor.replace('#', '');
			if (hex.length === 3) hex = hex.split('').map(c => c + c).join('');
			let r = parseInt(hex.substring(0, 2), 16);
			let g = parseInt(hex.substring(2, 4), 16);
			let b = parseInt(hex.substring(4, 6), 16);
			return `rgba(${r},${g},${b},${alpha})`;
		},
		initData($data,callback=() => {}){
			let that = this;
			if(uni.getStorageSync("apply-token")){
				if(uni.getStorageSync("apply-userinfo") && uni.getStorageSync("apply-userinfo").agencyId == $data.id){
					that.isSelf = true;
					let hasCaidan = that.tabInfo.list.some(item => item.name === '采单');
					if (!hasCaidan) {
						that.tabInfo.list.push({
							name: '采单',
							classify: 2
						});
					}
					callback();
				}else{
					that.isSelf = false;
					callback();
				}
			}else{
				that.isSelf = false;
				callback();
			}
		},
		getMore(){
			let that = this;
			if(that.isJm){
				uni.navigateTo({
					url:'/root/merchantManagement/dynamicNotice?cont=' + that.noticList[0]
				})
			}
		},
		// 检查是否需要弹出申请加入弹窗（isAgency为false，每天只弹一次）
		checkShowApplyModal() {
			let that = this;
			// 如果已经是代理，不需要弹窗
			if (that.isAgency) {
				return;
			}
			
			// 获取上次弹窗日期
			let lastShowDate = uni.getStorageSync("apply_modal_last_date");
			let today = new Date().toDateString();
			
			// 如果今天还没弹过，则弹出
			if (lastShowDate !== today) {
				uni.showModal({
					title: "",
					content: "申请加入",
					confirmText: "去申请",
					showCancel: false,
					confirmColor: getApp().globalData.themeColor,
					success(res) {
						if (res.confirm) {
							// 跳转到申请页面
							uni.navigateTo({
								url: "/root/apply/index"
							});
						}
					}
				});
				// 记录今天已弹窗
				uni.setStorageSync("apply_modal_last_date", today);
			}
		},
		loadSelectedCityFromCache() {
			// 假设缓存中的键名为 'selectedCity'
			return new Promise((reso, rej) => {
				const cachedCity = uni.getStorageSync("selectedCity");
				console.log("this.selectedCity", this.selectedCity);
				console.log("this.selectedCity", cachedCity);
				if (cachedCity && this.selectedCity != cachedCity) {
					this.selectedCity = cachedCity;
				}
				// 无论是否有缓存，都要resolve，确保后续逻辑能继续执行
				reso();
			});
		},
		getLocation() {
			let that = this;
			return new Promise((resolve, reject) => {
				uni.authorize({
					scope: "scope.userLocation",
					success() {
						uni.getLocation({
							type: "wgs84",
							success(res) {
								that.currentInfo = {
									latitude: res.latitude,
									longitude: res.longitude,
									timestamp: new Date().getTime(),
								};
								resolve();
							},
							fail(err) {
								resolve();
							},
						});
					},
					fail(err) {
						uni.showToast({
							title: "请开启定位权限以显示距职位距离",
							icon: "none",
						});
						resolve();
					},
				});
			});
		},
		getCityNameByLatLng() {
			let that = this;
			return new Promise((resolve, reject) => {
				if (!this.currentInfo.latitude || !this.currentInfo.longitude) {
					resolve();
					return;
				}
				this.G.Get("/location/getCityNameByLatLng", { lng: this.currentInfo.longitude, lat: this.currentInfo.latitude }, (res) => {
					if (res) {
						that.currentCity = res.replace("市", "");
					}
					resolve();
				});
			});
		},
		initSelectedCityByAgencyInfo() {
			let that = this;
			return new Promise((resolve) => {
				let agencyInfo = uni.getStorageSync("agencyInfo");
				if (agencyInfo && agencyInfo.fdbHomeCity !== undefined) {
					that.processAgencyInfo(agencyInfo, resolve);
				} else {
					that.G.Get("/yishoudan/agency/getInfo", {}, (res) => {
						if (res && res.agency) {
							uni.setStorageSync("agencyInfo", res.agency);
							that.processAgencyInfo(res.agency, resolve);
						} else {
							that.cityLoading = false;
							resolve();
						}
					}, () => {
						that.cityLoading = false;
						resolve();
					});
				}
			});
		},
		processAgencyInfo(agencyInfo, resolve) {
			let that = this;
			if (agencyInfo && agencyInfo.fdbHomeCity !== undefined) {
				if (agencyInfo.fdbHomeCity == 1) {
					that.selectedCity = "全国";
					that.cityLoading = false;
					resolve();
				} else if (agencyInfo.fdbHomeCity == 0) {
					that.getLocation().then(() => {
						that.getCityNameByLatLng().then(() => {
							if (that.currentCity) {
								that.selectedCity = that.currentCity;
							}
							that.cityLoading = false;
							resolve();
						});
					});
				}
			} else {
				that.cityLoading = false;
				resolve();
			}
			// 设置默认tab
			if (agencyInfo && agencyInfo.fdbHomeTab !== undefined) {
				that.tabInfo.active = agencyInfo.fdbHomeTab == 1 ? 0 : 1;
				// 重置查询条件，参考handleUpdateTab的处理
				that.isshowskit = false;
				that.usetype = "share";
				that.useshare = true;
				that.query.list = [];
				that.loading = true;
				that.query.page = 1;
				that.speed = -1;
				if (that.tabInfo.list[that.tabInfo.active].classify == 2) {
					that.query.ujc = 1;
				} else {
					that.query.ujc = 0;
				}
			}
		},
		checkScroll() {
			let that = this;
			uni
				.createSelectorQuery()
				.select("#tttop")
				.boundingClientRect((data) => {
					// // console.log("data", data);
					if (data.top <= 0) {
						that.toTop = true;
					} else {
						that.toTop = false;
					}
					// domTopInfo.value[id] = data.top;
					// scrollTop.value = data.top - 200;
				})
				.exec();
		},
		/**
		 * 筛选相关========================================================
		 */
		deleteSex() {
			// console.log("deleteSex");
			this.getFilterData.sex = -1;
			this.getList();
		},
		deleteAge() {
			// console.log("deleteAge");
			this.getFilterData.ageRangeStr = "";
			this.getList();
		},

		deleteJobCategoryLabel(id) {
			// console.log(id);
			this.getFilterData.jobCategoryLabelObjects = this.getFilterData.jobCategoryLabelObjects.filter((obj) => obj.id != id);

			const idsArray = this.getFilterData.jobCategoryLabelObjects.map((obj) => obj.id);
			// 将数组转换为字符串
			this.getFilterData.jobCategoryLabelIds = idsArray.join(",");
			// console.log("deleteJobCategoryLabel", this.getFilterData);

			this.getList();
		},
		deleteJobSpecialLabel(id) {
			this.getFilterData.jobSpecialLabelObjects = JSON.parse(JSON.stringify(this.getFilterData.jobSpecialLabelObjects.filter((obj) => obj.id != id)));
			const idsArray = this.getFilterData.jobSpecialLabelObjects.map((obj) => obj.id);
			// 将数组转换为字符串
			this.getFilterData.jobSpecialLabelIds = idsArray.join(",");
			this.getFilterData["jobRequestLabelIds"] = idsArray.join(",");
			// console.log("deleteJobSpecialLabel", this.getFilterData);
			this.getList();
		},
		clearFilter1() {
			var that = this;
			this.getFilterData.jobCategoryLabelIds = "";
			this.getFilterData.jobSpecialLabelIds = "";
			this.getFilterData.jobCategoryLabelObjects = [];
			this.getFilterData.jobSpecialLabelObjects = [];
			this.scrollTo = "";
			this.getFilterData.sex = -1;
			this.getFilterData.ageRangeStr = "";
			// console.log("this.getFilterData", this.getFilterData);
			this.$refs.filterChild.clearFilter();
			this.getList();

			setTimeout(() => {
				that.scrollTo = "listBox";
				// console.log("aaaaaaaaa");
			}, 1);
		},
		receiveFromChild(data) {
			// console.log(data);
			this.whichOneShow = "";
			this.query.page = 1;
			this.getFilterData = JSON.parse(JSON.stringify(data));
			// console.log("getFilterData in receiveFromChild", this.getFilterData);
			this.getList();
			// this.messageFromChild = data.message;
		},
		chooseNl(type) {
			let that = this;

			that.scrollTo = "";
			that.whichOneShow = that.whichOneShow == type ? "" : type;
			setTimeout(() => {
				that.scrollTo = "tttop";
			}, 1);
		},
		handleOpenCamera() {
			let that = this;
			that.G.handleScanCode();
		},
		goPage($path) {
			uni.navigateTo({
				url: $path,
			});
		},
		reachBottom() {
			let that = this;
			if ((!uni.getStorageSync("apply-token") && that.tabInfo.active == 1) || !this.isLogin) {
				return false;
			}
			if (that.query.isFinish == -1 || that.query.isFinish == that.query.size) {
				that.query.page++;
				that.getList("concat");
			} else {
				if (that.tabInfo.active == 1 && that.usetype == "share") {
					that.isshowskit = true;
					that.usetype = "only";
					that.useshare = false;
					that.query.isFinish = -1;
					that.query.page = 1;
					that.query.size = 50;
					that.getList("initall");
				}
			}
		},
		isCheckShare(callback = () => {}) {
			let that = this,
				params = {};
			params = {
				...that.getFilterData,
				pageNum: that.query.page,
				pageSize: that.query.size,
				keys: that.keyword,
				ujc: that.query.ujc,
				sortTag: that.query.sortTag,
				recruitment: 1,
				classify: 1,
				workTypeStr: "",
				jobClassify: "",
				cityName: that.selectedCity == "全国" ? "" : that.selectedCity,
				brandIds: "",
			};
			params.lat = "";
			params.lng = "";
			let _url = that.api.job_share;
			// if (that.tabInfo.active == 1) {
			// 	params.topRecommend = 1;
			// }
			that.G.Post(_url, params, (res) => {
				console.log("一才职位列表：", res);
				let resData = {};
				resData = res.pageBean;
				// 只有在没有配置时才根据职位数量设置tab，否则尊重配置
				let agencyInfo = uni.getStorageSync("agencyInfo");
				if (!agencyInfo || agencyInfo.fdbHomeTab === undefined) {
					if (resData.recordCount == 0) {
						that.tabInfo.active = 0;
					} else {
						that.tabInfo.active = 1;
					}
				}
				console.log("that.tabInfo.active", that.tabInfo.active);
				callback();
			});
		},
		getList($type = "init") {
			let that = this,
				params = {};
			if (that.query.list.length != 0) {
				uni.showLoading({
					title: "加载中...",
					mask: true,
				});
			}

			let currentClassify = that.tabInfo.list[that.tabInfo.active].classify;
			params = {
				...that.getFilterData,
				pageNum: that.query.page,
				pageSize: that.query.size,
				keys: that.keyword,
				ujc: currentClassify == 2 ? 0 : that.query.ujc,
				sortTag: that.query.sortTag,
				recruitment: 1,
				classify: 1,
				workTypeStr: "",
				jobClassify: "",
				cityName: that.selectedCity == "全国" ? "" : that.selectedCity,
				brandIds: ""
			};
			if (currentClassify !== 2) {
				params.checkStore = true;
			}

			// if (that.tabInfo.list[that.tabInfo.active].classify == 1) {
			// 	params.jobType = 2;
			// }
			if (that.query.sortTag !== 2) {
				params.lat = "";
				params.lng = "";
				// params.sortTag = 0;
			} else {
				params.lat = that.currentInfo.latitude ? that.currentInfo.latitude : "";
				params.lng = that.currentInfo.longitude ? that.currentInfo.longitude : "";
				// params.sortTag = 2;
			}
			return new Promise((resolve, reject) => {
				let _url = "";
				if ($type == "initall") {
					_url = that.api.yi_job_list;
				} else {
					console.log(" that.useshare", that.useshare);
					if (that.tabInfo.active == 1 && that.useshare) {
						_url = that.api.job_share;
					} else {
						_url = that.api.yi_job_list;
					}
				}

				// if (that.tabInfo.active == 1 && $type != 'initall') {
				// 	params.topRecommend = 1;
				// }
				that.G.Post(_url, { ...params, abort: true }, (res) => {
					uni.hideLoading();
					// console.log("一才职位列表：", res);
					that.computeCode = 1;
					let resData = {};
					resData = res.pageBean;

					if (resData.recordCount == 0) {
						that.loading = false;
					} else {
						// 有数据时应该设置 loading = false，表示加载完成
						that.loading = false;
					}
					console.log("$type $type $type $type ", $type);
					// that.speed = resData.recordCount;
					// that.query.isFinish = resData.recordList.length;
					new Promise((reso) => {
						if (resData.recordList && resData.recordList.length > 0) {
							// if (that.tabInfo.active == 1) {
							// 	// 根据 distance 进行从小到大排序
							// 	resData.recordList.sort((a, b) => a.distance - b.distance);
							// }
							resData.recordList = that.G.toGetAddressv3(resData.recordList);
							resData.recordList = that.G.toGetAge(resData.recordList);
							if (uni.getStorageSync("JOB_REQUIRE_LIST") && Date.now() - uni.getStorageSync("JOB_REQUIRE_LIST").time < 2 * 24 * 60 * 60 * 1000) {
								resData.recordList = that.G.yijobCopy(resData.recordList);
								reso();
							} else {
								that.G.Post("/yishoudan/labels/type/app/80", {}, (res) => {
									uni.setStorageSync("JOB_REQUIRE_LIST", { data: res.labels, time: Date.now() });
									resData.recordList = that.G.yijobCopy(resData.recordList);
									reso();
								});
							}
						} else {
							reso();
						}
					}).then((res) => {
						console.log("00000000000000000000000000000000000000000000000000000000000000000000000000000res", res);
						if ($type == "init") {
							that.query.list = [];
							uni.setStorageSync("lin-liu", 0);
							uni.setStorageSync("lin-bao", 0);
							that.query.list = (resData.recordList || []).map((item, index) => {
								item.liuNum = uni.getStorageSync("lin-liu") ? uni.getStorageSync("lin-liu") : Math.floor(Math.random() * 1000);

								return {
									...item,
									liuNum: item.liuNum,
									baoNum: uni.getStorageSync("lin-bao") ? uni.getStorageSync("lin-bao") / 10 : Math.ceil(item.liuNum / 10),
									collected: item.collected ? true : false,
									cus_price: item.salaryClassify != 7 ? that.G.getSalaryClassifyValueHtml(item.salaryClassify, item.salaryClassifyValue) : "月薪",
									priceStr: item.salaryClassify != 7 ? that.G.getSalaryClassifyValue(item.salaryClassify, item.salaryClassifyValue) : "月薪",
									gender: that.G.getGenderByMinAge(item),
									recruitmentValue: item.recruitment == 1 ? true : false, 
									fuWuFei: that.G.setReturnFee(item.returnFee, item.returnFeeType),
									newXmf:uni.getStorageSync('apply-agencyId') == uni.getStorageSync('pgy-agency-id') ?
															 (item.agencyId == uni.getStorageSync('apply-agencyId') ? (item.upFullName || item.upAgencyName || item.upProviderName || '金马人力') : (item.agencyName || '金马人力')) : 
															'金马人力',
									newadd:that.G.setJobInfoPositionv3(item.storeDistrict || item.storeAddr)
								};
							});
							if (that.tabInfo.active == 1 && resData.recordList && resData.recordList.length < that.query.size) {
								console.log("111111111111111111111111111111111111111111111111");
								if (that.tabInfo.active == 1 && that.usetype == "share") {
									that.hrtext = 1;
									that.isshowskit = true;
									that.usetype = "only";
									that.useshare = false;
									that.query.isFinish = -1;
									that.query.page = 1;
									that.query.size = 50;
									that.getList("initall");
								} else {
									that.hrtext = 2;
								}
							}
						} else {
							if ($type == "initall") {
								that.query.list = that.query.list
									.concat([
										{
											isskit: 1,
											salaryClassifyValue: 3000,
											mainlyPopularize: 0,
											storeDistrict: "",
											agencyId: 115429,
											recommend: 0,
											collected: 0,
											cozeStructureRes:
												'{"企业位置":"湖北省武汉市","休息":"","住宿":"住宿免费，水电均摊","体检要求":"","佣金":"共计 1200 元","佣金详情":"利润：打卡 7 天 1200 元；卡点 3 天离职无费用；免车费或做到工期 150 元车补；不满 7 天及旷自离无费用","保险":"商保100元，按照记薪周期扣除","区域要求":"","厂牌押金":"","发薪日":"","吃饭":"刷卡吃饭，吃多少扣多少","员工福利":"免车费或做到工期150车补","安检门":"","宿舍押金":"","少数民族":"","岗位薪资":"30元/时","岗前培训":"","工作内容":"企业主要从事笔记本电脑组装","工作方式":"坐班为主，大部分坐着上班","工具押金":"","工衣":"","工装押金":"","带手机":"","性别年龄":"男 18 - 50；女 18 - 50","文化学历":"","案底黑户":"","流水线":"","班次工时":"","纬度":"30.584355","纹身烟疤":"","经度":"114.298572","综合月薪":"6930 - 9000元/月","职位分类":"电子厂","职位数量":"1","职位标签":"短期工 免费住宿 坐班为主 人走账清 免路费 有车补 工时高 交商保","职位标题":"武汉某电子厂小时工","薪资明细":"员工30元/小时，每天记薪10.5 - 11个小时，出勤不满点对点也按30元，工期需要在职20天，工期结束员工24元/小时留任需满月；做不到工期及留任不满月按16元/小时发放；不满7天及旷自离无工资；工资全额含服务费6%，服务费100元按照记薪周期扣除","试用期":"","资质证件":"","身份证":"身份证有效期要大于31天，小于31天的要临时身份证+身份证原件","身体状况":"测身高体重，BMI值17 - 32","车间":"","返厂政策":"","银行卡":"","面试地址":"","面试时间":"","面试注意事项":"身份证有效期要大于31天，小于31天的要临时身份证+身份证原件。测身高体重，BMI值17 - 31.99","面试评价":"","项目驻场":"","预支工资":"","餐卡押金":""}',
											recruitment: 1,
											picked: 0,
											maxMonthlyPay: 900000,
											logo: "",
											storeName: "",
											id: 154510,
											jobType: 2,
											upAgencyId: 115429,
											jobName: "武汉某电子厂小时工",
											storeAddr: "湖北省武汉市",
											salaryClassify: 0,
											minMonthlyPay: 693000,
											maxAgeWoman: 50,
											updateTime: 1757322659000,
											storeId: "",
											upProviderId: "",
											returnFeeType: 6,
											maxAge: 50,
											returnFee: 120000,
											visibleRange: 123,
											jobRequestLabelNames: "免费住宿, 交商保, 坐班为主, 短期工, 人走账清, 工时高, 有车补",
											minAge: 18,
											maxAgeMan: 50,
											minAgeWoman: 18,
											minAgeMan: 18,
										},
									])
									.concat(
										resData.recordList.map((item, index) => {
											return {
												...item,
												fuWuFei: that.G.setReturnFee(item.returnFee, item.returnFeeType),
												liuNum: item.liuNum,
												baoNum: uni.getStorageSync("lin-bao") ? uni.getStorageSync("lin-bao") / 10 : Math.ceil(item.liuNum / 10),
												collected: item.collected ? true : false,
												cus_price: item.salaryClassify != 7 ? that.G.getSalaryClassifyValueHtml(item.salaryClassify, item.salaryClassifyValue) : "月薪",
												priceStr: item.salaryClassify != 7 ? that.G.getSalaryClassifyValue(item.salaryClassify, item.salaryClassifyValue) : "月薪",
												gender: that.G.getGenderByMinAge(item),
												newXmf:uni.getStorageSync('apply-agencyId') == uni.getStorageSync('pgy-agency-id') ?
															 (item.agencyId == uni.getStorageSync('apply-agencyId') ? (item.upFullName || item.upAgencyName || item.upProviderName || '金马人力') : (item.agencyName || '金马人力')) : 
															'金马人力',
												newadd:that.G.setJobInfoPositionv3(item.storeDistrict || item.storeAddr)
											};
										}),
									);
							} else {
								that.query.list = that.query.list.concat(
									(resData.recordList || []).map((item, index) => {
										return {
											...item,
											liuNum: item.liuNum,
											baoNum: uni.getStorageSync("lin-bao") ? uni.getStorageSync("lin-bao") / 10 : Math.ceil(item.liuNum / 10),
											collected: item.collected ? true : false,
											cus_price: item.salaryClassify != 7 ? that.G.getSalaryClassifyValueHtml(item.salaryClassify, item.salaryClassifyValue) : "月薪",
											priceStr: item.salaryClassify != 7 ? that.G.getSalaryClassifyValue(item.salaryClassify, item.salaryClassifyValue) : "月薪",
											gender: that.G.getGenderByMinAge(item),
											recruitmentValue: item.recruitment == 1 ? true : false,
											fuWuFei: that.G.setReturnFee(item.returnFee, item.returnFeeType),
											newXmf:uni.getStorageSync('apply-agencyId') == uni.getStorageSync('pgy-agency-id') ?
														 (item.agencyId == uni.getStorageSync('apply-agencyId') ? (item.upFullName || item.upAgencyName || item.upProviderName || '金马人力') : (item.agencyName || '金马人力')) : 
															'金马人力',
												newadd:that.G.setJobInfoPositionv3(item.storeDistrict || item.storeAddr)
										};
									}),
								);
							}
						}
						that.speed = resData.recordCount || 0;
						that.query.isFinish = (resData.recordList || []).length;
						resolve();
					});
					// console.log("resData.recordList", resData.recordList);
				});
			});
		},
		goDetail($item) {
			uni.setStorageSync("HOME_ACTIVE_TAB", this.tabInfo.active);
			uni.setStorageSync("HOME_SKIP_REFRESH", true);
			uni.navigateTo({
				url: "/root/detail/job?id=" + $item.id,
			});
		},

		/**
		 * 搜索框的滚动监听变化
		 */
		searchAnimate() {
			return;
			let that = this;
			uni
				.createSelectorQuery()
				.select("#listBox")
				.fields(
					{
						scrollOffset: true,
						size: true,
					},
					(res) => {
						that.$mp.page.animate(
							"#searchInputBox",
							[
								{
									top: "10px",
									width: "100%",
								},
								{
									top: "-48px",
									width: "70%",
								},
							],
							800,
							{
								scrollSource: "#listBox",
								timeRange: 1000,
								startScrollOffset: 0,
								endScrollOffset: 60,
							},
						);
						that.$mp.page.animate(
							".the_city",
							[
								{
									color: "#333",
								},
								{
									color: "#fff",
								},
							],
							500,
							{
								scrollSource: "#listBox",
								timeRange: 1000,
								startScrollOffset: 0,
								endScrollOffset: 90,
							},
						);
					},
				)
				.exec();
		},
		shareJob(e) {
			// console.log(e);
			this.currentJob = e;
		},
		goSearch() {
			// this.G.isLogin();
			// if (this.G.isLogin()) {
			uni.navigateTo({
				url: "/root/other/search?from=home",
			});
			// }
		},
		goCity() {
			uni.navigateTo({
				url: "/root/other/city",
			});
		},
		getLocation() {
			let that = this;
			return new Promise((resolve, reject) => {
				uni.authorize({
					// 检测是否授权位置信息
					scope: "scope.userLocation",
					success() {
						// console.log("用户成功授权位置信息");
						uni.getLocation({
							type: "wgs84",
							success(res) {
								that.currentInfo = {
									latitude: res.latitude,
									longitude: res.longitude,
									timestamp: new Date().getTime(),
								};
								// console.log("获取当前经纬度：", that.currentInfo);
								resolve();
							},
							fail(err) {
								// console.log(err);
							},
							complete() {
								resolve();
							},
						});
					},
					fail(err) {
						// console.log(err);
						// console.log("用户拒绝授权位置信息，再次提示用户授权");
						uni.showToast({
							title: "请开启定位权限以显示距职位距离",
							icon: "none",
						});
						resolve();
						// that.showRefuseLocationPermission();
					},
					complete() {
						// console.log();
						// resolve();
					},
				});
			});
		},
		refreshJobList() {
			let that = this;
			this.query.page = 1;
			this.isTrigger = true;
			this.useshare = true;
			if (that.tabInfo.active == 1) {
				that.usetype = "share";
			}
			this.getList().then(() => {
				// console.log("that.isTrigger", that.isTrigger);
				that.isTrigger = false;
				that.getJobNum();
			});
		},
		getJobNum() {
			let that = this;
			that.G.Get(that.api.get_job_updateNum, { hour: 48 }, (res) => {
				// console.log("res", res);
				that.jobNum = res;
			});
		},
		getSearch(e) {
			this.speed = -1;
			this.isshowskit = false;
			this.keyword = e || "";
			this.query.page = 1;
			this.getList();
		},
		restoreActiveTab() {
			let savedTab = uni.getStorageSync("HOME_ACTIVE_TAB");
			if (savedTab !== "" && savedTab !== null && savedTab !== undefined) {
				uni.removeStorageSync("HOME_ACTIVE_TAB");
				if (savedTab !== this.tabInfo.active && savedTab < this.tabInfo.list.length) {
					this.tabInfo.active = savedTab;
					this.query.list = [];
					this.loading = true;
					this.query.page = 1;
					this.speed = -1;
					if (this.tabInfo.list[this.tabInfo.active].classify == 2) {
						this.query.ujc = 1;
					} else {
						this.query.ujc = 0;
					}
				}
			}
		},
		handleUpdateTab(e) {
			// console.log("获取tab数据：", e);
			let that = this;
			that.isshowskit = false;
			that.usetype = "share";
			that.useshare = true;
			that.query.list = [];
			that.loading = true;
			that.tabInfo.active = e;
			that.query.page = 1;
			that.speed = -1;
			if (that.tabInfo.list[that.tabInfo.active].classify == 2) {
				that.query.ujc = 1;
			} else {
				that.query.ujc = 0;
			}
			that.getList();
		},
		// 打开弹窗
		openPop() {
			uni.navigateTo({
				url: "/root/detail/select",
			});
		},

		// 批量分享
		goShare() {
			if (this.isLogin) {
				uni.navigateTo({
					url: "/root/detail/shareJob",
				});
			} else {
				uni.showModal({
					title: "登录提示",
					content: "该页面需要登录才能查看,是否登录",
					success(res) {
						if (res.confirm) {
							uni.navigateTo({
								url: "/root/login/index",
							});
						} else {
						}
					},
				});
			}
		},
		successLogin() {
			uni.reLaunch({
				url: "/pages/home/index",
			});
		},
		sortJob(ind) {
			let that = this;
			this.sortList.active = ind;
			that.loading = true;
			that.speed = -1;
			that.query.list = [];
			this.query.sortTag = this.sortList.list[ind].key;
			this.whichOneShow = "";
			if (this.query.sortTag === 2) {
				// 60 * 60 * 24
				if (that.currentInfo.latitude && new Date().getTime() - that.currentInfo.timestamp < 1000 * 10) {
					// console.log("inTime");
					this.getList();
				} else {
					// console.log("outTime");
					this.getLocation().then(() => {
						this.getList();
					});
				}
			} else {
				this.getList();
			}
		},
	},
};
</script>

<style lang="scss">
.ml8 {
	margin-left: 8px;
}
.bg_main {
	background-color: v-bind("globalData.themeBackgroundColor");
	border: 1px solid v-bind("globalData.themeColor");
}
.por {
	position: relative;
}

@font-face {
	font-family: "dongtai";
	font-display: swap;
	src: url("//at.alicdn.com/t/webfont_afw3rg7h8vi.eot");
	/* IE9*/
	src:
		url("//at.alicdn.com/t/webfont_afw3rg7h8vi.eot?#iefix") format("embedded-opentype"),
		/* IE6-IE8 */ url("//at.alicdn.com/t/webfont_afw3rg7h8vi.woff2") format("woff2"),
		url("//at.alicdn.com/t/webfont_afw3rg7h8vi.woff") format("woff"),
		/* chrome、firefox */ url("//at.alicdn.com/t/webfont_afw3rg7h8vi.ttf") format("truetype"),
		/* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url("//at.alicdn.com/t/webfont_afw3rg7h8vi.svg#NotoSansHans-DemiLight") format("svg");
	/* iOS 4.1- */
}

.dongtai {
	font-size: 30rpx;
	font-family: "dongtai";
	-webkit-text-stroke-width: 0.1px;
	// -moz-osx-font-smoothing: grayscale;
	font-weight: 600;
	color: #333;
}

.csbf {
	padding: 0px 8px;
	height: 28px;
	// background-color: #fff;
	border-radius: 16px;
	text-align: center;
	font-size: 14px;
	font-weight: 400;
	color: #333333;
	line-height: 28px;
	box-sizing: border-box;
	// margin-top: 6px;
	margin-right: 12px;
}

.p-home-inedx {
	background-color: #ededed;

	.m-more {
		position: absolute;
		left: 12rpx;
		bottom: -44rpx;
		width: 154px;
		background-color: #696969;
		box-shadow: 0px 2px 19px 0px rgba(179, 179, 179, 0.5);
		border-radius: 8px;
	}

	.suffix {
		position: absolute;
		right: 20rpx;
		top: 10px;
		z-index: 1;
		border-top-right-radius: 110rpx;
		border-bottom-right-radius: 110rpx;
	}

	// #ifdef MP-WEIXIN
	.u-border {
		border-color: #fff !important;
		background-color: #fff;
	}

	.navigatorBar .tabs {
		position: relative;
		left: 50%;
		color: #fff;
		transform: translateX(-50%);
		justify-content: center;
		box-sizing: border-box;
	}

	.sticky {
		position: sticky;
		top: 0px;
		left: 0;
		z-index: 100;
	}

	#searchInputBox {
		display: flex;
		justify-content: space-between;
		padding: 0 10px;
		top: 10px;
		box-sizing: border-box;
		position: relative;
		z-index: 9999;
		width: 100vw;
	}

	// #endif
}

.quickapply {
	/* position: relative; */
	display: flex;
	justify-content: space-between;
	height: 80px;
	margin: 0 10px 0;
	padding-top: 10px;
	margin-bottom: 0;
	/* background-color: #fff; */
	overflow: hidden;
}

.quickapply button {
	display: flex;
	height: 100%;
	width: 100%;
	padding: 0;
	margin: 0;
}

.sticky {
	position: sticky;
	top: 0px;
	left: 0;
	z-index: 999;
}

.quickapply button > view {
	position: relative;
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 50%;
	padding: 20px 24px;
	border-radius: 8px;
	background-color: #fff;
}

.quickapply button > view:last-child {
	margin-left: 10px;
}

.display-flex {
	display: flex;
	justify-content: space-between;
}

/* .quickapply button > view:first-child::after {
	content: "";
	width: 1px;
	height: 20px;
	position: absolute;
	right: 0;
	top: 50%;
	transform: translateY(-50%);
	background-color: #eee;
} */
.quickapply button > view .t-icon {
	width: 38px;
	height: 38px;
}

.quickapply button > view .info > view {
	text-align: left;
	line-height: 1.6;
}

.clear {
	position: sticky;
	right: 0px;
	top: 0px;
	height: 44px;
	min-width: 60px;
	text-align: center;
	line-height: 44px;
	font-size: 14px;
	background: linear-gradient(180deg, #f5f5f5, #ffffff 23%, #ffffff 79%, #f5f5f5);
	box-shadow: -12px 0px 8px -4px rgba(206, 206, 206, 0.6);
}

.clear_icon {
	position: absolute;
	display: inline-block;
	width: 12px;
	height: 12px;
	line-height: 10px;
	border-radius: 50%;
	background-color: #fff;
	right: -2px;
	top: -2px;
	color: #aaa;
	/* font-size: 12px; */
}

.u-notice-box {
	margin-left: 0 !important;
}
.defaultShadow {
	box-shadow: 0px 2px 3px 0px rgba(214, 214, 214, 0.3);
}
.loading-dot {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 20px;
}

.dot {
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background-color: #999;
	margin: 0 2px;
	animation: dotPulse 1.4s infinite ease-in-out;
}

.dot1 { animation-delay: 0s; }
.dot2 { animation-delay: 0.2s; }
.dot3 { animation-delay: 0.4s; }

@keyframes dotPulse {
	0%, 80%, 100% {
		transform: scale(0);
		opacity: 0.5;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
</style>
