Commit f4b1ebe4 authored by wjf's avatar wjf

l

parent bac72bee
{ {
"groups": [ "groups": [
{ {
"keys": "comCloseBtn.png,light.png,toastBg.png,waitingBg.png,waitingRot.png", "keys": "comCloseBtn.png,light.png,n0.png,n1.png,n2.png,n3.png,n4.png,n5.png,n6.png,n7.png,n8.png,n9.png,nx.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
}, },
{ {
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"name": "startScene" "name": "startScene"
}, },
{ {
"keys": "jiaohuan.png,kaixinshouxia.png,libao.png,lvwang.png,t0.png,t1.png,t2.png,t3.png,t4.png,t5.png,t6.png,t7.png,t8.png,t9.png,taskCompletePanelBg.png,tx.png,zhadan.png", "keys": "jiaohuan.png,kaixinshouxia.png,libao.png,lvwang.png,taskCompletePanelBg.png,zhadan.png",
"name": "taskCompletePanel" "name": "taskCompletePanel"
}, },
{ {
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"name": "taskPanel" "name": "taskPanel"
}, },
{ {
"keys": "jixuyouxi.png,n0.png,n1.png,n2.png,n3.png,n4.png,n5.png,n6.png,n7.png,n8.png,n9.png,unlock128.png,unlockMsg.png,unlockPanelBg.png", "keys": "jixuyouxi.png,unlock128.png,unlockMsg.png,unlockPanelBg.png",
"name": "unlockPanel" "name": "unlockPanel"
} }
] ]
......
...@@ -30,7 +30,7 @@ window.addEventListener("load", function () { ...@@ -30,7 +30,7 @@ window.addEventListener("load", function () {
var r = document.createElement("script"); var r = document.createElement("script");
r.async = !0, r.src = "//yun.tuia.cn/tuia/skyeye/skyeye.js", r.crossOrigin = "anonymous", r.onerror = r.async = !0, r.src = "//yun.tuia.cn/tuia/skyeye/skyeye.js", r.crossOrigin = "anonymous", r.onerror =
function () { function () {
t--, t > 0 && setTimeout(e, 1500) t-- , t > 0 && setTimeout(e, 1500)
}, document.head && document.head.appendChild(r) }, document.head && document.head.appendChild(r)
}; };
setTimeout(n, 1500); setTimeout(n, 1500);
...@@ -67,7 +67,7 @@ export class Main { ...@@ -67,7 +67,7 @@ export class Main {
showWaiting(); showWaiting();
sendTbNet(TbNetName.getAppData, {}, (s, res) => { sendTbNet(TbNetName.getAppData, {}, (s, res) => {
Tool.globalData = res.data; Tool.globalData = res.data;
// changeScene(PlayScene); // changeScene(PlayScene,Tool.globalData.gameObj);
changeScene(StartScene); changeScene(StartScene);
}) })
......
...@@ -29,7 +29,21 @@ export enum TbNetName { ...@@ -29,7 +29,21 @@ export enum TbNetName {
* activityId * activityId
*/ */
getTaskList = "getTaskList", getTaskList = "getTaskList",
/**
* 领取道具
* activityId,toolType
*/
getToolsByType = "getToolsByType",
/**
* 消耗道具
* activityId,type,playId
*/
useTools = "useTools",
/**
* 单纯接收来自小程序的信息,事件自行绑定
*/
returnGame = "returnGame",
//前端自己调用小程序的方法 //前端自己调用小程序的方法
...@@ -61,7 +75,7 @@ export enum TbNetName { ...@@ -61,7 +75,7 @@ export enum TbNetName {
/** /**
* 单纯接收来自小程序的信息,事件自行绑定 * 单纯接收来自小程序的信息,事件自行绑定
*/ */
returnGame = "mine.returnGame", // returnGame = "mine.returnGame",
} }
//返回数据类型,到时再调整 //返回数据类型,到时再调整
interface dataIn { interface dataIn {
...@@ -251,7 +265,6 @@ const mockData = { ...@@ -251,7 +265,6 @@ const mockData = {
{ {
"taskName": "doCollect", "taskName": "doCollect",
"isComplete": false, "isComplete": false,
"collectCount": 3,
"taskDrawStatus": 0 "taskDrawStatus": 0
}, },
{ {
...@@ -261,6 +274,13 @@ const mockData = { ...@@ -261,6 +274,13 @@ const mockData = {
} }
] ]
} }
},
//领取道具
"getToolsByType": {
"success": true,
"data": {
"inviteSuccessCount": 2
}
} }
} }
......
...@@ -112,8 +112,16 @@ export class Tool { ...@@ -112,8 +112,16 @@ export class Tool {
activityId: string, activityId: string,
nickName: string, nickName: string,
avatar: string, avatar: string,
shareId?: string,//分享者的 gameObj: {
theme: string,//adult kid maxScore: number,
bombCount: number,
exchangeCount: number,
netCount: number,
unlockGrade: number,
id: string
}
// shareId?: string,//分享者的
// theme: string,//adult kid
}; };
} }
\ No newline at end of file
...@@ -2,12 +2,18 @@ import { sendTbNet, TbNetName } from "./TaoBaoNet"; ...@@ -2,12 +2,18 @@ import { sendTbNet, TbNetName } from "./TaoBaoNet";
import { Tool } from "./Tools"; import { Tool } from "./Tools";
import { GDispatcher } from "../engine/2d/events"; import { GDispatcher } from "../engine/2d/events";
export enum TaskType {
doFollowShop = "doFollowShop",
doInvite = "doInvite",
doCollect = "doCollect",
doOrder = "doOrder"
}
/** /**
* *
* @param callback * @param callback
* @param score * @param score
* @param grade * @param grade
* @param id
* @param isFinal 是否最终提交,默认是的 * @param isFinal 是否最终提交,默认是的
*/ */
export function submit(callback: (s: boolean, res?: any) => void, score: number, grade: number, id: string, isFinal: boolean = true) { export function submit(callback: (s: boolean, res?: any) => void, score: number, grade: number, id: string, isFinal: boolean = true) {
......
...@@ -128,7 +128,7 @@ export class GameOverPanel extends Panel { ...@@ -128,7 +128,7 @@ export class GameOverPanel extends Panel {
desTxt.x = 450; desTxt.x = 450;
desTxt.y = 887; desTxt.y = 887;
desTxt.text = "(" + levelDes[this.data.grade] + ")"; desTxt.text = "(" + levelDes[this.data.grade] + ")";
this.addChild(desTxt); // this.addChild(desTxt);//貌似不用显示了
//返回首页按钮 //返回首页按钮
this.returnBtn = this.addChild(new Button(RES.getRes("fanhuishouye.png"))) as Button; this.returnBtn = this.addChild(new Button(RES.getRes("fanhuishouye.png"))) as Button;
this.returnBtn.position.set(117, 959); this.returnBtn.position.set(117, 959);
......
...@@ -12,7 +12,7 @@ import { showWaiting, hideWaiting, showPanel } from '../../module/ctrls'; ...@@ -12,7 +12,7 @@ import { showWaiting, hideWaiting, showPanel } from '../../module/ctrls';
import { GameOverPanel } from './GameOverPanel'; import { GameOverPanel } from './GameOverPanel';
/** /**
* 弹框复制用 * 退出弹框
*/ */
export class QuitPanel extends Panel { export class QuitPanel extends Panel {
get groupNames() { return ["quitPanel"] } get groupNames() { return ["quitPanel"] }
...@@ -34,7 +34,7 @@ export class QuitPanel extends Panel { ...@@ -34,7 +34,7 @@ export class QuitPanel extends Panel {
this.addChild(this.closeBtn); this.addChild(this.closeBtn);
//继续闯关 //继续闯关
this.addChild(new Button(RES.getRes("jixuchuangguan.png"))) this.addChild(new Button(RES.getRes("jixuchuangguan.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this) .once(MouseEvent.CLICK, this.onClick_closeBtn, this)//destroy会移除
.position.set(398, 750) .position.set(398, 750)
//退出本关,提交后,出结束弹框, //退出本关,提交后,出结束弹框,
this.addChild(new Button(RES.getRes("tuichubenguan.png"))) this.addChild(new Button(RES.getRes("tuichubenguan.png")))
......
...@@ -7,6 +7,16 @@ import { Panel } from "../../module/views/Panel"; ...@@ -7,6 +7,16 @@ import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES"; import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display"; import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics'; import { Graphics } from '../../engine/2d/graphics';
import { TaskType } from '../commonNet';
import { BitmapText } from '../../engine/2d/text';
import { TEXT_ALIGN } from '../../engine/2d/const';
const PrizeType = {
[TaskType.doFollowShop]: "jiaohuan",//1
[TaskType.doCollect]: "zhadan",//1
[TaskType.doInvite]: "lvwang",//?
[TaskType.doOrder]: "libao",//3
}
/** /**
* 任务完成,点击领取弹框,还没好 * 任务完成,点击领取弹框,还没好
...@@ -16,6 +26,10 @@ export class TaskCompletePanel extends Panel { ...@@ -16,6 +26,10 @@ export class TaskCompletePanel extends Panel {
closeBtn: Button; closeBtn: Button;
data: {
type: TaskType,//
num?: number
}
initUi() { initUi() {
//背景 //背景
this.addChild(Tool.addSprite("taskCompletePanelBg.png")); this.addChild(Tool.addSprite("taskCompletePanelBg.png"));
...@@ -27,14 +41,27 @@ export class TaskCompletePanel extends Panel { ...@@ -27,14 +41,27 @@ export class TaskCompletePanel extends Panel {
this.addChild(new Button(RES.getRes("kaixinshouxia.png"))) this.addChild(new Button(RES.getRes("kaixinshouxia.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this) .once(MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set(212, 846) .position.set(212, 846)
//领奖内容,注意发接口刷新道具数量,更新场景道具数量 //领奖内容,
var image = this.addChild(new Sprite(RES.getRes(PrizeType[this.data.type] + ".png")))
//位图文本
var textures = {}
textures["x"] = RES.getRes("nx.png");
for (var i = 0; i < 10; i++)textures[i] = RES.getRes("n" + i + ".png");
var num = new BitmapText(textures);
num.textAlign = TEXT_ALIGN.LEFT;
this.addChild(num);
if (this.data.type == TaskType.doOrder) {
num.text = "x3"
num.position.set(473, 746)
image.position.set(233, 612)
} else {
num.text = this.data.num ? "x" + this.data.num : "x1"
num.position.set(420, 746)
image.position.set(300, 638)
} }
data: {
} }
start(data) { start(data) {
super.start(); super.start();
} }
......
...@@ -9,6 +9,22 @@ import { Sprite } from "../../engine/2d/display"; ...@@ -9,6 +9,22 @@ import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics'; import { Graphics } from '../../engine/2d/graphics';
import { layers } from '../../module/views/layers'; import { layers } from '../../module/views/layers';
import Tween from '../../engine/tween/Tween'; import Tween from '../../engine/tween/Tween';
import { sendTbNet, TbNetName } from '../TaoBaoNet';
import { showWaiting, hideWaiting, showPanel, showToast } from '../../module/ctrls';
import { Texture } from '../../engine/2d/texture';
import { GDispatcher } from '../../engine/2d/events';
import { TaskCompletePanel } from './TaskCompletePanel';
import { TaskType, getTools } from '../commonNet';
interface TaskData {
taskName: TaskType,
isComplete: boolean,
taskDrawStatus: number
}
const flushTaskEvent = "flushTaskEvent";
/** /**
* 任务弹框,还没好 * 任务弹框,还没好
...@@ -18,6 +34,14 @@ export class TaskPanel extends Panel { ...@@ -18,6 +34,14 @@ export class TaskPanel extends Panel {
closeBtn: Button; closeBtn: Button;
[TaskType.doFollowShop]: CusButton;
[TaskType.doInvite]: CusButton;
[TaskType.doCollect]: CusButton;
[TaskType.doOrder]: CusButton;
//为了toast提示:成功完成下单任务,可领取道具大礼包
toShowMsg: number;
initUi() { initUi() {
//底部适配,原先都是居中的, //底部适配,原先都是居中的,
this.y = (layers.stageHeight - 1624) / 2 this.y = (layers.stageHeight - 1624) / 2
...@@ -27,7 +51,16 @@ export class TaskPanel extends Panel { ...@@ -27,7 +51,16 @@ export class TaskPanel extends Panel {
this.closeBtn = new Button(RES.getRes("comCloseBtn.png")); this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(681, 870); this.closeBtn.position.set(681, 870);
this.addChild(this.closeBtn); this.addChild(this.closeBtn);
//四个按钮 //四个按钮,先默认状态,然后start里刷任务接口
this[TaskType.doFollowShop] = this.addChild(new CusButton(TaskType.doFollowShop))
this[TaskType.doFollowShop].position.set(561, 1022);
this[TaskType.doCollect] = this.addChild(new CusButton(TaskType.doCollect))
this[TaskType.doCollect].position.set(561, 1022 + 153);
this[TaskType.doInvite] = this.addChild(new CusButton(TaskType.doInvite))
this[TaskType.doInvite].position.set(561, 1022 + 153 * 2);
this[TaskType.doOrder] = this.addChild(new CusButton(TaskType.doOrder))
this[TaskType.doOrder].position.set(561, 1022 + 153 * 3);
} }
//动画重写,从下往上 //动画重写,从下往上
...@@ -40,8 +73,50 @@ export class TaskPanel extends Panel { ...@@ -40,8 +73,50 @@ export class TaskPanel extends Panel {
start(data) { start(data) {
super.start(); super.start();
//监听任务回来的事件
GDispatcher.addEvent(flushTaskEvent, this.updateTask, this)
//刷新任务数据
this.flushTask();
}
updateTask() {
this.flushTask();
//获取道具数量,更新道具数量
getTools();
}
async flushTask() {
showWaiting();
var list = await getTaskList().catch(() => { });//加了catch,后面逻辑继续走
hideWaiting();
if (!list) return
//修改按钮状态
for (var i = 0; i < list.length; i++) {
var l = list[i];
//未完成
if (!l.isComplete) {
this[l.taskName].canGetStatus = false;
this[l.taskName].enabled = true;
if (l.taskName == TaskType.doOrder) this.toShowMsg = 1//标记是没完成的
}
//三个状态,到时确认
else if (l.taskDrawStatus == 0) {//待领取状态
this[l.taskName].canGetStatus = true;
this[l.taskName].enabled = true;
//额外判断下单,原先是1,且待领取状态,
if (l.taskName == TaskType.doOrder && this.toShowMsg === 1) {
this.toShowMsg = 2;
showToast("成功完成下单任务,可领取道具大礼包")
}
}
else if (l.taskDrawStatus == 1) {//已领取状态
this[l.taskName].enabled = false;
}
}
} }
initEvents() { initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this) this.onClick(this.closeBtn, this.onClick_closeBtn, this)
} }
...@@ -52,6 +127,135 @@ export class TaskPanel extends Panel { ...@@ -52,6 +127,135 @@ export class TaskPanel extends Panel {
removeEvents() { removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this) this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
GDispatcher.removeEvent(flushTaskEvent, this.updateTask, this)
} }
} }
function getTaskList(): Promise<TaskData[]> {
return new Promise((resolve, reject) => {
sendTbNet(
TbNetName.getTaskList,
{ activityId: Tool.globalData.activityId },
(s, res) => {
if (s) {
resolve(res.data.list)
} else {
reject(null);
}
}
)
})
}
/**
* 3种状态的按钮
* 除了邀请没有disable,其他都一样
*/
class CusButton extends Button {
private type: TaskType
private _canGetStatus: boolean;
get canGetStatus() {
return this._canGetStatus
}
set canGetStatus(value) {
this._canGetStatus = value;
var t: [Texture, Texture]
if (value) {//能领取时换图
t = [RES.getRes("lingqujiangli.png"), null]
} else {
t = getTexture(this.type)
}
this.changeTexture(t[0], t[0], t[1])
}
constructor(type: TaskType) {
var t = getTexture(type)
super(t[0], t[0], t[1])
this.type = type;
//事件统一写吧
this.addEventListener(MouseEvent.CLICK, this.onClick, this)
}
onClick() {
if (this.canGetStatus) {//能领取,发接口
showWaiting();
sendTbNet(
TbNetName.getToolsByType,
{ activityId: Tool.globalData.activityId, toolType: this.type },
(s, res) => {
hideWaiting();
if (s) showPanel(TaskCompletePanel, { type: this.type, num: res.data.inviteSuccessCount })
}
)
} else {//发对应任务方法
//都弄个延时
this.mouseEnable = false;
setTimeout(() => { this.mouseEnable = true; }, 1000)
switch (this.type) {
case TaskType.doFollowShop:
sendTbNet(
TbNetName.navigateToOutside,
{ url: "" },//关注店铺路径路径待写
() => { },
true
)
break;
case TaskType.doCollect:
sendTbNet(
TbNetName.navigateTo,
{ url: "" },//收藏页面路径待写
() => { },
true
);
break;
case TaskType.doInvite:
sendTbNet(
TbNetName.invite,
undefined,
() => { },
true
);
break;
case TaskType.doOrder:
sendTbNet(
TbNetName.navigateTo,
{ url: "" },//下单页面路径待写
() => { },
true
);
break;
}
//都需要添加事件,回来时,派发事件刷任务接口
let fun = () => {
GDispatcher.removeEvent(TbNetName.returnGame, fun, this)
GDispatcher.dispatchEvent(flushTaskEvent)
}
GDispatcher.addEvent(TbNetName.returnGame, fun, this)
}
}
}
function getTexture(type: TaskType): [Texture, Texture] {
var tup: Texture, tdis: Texture;
switch (type) {
case TaskType.doFollowShop:
tup = RES.getRes("quguanzhu.png")
tdis = RES.getRes("yiguanzhu.png")
break;
case TaskType.doCollect:
tup = RES.getRes("qushoucang.png")
tdis = RES.getRes("yilingqu.png")
break;
case TaskType.doInvite:
tup = RES.getRes("quyaoqing.png")
break;
case TaskType.doOrder:
tup = RES.getRes("quxiadan.png")
tdis = RES.getRes("yilingqu.png")
break;
}
return [tup, tdis];
}
\ No newline at end of file
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