<script>
export default {
	globalData: {
		isUseNewJob: true,
		// #ifdef MP-WEIXIN
		"g-open-env": "MP-MINI",
		appId: uni.getAccountInfoSync().miniProgram.appId,
		title: "",
		themeColor: "",
		logo: "",
		// #endif
		// #ifdef MP-TOUTIAO
		"g-open-env": "MP-TOUTIAO",
		appId: tt.getEnvInfoSync().microapp.appId,
		title: "",
		themeColor: "",
		logo: "",
		// #endif
		// #ifdef MP-KUAISHOU
		"g-open-env": "MP-KUAISHOU",
		appId: uni.getAccountInfoSync().miniProgram.appId,
		title: "",
		themeColor: "",
		logo: "",
		// #endif
	},
	onShow: function (options) {
		let that = this;
		uni.onNetworkStatusChange((res) => {
			console.log("res", res);
			console.log("网络状态改变");
		});
		// 小程序版本的判断(正式:release, 体验:trial, 开发:develop)
		uni.setStorageSync("ENV_VERSION", __wxConfig.envVersion);
		if (that.globalData.appId == "wxb0dea4d11428c6a5") {
			that.globalData.title = "伯才供应链";
			that.globalData.themeColor = "#3578f6";
			that.globalData.logo = uni.getStorageSync("miniApp-info").logo || "https://matripe-cms.oss-cn-beijing.aliyuncs.com/pugongying/renhailaowu.png";
		} else if (that.globalData.appId == "wxe431e0b3abd9ae0b") {
			that.globalData.title = "伯才工作";
			that.globalData.themeColor = "#3578f6";
			that.globalData.logo = uni.getStorageSync("miniApp-info").logo || "https://matripe-cms.oss-cn-beijing.aliyuncs.com/pugongying/renhailaowu.png";
		} else if (that.globalData.appId == "wxb0c590fd696b79be") {
			that.globalData.title = "稻田工作";
			that.globalData.themeColor = "#0dcc91";
			that.globalData.logo = uni.getStorageSync("miniApp-info").logo || "https://matripe-cms.oss-cn-beijing.aliyuncs.com/pugongying/yicaiLogoBgf913.png";
		} 

		if (options.query.id) {
			uni.setStorageSync("apply-jobdetail-id", options.query.id);
		} else {
			uni.setStorageSync("apply-jobdetail-id", 0);
		}

		if (options.query.scene) {
			let str = decodeURIComponent(options.query.scene);
			uni.setStorageSync(
				"apply-invite-code",
				JSON.stringify({
					key: str.split("=")[0],
					value: str.split("=")[1],
				})
			);
		} else {
			uni.setStorageSync("apply-invite-code", "");
		}
		// 获取小程序权限信息
		if (uni.getStorageSync("apply-token")) {
			that.G.Get(
				that.api.user_checkPermission,
				{},
				(res) => {
					console.log(res);

					uni.setStorageSync("HAS_PERMISSION", 1); // 1.有权限 2.无权限
				},
				(err) => {
					console.log(err);
					if (err) {
						uni.setStorageSync("HAS_PERMISSION", 2);
					}
				}
			);
		}

		const updateManager = uni.getUpdateManager();
		updateManager.onCheckForUpdate(function (res) {
			console.log("检测是否有新版本：", res.hasUpdate);
		});
		updateManager.onUpdateReady(function (res) {
			uni.showModal({
				title: "更新提示",
				content: "新版本已经准备好，需重启应用",
				showCancel: false,
				success(res) {
					if (res.confirm) {
						console.log("新版本已经准备好，需重启应用");
						updateManager.applyUpdate();
					}
				},
			});
		});
		updateManager.onUpdateFailed(function (res) {
			uni.showModal({
				title: "更新提示",
				content: "新版本下载异常，需重启应用",
				showCancel: false,
				success(res) {
					if (res.confirm) {
						console.log("新版本下载异常，需重启应用");
						updateManager.applyUpdate();
					}
				},
			});
		});
		this.G.getAgencyInfo();
		this.G.getServiceQRCode();
		if (uni.getStorageSync("apply-token")) {
			that.G.checkToken();
		}
		this.$forceUpdate();
	},
	onLoad() {
		this.getAgencyInfo();
	},
	onHide: function () {},
	methods: {
		getAgencyInfo() {
			let that = this;
			// that.G.Get("/yishoudan/agency/getInfo", "", (res) => {
			// 	console.log("res12312312312312", res);
			// });
		},
	},
};
</script>

<style lang="scss">
@import "./static/css/iconfont.css";
@import "uview-ui/index.scss";
@import "./static/css/base.scss";
@import "./static/font/iconfont-weapp-icon.wxss";

// #ifdef MP-WEIXIN
page {
	width: 100vw;
	height: 100vh;
}
// #endif
// #ifdef H5 || APP-PLUS || MP-TOUTIAO || MP-KUAISHOU
page {
	width: 100vw;
	height: calc(100% - 0px);
	--color-ysd: #ff4400;
	--color-hover: #ff4400cc;
	--color-be: #ff4400;
	--color-027: #ff4400;
	--color-href: #576b95;
}
// #endif

// uview默认样式覆盖
.u-badge-mini {
	top: 22rpx !important;
	right: 102rpx !important;
	color: transparent !important;
	width: 10px !important;
	height: 10px !important;
	border-radius: 50% !important;
}
.u-radio {
	&:last-child {
		.u-radio__label {
			margin-right: 0;
		}
	}
}

.g-apply-tab {
	.u-tab-bar {
		bottom: -2px !important;
	}
}
.home-swiper {
	.u-notice-bar {
		border-radius: 6px;
	}
}
</style>
