Commit 41e902d4 authored by 邱旭's avatar 邱旭

1

parent b1675f08
......@@ -76,6 +76,7 @@ export enum NetName {
// 邀请有礼
GET_SHARECODE,
DO_HELP,
GET_INVATE_INFO
GET_INVATE_INFO,
ACCEPT_INVITATION
}
\ No newline at end of file
......@@ -1983,7 +1983,7 @@ export class NetManager extends ABNetManager {
* 获取邀请详情
* @param callback
*/
public getInvateInfo(callback: Function): void {
public getInviteInfo(callback: Function): void {
const net: INetData = {
name: NetName.GET_INVATE_INFO,
uri: '/customActivity/happyclear/invitationInfo',
......@@ -1996,5 +1996,23 @@ export class NetManager extends ABNetManager {
};
this.send(net);
}
/**
* 接受任务
* @param callback
*/
public acceptInvitationInfo(callback: Function): void {
const net: INetData = {
name: NetName.ACCEPT_INVITATION,
uri: '/customActivity/happyclear/acceptInvitationInfo',
type: 'post',
dataType: 'json',
param: {
activityId: DataManager.ins.customCfgData.actId,
},
callback: callback
};
this.send(net);
}
///////////////////////////////////////////////////////////////////////////////////
}
\ No newline at end of file
......@@ -32,11 +32,16 @@ export default class MapScene extends Scene {
static starHash: any = {};
_data;
// 邀请有礼角标倒计时
private timer: egret.Timer;
private cutTime: number;
async start(data?) {
super.start();
this.updateMyInfo();
this.updateAdData();
this.getInviteInfo(); // 查询邀请信息,控制邀请有礼角标
this['avatar'].mask = this['avatarMask'];
setTimeout(() => {
......@@ -368,7 +373,7 @@ export default class MapScene extends Scene {
}
onTap_inviteBtn() {
NetManager.ins.getInvateInfo((success, res) => {
NetManager.ins.getInviteInfo((success, res) => {
if (!success || !res.data) {
return;
}
......@@ -395,6 +400,72 @@ export default class MapScene extends Scene {
});
}
//////////////////////////////////////// 邀请有礼角标 //////////////////////////////////////////////
/**
* 查询邀请信息
*/
getInviteInfo(){
NetManager.ins.getInviteInfo((success, res) => {
if (!success || !res.data) {
return;
}
let flag = res.data.completeFlag;
switch(true) {
case (flag == 0): // 未完成 显示倒计时
this.cutTime = res.data.endTime - res.data.sysTime + 1000;
console.log(this.cutTime);
this.timer = new egret.Timer(1000, 0);
this.timer.addEventListener(egret.TimerEvent.TIMER, this.cutTimer, this);
this.timer.start();
this.cutTimer();
break;
case (flag == 1): // 完成未开奖 待领奖 显示待领奖
this["inviteTips"].text = "待领奖";
break;
case (flag == 2): // 领奖成功
break;
case (flag == 3): // 领奖失败
break;
case (flag == 4): // 可以开启下一次发任务
break;
default:
break;
}
});
}
// 倒计时
private cutTimer() {
let timer = this.convertTime(this.cutTime -= 1000);
if(timer.hour === "00"
&& timer.min === "00"
&& timer.sec === "00") {
this.timer.stop();
this.getInviteInfo();
}
this["inviteTips"].text = `${timer.hour}:${timer.min}:${timer.sec}`;
}
// 通过时间戳获取时间计数(时,分,秒)
private convertTime(time: number) {
let hour = ~~(time / 3600000); // 小时
let min = ~~((time - hour * 3600000) / 60000); // 分
let sec = ~~((time - hour * 3600000 - min * 60000) / 1000); // 秒
return {
hour: this.prefixInteger(hour, 2),
min: this.prefixInteger(min, 2),
sec: this.prefixInteger(sec, 2)
}
}
// 截取数字补0
prefixInteger(num, length) {
return (Array(length).join('0') + num).slice(-length);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
onTap_friendBtn() {
PanelCtrl.instance.show('friend');
}
......
import Panel from "../../libs/new_wx/components/Panel";
import { changeMapScene } from "../startScene/StartScene";
import PanelCtrl from "../../libs/new_wx/ctrls/panelCtrl";
import getHomeData from "../getHomeData";
import { ModuleTypes } from "../../libs/new_wx/types/sceneTypes";
/**
* 邀请规则面板
*/
export default class InviteCutTimePanel extends Panel {
public cutTimeLabel:eui.BitmapLabel;
public closeBtn:eui.Button;
public ok_btn:eui.Button;
public cutTimeLabel: eui.BitmapLabel;
public closeBtn: eui.Button;
public ok_btn: eui.Button;
private timer: egret.Timer;
private cutTime: number;
......@@ -26,17 +30,22 @@ export default class InviteCutTimePanel extends Panel {
initEvents() {
super.initEvents();
this.ok_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.ok_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchOK, this);
}
removeEvents() {
super.removeEvents();
this.ok_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.ok_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchOK, this);
}
initUI() {
this.cutTime = this.data.endTime - this.data.sysTime + 1000;
onTouchOK() {
PanelCtrl.instance.show("StartPanel", getHomeData().levels.length + 1);
}
initUI() {
// 到第二天0点的倒计时
let endTime = this.data.sysTime + 86400000 - ((this.data.sysTime + 86400000) % 86400000) - 8 * 3600000;
this.cutTime = endTime - this.data.sysTime + 1000;
this.timer = new egret.Timer(1000, 0);
this.timer.addEventListener(egret.TimerEvent.TIMER, this.cutTimer, this);
this.timer.start();
......
import Panel from "../../libs/new_wx/components/Panel";
import PanelCtrl from "../../libs/new_wx/ctrls/panelCtrl";
import getHomeData from "../getHomeData";
/**
* 邀请规则面板
*/
export default class InvitePrizePanel 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){
constructor(data) {
super();
this.data = data;
}
......@@ -25,17 +27,21 @@ export default class InvitePrizePanel extends Panel {
initEvents() {
super.initEvents();
this.ok_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapGoPrize, this);
this.game_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.game_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchOK, this);
}
removeEvents() {
super.removeEvents();
this.ok_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapGoPrize, this);
this.game_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.game_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchOK, this);
}
onTapGoPrize(){
onTouchOK() {
PanelCtrl.instance.show("StartPanel", getHomeData().levels.length + 1);
}
onTapGoPrize() {
window.location.href = window['__link__'];
}
initUI() {
......
......@@ -7,7 +7,7 @@
"invitationId": "活动id",
"invitationCount": 4,
"img": "http://yun.duiba.com.cn/db_games/xiaoxiaole.jpg",
"sysTime": 1570597800000,
"sysTime": 1570630215000,
"endTime": 1570672800000,
"invitationUser": [
{
......@@ -15,7 +15,7 @@
"avatar": "http://yun.duiba.com.cn/db_games/xiaoxiaole.jpg"
}
],
"completeFlag": 2,
"completeFlag": 0,
"openPrizeMsg": "图片",
"prizeType": "nickname",
"prizeName": "nickname",
......
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