<template>
	<view class="p-root-person-collect g_w_all g_bg_f_5 g_pt_10 g_kuaishou">
		<view v-show="computeCode == -1" class="g_flex_column_center">
			<rh-loading marginBottom="g_mb_130" />
		</view>
		<view v-show="computeCode > -1" class=" ">
			<!-- 列表区 -->
			<scroll-view class="m-list" id="listBox" :style="{ height: `${wheight}px)` }" :scroll-y="true" @scrolltolower="reachBottom">
				<view class="">
					<g-yi-list-job from="collect" class="g_h_all" :list="query.list" @clickCard="goDetail" :loading="loading" :speed="speed" :query="query" emptyText="嘿，这里还没有数据呢" pt="260" />
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
export default {
	onReady() {},
	onShareAppMessage() {
		return this.G.shareFun();
	},
	onLoad() {
		let that = this;
	},
	data() {
		return {
			wheight: uni.getSystemInfoSync().windowHeight,
			computeCode: -1,
			cdnBaseImg: this.G.store().cdnBaseImg,
			localBaseImg: this.G.store().localBaseImg,
			loading: true,
			appId: getApp().globalData.appId,
			speed: -1,
			query: {
				page: 1,
				size: 50,
				list: [],
				isFinish: -1,
			},
		};
	},
	onShow() {
		let that = this;
		that.getList();
	},
	onReachBottom() {
		let that = this;
		this.G.isLogin();
		if (this.G.isLogin()) {
			if (that.query.isFinish == -1 || that.query.isFinish == that.query.size) {
				that.query.page++;
				that.getList("concat");
			}
		}
	},
	methods: {
		reachBottom() {
			let that = this;
			this.G.isLogin();
			if (this.G.isLogin()) {
				if (that.query.isFinish == -1 || that.query.isFinish == that.query.size) {
					that.query.page++;
					that.getList("concat");
				}
			}
		},
		getList($type = "init") {
			let that = this;
			let url = "yi_job_list";
			that.G.Post(
				that.api[url],
				{
					pageNum: that.query.page,
					pageSize: that.query.size,
					keys: "",
					ujc: 1,

					recruitment: 1,
					classify: 1,
					sex: -1,
					workTypeStr: "",
					lat: "",
					lng: "",
					jobClassify: "",
					sortTag: 0,
					jobSpecialLabelIds: "",
					cityName: "",
					brandIds: "",
					jobCategoryLabelIds: "",
					checkStore: true
				},
				(res) => {
					console.log("一才职位列表：", res);
					that.computeCode = 1;
					let resData = {};
					resData = res.pageBean;
					if (resData.recordCount == 0) {
						that.loading = false;
					} else {
						that.loading = true;
					}
					that.speed = resData.recordCount;
					that.query.isFinish = resData.recordList.length;
					if (resData.recordList && resData.recordList.length > 0) {
						resData.recordList = that.G.toGetAddressv3(resData.recordList);
						resData.recordList = that.G.toGetAge(resData.recordList);
						resData.recordList = that.G.yijobCopy(resData.recordList);
						// resData.recordList.forEach((ita) => {
						// 	ita.addss = that.G.setJobInfoPositionv3(ita.storeAddr);
						// });
					}
					if ($type == "init") {
						that.query.list = [];
						that.query.list =
							resData.recordList && resData.recordList.length > 0
								? resData.recordList.map((item, index) => {
										return {
											...item,
											collected: item.collected ? true : false,
											cus_price: item.salaryClassify != 7 ? that.G.getSalaryClassifyValueHtml(item.salaryClassify, item.salaryClassifyValue) : "月薪",
											gender: that.G.getGenderByMinAge(item),
											newadd:that.G.setJobInfoPositionv3(item.storeDistrict || item.storeAddr)
										};
								  })
								: [];
					} else {
						that.query.list = that.query.list.concat(
							resData.recordList && resData.recordList.length > 0
								? resData.recordList.map((item, index) => {
										return {
											...item,
											collected: item.collected ? true : false,
											cus_price: item.salaryClassify != 7 ? that.G.getSalaryClassifyValueHtml(item.salaryClassify, item.salaryClassifyValue) : "月薪",
											gender: that.G.getGenderByMinAge(item),
											newadd:that.G.setJobInfoPositionv3(item.storeDistrict || item.storeAddr)
										};
								  })
								: []
						);
					}
				}
			);
		},
		goDetail($item) {
			console.log("前往详情页", $item);
			uni.navigateTo({
				url: "/root/detail/job?id=" + $item.id,
			});
		},
	},
};
</script>

<style lang="scss">
.p-root-person-collect {
	background-color: #ededed;
	min-height: 100%;
}
</style>
