增加分享链接copy进剪贴板的功能

This commit is contained in:
zhl 2019-02-27 21:03:35 +08:00
parent 701d89d8a3
commit 69c16702f6
7 changed files with 422 additions and 49 deletions

View File

@ -26,21 +26,21 @@
"__id__": 10
},
{
"__id__": 23
"__id__": 30
}
],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 34
"__id__": 41
},
{
"__id__": 35
"__id__": 42
}
],
"_prefab": {
"__id__": 36
"__id__": 43
},
"_opacity": 255,
"_color": {
@ -346,18 +346,18 @@
"__id__": 11
},
{
"__id__": 14
"__id__": 20
}
],
"_active": true,
"_level": 3,
"_components": [
{
"__id__": 21
"__id__": 28
}
],
"_prefab": {
"__id__": 22
"__id__": 29
},
"_opacity": 255,
"_color": {
@ -411,16 +411,23 @@
"_parent": {
"__id__": 10
},
"_children": [],
"_children": [
{
"__id__": 12
},
{
"__id__": 15
}
],
"_active": true,
"_level": 4,
"_components": [
{
"__id__": 12
"__id__": 18
}
],
"_prefab": {
"__id__": 13
"__id__": 19
},
"_opacity": 255,
"_color": {
@ -467,6 +474,204 @@
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "url_label",
"_objFlags": 0,
"_parent": {
"__id__": 11
},
"_children": [],
"_active": true,
"_level": 5,
"_components": [
{
"__id__": 13
}
],
"_prefab": {
"__id__": 14
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 508,
"height": 90
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 32,
"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.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_useOriginalSize": false,
"_string": "http://wechat.kingsome.cn/s/0NNhvYtRQ",
"_N$string": "http://wechat.kingsome.cn/s/0NNhvYtRQ",
"_fontSize": 30,
"_lineHeight": 45,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 3,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "bdf9cd55-9cf3-4bf8-b902-2431701b3d6c"
},
"fileId": "e3RtCfIXlKlr6WsqbNjsDk",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 11
},
"_children": [],
"_active": true,
"_level": 5,
"_components": [
{
"__id__": 16
}
],
"_prefab": {
"__id__": 17
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 119,
"g": 119,
"b": 119,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 280,
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": -36,
"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.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_useOriginalSize": false,
"_string": "长按复制链接,分享给好友哦~",
"_N$string": "长按复制链接,分享给好友哦~",
"_fontSize": 20,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "bdf9cd55-9cf3-4bf8-b902-2431701b3d6c"
},
"fileId": "03MqpiZdxMBbJPQQayvabJ",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
@ -515,18 +720,21 @@
},
"_children": [
{
"__id__": 15
"__id__": 21
}
],
"_active": true,
"_level": 4,
"_components": [
{
"__id__": 19
"__id__": 25
},
{
"__id__": 26
}
],
"_prefab": {
"__id__": 20
"__id__": 27
},
"_opacity": 255,
"_color": {
@ -578,21 +786,21 @@
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 14
"__id__": 20
},
"_children": [],
"_active": true,
"_level": 5,
"_components": [
{
"__id__": 16
"__id__": 22
},
{
"__id__": 17
"__id__": 23
}
],
"_prefab": {
"__id__": 18
"__id__": 24
},
"_opacity": 255,
"_color": {
@ -644,7 +852,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
"__id__": 21
},
"_enabled": true,
"_srcBlendFactor": 1,
@ -669,7 +877,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
"__id__": 21
},
"_enabled": true,
"_color": {
@ -698,7 +906,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
"__id__": 20
},
"_enabled": true,
"_srcBlendFactor": 770,
@ -721,6 +929,59 @@
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"transition": 0,
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 214,
"g": 214,
"b": 214,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 20
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
@ -780,21 +1041,21 @@
},
"_children": [
{
"__id__": 24
"__id__": 31
},
{
"__id__": 28
"__id__": 35
}
],
"_active": true,
"_level": 3,
"_components": [
{
"__id__": 32
"__id__": 39
}
],
"_prefab": {
"__id__": 33
"__id__": 40
},
"_opacity": 255,
"_color": {
@ -846,21 +1107,21 @@
"_name": "menu_close_btn",
"_objFlags": 0,
"_parent": {
"__id__": 23
"__id__": 30
},
"_children": [],
"_active": true,
"_level": 4,
"_components": [
{
"__id__": 25
"__id__": 32
},
{
"__id__": 26
"__id__": 33
}
],
"_prefab": {
"__id__": 27
"__id__": 34
},
"_opacity": 255,
"_color": {
@ -912,7 +1173,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
"__id__": 31
},
"_enabled": true,
"_srcBlendFactor": 770,
@ -940,7 +1201,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
"__id__": 31
},
"_enabled": true,
"transition": 0,
@ -984,7 +1245,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 24
"__id__": 31
},
"_id": ""
},
@ -1004,21 +1265,21 @@
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 23
"__id__": 30
},
"_children": [],
"_active": true,
"_level": 4,
"_components": [
{
"__id__": 29
"__id__": 36
},
{
"__id__": 30
"__id__": 37
}
],
"_prefab": {
"__id__": 31
"__id__": 38
},
"_opacity": 255,
"_color": {
@ -1070,7 +1331,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 28
"__id__": 35
},
"_enabled": true,
"_srcBlendFactor": 1,
@ -1095,7 +1356,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 28
"__id__": 35
},
"_enabled": true,
"_color": {
@ -1124,7 +1385,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 23
"__id__": 30
},
"_enabled": true,
"_srcBlendFactor": 770,
@ -1194,7 +1455,16 @@
},
"_enabled": true,
"closeBtn": {
"__id__": 24
"__id__": 31
},
"shareBtn": {
"__id__": 20
},
"urlBtn": {
"__id__": 12
},
"urlLabel": {
"__id__": 13
},
"_id": ""
},

View File

@ -72,6 +72,16 @@ cc.Class({
webapi.sendSms(mobile, code)
.then(res => {
console.log(res);
if (res.errcode === 103) {
alert('当前手机号超过当日发送限额。');
} else if (res.errcode === 102) {
alert('发送太过频繁,请稍候再试。');
} else if (res.errcode === 101) {
alert('图形验证码错误。');
self.showCaptchaInput();
} else {
alert('短信已发送至您手机, 请输入收到的验证码。');
}
})
.catch(err => {
console.log(err);

View File

@ -1,3 +1,5 @@
let webapi = require('./utils/webapi');
let clipboard = require('./utils/clipboard');
cc.Class({
extends: cc.Component,
@ -5,7 +7,20 @@ cc.Class({
closeBtn: {
default: null,
type: cc.Node
}
},
shareBtn: {
default: null,
type: cc.Node
},
urlBtn: {
default: null,
type: cc.Node
},
urlLabel: {
default: null,
type: cc.Label
},
page: ''
},
// LIFE-CYCLE CALLBACKS:
@ -14,11 +29,22 @@ cc.Class({
let self = this;
this.closeBtn.on('click', function () {
self.node.removeFromParent(true);
});
webapi.getShareUrl()
.then(rep => {
if (rep.errcode === 0) {
self.urlLabel.string = rep.link;
self.page = rep.link;
}
})
.catch(err => {
console.log('error get share url');
});
this.shareBtn.on('click', function () {
let result = clipboard.webCopyString(self.page);
if (result) {
alert('链接已复制至剪贴板');
}
})
},
start () {
},
// update (dt) {},
}
});

View File

@ -1,6 +1,7 @@
var onfire = require('./utils/onfire');
let webapi = require('./utils/webapi');
let stringUtil = require('./utils/string.util');
cc.Class({
extends: cc.Component,
@ -65,7 +66,8 @@ cc.Class({
needCode: true,
logined: false,
mobile: '',
images: []
images: [],
uid: ''
},
// LIFE-CYCLE CALLBACKS:
@ -90,6 +92,7 @@ cc.Class({
if (userRep.errcode === 0) {
self.mobile = userRep.user.username;
self.images = userRep.user.images;
self.uid = userRep.user.uid;
self.mainScrollContent.getComponent('scrollContent').updateUserName(stringUtil.parseMobile(self.mobile));
self.mainScrollContent.getComponent('scrollContent').updatePuzzle(self.images);
self.mainScrollContent.getComponent('scrollContent').toggleLoginStatus(true);
@ -173,8 +176,19 @@ cc.Class({
this.node.addChild(resultView, 11);
},
showInviteMenu() {
let inviteMenu = cc.instantiate(this.inviteMenuPrefab);
this.node.addChild(inviteMenu, 11);
if (this.logined) {
let inviteMenu = cc.instantiate(this.inviteMenuPrefab);
inviteMenu.getComponent('inviteMenu').top = this;
this.node.addChild(inviteMenu, 11);
} else {
alert('请先预约');
let y = this.partsY[0];
this.scrollView.scrollToOffset(cc.v2(0, y), 0.1);
if (this.topMenu) {
this.topMenu.getComponent('topMenuContent').updateMenuShow(0);
}
}
},
showRuleMenu() {
let ruleMenu = cc.instantiate(this.rulePrefab);
@ -199,6 +213,7 @@ cc.Class({
self.logined = true;
self.mobile = rep.user.username;
self.images = rep.user.images;
self.uid = rep.user.uid;
self.mainScrollContent.getComponent('scrollContent').updateUserName(stringUtil.parseMobile(self.mobile));
self.mainScrollContent.getComponent('scrollContent').updatePuzzle(self.images);
self.mainScrollContent.getComponent('scrollContent').toggleLoginStatus(true);
@ -222,6 +237,7 @@ cc.Class({
webapi.logout()
.then(rep => {
if (rep.errcode === 0) {
self.logined = false;
self.mainScrollContent.getComponent('scrollContent').toggleLoginStatus(false);
self.mainScrollContent.getComponent('scrollContent').updatePuzzle([0,0,0,0,0,0,0,0,0]);
}

View File

@ -0,0 +1,38 @@
export default{
webCopyString: function(str){
console.log('复制');
var input = str + '';
const el = document.createElement('textarea');
el.value = input;
el.setAttribute('readonly', '');
el.style.contain = 'strict';
el.style.position = 'absolute';
el.style.left = '-9999px';
el.style.fontSize = '12pt'; // Prevent zooming on iOS
const selection = getSelection();
var originalRange = false;
if (selection.rangeCount > 0) {
originalRange = selection.getRangeAt(0);
}
document.body.appendChild(el);
el.select();
el.selectionStart = 0;
el.selectionEnd = input.length;
var success = false;
try {
success = document.execCommand('copy');
} catch (err) {}
document.body.removeChild(el);
if (originalRange) {
selection.removeAllRanges();
selection.addRange(originalRange);
}
return success;
},
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "0a2be9c2-f2e1-463c-a3c1-bb4521403f0d",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -33,5 +33,9 @@ export default {
logout: () => {
let url = baseUrl + '/activity/api/logout';
return http.post(url, {});
},
getShareUrl: () => {
let url = baseUrl + '/activity/api/getShareUrl';
return http.get(url);
}
}