diff --git a/assets/resources/prefabs/invite_menu.prefab b/assets/resources/prefabs/invite_menu.prefab index 02f6ff5..4b308dc 100644 --- a/assets/resources/prefabs/invite_menu.prefab +++ b/assets/resources/prefabs/invite_menu.prefab @@ -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": "" }, diff --git a/assets/scripts/infoMenu.js b/assets/scripts/infoMenu.js index 068f6a2..08e7ceb 100644 --- a/assets/scripts/infoMenu.js +++ b/assets/scripts/infoMenu.js @@ -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); diff --git a/assets/scripts/inviteMenu.js b/assets/scripts/inviteMenu.js index 8b6a3a7..c5d3e50 100644 --- a/assets/scripts/inviteMenu.js +++ b/assets/scripts/inviteMenu.js @@ -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) {}, + } }); diff --git a/assets/scripts/main.js b/assets/scripts/main.js index 19d3af2..c108362 100644 --- a/assets/scripts/main.js +++ b/assets/scripts/main.js @@ -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]); } diff --git a/assets/scripts/utils/clipboard.js b/assets/scripts/utils/clipboard.js new file mode 100644 index 0000000..9c96166 --- /dev/null +++ b/assets/scripts/utils/clipboard.js @@ -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; + }, +} diff --git a/assets/scripts/utils/clipboard.js.meta b/assets/scripts/utils/clipboard.js.meta new file mode 100644 index 0000000..ed8ee8f --- /dev/null +++ b/assets/scripts/utils/clipboard.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "0a2be9c2-f2e1-463c-a3c1-bb4521403f0d", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/scripts/utils/webapi.js b/assets/scripts/utils/webapi.js index c15aeee..093ceac 100644 --- a/assets/scripts/utils/webapi.js +++ b/assets/scripts/utils/webapi.js @@ -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); } }