159 lines
4.3 KiB
JavaScript
159 lines
4.3 KiB
JavaScript
let onfire = require('./utils/onfire');
|
|
let webapi = require('./utils/webapi');
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
part1: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
part2: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
part3: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
part4: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
part5: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
processBarPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
puzzlePrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
tipPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
imageSwiperPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
bottomSwiperPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
joinBtn: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
inviteBtn: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
ruleBtn: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
loginStatusLabel: {
|
|
default: null,
|
|
type: cc.Label
|
|
},
|
|
logoutBtn: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
qrCodeQQ: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
qrCodeWechat: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
touchTarget: null,
|
|
tipLabel: {
|
|
default: null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
let self = this;
|
|
this.loginStatusLabel.node.active = false;
|
|
var processBar = cc.instantiate(this.processBarPrefab);
|
|
// processBar.getComponent('progressBar').currentVal = 50000;
|
|
this.part1.addChild(processBar);
|
|
processBar.getComponent('progressBar').updateShow(1024);
|
|
this.puzzle = cc.instantiate(this.puzzlePrefab);
|
|
this.part2.addChild(this.puzzle);
|
|
this.tipLabel = cc.instantiate(this.tipPrefab);
|
|
this.part2.addChild(this.tipLabel);
|
|
|
|
var imageSwiper = cc.instantiate(this.imageSwiperPrefab);
|
|
this.part4.addChild(imageSwiper, 0);
|
|
var bottomSwiper = cc.instantiate(this.bottomSwiperPrefab);
|
|
this.part5.addChild(bottomSwiper);
|
|
this.logoutBtn.on('click', function () {
|
|
self.top.userLogout();
|
|
});
|
|
webapi.getActivityInfo()
|
|
.then(rep => {
|
|
if (rep.errcode === 0) {
|
|
processBar.getComponent('progressBar').updateShow(rep.count);
|
|
}
|
|
})
|
|
.catch(err => {
|
|
cc.log('error get activity info');
|
|
});
|
|
|
|
// this.scheduleOnce(function () {
|
|
// processBar.getComponent('progressBar').updateShow(35000);
|
|
// self.puzzle.getComponent('puzzle').updateValues([])
|
|
// }, 5);
|
|
},
|
|
|
|
start() {
|
|
this.startup = false;
|
|
this.qrCodeQQ.on(cc.Node.EventType.TOUCH_START, this.onTouchBg, this);
|
|
this.qrCodeQQ.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
|
this.qrCodeWechat.on(cc.Node.EventType.TOUCH_START, this.onTouchBg, this);
|
|
this.qrCodeWechat.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
|
},
|
|
|
|
update(dt) {
|
|
if (this.startup) {
|
|
this.time += dt;
|
|
if (this.time > 1) {
|
|
this.onTouchEnd();
|
|
onfire.fire("longPressed", {target: this.touchTarget, val: ''});
|
|
}
|
|
}
|
|
},
|
|
onTouchBg(e) {
|
|
this.touchTarget = e.target.name;
|
|
this.time = 0;
|
|
this.startup = true;
|
|
},
|
|
onTouchEnd(e) {
|
|
this.time = 0;
|
|
this.startup = false;
|
|
},
|
|
updatePuzzle(valArr) {
|
|
this.puzzle.getComponent('puzzle').updateValues(valArr)
|
|
},
|
|
updateUserName(username) {
|
|
this.loginStatusLabel.string = username;
|
|
},
|
|
toggleLoginStatus(status) {
|
|
this.loginStatusLabel.node.active = status;
|
|
this.joinBtn.active = !status;
|
|
},
|
|
updateTipTxt(str) {
|
|
this.tipLabel.getComponent('inviteTip').setLabelTxt(str);
|
|
}
|
|
});
|