增加二维码长按跳转的功能

This commit is contained in:
zhl 2019-02-26 17:20:25 +08:00
parent da7864bd1f
commit aed66eb00f
5 changed files with 130 additions and 24 deletions

View File

@ -23,21 +23,21 @@
"__id__": 7
},
{
"__id__": 13
"__id__": 15
}
],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 17
"__id__": 19
},
{
"__id__": 18
"__id__": 20
}
],
"_prefab": {
"__id__": 19
"__id__": 21
},
"_opacity": 255,
"_color": {
@ -239,17 +239,20 @@
"_children": [
{
"__id__": 8
},
{
"__id__": 11
}
],
"_active": true,
"_level": 3,
"_components": [
{
"__id__": 11
"__id__": 13
}
],
"_prefab": {
"__id__": 12
"__id__": 14
},
"_opacity": 255,
"_color": {
@ -395,6 +398,76 @@
"fileId": "79cGSCknBEPp6kBMV9zb6n",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "qr_qq",
"_objFlags": 0,
"_parent": {
"__id__": 7
},
"_children": [],
"_active": true,
"_level": 4,
"_components": [],
"_prefab": {
"__id__": 12
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 222,
"height": 222
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": -18,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"_zIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "50fc505c-5051-4781-84b8-6bdf8254ed17"
},
"fileId": "b99kYNlu9CEauNV0vQPKpA",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
@ -446,14 +519,14 @@
"_level": 3,
"_components": [
{
"__id__": 14
"__id__": 16
},
{
"__id__": 15
"__id__": 17
}
],
"_prefab": {
"__id__": 16
"__id__": 18
},
"_opacity": 255,
"_color": {
@ -505,7 +578,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
"__id__": 15
},
"_enabled": true,
"_srcBlendFactor": 770,
@ -533,7 +606,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
"__id__": 15
},
"_enabled": true,
"transition": 0,
@ -577,7 +650,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 13
"__id__": 15
},
"_id": ""
},
@ -628,7 +701,10 @@
},
"_enabled": true,
"closeBtn": {
"__id__": 13
"__id__": 15
},
"qrBtn": {
"__id__": 11
},
"_id": ""
},

View File

@ -31,7 +31,6 @@ cc.Class({
start () {
},
// update (dt) {},
showResultView() {
let result = cc.instantiate(this.resultPrefab);
this.top.node.addChild(result, 11);

View File

@ -1,4 +1,5 @@
var http = require('./utils/http');
var onfire = require('./utils/onfire');
cc.Class({
extends: cc.Component,
@ -86,12 +87,14 @@ cc.Class({
// let offsetY = self.scrollView.getScrollOffset().y;
// console.log('getScrollOffset: ' + offsetY);
});
this.longPressListener = onfire.on('longPressed', this.longPressed.bind(this));
},
start () {
},
onDestroy: function () {
onfire.un(this.topMenuListener);
onfire.un(this.longPressListener);
},
// update (dt) {},
showTopMenu() {
@ -132,5 +135,16 @@ cc.Class({
showRuleMenu() {
let ruleMenu = cc.instantiate(this.rulePrefab);
this.node.addChild(ruleMenu, 11);
},
longPressed(data) {
console.log(data);
switch (data.target) {
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;
}
}
});

View File

@ -5,6 +5,10 @@ cc.Class({
closeBtn: {
default: null,
type: cc.Node
},
qrBtn: {
default: null,
type: cc.Node
}
},
@ -18,7 +22,27 @@ cc.Class({
},
start () {
this.startup = false;
this.qrBtn.on(cc.Node.EventType.TOUCH_START, this.onTouchBg, this);
this.qrBtn.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
},
// update (dt) {},
update(dt) {
if (this.startup) {
this.time += dt;
if (this.time > 1) {
this.onTouchEnd();
onfire.fire("longPressed", {target: 'qr_qq', val: ''});
}
}
},
onTouchBg(e) {
this.time = 0;
this.startup = true;
},
onTouchEnd(e) {
this.time = 0;
this.startup = false;
},
});

View File

@ -1,3 +1,4 @@
let onfire = require('./utils/onfire');
cc.Class({
extends: cc.Component,
@ -107,17 +108,9 @@ cc.Class({
update(dt) {
if (this.startup) {
this.time += dt;
if (this.time > 2) {
if (this.time > 1) {
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;
}
onfire.fire("longPressed", {target: this.touchTarget, val: ''});
}
}
},