123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
- import { PopName } from "./EventName/EventName";
- import { SetMap, SetPreviewMap } from "./GameLogic/DataConfig";
- import PopManger from "./GameUI/PopManger";
- import HTTPS from "./Template/HTTPS";
- interface MapDataResponse {
- code: number;
- msg: string;
- data: MapData;
- }
- interface MapData {
- Id: string;
- DifficultyLevel: string;
- MapDataBusTypes: string;
- MapData: number[][]; // 二维数组
- MapDataRoloQueues: number[]; // 一维数组
- MapDataGraySitDownColor: string;
- MapDataCountDown: string;
- Status: string;
- }
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class PreviewScene extends cc.Component {
- onLoad() {
- // // 获取网址内携带的参数 账号 签名等数据
- let data = this.getUrlData(window.location.href);
- if (!data) {
- return
- }
- PopManger.getInstance().LoadBundle('sub').then((e) => {
- // 第一个 then 中的逻辑
- return HTTPS.Instance.get(`http://shangbansys.ranwenkeji.com/backend/site/map?PreviewID=${data.PreviewID}&PreviewType=${data.PreviewType}`);
- }).then((resp: MapDataResponse) => {
- // 第二个 then 中的逻辑
- // 处理 resp
- SetPreviewMap(resp.data)
- PopManger.getInstance().Pop(PopName.StartAnim, { animation: false })
- }).catch((error) => {
- // 处理可能出现的错误
- console.error(error);
- });
- }
- getUrlData(url: string): any {
- let arr = url.split("?");
- if (arr.length == 1) {
- return null
- }
- let arr1 = arr[1].split("&");
- let data = {};
- arr1.forEach(v => {
- let temp = v.split('=');
- if (!temp[1] || data[temp[0]]) {
- } else
- data[temp[0]] = temp[1];
- });
- return data;
- }
- }
|