Commit 99c9d4e4 authored by wjf's avatar wjf

l

parent 3879dfd7
......@@ -533,6 +533,8 @@ export default class MainBase extends eui.UILayer {
this.getBackReward(),
this.hcRedBoobBaseInfo(),
]);
//获取分享加体力的shareCode,不影响初始化场景,不进await
NetManager.ins.getUserShareCode(()=>{})
MapScene.adData = DataManager.ins.getData('hc_advert');
......
......@@ -60,8 +60,18 @@ export default class MapScene extends Scene {
//0224修改,取sceneCode,
const sceneCode = Utils.getRequestByKey('sceneCode')
if (sceneCode == CodeChannels.AddBlood) {//加体力的,0228到时会修改成助力,这里要加逻辑
if (window["test0228"]) {
if (window["test0228"]) {//测试助力,到时失败code再和后端对接
NetManager.ins.doHelpNew((s, res) => {
if (s) {
showToast("助力成功!")
}
else if (res) {
if (res.code == "0000") {
} else if (res.code == "00001") { }
} else {
showToast("助力失败")
}
}, code)
} else {
showToast("欢迎加入游戏,去闯关吧");
}
......
......@@ -14,6 +14,7 @@ import { gotoNextLevel } from "./gotoNextLevel";
import BloodPanel2 from "./BloodPanel2";
import PanelCtrl from "../../libs/new_wx/ctrls/panelCtrl";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
import { DataManager } from "../../libs/tw/manager/DataManager";
export default class BloodPanel extends Panel {
start(data) {
......@@ -145,24 +146,43 @@ export default class BloodPanel extends Panel {
});
})
} else {
showShareCodePanel(CodeChannels.AddBlood, null, () => {
if (data.askForEnergy >= BloodPanel.MAX) {
wait(2000).then(() => {
showToast('对不起,索要体力的机会已经用完了~');
});
if (window["test0228"]) {
//如果之前没获取到,就再发接口,几率很低
if (!DataManager.ins.getData("getUserShareCode")) {
this.touchEnabled = false
this.touchChildren = false
NetManager.ins.getUserShareCode((s, res) => {
this.touchEnabled = true
this.touchChildren = true
if (!s) {
showToast("获取分享信息失败,请重试")
} else {
showShareCodePanel(CodeChannels.AddBlood, res.data)
}
})
} else {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
this.updateData();
updateMainTimer();
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
showShareCodePanel(CodeChannels.AddBlood, DataManager.ins.getData("getUserShareCode").data);
}
} else {
showShareCodePanel(CodeChannels.AddBlood, null, () => {
if (data.askForEnergy >= BloodPanel.MAX) {
wait(2000).then(() => {
showToast('分享成功~');
showToast('对不起,索要体力的机会已经用完了~');
});
})
}
})
} else {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
this.updateData();
updateMainTimer();
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
wait(2000).then(() => {
showToast('分享成功~');
});
})
}
})
}
}
}
......
......@@ -13,6 +13,7 @@ import { showShare } from "../shareCtrl";
import BloodPanel from "./BloodPanel";
import PanelCtrl from "../../libs/new_wx/ctrls/panelCtrl";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
import { DataManager } from "../../libs/tw/manager/DataManager";
export default class BloodPanel2 extends Panel {
start(data) {
......@@ -143,24 +144,43 @@ export default class BloodPanel2 extends Panel {
});
})
} else {
showShareCodePanel(CodeChannels.AddBlood, null, () => {
if (data.askForEnergy >= BloodPanel.MAX) {
wait(2000).then(() => {
showToast('对不起,索要体力的机会已经用完了~');
});
if (window["test0228"]) {
//如果之前没获取到,就再发接口,几率很低
if (!DataManager.ins.getData("getUserShareCode")) {
this.touchEnabled = false
this.touchChildren = false
NetManager.ins.getUserShareCode((s, res) => {
this.touchEnabled = true
this.touchChildren = true
if (!s) {
showToast("获取分享信息失败,请重试")
} else {
showShareCodePanel(CodeChannels.AddBlood, res.data)
}
})
} else {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
this.updateData();
updateMainTimer();
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
showShareCodePanel(CodeChannels.AddBlood, DataManager.ins.getData("getUserShareCode").data);
}
} else {
showShareCodePanel(CodeChannels.AddBlood, null, () => {
if (data.askForEnergy >= BloodPanel.MAX) {
wait(2000).then(() => {
showToast('分享成功~');
showToast('对不起,索要体力的机会已经用完了~');
});
})
}
})
} else {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
this.updateData();
updateMainTimer();
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
wait(2000).then(() => {
showToast('分享成功~');
});
})
}
})
}
}
}
......
......@@ -111,7 +111,12 @@ export default class InvitePanel extends Panel {
}
for (let i = 0; i < this.data.invitationUser.length; i++) {
this.data.invitationUser[i]['callFun'] = () => {
NetManager.ins.getShareCode((success, res) => {
//加个防连点,这里影响功能了,要加
this.touchEnabled = false;
this.touchChildren = false;
NetManager.ins.getShareCode((success, res) => {//shareCode为啥不缓存,每次好像都一样吧,还有下面失败是否要给个toast
this.touchEnabled = true;
this.touchChildren = true;
if (!success) {
return;
}
......
......@@ -23,20 +23,20 @@ export default class ScratchPanel extends Panel {
setGtaphics(x, y) {
setTimeout(() => {
if(this.pIndex % 2 == 0) { // 双数
if (this.pIndex % 2 == 0) { // 双数
y -= 25;
if(y <= this["prizeImg"].y) {
if (y <= this["prizeImg"].y) {
this.pIndex++;
}
} else { // 单数
y += 25;
if(y >= (this["prizeImg"].y + this["prizeImg"].height)) {
if (y >= (this["prizeImg"].y + this["prizeImg"].height)) {
this.pIndex++;
}
}
x += 5;
this.myShape.graphics.lineTo(x, y);
if(x > this["prizeImg"].x + (+this.data.completePercent) / 100 * this["prizeImg"].width - 60) {
if (x > this["prizeImg"].x + (+this.data.completePercent) / 100 * this["prizeImg"].width - 60) {
return;
}
this.setGtaphics(x, y);
......@@ -77,8 +77,8 @@ export default class ScratchPanel extends Panel {
playBgAni() {
this['light1'].visible = this['light2'].visible = true;
const time = 7000;
egret.Tween.get(this['light1'], {loop: true}).to({rotation: 360}, time);
egret.Tween.get(this['light2'], {loop: true}).to({rotation: -360}, time);
egret.Tween.get(this['light1'], { loop: true }).to({ rotation: 360 }, time);
egret.Tween.get(this['light2'], { loop: true }).to({ rotation: -360 }, time);
}
showlog() {
......@@ -126,17 +126,17 @@ export default class ScratchPanel extends Panel {
this["prizeImg"].source = this.data.prizeImage;
if(!this.data.avatarList) {
if (!this.data.avatarList) {
this.data.avatarList = [];
}
// 添加邀请图标
let noAvatarNum = this.data.helpedCount - this.data.avatarList.length; // 没有头像的人数
let dNum = this.data.totalNeedCount - this.data.avatarList.length - noAvatarNum; // 没邀请的人数
for(let i = 0; i < noAvatarNum; i++) {
for (let i = 0; i < noAvatarNum; i++) {
this.data.avatarList.push("");
}
for(let i = 0; i < dNum; i++) {
for (let i = 0; i < dNum; i++) {
this.data.avatarList.push("scratch_invite_png");
}
// 添加假用户
......@@ -144,7 +144,7 @@ export default class ScratchPanel extends Panel {
// 创建渲染列表
let rendererList = [];
for(let i = 0; i < this.data.avatarList.length; i++) {
for (let i = 0; i < this.data.avatarList.length; i++) {
rendererList.push({
avatar: this.data.avatarList[i], // 传递头像
wxShareTip: this["wxShareTip"], // 传递shareGroup的引用
......@@ -160,12 +160,12 @@ export default class ScratchPanel extends Panel {
// 倒计时
this.cutTimer = new CutTimer(this["cutTimeLabel"], "将在<b>hh:mm:ss</b>失效", () => {
this.hidePanel();
GDispatcher.dispatchEvent("updateScratchTips");
}
this.hidePanel();
GDispatcher.dispatchEvent("updateScratchTips");
}
);
let cutTime = this.data.endTime - this.data.currentTime + 3000;
if(!this.cutTimer.start(cutTime)) {
if (!this.cutTimer.start(cutTime)) {
this.cutTimer.stop();
this.cutTimer.start(cutTime);
}
......@@ -176,18 +176,18 @@ export default class ScratchPanel extends Panel {
* @param progress 进度 0 - 100
*/
private setProgress(progress) {
if(progress > 100) {
if (progress > 100) {
progress = 100;
} else if(progress < 0) {
} else if (progress < 0) {
progress = 0;
}
this['numLabel'].textFlow = (new HtmlTextParser).parser(`共<b>${2 + this.data.helpedCount}</b>位好友帮你刮了<b>${progress.toFixed(2)}</b>%`) ;
this['numLabel'].textFlow = (new HtmlTextParser).parser(`共<b>${2 + this.data.helpedCount}</b>位好友帮你刮了<b>${progress.toFixed(2)}</b>%`);
this["progressLabel"].textFlow = (new HtmlTextParser).parser(`仅剩<b>${(100 - progress).toFixed(2)}</b>%`); // 进度条文字
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);
egret.Tween.get(this["progress"]).to({ width: _width }, _duration);
}
private setWXShareTip() {
......@@ -197,7 +197,7 @@ export default class ScratchPanel extends Panel {
}
private hongbaoEffect() {
egret.Tween.get(this["hongbao"]).to({scaleX: 0.8, scaleY: 0.8}, 200, egret.Ease.quadInOut).call(() => {
egret.Tween.get(this["hongbao"]).to({ scaleX: 0.8, scaleY: 0.8 }, 200, egret.Ease.quadInOut).call(() => {
egret.Tween.get(this["hongbao"]).to({
scaleX: 1,
scaleY: 1
......@@ -243,9 +243,14 @@ class ScratchItem extends eui.ItemRenderer {
let s = this.data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
this.img.source = this.data.avatar || "http://yun.duiba.com.cn/db_games/default_avatar.png";
this.img.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
//加个防连点,这里影响功能了,要加,但是这里没阻止整个场景的点击事件,再说了
this.touchEnabled = false;
this.touchChildren = false;
NetManager.ins.clickLog(getlogItem(50));
NetManager.ins.scratchGetShareCode((success, res) => {
if(!success) {
NetManager.ins.scratchGetShareCode((success, res) => {//shareCode为啥不缓存,每次好像都一样吧,还有下面失败是否要给个toast
this.touchEnabled = true;
this.touchChildren = true;
if (!success) {
return;
}
let shareCode = res.data; // 分享码
......@@ -254,14 +259,14 @@ class ScratchItem extends eui.ItemRenderer {
CFG.wxShareTitle = '萌狮消消消';
CFG.wxShareDesc = '超好玩的萌狮消消乐,快来和我一起玩吧~';
CFG.wxShareImg = "http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg";
if(iswx()) { //微信端
if (iswx()) { //微信端
this.data.wxShareTip.visible = true;
window["invokeWX"]();
} else {//端内
this.data.wxShareTip.visible = false;
// window["scratchShare"](code);
//0224修改,去掉原先邀请逻辑,新增口令逻辑
showShareCodePanel(CodeChannels.InvitePrize, code)
showShareCodePanel(CodeChannels.Scratch, code)
}
}, this.data.scratchTaskId);
}, this);
......
......@@ -41,7 +41,7 @@ const panelMsg = {
interface ShareData {
channel: CodeChannels,
shareCode?: string,//0224期加体力和排行榜分享好友没有分享码
addFun: Function,//点击立即前往的额外操作
addFun?: Function,//点击立即前往的额外操作
}
class ShareCodePanel extends ComponentBase {
......@@ -254,10 +254,18 @@ function linkWx() {
/**
* 唤起微信朋友圈
* 暂未实现
* 暂未实现,也跳微信
*/
function linkWxpyq() {
var locatUrl = "weixin://";
if (/ipad|iphone|mac/i.test(navigator.userAgent)) {
var ifr = document.createElement("iframe");
ifr.src = locatUrl;
ifr.style.display = "none";
document.body.appendChild(ifr);
} else {
window.location.href = locatUrl;
}
}
/**
......
......@@ -21,6 +21,7 @@ import { addAdComp } from "./BoxPanel";
import { getChapterData } from "../something/chapters/getChapter";
import { getlogItem } from "../Main";
import { showShareCodePanel, CodeChannels } from "./ShareCodePanel";
import { DataManager } from "../../libs/tw/manager/DataManager";
export default class StartPanel extends Panel {
static currlevel;
......@@ -114,17 +115,38 @@ export default class StartPanel extends Panel {
});
})
} else
// showShare(1);
showShareCodePanel(CodeChannels.AddBlood, null, () => {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
wait(2000).then(() => {
showToast('分享成功~');
});
})
});
// showShare(1);
{
if (window["test0228"]) {
//如果之前没获取到,就再发接口,几率很低
if (!DataManager.ins.getData("getUserShareCode")) {
this.touchEnabled = false
this.touchChildren = false
NetManager.ins.getUserShareCode((s, res) => {
this.touchEnabled = true
this.touchChildren = true
if (!s) {
showToast("获取分享信息失败,请重试")
} else {
showShareCodePanel(CodeChannels.AddBlood, res.data)
}
})
} else {
showShareCodePanel(CodeChannels.AddBlood, DataManager.ins.getData("getUserShareCode").data);
}
} else {
showShareCodePanel(CodeChannels.AddBlood, null, () => {
NetManager.ins.hc_askForEnergy((success) => {
NetManager.ins.hc_home(() => {
SceneCtrl.instance.updateScene();
}, window['collectRuleId']);
wait(2000).then(() => {
showToast('分享成功~');
});
})
});
}
}
}
return;
}
......
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