var state = { token: "", ecId: 0, from: "", mcId: 0, mcName: "", mcType: 0, beginSecond: null, endSecond: null, coiId: 0, coiName: "", teamNum: 0, nickName: "", coiRs: [], configParam: { labelName: "昵称", labelOrg: "组织", subTitle: "" }, introduce: { title: "", content: "" }, activityRules: { title: "", content: "" }, mcState: 0 }; function initSignupPage() { const params = new URLSearchParams(window.location.search); state.token = params.get('token') || ''; state.ecId = params.get('id') || 0; state.from = params.get('from') || ''; window.cardfunc.init(state.token, state.ecId); window.cardfunc.getCardConfig(onConfigLoaded); // Bind events // Dropdown logic is already in HTML script, but we can enhance or replace it. // For now, I'll assume the HTML script functions are available or I should override them // if I want to connect them to state. // The HTML script defines `selectOption` globally. I should probably piggyback on that or replace it. // Let's expose necessary functions to window so HTML can call them window.selectOption = selectOption; window.openConfirm = openConfirm; } function onConfigLoaded(config) { // Load logic from signup.vue loadConfig const pageConfig = window.cardfunc.parseCardConfig(config['signup']); if(pageConfig) { // Load params const param = pageConfig.param; if (param) { if (param.labelName) state.configParam.labelName = param.labelName; if (param.labelOrg) state.configParam.labelOrg = param.labelOrg; if (param.subTitle) state.configParam.subTitle = param.subTitle; } // Load introduce/rules if needed to display (HTML structure is static, but content could be dynamic) // The new UI seems to have static "Match Intro". // If we want to use dynamic intro, we need to inject it. // For now, let's stick to the static UI as per "migration to new UI" request, // unless the new UI requires dynamic text. The HTML provided has hardcoded intro. // I will leave it static for now to preserve the new design. } // Fetch Data getCardDetailQuery(); } function getCardDetailQuery() { uni.request({ url: window.apiCardDetailQuery, header: { "Content-Type": "application/x-www-form-urlencoded", "token": state.token }, method: "POST", data: { ecId: state.ecId }, success: (res) => { const data = res.data.data; if(data) { state.mcType = data.mcType; state.mcId = data.mcId; state.mcName = data.mcName; state.beginSecond = data.beginSecond; state.endSecond = data.endSecond; state.coiId = data.coiId; state.coiName = data.coiName; state.teamNum = data.teamNum; state.nickName = data.nickName; state.mcState = window.tools.checkMcState(state.beginSecond, state.endSecond); // Update Time UI updateTimeUI(); // Fetch Dropdown Options getOnlineMcSignUpDetail(); // Pre-fill form if data exists if(state.nickName) { document.getElementById('userName').value = state.nickName; } if(state.coiId > 0 && state.coiName) { // We will update dropdown after fetching details } } } }); } function getOnlineMcSignUpDetail() { uni.request({ url: window.apiOnlineMcSignUpDetail, header: { "Content-Type": "application/x-www-form-urlencoded", "token": state.token, }, method: "POST", data: { mcId: state.mcId }, success: (res) => { const data = res.data.data; if(data) { state.coiRs = data.coiRs; if (!state.nickName && data.name) { state.nickName = data.name; document.getElementById('userName').value = state.nickName; } renderDropdown(); // If user already selected a team (re-entering page) if(state.coiId > 0) { // Find team name if not set const team = state.coiRs.find(t => t.coiId == state.coiId); if(team) selectOption(team.coiId, team.coiName, true); // true = skip UI toggle } } } }); } function updateTimeUI() { // Format: 11.28 08:00 - 11.30 18:00 const timeStr = window.tools.fmtMcTime2(state.beginSecond, state.endSecond); // Need to find the element. The HTML has "11.28 08:00 - 11.30 18:00" hardcoded. // I'll search for the element containing the time. // The HTML structure: ... // I should give it an ID in the HTML update step, but for logic file I'll assume I can access it. // I'll use document.querySelector to find it relative to "比赛时间" text or add an ID in Step 10. // Let's assume I will add ID `matchTimeDisplay` to the span. const el = document.getElementById('matchTimeDisplay'); if(el) el.innerText = timeStr; } function renderDropdown() { const ul = document.querySelector('#dropdownMenu ul'); if(!ul) return; let html = ''; state.coiRs.forEach(team => { html += `