<!-- 
[报名] 样式3 - 排名总览
http://localhost:5173/card/#/pages/bm/style4/rankOverview
https://oss-mbh5.colormaprun.com/card/#/pages/bm/style4/rankOverview
 -->
<template>
	<view class="body">
		<view class="content uni-column">
			<view class="uni-column" :class="cssTop">
				<my-topbar :mcName="mcName" :class="cssTopbarColor"
					@btnBackClick="btnBack" @btnInfoClick="btnInfo"></my-topbar>
				
				<view class="topcontent uni-column uni-jcsa">
					<view class="logo"></view>
					<text v-if="configParam.subTitle.length > 0" class="top-acttime">{{configParam.subTitle}}</text>
					<text v-else class="top-acttime">{{fmtMcTime2(beginSecond, endSecond)}}</text>
				</view>
			</view>

			<view class="mid uni-column">
				<view class="mid-0 uni-row uni-jcsb">
					<e-select class="" v-model="ocaId" :options="mapList" :search="false" :inputClick="true"
						:clearable="false" @change="eSelectChange"></e-select>
				</view>
				<view class="mid-1 uni-row uni-jcsa">
					<text class="mid-1-text">{{nickName}}</text>
					<text class="mid-1-text">{{coiName}}</text>
					<text class="mid-1-text" style="color: #aaaaaa;" v-if="mcState==1 && allowMcSignUp"
						@click="btnReGroup">修改</text>
				</view>
				<view class="mid-2 uni-row uni-jcsa">
					<view class="uni-column">
						<text class="mid-2-value">{{regionTotalNum}}</text>
						<text class="mid-2-text">总场次</text>
					</view>

					<view class="mid-line"></view>
					<view class="uni-column">
						<text class="mid-2-value">{{regionTotalCp}}</text>
						<text class="mid-2-text">总打点数</text>
					</view>

					<view class="mid-line"></view>
					<view class="uni-column">
						<text class="mid-2-value">{{regionTotalCpRankNum}}</text>
						<text class="mid-2-text">个人排名</text>
					</view>

				</view>
			</view>

			<view class="main uni-column">
				<text class="main-title">选择比赛路线</text>
				<my-pathList :style="pathListStyle.style" :pathList="pathList"
					:selectedPath="ocaId" :mcState="mcState" :showLine="pathListStyle.showLine"
					@onPathClick="onPathClick"></my-pathList>
			</view>
			
			<view class="bottom uni-column">
				<button class="btnStartGame" @click="btnStartGame">开始比赛</button>
			</view>
			
			<my-popup ref="mypopup" :config="popupRuleConfig" :dataList="popupDataList" :acttime="acttime"></my-popup>
			<!-- <my-popup-map ref="mypopupmap" :point="navPoint"></my-popup-map> -->
		</view>
	</view>
</template>

<script>
	import tools from '/common/tools';
	import {
		defaultPopUpDataList
	} from '/common/define';
	import {
		token,
		apiMapListQuery,
		apiMatchRsDetailQuery,
		apiCardConfigQuery,
		apiIsAllowMcSignUp,
		checkResCode
	} from '/common/api';

	export default {
		data() {
			return {
				// audioSrc: "/static/audio/2.mp3",
				// audioSrc: "https://oss-mbh5.colormaprun.com/card/static/audio/2.mp3",
				// audioSrc: "http://t-oss-mbh5.colormaprun.com/card/static/audio/2.mp3",
				pageName: "rankOverview",
				firstEnterKey: 'firstEnter-bm-style4',
				rankKey: "rank-bm-style4",
				mapKey: "rank-bm-style4-map",
				queryObj: {},
				queryString: "",
				token: "",

				ecId: 0, // 卡片id
				mcId: 0, // 赛事id
				mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
				mcName: "", // 赛事名称
				coiName: "", // 已报名单位名称
				acttime: "", // 活动时间
				beginSecond: null, // 活动或赛事开始时间戳，单位秒
				endSecond: null, // 活动或赛事结束时间戳，单位秒
				ocaId: 0, // 关联id，带入到App活动详情页面
				nickName: "", // 昵称

				totalNum: null, // 总场次
				totalDistanct: null, // 总距离,单位米
				totalDistanctRankNum: null, // 总距离排名
				totalCp: null, // 总打点数
				totalCpRankNum: null, // 总打点数排名
				totalSysPoint: null, // 总百味豆
				totalSysPointRankNum: null, // 总百味豆排名
				fastPace: null, // 个人最快配速
				fastPaceRankNum: null, // 个人最快配速排名
				regionTotalNum: null, // 地图内总场次
				regionTotalCp: null, // 地图内打点数
				regionTotalCpRankNum: null, // 地图内个人打点排名
				ocaRs: [], // 卡片对应活动集合

				mapList: [], // 地图列表

				interval: null,
				mcState: 0, // 赛事/活动状态 0: 未开始  1: 进行中  2: 已结束
				allowMcSignUp: false, // 是否允许重新分组
				cssTop: "",
				cssTopbarColor: "",
				pathList: {},
				pathListStyle: {},
				popupRuleConfig: {}, // 规则弹窗配置
				popupDataList: [],
				navPoint: {},
				configParam: {
					subTitle: ""
				},
			}
		},
		computed: {
			pathListLen() {
				return Object.keys(this.pathList).length;
			}
		},
		onLoad(query) { // 类型非必填，可自动推导
			// console.log("query:", query);
			this.queryObj = query;
			this.queryString = tools.objectToQueryString(this.queryObj);
			// console.log(queryString);
			this.token = query["token"] ?? token;
			this.ecId = query["id"] ?? 0;

			this.firstEnterKey += "-" + this.ecId;
			console.log("firstEnterKey:", this.firstEnterKey);

			this.rankKey += "-" + this.ecId;
			console.log("rankKey:", this.rankKey);

			this.mapKey += "-" + this.ecId;
			console.log("mapKey:", this.mapKey);

			tools.removeCssCode();

			const mapValue = uni.getStorageSync(this.mapKey);
			if (mapValue) {
				console.log("mapValue:", mapValue);
				this.ocaId = mapValue;
			}

			this.getCardConfigQuery();
		},
		// 页面初次渲染完成，此时组件已挂载完成，DOM 树($el)已可用
		onReady() {
			// this.dealFirstEnter();
			// this.playMusic();
		},
		onShow() {
			// uni.showToast({
			// 	icon: "none",
			// 	title: "[rankOverview] onShow"
			// })
			// if (this.$audio.audioStatus == 2 && this.$audio.audioSrc == this.audioSrc) {
			// 	this.$audio.play();
			// }
		},
		onUnload() {
			this.clear();
		},
		methods: {
			playMusic() {
				return;
				// uni.showToast({
				// 	title: 'playMusic',
				// 	icon: 'none',
				// 	duration: 2000
				// });
				// if (this.$audio.audioStatus == 0 || this.$audio.audioSrc != this.audioSrc) {
				// 	this.$audio.playAudio(this.audioSrc);
				// }
			},
			dealNotice(rank) {
				// console.log('[dealFirstEnter]');
				let that = this;
				uni.getStorage({
					key: that.rankKey,
					success: (res) => {
						console.log('[getStorage]', that.rankKey, res.data);
						const oldRank = res.data;
						if (oldRank != rank) {
							// that.notice = true;
							that.setRankValue(rank);
						}
					},
					fail: (e) => {
						console.log('[getStorage] fail', that.rankKey, e);
						// that.notice = false;
						that.setRankValue(rank);
					},
				})
			},
			setRankValue(data) {
				let that = this;
				uni.setStorage({
					key: that.rankKey,
					data: data,
					success: () => {
						console.log('[setStorage] success', that.rankKey, data);
					},
					fail: (e) => {
						console.log('[setStorage] fail', that.rankKey, e);
					},
				})
			},
			dealFirstEnter() {
				// console.log('[dealFirstEnter]');
				let that = this;
				uni.getStorage({
					key: that.firstEnterKey,
					success: (res) => {
						console.log('[getStorage]', that.firstEnterKey, res.data);
					},
					fail: (e) => {
						console.log('[getStorage] fail', that.firstEnterKey, e);
						that.btnInfo();
						that.setFirstEnterValue(true);
					},
				})
			},
			setFirstEnterValue(data) {
				let that = this;
				uni.setStorage({
					key: that.firstEnterKey,
					data: data,
					success: () => {
						console.log('[setStorage] success', that.firstEnterKey, data);
					},
					fail: (e) => {
						console.log('[setStorage] fail', that.firstEnterKey, e);
					},
				})
			},
			clear() {
				if (this.interval != null) {
					clearInterval(this.interval);
					this.interval = null;
				}
			},
			loadConfig(config) {
				// console.log("config", config);

				// 加载CSS样式
				const css = config.css;
				if (css != undefined && css.length > 0) {
					tools.loadCssCode(css);

					if (css.indexOf(".top{") >= 0) {
						this.cssTop = "top";
					}
					if (css.indexOf(".topbar-color{") >= 0) {
						this.cssTopbarColor = "topbar-color";
					}
				}

				if (this.cssTop == "") {
					this.cssTop = "top-default";
				}
				if (this.cssTopbarColor == "") {
					this.cssTopbarColor = "topbar-color-default";
				}
				console.log("[loadConfig] cssTop:", this.cssTop);
				console.log("[loadConfig] cssTopbarColor:", this.cssTopbarColor);

				// 加载比赛路线数据
				const pathList = config.pathList;
				// console.log("[loadConfig] pathList:", pathList);
				if (pathList != undefined) {
					this.pathList = pathList;
				}

				// 加载比赛路线样式
				const pathListStyle = config.pathListStyle;
				// console.log("[loadConfig] pathList:", pathList);
				if (pathListStyle != undefined) {
					this.pathListStyle = pathListStyle;
				}

				// 加载规则弹窗配置
				const popupRuleConfig = config.popupRuleConfig;
				if (popupRuleConfig != undefined) {
					this.popupRuleConfig = popupRuleConfig;
				}
				// console.log("[loadConfig] popupRuleConfig:", this.popupRuleConfig);
				
				// 加载弹窗数据
				const popupDataList = config.popupDataList;
				// console.log("[loadConfig] popupDataList:", popupDataList);
				if (popupDataList != undefined && popupDataList.length > 0) {
					for (var i = 0; i < popupDataList.length; i++) {
						// console.log("[loadConfig] popupDataList", i, popupDataList[i]);
						if (popupDataList[i] == 'default') {
							for (var j = 0; j < defaultPopUpDataList.length; j++) {
								this.popupDataList.push(defaultPopUpDataList[j]);
							}
						} else {
							this.popupDataList.push(popupDataList[i]);
						}
					}
				} else {
					this.popupDataList = defaultPopUpDataList;
					console.log("[loadConfig] popupDataList 加载默认列表");
				}
				// console.log("[loadConfig] popupDataList:", this.popupDataList);
				
				// 加载页面参数
				const param = config.param;
				if (param != undefined) {
					if (param.subTitle != undefined && param.subTitle.length > 0) {
						this.configParam.subTitle = param.subTitle;
					}
				}
				// console.log("[loadConfig] param:", this.configParam);
			},
			// 获取倒计时
			getCountdown() {
				// console.log(this.endSecond)
				if (this.endSecond > 0) {
					const now = Date.now() / 1000;
					const dif = this.endSecond - now;
					// const dif = 3600*24 - 60;
					if (dif > 0) {
						this.countdown = '距结束 ' + tools.convertSecondsToDHM(dif);
					} else {
						this.countdown = "活动已结束";
					}
					// this.countdown = tools.convertSecondsToHMS(dif);
				} else {
					this.countdown = "距结束 --天--小时";
				}
			},
			// 格式化 距离
			fmtDistanct(val) {
				return Math.round(val * 100 / 1000) / 100;
				/* if (val < 1000)
					return Math.round(val * 10 / 1000) / 10;
				else
					return Math.round(val / 1000); */
			},
			// 格式化 配速
			fmtPace(val) {
				return tools.convertSecondsToHMS(val, 2);
			},
			fmtMcTime(timestamp) {
				return tools.fmtMcTime(timestamp);
			},
			// 获取活动时间
			getActtime() {
				this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
			},
			fmtMcTime2(timestamp1, timestamp2) {
				return tools.fmtMcTime2(timestamp1, timestamp2);
			},
			getCardConfigQuery() {
				uni.request({
					url: apiCardConfigQuery,
					header: {
						"Content-Type": "application/x-www-form-urlencoded",
						"token": this.token,
					},
					method: "POST",
					data: {
						ecId: this.ecId,
						pageName: this.pageName
					},
					success: (res) => {
						// console.log("getCardConfigQuery", res)
						const data = res.data.data;
						// console.log("configJson", data.configJson);
						const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
						// console.log("configJson", data.configJson);
						/* const config = {
							"css": `
								.top{
									position: relative;
									width: 100%;
									height: 220px;
									padding-top: 36px;
									justify-content: space-between;
									background-image: url('static/backgroud/top_bg_sddx.png');
									background-repeat: no-repeat;
									background-position-x: center;
									background-position-y: center;
									background-size: cover;
								}
								.logo{
									background-image: url('static/logo/sddx.png');
								}
								.top-acttime{
									display: flex !important;
								}
								.topbar-color{
									color: #ffffff;
								}
								.mid{
									margin-top: -40px !important;
								}
								.btnStartGame{
									background-color: #a43a07 !important;
								}
								.e-select{
									background-color: #a43a07 !important;
								}
								.swiper-item-button{
									background-color: #a43a07 !important;
								}
								.uni-swiper-dot-active{
									background: #a43a07 !important;
								}
							`,
							"pathList": {
								 "row1": [
									{
										"type": 3,
										"pathImg": "/static/common/sdzxxq.png",
										"path": {
											"ocaId": 9,
											"mcType": 3
										},
										"navImg": "/static/common/nav.png",
										"point": {
											"longitude": 117.05842197272015,
											"latitude": 36.6773045110179,
											"name": "山大中心校区起始点"
										}
									},
									{
										"type": 3,
										"pathImg": "/static/common/sdbtqxq.png",
										"path": {
											"ocaId": 19,
											"mcType": 3
										},
										"navImg": "/static/common/nav.png",
										"point": {
											"longitude": 117.01808165974633,
											"latitude": 36.651520245517816,
											"name": "山大趵突泉校区起始点"
										}
									}
								],
								"row2": [
									{
										"type": 3,
										"pathImg": "/static/common/sdhjlxq.png",
										"path": {
											"ocaId": 10,
											"mcType": 3
										},
										"navImg": "/static/common/nav.png",
										"point": {
											"longitude": 117.06584701149195,
											"latitude": 36.68711365814297,
											"name": "山大洪家楼校区起始点"
										}
									},
									{
										"type": 3,
										"pathImg": "/static/common/sdrjyxq.png",
										"path": {
											"ocaId": 21,
											"mcType": 3
										},
										"navImg": "/static/common/nav.png",
										"point": {
											"longitude": 117.1434547046918,
											"latitude": 36.66680223258383,
											"name": "山大软件园校区起始点"
										}
									}
								],
								"row3": [
									{
										"type": 3,
										"pathImg": "/static/common/sdxlsxq.png",
										"path": {
											"ocaId": 11,
											"mcType": 3
										},
										"navImg": "/static/common/nav.png",
										"point": {
											"longitude": 117.0517531094238,
											"latitude": 36.598365483441846,
											"name": "山大兴隆校区起始点"
										}
									},
									{
										"type": 3,
										"pathImg": "/static/common/sdqfsxq.png",
										"path": {
											"ocaId": 20,
											"mcType": 3
										},
										"navImg": "/static/common/nav.png",
										"point": {
											"longitude": 117.0281052458668,
											"latitude": 36.64736827526403,
											"name": "山大千佛山校区起始点"
										}
									}
								]
							},
							"pathListStyle": {
								"showLine": true,
								"style": "justify-content: flex-start;"
							},
							"popupRuleConfig": {
								"height": "500px"
							},
							"popupDataList": [
								{
									"type": 1,
									"data": {
										"title": "山大24级新生校园定向赛",
										"img": "/static/logo/sddx.png",
										"content": "　　开学季来袭！山大24级新生校园定向赛燃情启幕！探索校园每一个角落，挑战智慧与体能，全校师生共同开启新学期活力篇章！等你来挑战！"
									}
								},
								{
									"type": 7,
									"data": {
										"topLogo": {
											"src": "/static/logo/sddx.png",
											"width": "80px",
											"height": "80px"
										},
										"bottomLogo": {
											"src": "/static/logo/inzone.png",
											"width": "150px",
											"height": "30px"
										},
										"title": "活动流程",
										"content": "<br>① 起点打点 → ② 依次打点 → ③ 接受挑战 <br><br>④ 终点打点 → ⑤ 查看成绩 → ⑥ 赢取奖励",
										"imageList": []
									}
								},
								{
									"type": 7,
									"data": {
										"topLogo": {
											"src": "/static/logo/sddx.png",
											"width": "80px",
											"height": "80px"
										},
										"bottomLogo": {
											"src": "/static/logo/inzone.png",
											"width": "150px",
											"height": "30px"
										},
										"title": "赛事规则",
										"content": "<p style='margin-bottom:12px;'>① 选择所在校区，参赛时间自由、路线随机</p> <p style='margin-bottom:12px;'>② 准确填报院系，共筑个人与院系荣耀</p> <p style='margin-bottom:12px;'>③ 打点1次1积分，途经点正确答题1积分，多次完赛，点数累加</p> <p style='margin-bottom:12px;'>④ 正常完赛累计积分，未完赛积分不计入</p>",
										"imageList": []
									}
								},
								{
									"type": 7,
									"data": {
										"topLogo": {
											"src": "/static/logo/sddx.png",
											"width": "80px",
											"height": "80px"
										},
										"bottomLogo": {
											"src": "/static/logo/inzone.png",
											"width": "150px",
											"height": "30px"
										},
										"title": "赛事奖励1",
										"content": "团队奖：<br>院系累计积分前8名； <text style='color:red;'>奖励</text>：团队奖杯 <br><br>个人奖：<br>各校区累计积分前10名；<text style='color:red;'>奖励</text>：荣誉证书完赛者均可获得参赛证书。<br> <text style='color:#A6A6A6;'>（赛事结束后体育委员会自APP颁发）</text>",
										"imageList": []
									}
								},
								{
									"type": 7,
									"data": {
										"topLogo": {
											"src": "/static/logo/sddx.png",
											"width": "80px",
											"height": "80px"
										},
										"bottomLogo": {
											"src": "/static/logo/inzone.png",
											"width": "150px",
											"height": "30px"
										},
										"title": "赛事奖励2",
										"content": "<p style='margin-bottom:12px;'>外部奖励：<br>各校区前10名获银座集团价值<text style='color:red;'>200元</text>进阶宠爱大礼。</p> <p style='margin-bottom:12px;'>完赛一次，可获银座价值<text style='color:red;'>50元</text>新生宠爱盲盒。<text style='color:#A6A6A6;'>（数量有限，发完为止）</text></p>每获25积分，可获银座<text style='color:red;'>100减10</text>优惠券1张。封顶5张，可与店内优惠叠加使用。<br><text style='color:#A6A6A6;'>（部分商品、特殊特例商品除外）</text>",
										"imageList": []
									}
								},
								{
									"type": 7,
									"data": {
										"title": "安全提示",
										"content": "<br><text style='color:#FFBA99; font-size: 20px; margin-right: 5px;'>●</text> 避免聚集，注意安全<br><br> <text style='color:#FFBA99; font-size: 20px; margin-right: 5px;'>●</text> 评估自身健康，适时参与<br><br> <text style='color:#FFBA99; font-size: 20px; margin-right: 5px;'>●</text> 注意交通与场地安全",
										"imageList": [{
											"src": "/static/backgroud/shanda.png",
											"width": "300px",
											"height": "150px"
										}]
									}
								},								
								{
									"type": 2,
									"data": {
										"title": "基本图例",
										"img": "/static/common/jbtl.png"
									}
								},
								{
									"type": 2,
									"data": {
										"title": "基本标识",
										"img": "/static/common/jbbs2.png"
									}
								},
								{
									"type": 7,
									"data": {
										"topLogo": {
											"src": "/static/logo/sddx.png",
											"width": "80px",
											"height": "80px"
										},
										"bottomLogo": {
											"src": "/static/logo/inzone.png",
											"width": "150px",
											"height": "30px"
										},
										"title": "山大定向赛咨询群",
										"content": "",
										"imageList": [{
											"src": "/static/common/qrcode_sddxszxq.png",
											"width": "116px",
											"height": "116px"
										}],
										"memo": "<view style='display:block; text-align:center;'>赛事规程、流程、奖励咨询 <br><view style='color:#808080; font-size:12px'>（7*24小时解答）</view></view>"
									}
								},
								{
									"type": 8,
									"data": {
										"title": "兑换地点",
										"topImg": {
											"src": "/static/logo/inzone2.png",
											"width": "72px",
											"height": "72px"
										},
										"topMemo": "<view style='color:#E60012;font-size:14px;'>品质消费引领者 &nbsp; &nbsp; 美好生活推荐官</view>",
										"bottomMemo": "<view style='display: block; margin-top: 20px; text-align: center; font-weight: 500; font-size: 14px;'>优惠券使用说明</view>",
										"bottomMemoUrl": "https://oss-mbh5.colormaprun.com/page/explanation/inzone.html",
										"pointList": [
											{
												"map": "中 心 校 区",
												"name": "银座燕山店",
												"longitude": 117.075174,
												"latitude": 36.654108
											},
											{
												"map": "洪家楼校区",
												"name": "银座洪楼店",
												"longitude": 117.062653,
												"latitude": 36.684249
											},
											{
												"map": "兴隆山校区",
												"name": "银座七里山店",
												"longitude": 117.004617,
												"latitude": 36.613655
											},
											{
												"map": "趵突泉校区",
												"name": "银座泉城广场店",
												"longitude": 117.023766,
												"latitude": 36.661532
											},
											{
												"map": "千佛山校区",
												"name": "银座玉函店",
												"longitude": 117.014735,
												"latitude": 36.647098
											},
											{
												"map": "软件园校区",
												"name": "银座高新店",
												"longitude": 117.122241,
												"latitude": 36.682175
											}
										]
									}
								}
							],
							"param": {
								"subTitle": "山东大学123周年庆"
							}
						}; */

						this.loadConfig(config);
						this.matchRsDetailQuery();

						setTimeout(this.dealFirstEnter, 500);
					},
					fail: (err) => {
						console.log("getCardConfigQuery err", err)
					},
				});
			},
			// 卡片对应地图列表详情查询
			mapListQuery() {
				uni.request({
					url: apiMapListQuery,
					header: {
						"Content-Type": "application/x-www-form-urlencoded",
						"token": this.token,
					},
					method: "POST",
					data: {
						mcId: this.mcId
					},
					success: (res) => {
						// console.log("mapListQuery", res);
						if (res.data.code == 0) {
							const data = res.data.data;
							this.mapList = data;

							let mapItems = [];
							for (var i = 0; i < data.length; i++) {
								let map = {};
								map.text = data[i].mapName;
								map.value = data[i].ocaId;
								mapItems.push(map);
							}
							this.mapList = mapItems;
							// console.log("mapList", this.mapList);
						}
					},
					fail: (err) => {
						console.log("mapListQuery err", err);
					},
				});
			},
			// 卡片对应线上赛多个活动查询
			matchRsDetailQuery() {
				uni.request({
					url: apiMatchRsDetailQuery,
					header: {
						"Content-Type": "application/x-www-form-urlencoded",
						"token": this.token,
					},
					method: "POST",
					data: {
						ecId: this.ecId,
						ocaId: this.ocaId
					},
					success: (res) => {
						// console.log("matchRsDetailQuery", res);
						if (checkResCode(res)) {
							const data = res.data.data;
							this.mcType = data.mcType;
							this.mcId = data.mcId;
							this.mcName = data.mcName;
							this.coiName = data.coiName;
							this.beginSecond = data.beginSecond;
							this.endSecond = data.endSecond;
							this.nickName = data.nickName;
							this.totalNum = data.totalNum;
							this.totalDistanct = data.totalDistanct;
							this.totalDistanctRankNum = data.totalDistanctRankNum;
							this.totalCp = data.totalCp;
							this.totalCpRankNum = data.totalCpRankNum;
							this.totalSysPoint = data.totalSysPoint;
							this.totalSysPointRankNum = data.totalSysPointRankNum;
							this.fastPace = data.fastPace;
							this.fastPaceRankNum = data.fastPaceRankNum;
							this.regionTotalNum = data.regionTotalNum;
							this.regionTotalCp = data.regionTotalCp;
							this.regionTotalCpRankNum = data.regionTotalCpRankNum;
							this.ocaRs = data.ocaRs;

							this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);

							const rank = JSON.stringify(data);
							this.dealNotice(rank);

							this.getCountdown();
							this.getActtime();

							this.isAllowMcSignUp();
							this.mapListQuery();

							this.clear();
							this.interval = setInterval(this.getCountdown, 60000);
						}
					},
					fail: (err) => {
						console.log("matchRsDetailQuery err", err)
					},
				});
			},
			// 是否允许重新分组（报名）
			isAllowMcSignUp() {
				uni.request({
					url: apiIsAllowMcSignUp,
					header: {
						"Content-Type": "application/x-www-form-urlencoded",
						"token": this.token,
					},
					method: "POST",
					data: {
						ecId: this.ecId
					},
					success: (res) => {
						// console.log("isAllowMcSignUp", res)
						if (res.data.code == 0) {
							const data = res.data.data;
							this.allowMcSignUp = data.allowSignUp;
						}
					},
					fail: (err) => {
						console.log("isAllowMcSignUp err", err)
					},
				});
			},
			btnBack() {
				// const url = `action://to_home/`;
				// tools.appAction(url);

				// uni.navigateTo({
				// 	url: "/pages/bm/style4/rankList?" + this.queryString
				// });
				const url = "/pages/bm/style4/rankList?" + this.queryString;
				tools.appAction(url, "uni.navigateTo");
			},
			btnInfo() {
				// console.log(this.$refs.mypopup);
				this.$refs.mypopup.popupOpen();
			},
			btnReGroup() {
				this.queryObj.from = "rankOverview";
				this.queryString = tools.objectToQueryString(this.queryObj);
				// uni.navigateTo({
				// 	url: '/pages/bm/style4/signup?' + this.queryString
				// });
				const url = '/pages/bm/style4/signup?' + this.queryString;
				tools.appAction(url, "uni.navigateTo");
			},
			onOverviewClick(ovtype) {
				this.queryObj.ovtype = ovtype;
				this.queryString = tools.objectToQueryString(this.queryObj);
				// uni.navigateTo({
				// 	url: "/pages/bm/style4/rankList?" + this.queryString
				// });
				const url = "/pages/bm/style4/rankList?" + this.queryString;
				tools.appAction(url, "uni.navigateTo");
			},
			eSelectChange(data) {
				console.log("eSelectChange:", data);
				this.ocaId = data.value;
				this.matchRsDetailQuery();
				uni.setStorageSync(this.mapKey, this.ocaId);
			},
			onPathClick(data) {
				console.log("onPathClick:", data);
				if (this.ocaId != data.path.ocaId) {
					this.ocaId = data.path.ocaId;
					this.matchRsDetailQuery();
					uni.setStorageSync(this.mapKey, data.path.ocaId);
				}
			},
			btnStartGame() {
				// 赛事/活动状态 0: 未开始  1: 进行中  2: 已结束
				if (this.mcState == 1) {
					const url = `action://to_detail/?id=${this.ocaId}&matchType=${this.mcType}`;
					tools.appAction(url);
				} else if (this.mcState == 0) {
					uni.showToast({
						title: '比赛尚未开始',
						icon: 'none',
						duration: 3000
					});
				} else if (this.mcState == 2) {
					uni.showToast({
						title: '比赛已结束',
						icon: 'none',
						duration: 3000
					});
				}
			}
		}
	}
</script>

<style scoped>
	.content {
		width: 100vw;
		min-height: 100vh;
		overflow-x: scroll;
	}

	.top-default {
		position: relative;
		z-index: 10;
		width: 100%;
		height: 270px;
		padding-top: 36px;
		justify-content: space-between;
		background-image: url("/static/backgroud/top_bg_egg2.png");
		background-repeat: no-repeat;
		background-position-x: center;
		background-position-y: -8px;
		background-size: 100% 100%;
		/* background-size: cover; */
	}

	.topbar-color-default {
		color: #333333;
	}

	.topcontent {
		height: 90%;
		margin-bottom: 50px;
	}

	.logo {
		width: 80px;
		height: 80px;
		margin-top: 10px;
		/* background-image: url('/static/logo/sddx.png'); */
		background-repeat: no-repeat;
		background-position-x: center;
		background-position-y: center;
		background-size: contain;
	}

	.top-acttime {
		display: none;
		text-shadow: 3px 3px 0px #640008;
		font-family: YouSheBiaoTiHei;
		/* font-family: Arial, Helvetica, sans-serif; */
		font-weight: bold;
		color: #ffee0b;
		font-size: 26px;
	}

	.topbtm {
		width: 100%;
		/* height: 60rpx; */
		margin-bottom: 40px;
		justify-content: space-evenly;
	}

	.topbtm-name {
		/* width: 320rpx; */
		/* height: 28px; */
		padding: 5px 12px;
		background-color: #9fda39;
		border-radius: 5px;
		/* backdrop-filter: blur(30px); */
		text-align: center;
		font-weight: 500;
		color: #497400;
		font-size: 14px;
	}

	.mid {
		width: 90%;
		height: 150px;
		position: relative;
		z-index: 20;
		margin-top: -100px;
		background: #ffffff;
		border-radius: 9px;
		box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
		font-family: Source Han Sans CN;
	}

	.mid-0 {
		width: 56%;
		margin: 12px;
		font-weight: 500;
		color: #8e8e8e;
		font-size: 14px;
	}

	.mid-1 {
		width: 90%;
		margin-bottom: 12px;

	}

	.mid-1-text {
		/* min-width: 60px; */
		font-weight: 500;
		color: #9a300e;
		font-size: 12px;
	}

	.mid-2 {
		width: 92%;
		/* margin: 0 10px; */
	}

	.mid-2-value {
		font-weight: 900;
		font-size: 22px;
		line-height: 25px;
	}

	.mid-2-text {
		color: #989898;
		font-size: 12px;
	}

	.mid-line {
		width: 0px;
		height: 40px;
		border: 1px solid;
		border-color: #e6e6e6;
	}

	.overview-1 {
		width: 111px;
		height: 54px;
		background: #ffb40b;
		border-radius: 50%;
		box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
		pointer-events: auto;
	}

	.overview-2 {
		margin-top: -43px;
		color: #ffffff;
		font-size: 18px;
		pointer-events: auto;
	}

	.overview-3 {
		width: 111px;
		height: 54px;
		background: #f39509;
		border-radius: 50%;
		box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
		pointer-events: auto;
	}

	.overview-4 {
		width: 111px;
		height: 54px;
		background: #81cd00;
		border-radius: 50%;
		box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
		pointer-events: auto;
	}

	.overview-5 {
		width: 111px;
		height: 54px;
		background: #64cbb0;
		border-radius: 50%;
		box-shadow: 3px 3px 0px rgba(140, 140, 140, 1);
		pointer-events: auto;
	}

	.ovline1 {
		margin-top: 9px;
		color: #ffffff;
		font-size: 12px;
	}

	.ovline2 {
		color: #ffffff;
		font-size: 16px;
	}

	.main {
		width: 100%;
		margin-top: 20px;
		margin-bottom: 20px;
		/* height: 70vh; */
		justify-content: space-around;
		/* justify-content: space-between; */
	}

	.main-title {
		margin-bottom: 10px;
		font-weight: 550;
		color: #333333;
		font-size: 16px;
	}

	.bottom {
		width: 100%;
		flex-grow: 1;
		justify-content: flex-end;
	}

	.btnStartGame {
		width: 70%;
		height: 80rpx;
		/* margin-top: 50rpx; */
		margin-bottom: 20rpx;
		/* font-weight: bold; */
		color: white;
		font-size: 32rpx;
		line-height: 80rpx;
		border-radius: 27px;
		background-color: #2e85ec;
	}
	
	/deep/ .e-select {
		/* width: 60%; */
		height: 60rpx;
		background: #2e85ec;
		color: #ffffff;
		border-radius: 18px;
		justify-content: space-around;

		font-size: 16px;
		font-weight: 500;
		line-height: 60rpx;
		text-align: center;
		border: none !important;
	}

	/deep/ .e-select-input-text {
		color: inherit !important;
	}

	/deep/ .e-select-selector-item {
		color: #818181;
	}

	/deep/ .uni-icons {
		color: inherit !important;
	}

	/deep/ .e-select-icon {
		width: 26px !important;
	}
</style>