invite_page/assets/scripts/scrollContent.js

134 lines
3.7 KiB
JavaScript

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
},
// LIFE-CYCLE CALLBACKS:
onLoad() {
this.loginStatusLabel.node.active = false;
var processBar = cc.instantiate(this.processBarPrefab);
processBar.getComponent('progressBar').currentVal = 50000;
this.part1.addChild(processBar);
var puzzle = cc.instantiate(this.puzzlePrefab);
this.part2.addChild(puzzle);
var tip = cc.instantiate(this.tipPrefab);
this.part2.addChild(tip);
tip.getComponent('inviteTip').setLabelTxt('xx接受了您的邀请');
var imageSwiper = cc.instantiate(this.imageSwiperPrefab);
this.part4.addChild(imageSwiper, 0);
var bottomSwiper = cc.instantiate(this.bottomSwiperPrefab);
this.part5.addChild(bottomSwiper);
let self = this;
this.scheduleOnce(function () {
processBar.getComponent('progressBar').updateShow(35000);
puzzle.getComponent('puzzle').updateValues([0, 1, 0, 1, 0, 1, 1, 0, 1])
}, 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 > 2) {
this.onTouchEnd();
switch (this.touchTarget) {
case 'qr_wechat':
window.location.href = 'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzU0MTk4MzkyNQ==&scene=124#wechat_redirect';
break;
case 'qr_qq':
window.location.href = 'http://qm.qq.com/cgi-bin/qm/qr?k=9OEVDuOyP1BZ_cXOApidE9P2ea8daCVF';
break;
}
}
}
},
onTouchBg(e) {
this.touchTarget = e.target.name;
this.time = 0;
this.startup = true;
},
onTouchEnd(e) {
this.time = 0;
this.startup = false;
},
});