Commit f8452261 authored by 邱旭's avatar 邱旭

1

parent fbbd6d16
......@@ -77,6 +77,11 @@ export enum NetName {
GET_SHARECODE,
DO_HELP,
GET_INVATE_INFO,
ACCEPT_INVITATION
ACCEPT_INVITATION,
SCRATCH_GET_TASKINFO,
SCRATCH_TAKEPRIZE,
SCRATCH_GET_SHARECODE,
SCRATCH_DOHELP,
}
\ No newline at end of file
......@@ -2036,4 +2036,76 @@ export class NetManager extends ABNetManager {
this.send(net);
}
///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// 消消乐刮刮卡 /////////////////////////////////////
/**
* 刮刮卡获取任务信息
* @param callback
*/
public scratchGetTaskInfo(callback: Function): void {
const net: INetData = {
name: NetName.SCRATCH_GET_TASKINFO,
uri: window['duiba'] +'/customActivity/happyclear/scratchCard/getTaskInfo',
type: 'get',
dataType: 'json',
hideMsg: true,
param: {
activityId: DataManager.ins.customCfgData.actId,
},
callback: callback
};
this.send(net);
}
/**
* 刮刮卡领取奖励
* @param callback
* @param scratchCardTaskId 刮刮卡任务id
*/
public scratchTakePrize(callback: Function, scratchCardTaskId): void {
const net: INetData = {
name: NetName.SCRATCH_TAKEPRIZE,
uri: window['duiba'] +'/customActivity/happyclear/scratchCard/takePrize',
type: 'get',
dataType: 'json',
hideMsg: true,
param: {
activityId: DataManager.ins.customCfgData.actId,
scratchCardTaskId:scratchCardTaskId
},
callback: callback
};
this.send(net);
}
public scratchGetShareCode(callback: Function, scratchCardTaskId): void {
const net: INetData = {
name: NetName.SCRATCH_GET_SHARECODE,
uri: window['duiba'] +'/customActivity/happyclear/scratchCard/GetShareCode',
type: 'get',
dataType: 'json',
hideMsg: true,
param: {
activityId: DataManager.ins.customCfgData.actId,
scratchCardTaskId:scratchCardTaskId
},
callback: callback
};
this.send(net);
}
public scratchDoHelp(callback: Function, shareCode): void {
const net: INetData = {
name: NetName.SCRATCH_DOHELP,
uri: window['duiba'] +'/customActivity/happyclear/scratchCard/doHelp',
type: 'get',
dataType: 'json',
hideMsg: true,
param: {
activityId: DataManager.ins.customCfgData.actId,
shareCode:shareCode
},
callback: callback
};
this.send(net);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="InviteSkin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui"
xmlns:w="http://ns.egret.com/wing">
<e:Image y="45.33" horizontalCenter="0" source="scratchPrize_bg_png"/>
xmlns:w="http://ns.egret.com/wing" xmlns:ns1="*">
<e:Image y="45" horizontalCenter="0" source="scratchPrize_bg_png"/>
<e:Image id="prizeImg" y="426.77" source="" horizontalCenter="0" width="510" height="228"/>
<e:Button id="closeBtn" label="" x="624" y="313.33">
<e:skinName>
......@@ -15,7 +15,7 @@
<e:Button id="ok_btn" label="" y="764" anchorOffsetX="138.5" anchorOffsetY="56.5" x="236.5">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="scratchPrize_btn_png"/>
<e:Image width="100%" height="100%" source="scratchPrize_btn_png" source.down="scratchPrize_btn_png" source.disabled="scratchPrize_btn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
......@@ -23,7 +23,7 @@
<e:Button id="game_btn" label="" y="764" anchorOffsetX="139" anchorOffsetY="56.5" x="527">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="scratchPrize_game_btn_png"/>
<e:Image width="100%" height="100%" source="scratchPrize_game_btn_png" source.down="scratchPrize_game_btn_png" source.disabled="scratchPrize_game_btn_png"/>
<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
</e:Skin>
</e:skinName>
......
/**
* 简单的倒计时
* Created by haiyoucuv on 2019/10/24
* Created on 2019/10/24
*/
export default class CutTimer {
private _timer: egret.Timer = null;
......
/**
* 地图页图标基类
* Created by haiyoucuv on 2019/10/25
* Created on 2019/10/25
*/
export default class IconBase{
private iconGroup:eui.Group;
private iconBtn:eui.Button;
private iconTipsBg:eui.Image;
private iconTips:eui.Label;
private readonly _name:string;
public get name(){
export default class IconBase {
protected iconGroup: eui.Group;
protected iconBtn: eui.Button;
protected iconTipsBg: eui.Image;
protected iconTips: eui.Label;
protected readonly _name: string;
public get name() {
return this._name;
}
constructor(name:string, group:eui.Group, btn:eui.Button, tipsBg?:eui.Image, tipsLabel?:eui.Label){
constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg?: eui.Image, tipsLabel?: eui.Label) {
this.iconGroup = group;
this.iconBtn = btn;
this.iconTipsBg = tipsBg;
......@@ -23,23 +24,23 @@ export default class IconBase{
this.start();
}
protected start(){
protected start() {
this.initEvents();
}
protected initEvents(){
protected initEvents() {
this.iconBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchBtn, this);
}
protected onTouchBtn(e:egret.TouchEvent){
protected onTouchBtn(e: egret.TouchEvent) {
}
protected removeEvents(){
protected removeEvents() {
this.iconBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchBtn, this);
}
protected destory(){
protected destory() {
this.removeEvents();
}
......@@ -48,7 +49,10 @@ export default class IconBase{
* 设置图标提示的隐藏与显示
* @param visible
*/
public set tipsVisible(visible:boolean){
public set tipsVisible(visible: boolean) {
if(visible == true) {
this.visible = true;
}
this.iconTipsBg.visible = visible;
this.iconTips.visible = visible;
}
......@@ -57,7 +61,7 @@ export default class IconBase{
* 设置图标隐藏与显示
* @param visible
*/
public set visible(visible:boolean){
public set visible(visible: boolean) {
this.iconGroup.visible = visible;
this.iconBtn.visible = visible;
this.iconTipsBg.visible = visible;
......
import IconBase from "./IconBase";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl";
import CutTimer from "../../CutTimer";
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
import { ModuleTypes } from "../../../libs/new_wx/types/sceneTypes";
export default class ScratchIcon extends IconBase {
private cutTimer: CutTimer = null;
constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg?: eui.Image, tipsLabel?: eui.Label) {
super(name, group, btn, tipsBg, tipsLabel);
}
protected start() {
super.start();
this.getTaskInfo(); // 获取任务信息 (控制角标)
}
protected initEvents() {
super.initEvents();
public getTaskInfo() {
NetManager.ins.scratchGetTaskInfo((success, res) => {
if(!success) {
return;
}
let status = res.data.taskStatus;
if(this.cutTimer){ // 先停止计时器一次
this.cutTimer.stop();
}
switch(true) {
case (status == 0): // 当前无任务,隐藏icon
this.visible = false;
break;
case (status == 1): // 当前任务进行中,显示倒计时
this.tipsVisible = true;
// 开启新的计时器
this.cutTimer = new CutTimer(this.iconTips, "hh:mm:ss", ()=>{
this.getTaskInfo();
});
let cutTime = res.data.endTime - res.data.currentTime + 3000;
if(!this.cutTimer.start(cutTime)) {
this.cutTimer.stop();
this.cutTimer.start(cutTime);
}
break;
case (status == 2): // 当前任务完成待领奖,显示待领奖
this.tipsVisible = true;
this.iconTips.text = "待领取";
break;
default:
break;
}
})
}
/**
* 点击icon
* @param e 点击事件
*/
protected onTouchBtn(e: egret.TouchEvent) {
super.onTouchBtn(e);
NetManager.ins.getInviteInfo((success, res) => {
NetManager.ins.scratchGetTaskInfo((success, res) => {
if(!success) {
return;
}
PanelCtrl.instance.show('scratch', res.data);
let status = res.data.taskStatus;
switch(true) {
case (status == 0): // 当前无任务(一般icon不会出现),拦截
break;
case (status == 1): // 当前任务进行中 打开任务面板
PanelCtrl.instance.show('scratch', res.data);
break;
case (status == 2): // 当前任务完成待领奖 请求领奖接口
NetManager.ins.scratchTakePrize((success, res)=>{
if(!success){
return;
}
PanelCtrl.instance.show("scratchPrize", res.data);
}, res.data.scratchCardTaskId);
break;
default:
break;
}
});
}
protected initEvents() {
GDispatcher.addEvent("updateScratchTips", this.getTaskInfo, this);
super.initEvents();
}
protected removeEvents() {
GDispatcher.removeEvent("updateScratchTips", this.getTaskInfo, this);
super.removeEvents();
}
......
......@@ -52,7 +52,7 @@ export default class ScratchPanel extends Panel {
}
onTouchTap_closeBtn() {
// GDispatcher.dispatchEvent("getInviteInfo");
GDispatcher.dispatchEvent("updateScratchTips");
super.onTouchTap_closeBtn();
}
......@@ -80,61 +80,43 @@ export default class ScratchPanel extends Panel {
this.hongbaoEffect();
this.setWXShareTip();
this["progressGroup"].mask = this["progressMask"];
this.setProgress(98);
this["prizeImg"].source = this.data.prizeImg;
if(!this.data.invitationUser) {
this.data.invitationUser = [];
this["prizeImg"].source = this.data.prizeImage;
if(!this.data.avatarList) {
this.data.avatarList = [];
}
// 添加邀请图标
let dNum = this.data.invitationCount - this.data.invitationUser.length;
let dNum = this.data.helpedCount - this.data.avatarList.length;
for(let i = 0; i < dNum; i++) {
this.data.invitationUser.push({
nickname: "nickname",
avatar: "scratch_invite_png",
});
this.data.avatarList.push("scratch_invite_png");
}
// 添加假用户
this.data.invitationUser.unshift({
nickname: "nickname",
avatar: "scratch_user1_png",
}, {
nickname: "nickname",
avatar: "scratch_user2_png",
});
// 添加回调函数
for(let i = 0; i < this.data.invitationUser.length; i++) {
this.data.invitationUser[i]['callFun'] = () => {
NetManager.ins.getShareCode((success, res) => {
if(!success) {
return;
}
let shareCode = res.data; // 分享码
CFG.wxShareLink = window['h5URL'] + "&shareCode=" + shareCode; // 分享链接
CFG.wxShareTitle = '狮狮连萌超好玩~我已经玩到第一了!';
CFG.wxShareDesc = '我在萌狮消消乐等你来挑战哦';
CFG.wxShareImg = "http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg";
if(iswx()) { //微信端
this["wxShareTip"].visible = true;
window["invokeWX"]();
} else {//端内
this["wxShareTip"].visible = false;
window["inviteShare"](shareCode);
}
});
}
this.data.avatarList.unshift("scratch_user1_png", "scratch_user2_png");
// 创建渲染列表
let rendererList = [];
for(let i = 0; i < this.data.avatarList.length; i++) {
rendererList.push({
avatar: this.data.avatarList[i], // 传递头像
wxShareTip: this["wxShareTip"], // 传递shareGroup的引用
scratchTaskId: this.data.scratchCardTaskId, // 任务id
});
}
this["list"].useVirtualLayout = false;
this["list"].itemRenderer = ScratchItem;
this["list"].dataProvider = new eui.ArrayCollection(this.data.invitationUser);
this["list"].dataProvider = new eui.ArrayCollection(rendererList);
this.setProgress(+this.data.completePercent);
// 倒计时
this.cutTimer = new CutTimer(this["cutTimeLabel"], "将在hh:mm:ss后消失", () => {
this.hidePanel();
GDispatcher.dispatchEvent("updateScratchTips");
}
);
let cutTime = this.data.endTime - this.data.sysTime + 3000;
let cutTime = this.data.endTime - this.data.currentTime + 3000;
if(!this.cutTimer.start(cutTime)) {
this.cutTimer.stop();
this.cutTimer.start(cutTime);
......@@ -151,28 +133,28 @@ export default class ScratchPanel extends Panel {
} else if(progress < 0) {
progress = 0;
}
this['numLabel'].text = `共${this.data.invitationUser.length + 2}位好友帮你刮了${progress}%`;
this['numLabel'].text = `共${this.data.avatarList.length}位好友帮你刮了${progress}%`;
this["progressLabel"].text = `仅剩${(100 - progress).toFixed(2)}%`; // 进度条文字
let _width = this["progressBg"].width * progress / 100; // 宽度
let dProgress = Math.abs(progress - this["progress"].width / this["progressBg"].width); // 比当前进度的差值的绝对值
let _duration = 1000 * dProgress / 100; // 算出变化的时间
egret.Tween.get(this["progress"]).to({width: _width}, _duration);
let i = new eui.Image();
if(progress >= 100){
if(progress >= 100) {
this["scratch_progress"].visible = false;
} else if(progress >= 98 && progress < 100){
} else if(progress >= 98 && progress < 100) {
this["scratch_progress"].visible = true;
this["scratch_progress"].source = "scratch_card_98_png";
}else if(progress >= 96 && progress < 98){
} else if(progress >= 96 && progress < 98) {
this["scratch_progress"].visible = true;
this["scratch_progress"].source = "scratch_card_96_png";
}else if(progress >= 94 && progress < 96){
} else if(progress >= 94 && progress < 96) {
this["scratch_progress"].visible = true;
this["scratch_progress"].source = "scratch_card_94_png";
}else if(progress >= 92 && progress < 96){
} else if(progress >= 92 && progress < 96) {
this["scratch_progress"].visible = true;
this["scratch_progress"].source = "scratch_card_92_png";
}else if(progress < 92){
} else if(progress < 92) {
this["scratch_progress"].visible = true;
this["scratch_progress"].source = "scratch_card_90_png";
}
......@@ -197,7 +179,7 @@ export default class ScratchPanel extends Panel {
destroy() {
super.destroy();
this.cutTimer.stop();
this.cutTimer.stop(); // 面板销毁停止计时器(停止计时器,移除时间事件监听)
}
protected get closeBtns(): eui.Button[] {
......@@ -230,9 +212,23 @@ class ScratchItem extends eui.ItemRenderer {
this.img.mask = this.mask;
this.img.source = this.data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
this.img.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
if(this.data.callFun) {
this.data.callFun();
}
NetManager.ins.scratchGetShareCode((success, res) => {
if(!success) {
return;
}
let shareCode = res.data; // 分享码
CFG.wxShareLink = window['h5URL'] + "&shareCode=" + shareCode; // 分享链接
CFG.wxShareTitle = '狮狮连萌超好玩~我已经玩到第一了!';
CFG.wxShareDesc = '我在萌狮消消乐等你来挑战哦';
CFG.wxShareImg = "http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg";
if(iswx()) { //微信端
this.data.wxShareTip.visible = true;
window["invokeWX"]();
} else {//端内
this.data.wxShareTip.visible = false;
window["inviteShare"](shareCode);
}
}, this.data.scratchTaskId);
}, this);
}
}
......@@ -9,10 +9,10 @@ import { GDispatcher } from "../../libs/tc/util/GDispatcher";
* 邀请规则面板
*/
export default class ScratchPrizePanel extends Panel {
public prizeImg:eui.Image;
public closeBtn:eui.Button;
public ok_btn:eui.Button;
public game_btn:eui.Button;
public prizeImg: eui.Image;
public closeBtn: eui.Button;
public ok_btn: eui.Button;
public game_btn: eui.Button;
constructor(data) {
super();
......@@ -21,48 +21,53 @@ export default class ScratchPrizePanel extends Panel {
start() {
super.start();
this.initUI();
}
protected onSkinComplete() {
this.initUI();
}
initEvents() {
super.initEvents();
this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.ok_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapGoPrize, this);
this.game_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchOK, this);
this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
this.ok_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
this.game_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
}
removeEvents() {
super.removeEvents();
this.closeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.ok_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapGoPrize, this);
this.game_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchOK, this);
this.closeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
this.ok_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
this.game_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
}
onTouchTap_closeBtn() {
// GDispatcher.dispatchEvent("getInviteInfo");
super.onTouchTap_closeBtn();
}
onTouchTap(e: egret.TouchEvent) {
switch(true) {
case (e.target == this.closeBtn): // 关闭按钮
super.onTouchTap_closeBtn();
break;
case (e.target == this.ok_btn): // 去领奖
window.location.href = window['__link__'];
break;
case (e.target == this.game_btn): // 继续闯关
if((getHomeData().levels.length + 1) > window['last_level']) {
changeMapScene();
super.hidePanel();
return;
}
PanelCtrl.instance.show("StartPanel", getHomeData().levels.length + 1);
break;
onTouchOK() {
if((getHomeData().levels.length + 1) > window['last_level']) {
changeMapScene();
super.hidePanel();
return;
default:
break;
}
// GDispatcher.dispatchEvent("getInviteInfo");
PanelCtrl.instance.show("StartPanel", getHomeData().levels.length + 1);
}
onTapGoPrize() {
window.location.href = window['__link__'];
GDispatcher.dispatchEvent("updateScratchTips");
}
initUI() {
this.prizeImg.source = this.data.prizeImg;
addAdComp(84, 845.33, this);
this.prizeImg.source = this.data.prizeImage;
addAdComp(84, 875, this);
}
protected get closeBtns(): eui.Button[] {
......
......@@ -133,7 +133,19 @@ const config = {
},
'/customActivity/happyclear/acceptInvitationPrize':{
data: './happyclear/acceptInvitationPrize.json'
}
},
'/customActivity/happyclear/scratchCard/getTaskInfo':{
data: './happyclear/scratchGetTaskInfo.json'
},
'/customActivity/happyclear/scratchCard/takePrize':{
data: './happyclear/scratchTakePrize.json'
},
'/customActivity/happyclear/scratchCard/getShareCode':{
data: './happyclear/scratchGetShareCode.json'
},
'/customActivity/happyclear/scratchCard/doHelp':{
data: './happyclear/scratchDoHelp.json'
},
}
for (let item in config) {
......
{
"success":true,
"code":null,
"desc":null,
"timestamp":1566199822308,
"data":""
}
\ No newline at end of file
{
"success":true,
"code":null,
"desc":null,
"timestamp":1566199822308,
"data":""
}
\ No newline at end of file
{
"success": true,
"code": null,
"desc": null,
"timestamp": 1566199822308,
"data": {
"scratchCardTaskId": 1222,
"taskStatus": 1,
"prizeImage": "http://yun.duiba.com.cn/db_games/xiaoxiaole.jpg",
"currentTime": 1570673808000,
"endTime": 1570673810000,
"completePercent": "90.50",
"remainPercent": "9.50",
"helpedCount": 4,
"avatarList": [
"http://yun.duiba.com.cn/db_games/xiaoxiaole.jpg",
""
]
}
}
\ No newline at end of file
{
"success":true,
"code":null,
"desc":null,
"timestamp":1566199822308,
"data":{
"prizeImage": "http://yun.duiba.com.cn/db_games/xiaoxiaole.jpg"
}
}
\ 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