Commit e1f2e312 authored by wjf's avatar wjf

l

parent 84f09f41
......@@ -17,7 +17,7 @@ export class NetManager extends ABNetManager {
private static instance: NetManager;
public static get ins(): NetManager {
if(!this.instance) {
if (!this.instance) {
this.instance = new NetManager();
}
return this.instance;
......@@ -27,7 +27,7 @@ export class NetManager extends ABNetManager {
constructor() {
super();
if(this.isInit) {
if (this.isInit) {
throw Error(TwLang.lang_001);
}
this.isInit = true;
......@@ -98,7 +98,7 @@ export class NetManager extends ABNetManager {
*/
public addTimesForActivity(callback: Function, type: number, count: number, validType: number): void {
let activityId: number;
if(type == 1) {
if (type == 1) {
activityId = DataManager.ins.gameCfgData.gameInfo.oaId;
} else {
activityId = DataManager.ins.customCfgData.oaId;
......@@ -108,7 +108,7 @@ export class NetManager extends ABNetManager {
addCount: count,
activityId: activityId
};
if(validType) {
if (validType) {
param.validType = validType;
}
......@@ -149,15 +149,15 @@ export class NetManager extends ABNetManager {
public openCollectGoodsPrize(callback: Function, collectRuleId: number, type?: number): void {
let actId: number;
let param: any;
if(type == 1) {
if (type == 1) {
actId = DataManager.ins.gameCfgData.gameInfo.oaId;
} else if(type == 2) {
} else if (type == 2) {
actId = DataManager.ins.customCfgData.oaId;
}
if(type) {
param = {collectRuleId: collectRuleId, actId: actId}
if (type) {
param = { collectRuleId: collectRuleId, actId: actId }
} else {
param = {collectRuleId: collectRuleId};
param = { collectRuleId: collectRuleId };
}
const net: INetData = {
name: NetName.OPEN_COLLECT,
......@@ -238,7 +238,7 @@ export class NetManager extends ABNetManager {
uri: '/summer/getToyInfo',
type: 'get',
dataType: 'json',
param: {operatingActivityId: operatingActivityId},
param: { operatingActivityId: operatingActivityId },
callback: callback
};
this.send(net);
......@@ -254,7 +254,7 @@ export class NetManager extends ABNetManager {
public doStart(callback: Function, isAgain: boolean, credits?: number, customizedType?: number): void {
let addUrl = '';
if(isAgain) {
if (isAgain) {
addUrl += '?dpm=' + DataManager.ins.gameGetSubmitResultData.againExposure.dpm;
}
......@@ -263,11 +263,11 @@ export class NetManager extends ABNetManager {
oaId: DataManager.ins.gameCfgData.gameInfo.oaId
};
if(credits) {
if (credits) {
param.credits = credits;
}
if(customizedType) {
if (customizedType) {
param.customizedType = customizedType;
}
......@@ -294,7 +294,7 @@ export class NetManager extends ABNetManager {
const param: any = {
ticketId: ticketId
};
if(customizedType) {
if (customizedType) {
param.customizedType = customizedType
}
......@@ -421,7 +421,7 @@ export class NetManager extends ABNetManager {
sgin: sign,
dynamicData: JSON.stringify(dynamicData)
};
if(rankId) {
if (rankId) {
param.rankId = rankId;
}
const net: INetData = {
......@@ -441,7 +441,7 @@ export class NetManager extends ABNetManager {
kk = kk.substring(0, 16);
//补0;
var len = kk.length;
while(len < 16) {
while (len < 16) {
kk = kk + "0";
len++;
}
......@@ -476,7 +476,7 @@ export class NetManager extends ABNetManager {
deviceSessionId: window['_device_session_id'],
score: score
};
if(relatedTaskType) {
if (relatedTaskType) {
data['relatedTaskType'] = relatedTaskType;
}
var sgin = this.encrypt(JSON.stringify(data));
......@@ -572,10 +572,10 @@ export class NetManager extends ABNetManager {
sgin: sign,
dynamicData: dynamicData
};
if(checkScore) {
if (checkScore) {
param.checkScore = checkScore;
}
if(customizedType) {
if (customizedType) {
param.customizedType = customizedType;
}
......@@ -833,7 +833,7 @@ export class NetManager extends ABNetManager {
this.send(net);
}
public getShareInfo(callback: Function,): void {
public getShareInfo(callback: Function, ): void {
const net: INetData = {
name: 'getShareInfo',
uri: window['duiba'] + '/wechatShare/getShareInfo/v2',
......@@ -932,7 +932,7 @@ export class NetManager extends ABNetManager {
activityId: DataManager.ins.customCfgData.actId
};
if(propType) {
if (propType) {
d.propType = propType;
}
const net: INetData = {
......@@ -993,7 +993,7 @@ export class NetManager extends ABNetManager {
uri: window['duiba'] + '/customActivity/happyclear/getBackReward',
type: 'get',
dataType: 'json',
hideMsg:true,
hideMsg: true,
param: d,
callback: callback
};
......@@ -1006,7 +1006,7 @@ export class NetManager extends ABNetManager {
uri: window['duiba'] + '/customActivity/happyclear/hasBackReward',
type: 'get',
dataType: 'json',
hideMsg:true,
hideMsg: true,
param: d,
callback: callback
};
......@@ -1061,9 +1061,9 @@ export class NetManager extends ABNetManager {
public getMusicCategory(callback: Function, categoryID?: number, categoryCode?, liteVersion?): void {
const data: any = {};
if(categoryID) data.categoryID = categoryID;
if(categoryCode) data.categoryCode = categoryCode;
if(liteVersion) data.liteVersion = liteVersion;
if (categoryID) data.categoryID = categoryID;
if (categoryCode) data.categoryCode = categoryCode;
if (liteVersion) data.liteVersion = liteVersion;
const net: INetData = {
name: 'getMusicCategory',
uri: '/aaw/music/category',
......@@ -1098,8 +1098,8 @@ export class NetManager extends ABNetManager {
public getMusicItem(callback: Function, songListId, itemId): void {
const data: any = {};
if(itemId) data.itemId = itemId;
if(songListId) data.songListId = songListId;
if (itemId) data.itemId = itemId;
if (songListId) data.songListId = songListId;
const net: INetData = {
name: 'getMusicItem',
uri: '/aaw/music/item',
......@@ -1154,10 +1154,10 @@ export class NetManager extends ABNetManager {
activityType: 'hdtool',
consumerId: window['CFG'].consumerId
};
if(credits) {
if (credits) {
param.credits = credits;
}
if(collectRuleId) {
if (collectRuleId) {
param.collectRuleId = collectRuleId;
}
const net: INetData = {
......@@ -1851,7 +1851,7 @@ export class NetManager extends ABNetManager {
* @param net
*/
public getToken(net: INetData): void {
if(window['getDuibaToken']) {
if (window['getDuibaToken']) {
window['getDuibaToken']((tokenObj: any) => {
net.param.token = tokenObj.token;
this.send(net);
......@@ -1882,12 +1882,12 @@ export class NetManager extends ABNetManager {
let gTime: string = '?_=' + GTime.getTimestamp();
let realUrl: string = net.uri;
if(realUrl.indexOf('?') != -1) {
if (realUrl.indexOf('?') != -1) {
gTime = '&_=' + GTime.getTimestamp();
}
//url加参数等特殊需求(例如再玩一次需要在dostart接口的url上加埋点)
if(net.addUrl) {
if (net.addUrl) {
realUrl += net.addUrl;
}
......@@ -2009,33 +2009,33 @@ export class NetManager extends ABNetManager {
* @param result 结果
*/
protected onResponse(net: INetData, result: any): void {
if(net.name == 'hc_home') {
if (net.name == 'hc_home') {
// if(result.data.refectionCountdown==null)
// result.data.refectionCountdown==0;
if(result.data.refectionCountdown == 0)
if (result.data.refectionCountdown == 0)
result.data.refectionCountdown = 5;
result.data.refectionCountdown += Math.floor(new Date().getTime() / 1000);
}
//数据处理
const data: Data = DataManager.ins.updateData(net.name, result, net.param);
//接口成功
if(net.pollingCount && net.pollingCheck(data)) {
if (net.pollingCount && net.pollingCheck(data)) {
net.pollingCount -= 1;
//轮询接口特殊处理
setTimeout(() => {
this.send(net);
}, 500);
} else if(net.callback) {
if(net.pollingCheck && net.pollingCount == 0 && net.pollingCheck(data)) {
} else if (net.callback) {
if (net.pollingCheck && net.pollingCount == 0 && net.pollingCheck(data)) {
result.message = '系统异常,请稍后再试。';
data['success'] = false;
}
net.callback(data.success, data || result);
}
if(!data.success && !net.hideMsg) {
if (!data.success && !net.hideMsg) {
GDispatcher.dispatchEvent(ABNetManager.ERROR, net, result.message || result.desc || result.msg);
}
if(!data.success && !net.hideMsg) {
if (!data.success && !net.hideMsg) {
onNotSuccess(data, net.name)
}
}
......@@ -2048,11 +2048,11 @@ export class NetManager extends ABNetManager {
* @param message
*/
protected onError(net: INetData): void {
if(net.callback) {
if (net.callback) {
net.callback(false);
}
if(!net.hideMsg) {
if (!net.hideMsg) {
GDispatcher.dispatchEvent(ABNetManager.ERROR, net);
showToast('网络开小差了,再试一次吧');
console.log('接口错误', net.uri)
......@@ -2362,4 +2362,48 @@ export class NetManager extends ABNetManager {
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// 分享加体力 /////////////////////////////////////
/**
* 通用接口,现在用于获取分享加体力的分享码
*
*/
public getUserShareCode(callback: Function) {
const net: INetData = {
name: "getUserShareCode",
uri: window['duiba'] + '/activtyShareCode/getUserShareCode',
type: 'get',
dataType: 'json',
hideMsg: true,
param: {
activityId: DataManager.ins.customCfgData.actId,
activityType: "hdtool",
// dateUnit
},
callback: callback
};
this.send(net);
}
/**
* 通用接口,现在用于分享加体力助力
* @param callback
* @param shareCode
*/
public doHelpNew(callback: Function, shareCode: string) {
const net: INetData = {
name: "doHelpNew",
uri: window['duiba'] + '/activtyShareCode/doHelpNew',
type: 'get',
dataType: 'json',
hideMsg: true,
param: {
activityId: DataManager.ins.customCfgData.actId,
activityType: "hdtool",
shareCode,
// singleLimitType: "",//待写
// subType: "" //待写
},
callback: callback
};
this.send(net);
}
}
\ No newline at end of file
......@@ -32,6 +32,7 @@ import { NetName } from "../../libs/tw/enum/NetName";
import TaskCenterIcon from "./icon/TaskCenterIcon";
import HbBombIcon from "./icon/HbBombIcon";
import { createEffect1MovieClip } from "../effect/createEffect1";
import { CodeChannels } from "../panels/ShareCodePanel";
let doHelpFlag = false;
// let doScratchHelpFlag = false;
......@@ -51,17 +52,29 @@ export default class MapScene extends Scene {
private actIcon: ActIcon = null;
sendInvite() {
const code = Utils.getRequestByKey('shareCode');
if(!code) return;
if(doHelpFlag) {
const code = Utils.getRequestByKey('shareCode') || Utils.getRequestByKey('token');//0224新加用token取一边
if (!code) return;
if (doHelpFlag) {
return;
}
if(code.indexOf("12345678") == -1) { // 邀请有礼
//0224修改,取sceneCode,
const sceneCode = Utils.getRequestByKey('sceneCode')
if (sceneCode == CodeChannels.AddBlood) {//加体力的,0228到时会修改成助力,这里要加逻辑
if (window["test0228"]) {
} else {
showToast("欢迎加入游戏,去闯关吧");
}
}
else if (sceneCode == CodeChannels.RankPlay) {//排行榜邀请好友的,
showToast("欢迎加入游戏,去闯关吧");
}//剩下的就是邀请有礼和刮刮卡了,本身code上有区分
else if (code.indexOf("12345678") == -1) { // 邀请有礼
const dojoin = DataManager.ins.getData('hc_doJoin');
if(!dojoin) return;
if (!dojoin) return;
NetManager.ins.doHelp((success, res) => {
doHelpFlag = true;
switch(true) {
switch (true) {
case (res.code == "400017"):
showToast("您不是新用户呢~");
break;
......@@ -74,7 +87,7 @@ export default class MapScene extends Scene {
default:
break;
}
if(!success) {
if (!success) {
return;
}
showToast("助力成功");
......@@ -84,7 +97,7 @@ export default class MapScene extends Scene {
const _code = code.slice(8);
NetManager.ins.scratchDoHelp((success, res) => {
doHelpFlag = true;
switch(true) {
switch (true) {
case (res.code == "0000024"):
showToast("今日刮卡次数已达到上线限哦~");
break;
......@@ -97,7 +110,7 @@ export default class MapScene extends Scene {
default:
break;
}
if(!success) {
if (!success) {
return;
}
showToast("帮刮成功!");
......@@ -150,7 +163,7 @@ export default class MapScene extends Scene {
GDispatcher.dispatchEvent("getInviteInfo"); // 查询邀请信息,控制邀请有礼角标
this['avatar'].mask = this['avatarMask'];
if(getBgOn() && MapScene['firstPlayBgTag'] == true) {
if (getBgOn() && MapScene['firstPlayBgTag'] == true) {
playBg();
}
......@@ -167,12 +180,12 @@ export default class MapScene extends Scene {
const oldTimerStr2 = localStorage.getItem('nowTimer2Str' + window['CFG'].consumerId);
const hc_advert = DataManager.ins.getData('hc_advert').data || {};
let {noticeAdvert} = hc_advert;
if(noticeAdvert == null) {
noticeAdvert = {enable: false}
let { noticeAdvert } = hc_advert;
if (noticeAdvert == null) {
noticeAdvert = { enable: false }
}
if(noticeAdvert && noticeAdvert.enable && nowTimerStr2 != oldTimerStr2) {
if (noticeAdvert && noticeAdvert.enable && nowTimerStr2 != oldTimerStr2) {
// if (!adTag) {
panels.push('ad');
// adTag = true;
......@@ -181,14 +194,14 @@ export default class MapScene extends Scene {
}
const backData = DataManager.ins.getData('hc_hasBackReward');
if(backData.success) {
if (backData.success) {
backData.success = false;
panels.push('BackIndex');
}
const {signInfoVO} = DataManager.ins.getData('getSignInfo');
if(signInfoVO && signInfoVO.continueDay < 7) { //表示明天还可以签到
if(signInfoVO.todaySigned == 0 && oldTimerStr != nowTimerStr) {
const { signInfoVO } = DataManager.ins.getData('getSignInfo');
if (signInfoVO && signInfoVO.continueDay < 7) { //表示明天还可以签到
if (signInfoVO.todaySigned == 0 && oldTimerStr != nowTimerStr) {
panels.push('sign');
localStorage.setItem('nowTimerStr' + window['CFG'].consumerId, nowTimerStr);
}
......@@ -197,12 +210,12 @@ export default class MapScene extends Scene {
// 红包雨强提示
const hbRainRes = DataManager.ins.getData(NetName.HBRAIN_BASEINFO);
if(hbRainRes.data) {
if(hbRainRes.data.currentSession || hbRainRes.data.nextSession) {
if (hbRainRes.data) {
if (hbRainRes.data.currentSession || hbRainRes.data.nextSession) {
const sessionId = hbRainRes.data.currentSession ? hbRainRes.data.currentSession.sessionIndex : hbRainRes.data.nextSession.sessionIndex; // 场次ID
const nowTimerStr3 = date.getTime() + sessionId + '';
const oldTimerStr3 = localStorage.getItem('nowTimer3Str' + window['CFG'].consumerId);
if(nowTimerStr3 != oldTimerStr3) {
if (nowTimerStr3 != oldTimerStr3) {
panels.push('HbCutTime');
localStorage.setItem('nowTimer3Str' + window['CFG'].consumerId, nowTimerStr3);
}
......@@ -211,11 +224,11 @@ export default class MapScene extends Scene {
// 任务中心可领奖强提示
let canShow = localStorage.getItem('taskCenter' + window['CFG'].consumerId);
if(canShow == 'true') {
if (canShow == 'true') {
const taskInfoRes = DataManager.ins.getData(NetName.GET_TASKINFO);
if(taskInfoRes && taskInfoRes.data && taskInfoRes.data.length > 0) {
for(let i = 0; i < taskInfoRes.data.length; i++) {
if(taskInfoRes.data[i].count > 0) {
if (taskInfoRes && taskInfoRes.data && taskInfoRes.data.length > 0) {
for (let i = 0; i < taskInfoRes.data.length; i++) {
if (taskInfoRes.data[i].count > 0) {
panels.push('task');
break;
}
......@@ -225,18 +238,18 @@ export default class MapScene extends Scene {
localStorage.setItem('taskCenter' + window['CFG'].consumerId, 'false');
let res = DataManager.ins.getData('hc_redBombBaseInfo');
if(res && res.data){
if (res && res.data) {
let _t = res.data.redBombSwitchTime || "";
if(res.data.remain > 0) {
if (res.data.remain > 0) {
let showBomb = localStorage.getItem('showBomb' + window['CFG'].consumerId);
if(showBomb != _t.toString() && _t != "") {
if (showBomb != _t.toString() && _t != "") {
localStorage.setItem('showBomb' + window['CFG'].consumerId, _t.toString());
panels.push('BombTips2Panel');
}
}
}
if(!readCache() && getHomeData().levels.length <= 0) { //引导
if (!readCache() && getHomeData().levels.length <= 0) { //引导
const guide = new GuideCon(() => {
PanelCtrl.instance.showPanels(panels, [], this.onAllPanelHide);
});
......@@ -276,19 +289,19 @@ export default class MapScene extends Scene {
let target;
const homeData = getHomeData();
if(homeData.levels.length == 0) {
if (homeData.levels.length == 0) {
target = 1;
} else if(homeData.levels.length == window['total_level']) {
} else if (homeData.levels.length == window['total_level']) {
target = window['total_level'] + 1;
} else {
target = homeData.levels.length + 1;
}
for(const key in MapScene.iconHash) {
for (const key in MapScene.iconHash) {
const levelOrder = parseInt(key);
const element = MapScene.iconHash[key];
if(!element.hasEventListener(egret.TouchEvent.TOUCH_TAP)) {
if (!element.hasEventListener(egret.TouchEvent.TOUCH_TAP)) {
element.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
if(
if (
(levelOrder > (getHomeData().levels.length + 1) && levelOrder > 1)
|| (levelOrder > window['last_level'])
) {
......@@ -302,7 +315,7 @@ export default class MapScene extends Scene {
}
// 当前关卡的水花动效
if(homeData.levels.length < window['total_level']) {
if (homeData.levels.length < window['total_level']) {
const targetIcon = MapScene.iconHash[target];
const light = RES.getRes('lightani_png');
......@@ -315,7 +328,7 @@ export default class MapScene extends Scene {
pic.anchorOffsetY = 61;
// pic.x = 50 - 2;
// pic.y = 37 + 10;
egret.Tween.get(pic, {loop: true}).to({scaleX: 2, scaleY: 2, alpha: 0}, 1000).wait(1000);
egret.Tween.get(pic, { loop: true }).to({ scaleX: 2, scaleY: 2, alpha: 0 }, 1000).wait(1000);
this['pic'] = pic;
}
......@@ -325,8 +338,8 @@ export default class MapScene extends Scene {
this.showLog();
this.updateBox();
if(data.level) {
if(homeData.remainEnargy == 0)
if (data.level) {
if (homeData.remainEnargy == 0)
PanelCtrl.instance.show('bloodPanel')
else
......@@ -334,8 +347,8 @@ export default class MapScene extends Scene {
}
this.stage.once(egret.TouchEvent.TOUCH_TAP, () => {
if(!MapScene['firstPlayBgTag']) {
if(getBgOn()) {
if (!MapScene['firstPlayBgTag']) {
if (getBgOn()) {
playBg();
}
MapScene['firstPlayBgTag'] = true;
......@@ -343,7 +356,7 @@ export default class MapScene extends Scene {
}, this);
let lastOrder = homeData.levels.length + 1;
if(homeData.levels.length >= window['total_level'])
if (homeData.levels.length >= window['total_level'])
lastOrder = window['total_level'];
this.scroll.viewport.scrollV = this.getScrollV(lastOrder, this.stage.stageHeight);
// console.warn(this.getScrollV(lastOrder, this.stage.stageHeight));
......@@ -354,7 +367,7 @@ export default class MapScene extends Scene {
Promise.all([
RES.getResAsync(`${key}_json`),
RES.getResAsync(`${key}_png`)]);
} catch(error) {
} catch (error) {
}
RES.getResAsync('candydis0_json');
......@@ -388,7 +401,7 @@ export default class MapScene extends Scene {
loadSvga(getResPath() + 'resource/assets/svgas/monster.svga');
// loadSvga(getResPath() + 'resource/assets/svgas/fireworks.svga');
if(!window['development']) {
if (!window['development']) {
RES.getResAsync(`inviterulepanel_json`);
}
}, 5 * 1000);
......@@ -399,7 +412,7 @@ export default class MapScene extends Scene {
}
onAllPanelHide = () => {
if(!localStorage.getItem('activityguide')) {
if (!localStorage.getItem('activityguide')) {
// NetManager.ins.hbRainBaseInfo((success, res) => {
// if(!success) {
// if(res.code == "600054" || res.code == "600055") {
......@@ -423,21 +436,21 @@ export default class MapScene extends Scene {
const y1 = this.stage.stageHeight + this.scroll.viewport.scrollV - offset;
// console.log(y0, y1);
let count = 0;
for(const key in MapScene.iconHash) {
for (const key in MapScene.iconHash) {
const icon = MapScene.iconHash[key];
if(icon['visibleY'] >= y0 && icon['visibleY'] <= y1) {
if (icon['visibleY'] >= y0 && icon['visibleY'] <= y1) {
icon.show();
} else if(icon.parent) {
} else if (icon.parent) {
icon.hide();
}
if(icon.parent)
if (icon.parent)
count++;
}
if(this._avatarsCache) {
if (this._avatarsCache) {
this._avatarsCache.forEach((item) => {
if(item.parent) item.parent.addChild(item);
if (item.parent) item.parent.addChild(item);
});
}
......@@ -458,7 +471,7 @@ export default class MapScene extends Scene {
}
private removeIcon() {
for(let k in this.icons) {
for (let k in this.icons) {
this.icons[k].destory();
}
this.icons = {};
......@@ -471,20 +484,20 @@ export default class MapScene extends Scene {
this['nameTxt'].text = '';
// NetManager.ins.hc_userInfo(() => {
this['avatar'].visible = true;
const {data} = DataManager.ins.getData('hc_userInfo');
if(data)
const { data } = DataManager.ins.getData('hc_userInfo');
if (data)
this['avatar'].source = data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
else
this['avatar'].source = "http://yun.duiba.com.cn/db_games/default_avatar.png";
if(data && data.nickname)
if (data && data.nickname)
this['nameTxt'].text = getNick(data.nickname);
// });
}
updateSign() {
const {signInfoVO} = DataManager.ins.getData('getSignInfo');
if(signInfoVO && signInfoVO.continueDay < 7) { //表示明天还可以签到
const { signInfoVO } = DataManager.ins.getData('getSignInfo');
if (signInfoVO && signInfoVO.continueDay < 7) { //表示明天还可以签到
this['sign_s1'].visible = signInfoVO.todaySigned == 0;
this['sign_s2'].visible = !this['sign_s1'].visible;
} else {
......@@ -495,17 +508,17 @@ export default class MapScene extends Scene {
// 更新广告数据
updateAdData() {
const hc_advert = DataManager.ins.getData('hc_advert').data || {};
let {mapAdvert} = hc_advert;
if(mapAdvert == null)
mapAdvert = {enable: false, advertList: []}
let { mapAdvert } = hc_advert;
if (mapAdvert == null)
mapAdvert = { enable: false, advertList: [] }
this['adBtn'].visible = mapAdvert.enable;
if(this['adBtn'].visible) {
if (this['adBtn'].visible) {
NetManager.ins.showLog(getlogItem(32));
}
if(mapAdvert.enable) {
if (mapAdvert.enable) {
let result;
result = mapAdvert.advertList;
if(Array.isArray(mapAdvert.advertList)) {
if (Array.isArray(mapAdvert.advertList)) {
const index = Math.floor(mapAdvert.advertList.length * Math.random());
result = mapAdvert.advertList[index];
}
......@@ -523,12 +536,12 @@ export default class MapScene extends Scene {
this.removeIcon();
this.actIcon.destory();
if(this['pic']){
if (this['pic']) {
egret.Tween.removeTweens(this['pic']);
(this['pic'].parent as egret.DisplayObjectContainer).removeChild(this['pic']);
}
if(this.inviteTimer) {
if (this.inviteTimer) {
this.inviteTimer.stop();
this.inviteTimer.removeEventListener(egret.TimerEvent.TIMER, this.inviteCutTimer, this);
}
......@@ -536,19 +549,19 @@ export default class MapScene extends Scene {
this.scroll.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
this._avatarsCache.forEach((item) => {
if(item.parent) item.parent.removeChild(item);
if (item.parent) item.parent.removeChild(item);
});
this._avatarsCache = null;
}
getScrollV(lastOrder, stageHeight) {
// 如果是顶部
if(lastOrder <= MapTopPart.LEVEL_NUMS) {
if (lastOrder <= MapTopPart.LEVEL_NUMS) {
return this.getScrollV1(lastOrder, stageHeight);
}
// 如果是尾部
if(lastOrder > window['total_level'] - MapBottomPart.LEVEL_NUMS) {
if (lastOrder > window['total_level'] - MapBottomPart.LEVEL_NUMS) {
return this.getScrollV2(lastOrder, stageHeight);
}
......@@ -561,7 +574,7 @@ export default class MapScene extends Scene {
const ylist = [4, 55, 160, 315, 431, 529, 594, 714, 820, 900, 970, 1098, 1164, 1245, 1380, 1493, 1548, 1611, 1734, 1882, 2023, 2180];
const y0 = this._data.top.height;//顶部的高度
let a0 = (lastOrder - MapTopPart.LEVEL_NUMS) % MapRpeatPart.LEVEL_NUMS; //减去7后的order 8-7 = 1
if(a0 == 0) a0 = MapRpeatPart.LEVEL_NUMS;
if (a0 == 0) a0 = MapRpeatPart.LEVEL_NUMS;
const a1 = Math.ceil((lastOrder - MapTopPart.LEVEL_NUMS) / MapRpeatPart.LEVEL_NUMS) - 1;//当前地图repeat的顺序
const y1 = ylist[a0 - 1];
const y2 = y0 + y1 + a1 * this._data.list[0].height;
......@@ -572,7 +585,7 @@ export default class MapScene extends Scene {
getScrollV1(lastOrder, stageHeight) {
const ylist = [587, 691, 749, 849, 932, 1025, 1085, 1161].map(i => i + 40);
const targetY = ylist[lastOrder - 1] - stageHeight / 2;
if(targetY <= 0) return 0;
if (targetY <= 0) return 0;
return targetY;
}
......@@ -585,7 +598,7 @@ export default class MapScene extends Scene {
+ this._data.bottom.height;
const ylist = [62, 176, 314].map(i => i + 40);
const targetY = y0 + ylist[lastOrder - 1] - stageHeight / 2;
if(targetY >= (totalHeight - stageHeight)) return totalHeight - stageHeight;
if (targetY >= (totalHeight - stageHeight)) return totalHeight - stageHeight;
return targetY;
}
......@@ -634,7 +647,7 @@ export default class MapScene extends Scene {
updateBox() {
const homeData = getHomeData();
if(homeData.canReceiveTreasureBoxNum <= 0)
if (homeData.canReceiveTreasureBoxNum <= 0)
setGray(this['box']);
this['boxiconWrapper'].visible = homeData.canReceiveTreasureBoxNum > 0;
this['totalStarTxt'].text = `${homeData.totalStars}/${homeData.nextRangeStarsNum}`;
......@@ -659,7 +672,7 @@ export default class MapScene extends Scene {
parent.addChild(avatar);
avatar.x = item.x + 6;
avatar.y = item.y - avatar.height + 10;
if(!MapScene.starHash[level].visible) {
if (!MapScene.starHash[level].visible) {
avatar.y = item.y - avatar.height;
}
this._avatarsCache.push(avatar);
......@@ -669,11 +682,11 @@ export default class MapScene extends Scene {
updateFriends() {
NetManager.ins.hc_mapRank(() => {
const hc_mapRank = DataManager.ins.getData('hc_mapRank').data;
if(!hc_mapRank) return;
const {data} = DataManager.ins.getData('hc_userInfo');
if (!hc_mapRank) return;
const { data } = DataManager.ins.getData('hc_userInfo');
hc_mapRank.forEach((ele) => {
if(ele.levelNum == getHomeData().levels.length + 1) {
if(data == null)
if (ele.levelNum == getHomeData().levels.length + 1) {
if (data == null)
ele.rank[0].avatar = "http://yun.duiba.com.cn/db_games/default_avatar.png";
else
ele.rank[0].avatar = data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
......@@ -688,24 +701,24 @@ export default class MapScene extends Scene {
this['goldTxt'].text = `${homeData.wealth}`;
for(let j = 1; j < window['total_level']; j++) {
for (let j = 1; j < window['total_level']; j++) {
this.disableIcon(j + 1);
}
for(let i = 0; i < homeData.levels.length; i++) {
for (let i = 0; i < homeData.levels.length; i++) {
const level = homeData.levels[i];
const star = MapScene.starHash[i + 1];
if(level) {
if (level) {
star.setStar(level.stars);
this.enableIcon(level.levelNum);
} else {
this.disableIcon(level.levelNum);
}
}
if(homeData.levels.length == 0) {
if (homeData.levels.length == 0) {
const star = MapScene.starHash[1];
star.setStar(0);
this.enableIcon(1);
} else if(homeData.levels.length == window['last_level']) {
} else if (homeData.levels.length == window['last_level']) {
} else {
const star = MapScene.starHash[homeData.levels.length + 1];
......@@ -719,11 +732,11 @@ export default class MapScene extends Scene {
updateTimerView() {
//更新倒计时
if(this._countDown == null) {
if (this._countDown == null) {
this._countDown = new CountDown(this['countdown']);
}
const data = getHomeData();
if(data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
if (data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
this._countDown.stop();
this['fullTxt'].visible = true;
......@@ -753,28 +766,28 @@ export default class MapScene extends Scene {
onTap_inviteBtn() {
NetManager.ins.clickLog(getlogItem(33));
NetManager.ins.getInviteInfo((success, res) => {
if(!success || !res.data) {
if (!success || !res.data) {
return;
}
const flag = res.data.completeFlag;
switch(true) {
switch (true) {
case (flag == 0): // 未完成
this.loadsvga(res);
break;
case (flag == 1): // 完成未开奖 待领奖 请求领奖接口
try {
if(window['getRST']) window['getRST']();
} catch(error) {
if (window['getRST']) window['getRST']();
} catch (error) {
console.warn(error)
}
NetManager.ins.acceptInvitationPrize((success, res) => {
if(!success) {
if (!success) {
showToast("哎呀,萌狮开小差啦!\n过会再来看吧!");
GDispatcher.dispatchEvent("getInviteInfo");
return;
}
// console.log(res.data);
if(res.data.completeFlag == 3) {
if (res.data.completeFlag == 3) {
showToast("哎呀,萌狮开小差啦!\n过会再来看吧!");
GDispatcher.dispatchEvent("getInviteInfo");
} else {
......@@ -789,7 +802,7 @@ export default class MapScene extends Scene {
case (flag == 4): // 可以开启下一次发任务
NetManager.ins.acceptInvitationInfo((success, res) => {
if(!success) {
if (!success) {
return;
}
this.loadsvga(res);
......@@ -805,7 +818,7 @@ export default class MapScene extends Scene {
}
loadsvga(res) {
if(MapScene['svga']) {
if (MapScene['svga']) {
const mv = MapScene['svga']
mv.gotoAndStop(1);
res.data.svga = mv;
......@@ -830,21 +843,21 @@ export default class MapScene extends Scene {
*/
getInviteInfo() {
const hc_advert = DataManager.ins.getData('hc_advert').data || {};
const {mapAdvert} = hc_advert;
const { mapAdvert } = hc_advert;
// tslint:disable-next-line: cyclomatic-complexity
NetManager.ins.getInviteInfo((success, res) => {
if(!success || !res.data) {
if (!success || !res.data) {
return;
}
const flag = res.data.completeFlag;
if(this.inviteTimer) {
if (this.inviteTimer) {
this.inviteTimer.stop();
}
switch(true) {
switch (true) {
case (flag == 0): // 未完成 显示倒计时
this["inviteGroup"].visible = true;
this["inviteGroup"].touchEnabled = true;
if(!mapAdvert || mapAdvert.enable == false) {
if (!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -861,7 +874,7 @@ export default class MapScene extends Scene {
NetManager.ins.showLog(getlogItem(33));
this["inviteGroup"].visible = true;
this["inviteGroup"].touchEnabled = true;
if(!mapAdvert || mapAdvert.enable == false) {
if (!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -873,7 +886,7 @@ export default class MapScene extends Scene {
case (flag == 3): // 领奖失败 无角标
this["inviteGroup"].visible = true;
this["inviteGroup"].touchEnabled = true;
if(!mapAdvert || mapAdvert.enable == false) {
if (!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -884,7 +897,7 @@ export default class MapScene extends Scene {
case (flag == 4): // 可以开启下一次发任务 显示立即到账
this["inviteGroup"].visible = true;
this["inviteGroup"].touchEnabled = true;
if(!mapAdvert || mapAdvert.enable == false) {
if (!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -896,7 +909,7 @@ export default class MapScene extends Scene {
case (flag == 5): // 等待开启下一次发任务 无角标
this["inviteGroup"].visible = true;
this["inviteGroup"].touchEnabled = true;
if(!mapAdvert || mapAdvert.enable == false) {
if (!mapAdvert || mapAdvert.enable == false) {
this['activitys'].y = 458;
this['guideInner'].y = 185;
}
......@@ -908,7 +921,7 @@ export default class MapScene extends Scene {
this["inviteGroup"].visible = false;
this["inviteGroup"].touchEnabled = false;
this['adBtn'].y = 323.76;
if(mapAdvert && mapAdvert.enable) {
if (mapAdvert && mapAdvert.enable) {
this['guideInner'].y = 185;
this['activitys'].y = 458;
} else {
......@@ -925,7 +938,7 @@ export default class MapScene extends Scene {
// 倒计时
private inviteCutTimer() {
const timer = this.convertTime(this.cutTime -= 1000);
if(timer.hour === "00"
if (timer.hour === "00"
&& timer.min === "00"
&& timer.sec === "00") {
this.inviteTimer.stop();
......@@ -1018,9 +1031,9 @@ export default class MapScene extends Scene {
async onTap_boxLayer() {
NetManager.ins.clickLog(getlogItem(1));
const data = getHomeData();
if(data.canReceiveTreasureBoxNum > 0) {
if (data.canReceiveTreasureBoxNum > 0) {
this['boxLayer'].visible = true;
if(!this._mc)
if (!this._mc)
this._mc = await loadSvga(getResPath() + 'resource/assets/svgas/box.svga', this['boxani']);
this._mc.stop();
this._mc.gotoAndStop(1);
......@@ -1032,18 +1045,18 @@ export default class MapScene extends Scene {
await wait(50);
this._mc.visible = true;
const a = 100, b = 10;
egret.Tween.get(this._mc, {loop: true}).set({rotation: b})
.to({rotation: -b}, a).to({rotation: b}, a)
.to({rotation: -b}, a).to({rotation: b}, a)
.to({rotation: -b}, a).to({rotation: b}, a)
.to({rotation: 0}, a / 2)
egret.Tween.get(this._mc, { loop: true }).set({ rotation: b })
.to({ rotation: -b }, a).to({ rotation: b }, a)
.to({ rotation: -b }, a).to({ rotation: b }, a)
.to({ rotation: -b }, a).to({ rotation: b }, a)
.to({ rotation: 0 }, a / 2)
.wait(1000);
}
}
async playAni() {
if(this._mc) {
if (this._mc) {
egret.Tween.removeTweens(this._mc);
this._mc.gotoAndPlay(1, true);
await this.onPlaySTOP();
......@@ -1054,7 +1067,7 @@ export default class MapScene extends Scene {
async onPlaySTOP() {
return new Promise((r) => {
const func = () => {
if(this._mc.currentFrame >= 100) {
if (this._mc.currentFrame >= 100) {
this._mc.removeEventListener(egret.Event.ENTER_FRAME, func, this);
this._mc.stop();
r();
......@@ -1073,14 +1086,14 @@ export default class MapScene extends Scene {
this['boxani'].touchChildren = false;
await this.playAni();
try {
if(window['getRST']) window['getRST']();
} catch(error) {
if (window['getRST']) window['getRST']();
} catch (error) {
console.warn(error)
}
NetManager.ins.hc_openTreasureBox((success) => {
this['boxani'].touchEnabled = true;
this['boxani'].touchChildren = true;
if(success) {
if (success) {
const hc_openTreasureBox = DataManager.ins.getData('hc_openTreasureBox');
const boxdata = hc_openTreasureBox.data;
const homeData = DataManager.ins.getData('hc_home').data;
......@@ -1090,7 +1103,7 @@ export default class MapScene extends Scene {
homeData.isGetAllTreasureBox = boxdata.isGetAllTreasureBox;
this.updateBox();
if(hc_openTreasureBox.success && boxdata && boxdata.option) {
if (hc_openTreasureBox.success && boxdata && boxdata.option) {
PanelCtrl.instance.show('box');
} else {
......@@ -1124,7 +1137,7 @@ export default class MapScene extends Scene {
onTap_bloodBtn() {
NetManager.ins.clickLog(getlogItem(2));
if(getHomeData().remainEnargy > 0)
if (getHomeData().remainEnargy > 0)
PanelCtrl.instance.show('bloodPanel');
else
PanelCtrl.instance.show('blood2Panel');
......@@ -1137,14 +1150,14 @@ export default class MapScene extends Scene {
showRedBagAni() {
const hash = MapScene.iconHash;
const keys = [];
for(const key in hash) {
for (const key in hash) {
const ele = hash[key];
if(ele.parent)
if (ele.parent)
keys.push(key);
}
const p0 = new egret.Point(750 / 2, 750 / 1.5);
const pics = [];
for(const key of keys) {
for (const key of keys) {
const icon = MapScene.iconHash[key] as egret.DisplayObject;
const p = (icon.localToGlobal(0, 0));
const pic = createRedBagIcon(this);
......@@ -1161,7 +1174,7 @@ export default class MapScene extends Scene {
pic.visible = true;
const p2 = pic['__p2__'] as egret.Point;
let dir = 100;
if(p2.y < p0.y)
if (p2.y < p0.y)
dir *= -1;
const p1x = (p0.x + p2.x) / 2 + dir;
const p1y = (p0.y + p2.y) / 2;
......@@ -1171,16 +1184,16 @@ export default class MapScene extends Scene {
this.addChild(mc);
const x0 = pic['__icon__'].x;
const y0 = pic['__icon__'].y;
egret.Tween.get(pic['__icon__']).to({y: y0 + 10}, 100).to({y: y0}, 100);
egret.Tween.get(pic['__icon__']).to({ y: y0 + 10 }, 100).to({ y: y0 }, 100);
const light = new egret.Bitmap(RES.getRes('maplight2_png'));
light.anchorOffsetX = 75;
light.anchorOffsetY = 49;
light.x = 50;
light.y = 40 + 5;
pic['__icon__'].addChildAt(light, 0);
egret.Tween.get(light).to({scaleX: 1.5, scaleY: 1.5,}, 200).call(() => {
egret.Tween.get(light).to({ scaleX: 1.5, scaleY: 1.5, }, 200).call(() => {
pic['__icon__'].removeChild(light);
if(index == pics.length - 1) {
if (index == pics.length - 1) {
showToast('红包隐藏在任意关卡中,快去找他们吧~');
}
});
......@@ -1190,9 +1203,9 @@ export default class MapScene extends Scene {
}
}
export const getNick = (nickname, max = 4) => {
if(!nickname) return nickname;
if (!nickname) return nickname;
if(nickname.length > max)
if (nickname.length > max)
return nickname.slice(0, max) + '...';
return nickname;
};
\ No newline at end of file
......@@ -13,6 +13,7 @@ import { showShare } from "../shareCtrl";
import { gotoNextLevel } from "./gotoNextLevel";
import BloodPanel2 from "./BloodPanel2";
import PanelCtrl from "../../libs/new_wx/ctrls/panelCtrl";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
export default class BloodPanel extends Panel {
start(data) {
......@@ -36,17 +37,17 @@ export default class BloodPanel extends Panel {
private _countDown: CountDown;
private updateData() {
if(this._countDown == null) {
if (this._countDown == null) {
this._countDown = new CountDown(this['countdownTxt'], (str) => `距离下一次体力补给时间:${str}`);
}
const homeData = getHomeData();
this['bloodTxt'].text = `你的可用体力值为:${homeData.remainEnargy}`;
const data = getHomeData();
this['invitTxt'].text = `(已领${data.askForEnergy}/${BloodPanel.MAX})`;
if(data.askForEnergy >= BloodPanel.MAX) {
if (data.askForEnergy >= BloodPanel.MAX) {
this['inviteBtn2'].visible = true;
}
if(data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
if (data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
this['bloodTxt'].text = `你的可用体力值为:${homeData.remainEnargy}`;
this._countDown.stop();
this['countdownTxt'].visible = false;
......@@ -73,7 +74,7 @@ export default class BloodPanel extends Panel {
this['buyBtn'].enabled = false;
NetManager.ins.hc_exchange((success, res) => {
this['buyBtn'].enabled = true;
if(success) {
if (success) {
showToast('兑换成功');
NetManager.ins.hc_home(() => {
this.updateData();
......@@ -81,31 +82,58 @@ export default class BloodPanel extends Panel {
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
} else {
if(res.code == '600005') {
if (res.code == '600005') {
showToast('体力已满,快去闯关吧');
} else {
PanelCtrl.instance.show('shopTip', {from: 'bloodPanel', data: null});
PanelCtrl.instance.show('shopTip', { from: 'bloodPanel', data: null });
}
}
}, 1);
}
onTapInvite() {
// onTapInvite() {
if(iswx()) {
getShareUrl(this.stage);
} else
showShare(1);
// if(iswx()) {
// getShareUrl(this.stage);
// } else
// showShare(1);
// NetManager.ins.clickLog(getlogItem(4));
// const data = getHomeData();
// if(data.askForEnergy >= BloodPanel.MAX) {
// showToast('对不起,索要体力的机会已经用完了~');
// return;
// }
// this['inviteBtn'].enabled = false;
// NetManager.ins.hc_askForEnergy((success) => {
// this['inviteBtn'].enabled = true;
// if(success) {
// }
// NetManager.ins.hc_home(() => {
// this.updateData();
// updateMainTimer();
// SceneCtrl.instance.updateScene();
// }, window['collectRuleId']);
// wait(2000).then(() => {
// showToast('分享成功~');
// });
// })
// }
//0224修改
onTapInvite() {
NetManager.ins.clickLog(getlogItem(4));
const data = getHomeData();
if(data.askForEnergy >= BloodPanel.MAX) {
if (iswx()) {
//微信流程不变
getShareUrl(this.stage);
if (data.askForEnergy >= BloodPanel.MAX) {
showToast('对不起,索要体力的机会已经用完了~');
return;
}
this['inviteBtn'].enabled = false;
NetManager.ins.hc_askForEnergy((success) => {
this['inviteBtn'].enabled = true;
if(success) {
if (success) {
}
NetManager.ins.hc_home(() => {
this.updateData();
......@@ -116,7 +144,29 @@ export default class BloodPanel extends Panel {
showToast('分享成功~');
});
})
} else {
showShareCodePanel(CodeChannels.AddBlood, null, () => {
if (data.askForEnergy >= BloodPanel.MAX) {
wait(2000).then(() => {
showToast('对不起,索要体力的机会已经用完了~');
});
} else {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
this.updateData();
updateMainTimer();
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
wait(2000).then(() => {
showToast('分享成功~');
});
})
}
})
}
}
protected get closeBtns(): eui.Button[] {
return [this['closeBtn'], this['resumeBtn']]
......
......@@ -12,6 +12,7 @@ import CountDown from "../mapScene/CountDown";
import { showShare } from "../shareCtrl";
import BloodPanel from "./BloodPanel";
import PanelCtrl from "../../libs/new_wx/ctrls/panelCtrl";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
export default class BloodPanel2 extends Panel {
start(data) {
......@@ -31,17 +32,17 @@ export default class BloodPanel2 extends Panel {
private _countDown: CountDown;
private updateData() {
if(this._countDown == null) {
if (this._countDown == null) {
this._countDown = new CountDown(this['countdownTxt'], (str) => `距离下一次体力补给时间:${str}`);
}
const homeData = getHomeData();
this['bloodTxt'].text = `你的可用体力值为:${homeData.remainEnargy}`;
const data = getHomeData();
this['invitTxt'].text = `(已领${data.askForEnergy}/${BloodPanel.MAX})`;
if(data.askForEnergy >= BloodPanel.MAX) {
if (data.askForEnergy >= BloodPanel.MAX) {
this['inviteBtn2'].visible = true;
}
if(data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
if (data.remainEnargy >= BLOOD_NUMS_MAX) { //满了
this['bloodTxt'].text = `你的可用体力值为:${homeData.remainEnargy}`;
this._countDown.stop();
this['countdownTxt'].visible = false;
......@@ -68,7 +69,7 @@ export default class BloodPanel2 extends Panel {
this['buyBtn'].enabled = false;
NetManager.ins.hc_exchange((success, res) => {
this['buyBtn'].enabled = true;
if(success) {
if (success) {
showToast('兑换成功');
NetManager.ins.hc_home(() => {
this.updateData();
......@@ -77,31 +78,59 @@ export default class BloodPanel2 extends Panel {
}, window['collectRuleId']);
} else {
if(res.code == '600005') {
if (res.code == '600005') {
showToast('体力已满,快去闯关吧');
} else {
PanelCtrl.instance.show('shopTip', {from: 'blood2Panel', data: null});
PanelCtrl.instance.show('shopTip', { from: 'blood2Panel', data: null });
}
}
}, 1);
}
onTapInvite() {
// onTapInvite() {
if(iswx()) {
getShareUrl(this.stage);
} else
showShare(1);
// if(iswx()) {
// getShareUrl(this.stage);
// } else
// showShare(1);
// NetManager.ins.clickLog(getlogItem(4));
// const data = getHomeData();
// if(data.askForEnergy >= BloodPanel.MAX) {
// showToast('对不起,索要体力的机会已经用完了~');
// return;
// }
// this['inviteBtn'].enabled = false;
// NetManager.ins.hc_askForEnergy((success) => {
// this['inviteBtn'].enabled = true;
// if(success) {
// }
// NetManager.ins.hc_home(() => {
// this.updateData();
// updateMainTimer();
// SceneCtrl.instance.updateScene();
// }, window['collectRuleId']);
// wait(2000).then(() => {
// showToast('分享成功~');
// });
// })
// }
//0224修改
onTapInvite() {
NetManager.ins.clickLog(getlogItem(4));
const data = getHomeData();
if(data.askForEnergy >= BloodPanel.MAX) {
if (iswx()) {
getShareUrl(this.stage);
//原先微信流程不变
if (data.askForEnergy >= BloodPanel.MAX) {
showToast('对不起,索要体力的机会已经用完了~');
return;
}
this['inviteBtn'].enabled = false;
NetManager.ins.hc_askForEnergy((success) => {
this['inviteBtn'].enabled = true;
if(success) {
if (success) {
}
NetManager.ins.hc_home(() => {
......@@ -113,6 +142,26 @@ export default class BloodPanel2 extends Panel {
showToast('分享成功~');
});
})
} else {
showShareCodePanel(CodeChannels.AddBlood, null, () => {
if (data.askForEnergy >= BloodPanel.MAX) {
wait(2000).then(() => {
showToast('对不起,索要体力的机会已经用完了~');
});
} else {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
this.updateData();
updateMainTimer();
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
wait(2000).then(() => {
showToast('分享成功~');
});
})
}
})
}
}
protected get closeBtns(): eui.Button[] {
......
......@@ -7,6 +7,7 @@ import { showShare3 } from "../shareCtrl3";
import FriendItemRenderer from "./FriendItemRenderer";
import { getFriendShareUrl } from "../getFriendSharePic";
import { getlogItem } from "../Main";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
export default class FriendPanel extends Panel {
public list: eui.List;
......@@ -66,9 +67,9 @@ export default class FriendPanel extends Panel {
this['avatar'].source = this['avatar0'].source = data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
else
this['avatar'].source = this['avatar0'].source = "http://yun.duiba.com.cn/db_games/default_avatar.png";
if (data&&data.nickname)
if (data && data.nickname)
this['nameTxt'].text = getNick(data.nickname, 10);
if (data&&data.nickname)
if (data && data.nickname)
this['nameTxt0'].text = getNick(data.nickname, 10);
});
}
......@@ -92,7 +93,8 @@ export default class FriendPanel extends Panel {
if (iswx()) {
getFriendShareUrl(this.stage);
} else
showShare3();
// showShare3();
showShareCodePanel(CodeChannels.RankPlay);
}
protected get closeBtns(): eui.Button[] { return [this['closeBtn']] }
......
......@@ -7,6 +7,7 @@ import Utils from "../Utils";
import InviteRulePanel from "./InviteRulePanel";
import wait from "../../libs/new_tc/wait";
import { getlogItem } from "../Main";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
export default class InvitePanel extends Panel {
public prizeImg: eui.Image;
......@@ -118,13 +119,15 @@ export default class InvitePanel extends Panel {
CFG.wxShareLink = window['h5URL'] + "&shareCode=" + shareCode; // 分享链接
CFG.wxShareTitle = '狮狮连萌超好玩~我已经玩到第一了!';
CFG.wxShareDesc = '我在萌狮消消乐等你来挑战哦';
CFG.wxShareImg="http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg";
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);
// window["inviteShare"](shareCode);
//0224修改,去掉原先邀请逻辑,新增口令逻辑
showShareCodePanel(CodeChannels.InvitePrize, shareCode)
}
});
}
......@@ -189,7 +192,7 @@ export default class InvitePanel extends Panel {
destroy() {
super.destroy();
if(this.timer){
if (this.timer) {
this.timer.stop();
this.timer.removeEventListener(egret.TimerEvent.TIMER, this.cutTimer, this);
}
......
......@@ -7,6 +7,7 @@ import ScratchRulePanel from "./ScratchRulePanel";
import CutTimer from "../CutTimer";
import { getlogItem } from "../Main";
import { HtmlTextParser } from "../../libs/new_wx/HtmlTextParser";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
export default class ScratchPanel extends Panel {
private cutTimer: CutTimer;
......@@ -258,7 +259,9 @@ class ScratchItem extends eui.ItemRenderer {
window["invokeWX"]();
} else {//端内
this.data.wxShareTip.visible = false;
window["scratchShare"](code);
// window["scratchShare"](code);
//0224修改,去掉原先邀请逻辑,新增口令逻辑
showShareCodePanel(CodeChannels.InvitePrize, code)
}
}, this.data.scratchTaskId);
}, this);
......
......@@ -5,6 +5,8 @@ import { getlogItem } from "../Main";
import { showToast } from "../../libs/new_wx/ctrls/toastCtrl";
import ComponentBase from "../../libs/new_wx/components/ComponentBase";
import layers from "../../libs/new_wx/views/layers";
import SceneCtrl from "../../libs/new_wx/ctrls/sceneCtrl";
import wait from "../../libs/new_tc/wait";
export enum CodeChannels {
/**
......@@ -36,7 +38,11 @@ const panelMsg = {
"2": "快去邀请好友帮你刮卡",
"3": "快去邀请好友闯关赢现金"
}
interface ShareData {
channel: CodeChannels,
shareCode?: string,//0224期加体力和排行榜分享好友没有分享码
addFun: Function,//点击立即前往的额外操作
}
class ShareCodePanel extends ComponentBase {
public closeBtn: eui.Button;
......@@ -52,15 +58,12 @@ class ShareCodePanel extends ComponentBase {
* 0表示微信,1表示朋友圈
*/
private mark: 0 | 1
data: {
channel: CodeChannels,
shareCode?: string,
}
data: ShareData
/**
* 口令
*/
private code: string
setData(data) {
setData(data: ShareData) {
this.data = data;
//显示提示文案
this.msg.text = panelMsg[this.data.channel];
......@@ -70,11 +73,7 @@ class ShareCodePanel extends ComponentBase {
super.start();
this.height = this.stage.stageHeight;
}
//不再关闭
public onTouchTap_closeBtn() {
// super.onTouchTap_closeBtn();
this.panelGroup.visible = false;
}
initEvents() {
super.initEvents();
......@@ -82,6 +81,7 @@ class ShareCodePanel extends ComponentBase {
this.wxpyq.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchWxpyqBtn, this);
this.goBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchGoBtn, this);
this.clickBg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchClickBg, this);
this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchCloseBtn, this);
}
onTouchWxBtn() {
......@@ -102,13 +102,16 @@ class ShareCodePanel extends ComponentBase {
linkWxpyq();
break;
}
//还需要根据channel加体力接口
this.data.addFun && this.data.addFun();
}
onTouchClickBg() {
layers.shareLayer.visible = false;
//关闭后要置null
//关闭后要置null,因为不同渠道进来要获取不同的code
this.code = null
}
onTouchCloseBtn() {
this.panelGroup.visible = false;
}
private codeOpr() {
//如果是开发中,获取不到口令就用假的
......@@ -153,6 +156,7 @@ class ShareCodePanel extends ComponentBase {
this.wxpyq.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchWxpyqBtn, this);
this.goBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchGoBtn, this);
this.clickBg.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchClickBg, this);
this.closeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchCloseBtn, this);
}
get skinKey() {
......@@ -169,12 +173,12 @@ const initShare = () => {
share.start();
_share = share;
};
export const showShareCodePanel = (data: { channel: CodeChannels, shareCode?: string, }) => {
export const showShareCodePanel = (channel: CodeChannels, shareCode?: string, addFun?: Function) => {
if (!inited) {
initShare();
inited = true;
}
_share.setData(data);
_share.setData({ channel, shareCode, addFun });
layers.shareLayer.visible = true;
}
......
......@@ -20,6 +20,7 @@ import { addRankFriendList } from "../mapScene/RankFriendList";
import { addAdComp } from "./BoxPanel";
import { getChapterData } from "../something/chapters/getChapter";
import { getlogItem } from "../Main";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
export default class StartPanel extends Panel {
static currlevel;
......@@ -38,7 +39,7 @@ export default class StartPanel extends Panel {
this['price4'].text = `-${window['price4']}元宝`;
const homedata = getHomeData();
if(data > homedata.levels.length) {
if (data > homedata.levels.length) {
addAdComp(84, 901, this, 29);
NetManager.ins.showLog(getlogItem(29));
} else
......@@ -51,7 +52,7 @@ export default class StartPanel extends Panel {
this['targetGroup'].visible = false;
this['scoreGroup'].visible = false;
const levelType = getChapterData(mapDataIndex).passTarget.type;
if(levelType == PassType.ELEMENT_TARGET) {
if (levelType == PassType.ELEMENT_TARGET) {
this['targetGroup'].visible = true;
// this['targetTxt'].text = '在规定步数内\n消除足够数量目标';
......@@ -59,9 +60,9 @@ export default class StartPanel extends Panel {
const ac = new eui.ArrayCollection(getChapterData(mapDataIndex).passTarget.elements);
this.list.dataProvider = ac;
const elements = getChapterData(mapDataIndex).passTarget.elements;
if(elements.length == 1 && elements[0].type == ElementType.LOLLIPOP)
if (elements.length == 1 && elements[0].type == ElementType.LOLLIPOP)
this['tips'].text = '在指定步数内将目标元素移至最底部';
} else if(levelType == PassType.SCORE_TARGET) {
} else if (levelType == PassType.SCORE_TARGET) {
this['scoreGroup'].visible = true;
this['targetScoreTxt'].text = `${getChapterData(mapDataIndex).passTarget.score}`;
// this['targetTxt'].text = `在规定步数内\n分数达到${getChapterData(mapDataIndex).passTarget.score}分`;
......@@ -85,14 +86,36 @@ export default class StartPanel extends Panel {
onTap_startBtn() {
const homeData = getHomeData();
if(homeData.remainEnargy <= 0) {
if(homeData.askForEnergy) {
if (homeData.remainEnargy <= 0) {
if (homeData.askForEnergy) {
PanelCtrl.instance.show('blood2Panel');
} else {
if(iswx()) {
// if(iswx()) {
// getShareUrl(this.stage);
// } else
// showShare(1);
// NetManager.ins.hc_askForEnergy((success) => {
// NetManager.ins.hc_home(() => {
// SceneCtrl.instance.updateScene();
// }, window['collectRuleId']);
// wait(2000).then(() => {
// showToast('分享成功~');
// });
// })
//0224修改,微信环境不变
if (iswx()) {
getShareUrl(this.stage);
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
wait(2000).then(() => {
showToast('分享成功~');
});
})
} else
showShare(1);
// showShare(1);
showShareCodePanel(CodeChannels.AddBlood, null, () => {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
SceneCtrl.instance.updateScene();
......@@ -101,6 +124,7 @@ export default class StartPanel extends Panel {
showToast('分享成功~');
});
})
});
}
return;
}
......@@ -121,7 +145,7 @@ export default class StartPanel extends Panel {
wait(5000).then(() => {
updateMainTimerAfterGetData();
});
if(success) {
if (success) {
// Loading.instace.show();
this.hidePanel();
try {
......@@ -129,12 +153,12 @@ export default class StartPanel extends Panel {
await Promise.all([
RES.getResAsync(`${key}_json`),
RES.getResAsync(`${key}_png`)]);
} catch(error) {
} catch (error) {
}
// Loading.instace.hide();
SceneCtrl.instance.change(ModuleTypes.MAIN_SCENE, {chapter: this._level});
SceneCtrl.instance.change(ModuleTypes.MAIN_SCENE, { chapter: this._level });
StartPanel.currlevel = this._level
}
}, this._level);
......@@ -143,15 +167,15 @@ export default class StartPanel extends Panel {
}
onTap_buy1btn() {
PanelCtrl.instance.show('Buy1', {from: 'StartPanel', data: this._level});
PanelCtrl.instance.show('Buy1', { from: 'StartPanel', data: this._level });
}
onTap_buy2btn() {
PanelCtrl.instance.show('Buy2', {from: 'StartPanel', data: this._level});
PanelCtrl.instance.show('Buy2', { from: 'StartPanel', data: this._level });
}
onTap_buy3btn() {
PanelCtrl.instance.show('Buy3', {from: 'StartPanel', data: this._level});
PanelCtrl.instance.show('Buy3', { from: 'StartPanel', data: this._level });
}
get skinKey() {
......
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