Commit 39ac0990 authored by 王勇霞's avatar 王勇霞

接口接入活动页

parent 5bd7925a
......@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>畅玩欢乐城</title>
<title>21天"云"健身</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
......
{
"success": true,
"message": "",
"code": "",
"data": {
"ruleIdList": [
"ru_1",
"ru_2",
"ru_3",
"ru_4"
],
"drawStatus": 12,
"prizeId": "aa",
"gameCounts": 1
}
}
\ No newline at end of file
{
"success": true,
"desc": "labore amet laboris sit",
"data": {
"dataInfo": [
{
"num": 1,
"context": "闲看云",
"ifComplete": false,
"count": 74413176.81524068
},
{
"num": 2,
"context": "卷",
"ifComplete": false,
"count": 10
},
{
"num": 3,
"context": null,
"ifComplete": false,
"count": 10
},
{
"num": 5,
"context": "自在休闲",
"ifComplete": true,
"count": 10
},
{
"num": 4,
"context": "自在休闲",
"ifComplete": false,
"count": 10
}
],
"collectCount": 1,
"ifFirstPlay": true
},
"code": "ipsum est tempor qui",
"timestamp": 3627649.9094133973
}
\ No newline at end of file
{
"success": true,
"message": "",
"code": "",
"data": 1234
}
\ No newline at end of file
{
"success": true,
"message": "",
"code": "",
"data": {
"type": 1,
"status": 1,
"prize": {
"prizeId": "sp_1",
"prizeType": 1,
"optionId": "sdhjfhjhjjj",
"optionName": "10元话费",
"optionImg": "https://www.baidu.com/xxoo2.png",
"userRecordId": 1235,
"url": "https://www.baidu.com/order/1235"
}
}
}
\ No newline at end of file
{
"success": true,
"desc": "tempor et pariatur id",
"data": {
"startId": 72322899
},
"code": "ipsum quis nulla",
"timestamp": 29586841
}
\ No newline at end of file
{
"success": true,
"desc": "elit ipsum magna est",
"data": {
"point": -34090916
},
"code": "ut",
"timestamp": 1032620
}
\ No newline at end of file
......@@ -509,45 +509,23 @@
}
},
{
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png",
"keys": "backbtn.png,collect.png,rulebtn.png,startbg.jpg,startbtn.png,titile.png",
"name": "StartScene",
"atlas": {
"midbuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 493,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 493,
"ro": false
},
"mifcloud.png": {
"x": 2,
"y": 497,
"w": 750,
"h": 412,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 412,
"ro": false
},
"titile.png": {
"x": 754,
"x": 2,
"y": 2,
"w": 574,
"h": 177,
"h": 126,
"ox": 0,
"oy": 0,
"sw": 574,
"sh": 177,
"ro": true
"ro": false
},
"startbtn.png": {
"x": 2,
"y": 911,
"y": 130,
"w": 350,
"h": 99,
"ox": 0,
......@@ -556,31 +534,31 @@
"sh": 99,
"ro": false
},
"startop.png": {
"x": 754,
"y": 578,
"w": 117,
"h": 196,
"collect.png": {
"x": 2,
"y": 231,
"w": 308,
"h": 50,
"ox": 0,
"oy": 0,
"sw": 117,
"sh": 196,
"sw": 308,
"sh": 50,
"ro": false
},
"backbtn.png": {
"x": 754,
"y": 776,
"x": 354,
"y": 130,
"w": 145,
"h": 62,
"ox": 0,
"oy": 0,
"sw": 145,
"sh": 62,
"ro": false
"ro": true
},
"rulebtn.png": {
"x": 754,
"y": 840,
"x": 418,
"y": 130,
"w": 138,
"h": 62,
"ox": 0,
......
resource/StartScene/titile.png

90.9 KB | W: | H:

resource/StartScene/titile.png

83.9 KB | W: | H:

resource/StartScene/titile.png
resource/StartScene/titile.png
resource/StartScene/titile.png
resource/StartScene/titile.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -17,7 +17,7 @@
"name": "RulePanel"
},
{
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png",
"keys": "backbtn.png,collect.png,rulebtn.png,startbg.jpg,startbtn.png,titile.png",
"name": "StartScene"
},
{
......
......@@ -24,7 +24,12 @@ export class Main {
private requestID;
private _pause: boolean;
private canvas: HTMLCanvasElement
constructor(canvas: HTMLCanvasElement) {
constructor(canvas: HTMLCanvasElement, data = {
time: 60,
longitude: "",
latitude: ""
}) {
Tools.configInfo = data;
var sysInfo;
//淘宝小程序环境就用canvas初始化
if (!window) {//自行处理吧,这么判断也不保险,万一淘宝小程序加进了window
......
......@@ -509,45 +509,23 @@ export const ResJson = {
}
},
{
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png",
"keys": "backbtn.png,collect.png,rulebtn.png,startbg.jpg,startbtn.png,titile.png",
"name": "StartScene",
"atlas": {
"midbuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 493,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 493,
"ro": false
},
"mifcloud.png": {
"x": 2,
"y": 497,
"w": 750,
"h": 412,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 412,
"ro": false
},
"titile.png": {
"x": 754,
"x": 2,
"y": 2,
"w": 574,
"h": 177,
"h": 126,
"ox": 0,
"oy": 0,
"sw": 574,
"sh": 177,
"ro": true
"ro": false
},
"startbtn.png": {
"x": 2,
"y": 911,
"y": 130,
"w": 350,
"h": 99,
"ox": 0,
......@@ -556,31 +534,31 @@ export const ResJson = {
"sh": 99,
"ro": false
},
"startop.png": {
"x": 754,
"y": 578,
"w": 117,
"h": 196,
"collect.png": {
"x": 2,
"y": 231,
"w": 308,
"h": 50,
"ox": 0,
"oy": 0,
"sw": 117,
"sh": 196,
"sw": 308,
"sh": 50,
"ro": false
},
"backbtn.png": {
"x": 754,
"y": 776,
"x": 354,
"y": 130,
"w": 145,
"h": 62,
"ox": 0,
"oy": 0,
"sw": 145,
"sh": 62,
"ro": false
"ro": true
},
"rulebtn.png": {
"x": 754,
"y": 840,
"x": 418,
"y": 130,
"w": 138,
"h": 62,
"ox": 0,
......@@ -755,5 +733,5 @@ export const ResJson = {
"name": "svga"
}
],
"path": "https://yun.duiba.com.cn/db_games/activity/template/1678380297/resource/"
"path": "https://yun.duiba.com.cn/db_games/activity/template/1678450122/resource/"
}
\ No newline at end of file
......@@ -403,6 +403,16 @@ export const SkinJson = {
},
"id": "title"
},
{
"name": "collect",
"x": 224,
"y": 236,
"type": "sprite",
"props": {
"source": "collect.png"
},
"id": "collect"
},
{
"name": "titlelab",
"x": 0,
......@@ -413,7 +423,9 @@ export const SkinJson = {
"size": 20,
"fillColor": "#ab4a17",
"textAlpha": 1,
"lineHeight": 20
"lineHeight": 20,
"textWidth": 750,
"textAlign": "center"
},
"id": "titlelab"
},
......
......@@ -7,6 +7,13 @@ import Ease = FYGE.Ease;
* 定制,记录一些全局量和通用方法
*/
export class Tools {
// public static indexInfo;
// public static startId;
public static configInfo: {
longitude: string,
latitude: string,
time: number
}
/**
* 缓存key
......
......@@ -14,39 +14,39 @@ let mergeData = {
* web接口枚举,mock 文件名类似aaa/homeInfo.do
*/
export enum WebNetName {
/**
* 首页
* 参数a 参数b
*/
index = "/projectx/{projectId}/game/index.do",
/**
* 参与
*/
join = "/projectx/{projectId}/game/join.do",
/**
* 获取结果
*/
queryResult = "/projectx/{projectId}/game/queryResult.do",
/**
* 获取规则
*/
projectRule = "/projectx/{projectId}/projectRule.query",
/**
* 开始游戏
*/
startGame = "/projectx/{projectId}/happyCityScore/start.do",
// /**
// * 首页
// * 参数a 参数b
// */
// index = "/projectx/{projectId}/game/index.do",
// /**
// * 参与
// */
// join = "/projectx/{projectId}/game/join.do",
// /**
// * 获取结果
// */
// queryResult = "/projectx/{projectId}/game/queryResult.do",
// /**
// * 获取规则
// */
// projectRule = "/projectx/{projectId}/projectRule.query",
/**
* 游戏首页
*/
indexInfo = "/projectx/{projectId}/happyCityScore/gameIndex.do",
*/
indexInfo = "/zy-activity/game/index",
/**
* 提交游戏
*/
submitGame = "/projectx/{projectId}/happyCityScore/submit.do",
* 开始游戏
*/
startGame = "/zy-activity/game/start",
/**
* 通用埋点
* 提交游戏
*/
buriedPoint = "/projectx/{projectId}/buriedPoint"
submitGame = "/zy-activity/game/submit",
// /**
// * 通用埋点
// */
// buriedPoint = "/projectx/{projectId}/buriedPoint"
}
//返回数据类型
......@@ -54,7 +54,8 @@ interface dataOut {
success: boolean,
data?: any
code?: string,
message?: string
message?: string,
desc?: string,
}
//记录数据
......@@ -74,7 +75,7 @@ export function sendWebNet(
parameter?: any,
callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = false,
isGet: boolean = true,//这两个参数基本不设置,放后面吧
isGet: boolean = false,//这两个参数基本不设置,放后面吧
headers?: any,
): Promise<dataOut> {
//处理下参数
......@@ -85,8 +86,8 @@ export function sendWebNet(
if (/*window["development"]*/window.location.port == "8080") {//window.location.port == "8080";考虑按端口判断TODO
// var jname = netName.substring(netName.lastIndexOf("/") + 1);//待修改,TODO,部分接口后缀名字一致
// var url = "../../mock/miniTb/" + jname + ".json";
let path = netName.split('{projectId}/')[1];//后缀名字之前的是文件夹,mock里结构
if (path.indexOf('/') <= -1) path = `projectX/${path}`;
let path = netName.split('zy-activity/')[1];//后缀名字之前的是文件夹,mock里结构
if (path.indexOf('/') <= -1) path = `zy-activity/${path}`;
const url = "../../mock/webNet/" + path + ".json";
fetchAsync(url)
.then((data) => {
......
......@@ -43,7 +43,7 @@ export class FailPanel extends Panel {
const { success, data, message } = await sendWebNet(WebNetName.startGame, { token: token })
if (!success) {
this.isOpen = false
showToast(message || "网络异常,请重试~")
showToast(message || "网络开小差了,稍后再试~")
return
}
this.isOpen = false
......
......@@ -35,11 +35,12 @@ export class GuidePanel extends Panel {
if (this.guideStep < 4) {
this.guideStep++
this.guideUI();
} else {
} else if((this.guideStep == 4)) {
this.guideStep++
this.showCount();
}
}, this)
if(getWebData(WebNetName.startGame).data.firstGame){
if(getWebData(WebNetName.indexInfo).data.ifFirstPlay){
this.guideUI();
} else {
this.showCount();
......
......@@ -13,7 +13,10 @@ import { duiba_md5 } from "../../module/tools/security";
import { Tools } from "../Tools";
import { layers } from "../../module/views/layers";
import UI from "../UI";
import { getUrlParams } from "../../module/web/webTools";
import { GDispatcher } from "../Main";
const allWords:any = ['闲', '看', '晴', '云', '自', '卷', '舒', '静', '水', '流', '深', '心', '无', '意', '在', '休']
export class GameScene extends Scene {
get groupNames() { return ["GameScene"] };
get skinName() { return "GameScene" };
......@@ -25,47 +28,20 @@ export class GameScene extends Scene {
bgCon; //背景移动
_role; //人物
wordList = ['闲', '看', '晴', '云', '自', '卷', '舒', '静', '水', '流', '深', '心', '无', '意', '在', '休']; // 待随机出现的列表
wordList = this.getWordList(); // 待随机出现的列表
collectList: any = []; // 已收集列表
mapList = [];
cdnum: FYGE.TextField;
cloud: FYGE.Sprite;
peo: FYGE.Sprite;
tianpop: FYGE.Sprite;
xiangpop: FYGE.Sprite;
monster: FYGE.Sprite;
scorebg: FYGE.Sprite;
scorenum: FYGE.TextField;
close: FYGE.Sprite;
open: FYGE.Sprite;
jumpLock = false;
isonce = false;
score;
reset;
time = Tools.configInfo.time;
startLen = 12
public static instance: GameScene;
initUi() {
}
async start(data) {
async start() {
super.start();
GameScene.instance = this
this.left = new FYGE.SvgaAni(await RES.getResAsync("left.svga"))
this.left = this.addChild(this.left)
this.left.position.set(8, 979);
......@@ -79,16 +55,23 @@ export class GameScene extends Scene {
// 创建模型, 云层
this.bgCon = this.addChild(new FYGE.Container());
this.setChildIndex(this.bgCon, 2)
this.setChildIndex(this.reset, 3)
this.initCloud();
console.log("新手引导")
showPanel(GuidePanel);
// this.upDateInfo(); // 用于开始游戏 ----test
this.reset.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.btnDelay(this.reset)
this.onReset()
}, this)
// 添加指向的事件
this.left.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.btnDelay(this.left)
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex%2 == 0){
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex % 2 == 0) {
this.left.startAniRange(1, undefined, 1, () => {
console.log('this._role.currentIndex', this._role.currentIndex)
this._role.leftMove({
......@@ -96,10 +79,11 @@ export class GameScene extends Scene {
}, this.collectWordTx.bind(this, item))
})
}
})
}, this)
this.right.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.btnDelay(this.right)
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex%2 == 1){
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex % 2 == 1) {
this.right.startAniRange(1, undefined, 1, () => {
console.log('this._role.currentIndex', this._role.currentIndex)
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
......@@ -109,17 +93,53 @@ export class GameScene extends Scene {
}, this.collectWordTx.bind(this, item))
})
}
}, this)
}
getWordList() {
let dataInfo = getWebData(WebNetName.indexInfo).data.dataInfo;
let hasWordList:any = [];
let noWordList:any = [];
dataInfo.forEach(item => {
if (item.context) {
hasWordList = hasWordList.concat(item.context.split(""))
}
})
allWords.forEach(item => {
if (!hasWordList.includes(item) && !noWordList.includes(item)) {
noWordList.push(item)
}
})
return noWordList
}
upDateInfo() {
this.cdUIRender(this.time)
this.startGame()
this.countDown(this.time)
}
// 数据重置
onReset() {
changeScene(StartScene)
// this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
// this.wordList = this.getWordList();
// this.collectList = [];
// this.mapList = [];
// this.time = Tools.configInfo.time;
// this.outIndex = 0;
// this.removeChild(this.bgCon);
// clearTimeout(this.timer);
// this.bgCon = this.addChild(new FYGE.Container());
// this.setChildIndex(this.bgCon, 2)
// this.initCloud();
// this.upDateInfo()
}
startGame() {
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
}
time=60;
timer = null;
countDown(time) {
this.timer = setTimeout(() => {
......@@ -134,16 +154,16 @@ export class GameScene extends Scene {
}, 1000)
}
cdUIRender(num=60) {
cdUIRender(num = 60) {
// 先清除所有节点
this.cdbg.removeChildren();
let str = num + 's';
let arr = str.split("");
let startPos = (130 - (30*arr.length))/2
let startPos = (130 - (30 * arr.length)) / 2
arr.forEach((item, index) => {
UI.Sp(this.cdbg, `num_${item}.png`, startPos + (index*30), 38)
UI.Sp(this.cdbg, `num_${item}.png`, startPos + (index * 30), 38)
})
}
firstCoud;
initCloud() {
......@@ -151,15 +171,15 @@ export class GameScene extends Scene {
let offset = (1624 - this.stage.viewRect.height) / 2;
// 渲染人物脚下的一朵云层
this.firstCoud = UI.Sp(this.bgCon, 'cloud2.png', 190, 1150 - offset )
this.firstCoud = UI.Sp(this.bgCon, 'cloud2.png', 190, 1150 - offset)
// 创建角色
this.addRole()
// 开始循环添加
for (let i=0; i<15; i++) {
this.createCloudItem(stageHeight - (500 + 150*i), i + 1, i%2 == 0 ? 'left' : 'right');
for (let i = 0; i < this.startLen; i++) {
this.createCloudItem(stageHeight - (500 + 150 * i), i + 1, i % 2 == 0 ? 'left' : 'right');
}
}
......@@ -174,18 +194,18 @@ export class GameScene extends Scene {
let len = this.wordList.length
let randomIndex;
if (len > 0) {
randomIndex = Math.floor(Math.random()*len);
randomIndex = Math.floor(Math.random() * len);
}
let wordItem = new Word({
wordTx: len == 0 ? '' : this.wordList[randomIndex],
index: index
})
// 偏差值
let deviation = Math.floor(Math.random()*200) - 100;
let deviation = Math.floor(Math.random() * 200) - 100;
wordItem.fx = (direction === 'left' ? 88 : 440) + deviation + 100;
wordItem.fy = h + 5
this.bgCon.addChildAt(wordItem, 0)
let cloudItem = new Cloud({
direction
});
......@@ -205,14 +225,14 @@ export class GameScene extends Scene {
this.bgCon.addChild(role);
}
outIndex=0;
outIndex = 0;
onFarm() {
this.moveMap();
// 判断是否超出屏幕
let stageHeight = this.stage.stageHeight;
// console.log('this.mapList[0]', this.mapList[0].y + this.bgCon.y, this.stage.stageHeight)
if (this.mapList[this.outIndex][0].y + this.bgCon.y - 200 > stageHeight) {
if (this.mapList[this.outIndex][0].y + this.bgCon.y - 200 > stageHeight) {
if (this.firstCoud) {
this.bgCon.removeChild(this.firstCoud)
}
......@@ -221,20 +241,20 @@ export class GameScene extends Scene {
// console.log("超出屏幕")
this.bgCon.removeChild(this.mapList[_index][0])
this.bgCon.removeChild(this.mapList[_index][1])
let i = this.mapList[this.mapList.length - 1][0].index
// console.log(this.mapList[this.mapList.length - 1][0].index)
this.createCloudItem(stageHeight - (500 + 150*i), i + 1, i%2 == 0 ? 'left' : 'right')
this.createCloudItem(stageHeight - (500 + 150 * i), i + 1, i % 2 == 0 ? 'left' : 'right')
}
// 判断人物是否超出
if (this._role.y + this.bgCon.y - 305 > stageHeight) {
if (this._role.y + this.bgCon.y - 305 > stageHeight) {
let item = this.mapList[this.outIndex + 7][0]
this._role.onFreeFall({
x: item.x,
y: item.y
}, {
item:item
item: item
}, this.collectWordTx.bind(this, item))
}
......@@ -243,29 +263,75 @@ export class GameScene extends Scene {
this.bgCon.y = this.bgCon.y + 2
}
collectWordTx(item) {
this.bgCon.removeChild(item)
if (item.wordTx && !this.collectList.includes(item.wordTx)) {
this.collectList.push(item.wordTx);
let _i = this.wordList.indexOf(item.wordTx);
if (_i > -1) {
this.wordList.splice(_i, 1)
this.bgCon.removeChild(item)
if (item.wordTx && !this.collectList.includes(item.wordTx)) {
this.collectList.push(item.wordTx);
let _i = this.wordList.indexOf(item.wordTx);
if (_i > -1) {
this.wordList.splice(_i, 1)
}
}
}
}
async gameOver() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
let startInfo = getWebData(WebNetName.startGame).data.currInfo;
let activityId = getUrlParams('activityId')
let startId = getWebData(WebNetName.startGame).data.startId;
let timestamp = new Date().getTime();
let sign = duiba_md5(`score=${this.score}&startId=${startInfo.startId}&timestamp=${timestamp}&key=${startInfo.key + "9ef16b33920749fb26e8fc2f2913150a"}`)
const { success, data, message } = await sendWebNet(WebNetName.submitGame, { score: this.score, sign: sign, code: startInfo.code, timestamp: timestamp ,startId:startInfo.startId})
let type = 3
let sign = duiba_md5(String(activityId) + String(timestamp) + String(startId) + String(type) + 'posf3usrjjnd9sd4w21ln3p');
let dataArr = this.getDataArr();
const { success, data, desc } = await sendWebNet(WebNetName.submitGame, {
activityId,
type,
startId,
timestamp,
sign,
longitude: Tools.configInfo.longitude,
latitude: Tools.configInfo.latitude,
data: dataArr
})
if (success) {
GDispatcher.dispatchEvent("openGameEnd", {
isFillUp: data.point ? true : false,
point: data.point || 0
});
} else {
showToast(desc || "网络开小差了,稍后再试")
}
}
getDataArr() {
console.log('this.collectList', this.collectList)
let arr = ["闲看晴云自卷舒", "静水流深", "云卷舒", "心无意", "自在休闲"];
let tempData = []
arr.forEach((item, index) => {
let words = [];
item.split("").forEach(val => {
if (this.collectList.includes(val)) {
if (words.indexOf(val) == -1) {
words.push(val)
}
}
})
tempData.push({
num: index + 1,
context: words.join(',')
})
})
console.log('tempData', tempData)
return tempData
}
closeGame() {
changeScene(StartScene)
}
initEvents() {
super.initEvents();
GDispatcher.addEventListener("closeGame", this.closeGame, this);
}
removeEvents() {
super.removeEvents();
GDispatcher.addEventListener("closeGame", this.closeGame, this);
}
}
import { Scene } from "../../module/views/Scene";
import { changeScene, showPanel, showToast, hideWaiting } from "../../module/ctrls";
import { changeScene, showPanel, showToast } from "../../module/ctrls";
import { GameScene } from "./GameScene";
import { RES } from "../../module/RES";
import { RulePanel } from "../panels/RulePanel";
import { sendWebNet, WebNetName, getPxTokenSave } from "../webNet";
import { sendWebNet, WebNetName, getPxTokenSave, getWebData } from "../webNet";
import { GDispatcher } from "../Main";
import { getGameIndex } from "../hdTool/Hdtool";
import { getUrlParams } from "../../module/web/webTools";
export class StartScene extends Scene {
get groupNames() { return ["StartScene"] };
get skinName() { return "StartScene" };
startbtn;
startbg: FYGE.Sprite;
collect: FYGE.Sprite;
titlelab: FYGE.TextField;
backbrn: FYGE.Sprite;
rulebtn: FYGE.Sprite;
indexInfo;
gameInfo;
public static instance: StartScene
indexInfo;
initUi() {
}
async start(data) {
......@@ -41,59 +38,52 @@ export class StartScene extends Scene {
this.getIndexInfo()
}
async getIndexInfo() {
getGameIndex().then((r) => {
hideWaiting()
if (r.success) {
this.indexInfo = r.data;
this.titlelab.text = "今日收集字数( " + r.data.collectCount + " / 16 )"
}
const { success, data, desc } = await sendWebNet(WebNetName.indexInfo, {
activityId: getUrlParams('activityId'),
type: 3
})
if (!success) {
showToast(desc || "网络开小差了,稍后再试")
return
}
this.indexInfo = data
this.titlelab.text = "今日收集字数( " + data.collectCount + " / 16 )"
// this.openGame()
}
openRule() {
// showPanel(RulePanel)
GDispatcher.dispatchEvent("openRule");
}
isOpen = false
startId;
async openGame() {
this.btnDelay(this.startbtn)
if (this.indexInfo) {
if (!this.indexInfo.dailyPass) {
if (!this.isOpen) {
this.isOpen = true
let token = await getPxTokenSave()
const { success, code, data, message } = await sendWebNet(WebNetName.startGame, { token: token })
if (!success) {
this.isOpen = false
if (code == "20004") {
showToast("今日已过关,明日再来~")
} else {
showToast(message || "网络异常,请重试~")
}
return
}
this.isOpen = false
// changeScene(GameScene)
}
} else {
showToast("今日已过关,明日再来~")
}
}else{
showToast( "网络异常,请重试~")
const { success, code, data, desc } = await sendWebNet(WebNetName.startGame, {
activityId: getUrlParams('activityId'),
type: 3
})
if (success) {
this.startId = data.startId;
changeScene(GameScene)
} else {
showToast(desc || "网络开小差了,稍后再试")
}
}
goback() {
GDispatcher.dispatchEvent("backIndex");
}
async openCollect() {
let dataInfo = getWebData(WebNetName.indexInfo).data.dataInfo;
if (!dataInfo) {
await this.getIndexInfo()
}
GDispatcher.dispatchEvent("openCollect", getWebData(WebNetName.indexInfo).data.dataInfo);
}
initEvents() {
super.initEvents();
this.rulebtn.addEventListener(FYGE.MouseEvent.CLICK, this.openRule, this)
this.backbrn.addEventListener(FYGE.MouseEvent.CLICK, this.goback, this)
this.collect.addEventListener(FYGE.MouseEvent.CLICK, this.openCollect, this)
}
removeEvents() {
......@@ -101,6 +91,7 @@ export class StartScene extends Scene {
this.startbtn.removeEventListener(FYGE.MouseEvent.CLICK, this.openGame, this)
this.rulebtn.removeEventListener(FYGE.MouseEvent.CLICK, this.openRule, this)
this.backbrn.removeEventListener(FYGE.MouseEvent.CLICK, this.goback, this)
this.collect.removeEventListener(FYGE.MouseEvent.CLICK, this.openCollect, this)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment