mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-15 19:26:26 +08:00
Merge branch 'master' of https://github.com/Leo501/CocosCreatorTutorial
This commit is contained in:
53
WechatGame_login_v2/.gitignore
vendored
Normal file
53
WechatGame_login_v2/.gitignore
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Fireball Projects
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/library/
|
||||
/temp/
|
||||
/local/
|
||||
/build/
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# npm files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
npm-debug.log
|
||||
node_modules/
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Logs and databases
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# files for debugger
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.sln
|
||||
*.csproj
|
||||
*.pidb
|
||||
*.unityproj
|
||||
*.suo
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# OS generated files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# WebStorm files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.idea/
|
||||
|
||||
#//////////////////////////
|
||||
# VS Code files
|
||||
#//////////////////////////
|
||||
|
||||
.vscode/
|
||||
2
WechatGame_login_v2/README.md
Normal file
2
WechatGame_login_v2/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# hello-world
|
||||
Hello world new project template.
|
||||
6
WechatGame_login_v2/assets/Scene.meta
Normal file
6
WechatGame_login_v2/assets/Scene.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
723
WechatGame_login_v2/assets/Scene/helloworld.fire
Normal file
723
WechatGame_login_v2/assets/Scene/helloworld.fire
Normal file
@@ -0,0 +1,723 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.SceneAsset",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_native": "",
|
||||
"scene": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Scene",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_scale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0.3296875,
|
||||
"y": 0.3296875,
|
||||
"z": 1
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_is3DNode": true,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"autoReleaseAssets": false,
|
||||
"_id": "2d2f792f-a40c-49bb-a189-ed176a246e49"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Canvas",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
},
|
||||
{
|
||||
"__id__": 8
|
||||
},
|
||||
{
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 12
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 15
|
||||
},
|
||||
{
|
||||
"__id__": 16
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 252,
|
||||
"g": 252,
|
||||
"b": 252,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
480,
|
||||
320,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "a286bbGknJLZpRpxROV6M94"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Main Camera",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 4
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
275.2120666503906,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "bajsC4KotFLZ6XLFLKnycL"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Camera",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"_cullingMask": 4294967295,
|
||||
"_clearFlags": 7,
|
||||
"_backgroundColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"a": 255
|
||||
},
|
||||
"_depth": -1,
|
||||
"_zoomRatio": 1,
|
||||
"_targetTexture": null,
|
||||
"_fov": 60,
|
||||
"_orthoSize": 10,
|
||||
"_nearClip": 1,
|
||||
"_farClip": 4096,
|
||||
"_ortho": true,
|
||||
"_rect": {
|
||||
"__type__": "cc.Rect",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 1,
|
||||
"height": 1
|
||||
},
|
||||
"_renderStages": 1,
|
||||
"_id": "c7r5+B15dD56dUBiNj+0KH"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "background",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 6
|
||||
},
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 27,
|
||||
"g": 38,
|
||||
"b": 46,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "e2e0crkOLxGrpMxpbC4iQg1"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 5
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 1,
|
||||
"_target": null,
|
||||
"_alignFlags": 45,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 200,
|
||||
"_originalHeight": 150,
|
||||
"_id": "86+yud7pFDSrM+lsxByQvE"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 5
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "410fb916-8721-4663-bab8-34397391ace7"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "1bi08CbSBHsZSXfV2t6eKB"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "cocos",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 195,
|
||||
"height": 270
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
0,
|
||||
50,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "c4f30YOS65G64U2TwufdJ+2"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 8
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "42SM+92GZAXYsjLj89MLM+"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "label",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 11
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 223,
|
||||
"g": 35,
|
||||
"b": 35,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 146.81,
|
||||
"height": 75.6
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
0,
|
||||
-180,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "31f1bH7V69Ajr1iXhluMpTB"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 10
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_useOriginalSize": false,
|
||||
"_string": "Label",
|
||||
"_N$string": "Label",
|
||||
"_fontSize": 60,
|
||||
"_lineHeight": 60,
|
||||
"_enableWrapText": true,
|
||||
"_N$file": null,
|
||||
"_isSystemFontUsed": true,
|
||||
"_spacingX": 0,
|
||||
"_batchAsBitmap": false,
|
||||
"_N$horizontalAlign": 1,
|
||||
"_N$verticalAlign": 1,
|
||||
"_N$fontFamily": "Arial",
|
||||
"_N$overflow": 0,
|
||||
"_N$cacheMode": 0,
|
||||
"_id": "74saCdhnNHjbyDsdd1bTTt"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "LoginWx",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 13
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 14
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "bdNLKx2etLcYrVp05uFLji"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "btn",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 12
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 200,
|
||||
"height": 60
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float32Array",
|
||||
"array": [
|
||||
0,
|
||||
-111.26300048828125,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "4dl/7Y4w1FdbfcNqYypLjz"
|
||||
},
|
||||
{
|
||||
"__type__": "245f2ef2Z9M0p4msKbaxB4x",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 12
|
||||
},
|
||||
"_enabled": true,
|
||||
"path": "resources/btn_l_idlogin.png",
|
||||
"_id": "2dIyvKazBK7qeIHhjrM/L2"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Canvas",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_designResolution": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_fitWidth": false,
|
||||
"_fitHeight": true,
|
||||
"_id": "6f5cteKmlPh6NGUsUqxlFR"
|
||||
},
|
||||
{
|
||||
"__type__": "280c3rsZJJKnZ9RqbALVwtK",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"label": {
|
||||
"__id__": 11
|
||||
},
|
||||
"text": "Hello, World!",
|
||||
"_id": "dcGJ+cSA5D7qNtScKfLjJJ"
|
||||
}
|
||||
]
|
||||
7
WechatGame_login_v2/assets/Scene/helloworld.fire.meta
Normal file
7
WechatGame_login_v2/assets/Scene/helloworld.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.2.2",
|
||||
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
WechatGame_login_v2/assets/Script.meta
Normal file
6
WechatGame_login_v2/assets/Script.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
22
WechatGame_login_v2/assets/Script/HelloWorld.js
Normal file
22
WechatGame_login_v2/assets/Script/HelloWorld.js
Normal file
@@ -0,0 +1,22 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
label: {
|
||||
default: null,
|
||||
type: cc.Label
|
||||
},
|
||||
// defaults, set visually when attaching this script to the Canvas
|
||||
text: 'Hello, World!'
|
||||
},
|
||||
|
||||
// use this for initialization
|
||||
onLoad: function () {
|
||||
this.label.string = this.text;
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
9
WechatGame_login_v2/assets/Script/HelloWorld.js.meta
Normal file
9
WechatGame_login_v2/assets/Script/HelloWorld.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
118
WechatGame_login_v2/assets/Script/LoginWx.js
Normal file
118
WechatGame_login_v2/assets/Script/LoginWx.js
Normal file
@@ -0,0 +1,118 @@
|
||||
let AdapterApi = require("PlatformAdapter");
|
||||
let Global = require("Global");
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
path: 'resources/btn_l_idlogin.png'
|
||||
},
|
||||
|
||||
start() {
|
||||
|
||||
if (Global.isAuth || cc.sys.platform !== cc.sys.WECHAT_GAME) {
|
||||
this.node.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
window.AdapterApi = AdapterApi;
|
||||
window.Global = Global;
|
||||
AdapterApi.initCloud();
|
||||
|
||||
this.loadUserInfo((error) => {
|
||||
//失败手动授权
|
||||
if (error) {
|
||||
this.getUserInfo();
|
||||
} else {
|
||||
this.node.active = false;
|
||||
}
|
||||
AdapterApi.showGameClub(true);
|
||||
});
|
||||
},
|
||||
|
||||
getUserInfo() {
|
||||
console.log('creator login btn');
|
||||
if (Global.isAuth) {
|
||||
this.node.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.frameSize = cc.view.getFrameSize();
|
||||
let contentSize = this.doHandleContentSize();
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
let urlRaw = cc.url.raw(this.path);
|
||||
if (cc.loader.md5Pipe) {
|
||||
urlRaw = cc.loader.md5Pipe.transformURL(urlRaw);
|
||||
}
|
||||
let url = urlRaw;
|
||||
this._userInfoBtn = AdapterApi.createUserInfoBtnByImg(
|
||||
contentSize.left,
|
||||
contentSize.top,
|
||||
url,
|
||||
contentSize.width,
|
||||
contentSize.height,
|
||||
(userInfoRes) => {
|
||||
console.log("获取到的UserInfo:", userInfoRes);
|
||||
if (userInfoRes.errMsg.indexOf('fail') != -1) {
|
||||
AdapterApi.showModal('提示', '请点击允许按钮');
|
||||
return;
|
||||
}
|
||||
Global.nickName = userInfoRes.userInfo.nickName;
|
||||
Global.avatarUrl = userInfoRes.userInfo.avatarUrl;
|
||||
this._userInfoBtn.hide();
|
||||
this.node.active = false;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.node.active = false;
|
||||
}
|
||||
},
|
||||
|
||||
loadUserInfo(cb) {
|
||||
AdapterApi.callFunction("getOpenId").then(res => {
|
||||
Global.openId = res.result.openid;
|
||||
console.log('openId', Global.openId);
|
||||
}).catch(err => {
|
||||
console.log('getOpenId err', err);
|
||||
});
|
||||
|
||||
AdapterApi.getSetting('scope.userInfo').then(res => {
|
||||
Global.isAuth = true;
|
||||
console.log(res);
|
||||
// 已授权直接获取用户信息
|
||||
AdapterApi.getUserInfo().then(res => {
|
||||
console.log("用户信息:", res);
|
||||
Global.nickName = res.userInfo.nickName;
|
||||
Global.avatarUrl = res.userInfo.avatarUrl;
|
||||
console.log("Global.nickName", Global.nickName, "Global.avatarUrl", Global.avatarUrl);
|
||||
cb();
|
||||
}).catch(err => {
|
||||
console.log("用户信息 err:", err);
|
||||
cb(err);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
cb(err);
|
||||
});
|
||||
},
|
||||
|
||||
doHandleContentSize() {
|
||||
let btnNode = cc.find('btn', this.node);
|
||||
|
||||
let btnSize = cc.size(btnNode.width + 10, btnNode.height + 10);
|
||||
let frameSize = cc.view.getFrameSize();
|
||||
let winSize = cc.director.getWinSize();
|
||||
// console.log("winSize: ",winSize);
|
||||
// console.log("frameSize: ",frameSize);
|
||||
//适配不同机型来创建微信授权按钮
|
||||
let left = (winSize.width * 0.5 + btnNode.x - btnSize.width * 0.5) / winSize.width * frameSize.width;
|
||||
let top = (winSize.height * 0.5 - btnNode.y - btnSize.height * 0.5) / winSize.height * frameSize.height;
|
||||
let width = btnSize.width / winSize.width * frameSize.width;
|
||||
let height = btnSize.height / winSize.height * frameSize.height;
|
||||
return {
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height
|
||||
}
|
||||
}
|
||||
});
|
||||
9
WechatGame_login_v2/assets/Script/LoginWx.js.meta
Normal file
9
WechatGame_login_v2/assets/Script/LoginWx.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "245f279f-d99f-4cd2-9e26-b0a6dac41e31",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
7
WechatGame_login_v2/assets/Script/common.meta
Normal file
7
WechatGame_login_v2/assets/Script/common.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "1a2a6dee-26e6-4817-a01b-15247418c471",
|
||||
"isSubpackage": false,
|
||||
"subpackageName": "",
|
||||
"subMetas": {}
|
||||
}
|
||||
35
WechatGame_login_v2/assets/Script/common/Global.js
Normal file
35
WechatGame_login_v2/assets/Script/common/Global.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 全局参数
|
||||
*/
|
||||
module.exports = {
|
||||
isDebug: false,
|
||||
openId: "15B91788D2D3FDB763DEBA67EB3D646E",
|
||||
nickName: "Shawn", //用户昵称
|
||||
avatarUrl: "http://192.168.1.134:12888/img/head.png",
|
||||
inviter: "inGame",
|
||||
|
||||
isAudio: true, //默认是开启音效
|
||||
apiToken: undefined,
|
||||
share: false,
|
||||
isAuth: false,
|
||||
wxDb: undefined,
|
||||
|
||||
|
||||
URL: {
|
||||
// BASE_URL: "http://192.168.1.158:7870/sunflower/v1",
|
||||
BASE_URL: "https://newgame.qianfanggaoneng.net/sunflower/v1",
|
||||
EXCEL: "/getSunFlowerExcelServlet",
|
||||
RANK: "/getWorldRankingList",
|
||||
UPLOAD: "/setUserStorageServlet",
|
||||
|
||||
},
|
||||
|
||||
videoAd: undefined,
|
||||
bannerAd: undefined,
|
||||
|
||||
videoAdLoadCount: 0, //视频广告加载次数
|
||||
bannerAdLoadCount: 0, //banner广告加载次数
|
||||
|
||||
windowWidth: 720,
|
||||
windowHeight: 1280,
|
||||
};
|
||||
9
WechatGame_login_v2/assets/Script/common/Global.js.meta
Normal file
9
WechatGame_login_v2/assets/Script/common/Global.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "20f50d1f-6710-4294-87e3-fbc91ad8cfbe",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
129
WechatGame_login_v2/assets/Script/common/NetUtils.js
Normal file
129
WechatGame_login_v2/assets/Script/common/NetUtils.js
Normal file
@@ -0,0 +1,129 @@
|
||||
let Utils = require("./Utils");
|
||||
let Global = require("./Global");
|
||||
/**
|
||||
* post 请求
|
||||
* @param {*} url
|
||||
* @param {*} data
|
||||
* @param {*} callBack
|
||||
*/
|
||||
function post (url, type, data, callBack) {
|
||||
Utils.log("请求地址:" + url);
|
||||
Utils.log("请求参数:" + data);
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
let status = xhr.status;
|
||||
if (xhr.readyState == 4 && status == 200) {
|
||||
let responseBody = xhr.responseText;
|
||||
Utils.log("响应的结果:" + responseBody);
|
||||
callBack(status, JSON.parse(responseBody));
|
||||
}
|
||||
};
|
||||
xhr.open("POST", url, true);
|
||||
if (type == "json") {
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
// data=JSON.stringify({"key":"value"});
|
||||
} else if (type == "www") {
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
// data="key=value";
|
||||
}
|
||||
xhr.send(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* get请求
|
||||
* @param {*} url
|
||||
* @param {*} data
|
||||
* @param {*} callBack
|
||||
*/
|
||||
function get (url, data, callBack) {
|
||||
Utils.log("请求地址:" + url);
|
||||
Utils.log("请求参数:" + data);
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
let status = xhr.status;
|
||||
if (xhr.readyState == 4 && status == 200) {
|
||||
let responseBody = xhr.responseText;
|
||||
Utils.log("响应的结果:" + responseBody);
|
||||
callBack(status, JSON.parse(responseBody));
|
||||
}
|
||||
};
|
||||
xhr.open("GET", url + "?params=" + encodeURIComponent(data), true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录请求参数
|
||||
*/
|
||||
function setLoginData () {
|
||||
let loginObj = {};
|
||||
loginObj.accounttype = 4;
|
||||
loginObj.gameID = Global.gameId;
|
||||
loginObj.openid = Global.openId;
|
||||
loginObj.platform = Global.platform;
|
||||
loginObj.sex = Global.sex;
|
||||
loginObj.nickName = Global.nickName;
|
||||
loginObj.osVersion = Global.osVersion;
|
||||
if (Global.inviter) {
|
||||
loginObj.inviter = Global.inviter;
|
||||
}
|
||||
return JSON.stringify(loginObj);
|
||||
}
|
||||
|
||||
function doLogin (callBack) {
|
||||
let URL = Global.URL.BASE_URL + Global.URL.LOGIN;
|
||||
let params = setLoginData();
|
||||
get(URL, params, function(status, response) {
|
||||
let code = -1;
|
||||
if (status == 200) {
|
||||
code = 0;
|
||||
if (response && response.code == 0) {
|
||||
Global.WEB_SOCKET.URL = response.data.serverAddress;
|
||||
Global.WEB_SOCKET.TOKEN = response.data.token;
|
||||
}
|
||||
}
|
||||
callBack(code);
|
||||
});
|
||||
}
|
||||
|
||||
function doExcel (callBack) {
|
||||
let URL = Global.URL.BASE_URL + Global.URL.EXCEL;
|
||||
post(URL, "www", "gameId=sunflower", function(status, data) {
|
||||
if (status == 200) {
|
||||
callBack(0, data);
|
||||
} else {
|
||||
callBack(-1, data);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function uploadScore (score, callBack) {
|
||||
let URL = Global.URL.BASE_URL + Global.URL.UPLOAD;
|
||||
post(URL, "www", "gameId=sunflower&score=" + score + "&token=" + Global.token, function(status, data) {
|
||||
if (status == 200) {
|
||||
callBack(0, data);
|
||||
} else {
|
||||
callBack(-1, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getRankData (callBack) {
|
||||
let URL = Global.URL.BASE_URL + Global.URL.RANK;
|
||||
post(URL, "www", "gameId=sunflower", function(status, data) {
|
||||
if (status == 200) {
|
||||
callBack(0, data);
|
||||
} else {
|
||||
callBack(-1, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
post: post, //post请求
|
||||
get: get, //get请求
|
||||
doLogin: doLogin,
|
||||
doExcel: doExcel,
|
||||
uploadScore: uploadScore,
|
||||
getRankData: getRankData,
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "81a2b281-d1c2-4fdf-b153-1373148f3482",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
115
WechatGame_login_v2/assets/Script/common/PlatformAdapter.js
Normal file
115
WechatGame_login_v2/assets/Script/common/PlatformAdapter.js
Normal file
@@ -0,0 +1,115 @@
|
||||
const WxApi = require('./WxApi');
|
||||
|
||||
var wxApi = new WxApi();
|
||||
|
||||
function initCloud () {
|
||||
wxApi.initCloud('release-8b47d');
|
||||
}
|
||||
|
||||
function callFunction (funcName, params) {
|
||||
return wxApi.callFunction(funcName, params)
|
||||
}
|
||||
|
||||
// 获取设置,判断是否授权
|
||||
function getSetting (scope) {
|
||||
return wxApi.getSetting(scope);
|
||||
}
|
||||
// 登录获取code
|
||||
function login () {
|
||||
return wxApi.login();
|
||||
}
|
||||
|
||||
function getUserInfo () {
|
||||
return wxApi.getUserInfo();
|
||||
}
|
||||
|
||||
// 显示准发按钮
|
||||
function showShareMenu () {
|
||||
wxApi.showShareMenu();
|
||||
}
|
||||
|
||||
// 转发·小程序
|
||||
function onShareAppMessage () {
|
||||
wxApi.onShareAppMessage();
|
||||
}
|
||||
// 主动拉起转发
|
||||
function shareAppMessage () {
|
||||
wxApi.shareAppMessage();
|
||||
}
|
||||
|
||||
function showModal (title, content) {
|
||||
wxApi.showModal(title, content);
|
||||
}
|
||||
|
||||
function showLoading (title) {
|
||||
wxApi.showLoading(title)
|
||||
}
|
||||
|
||||
function hideLoading () {
|
||||
wxApi.hideLoading();
|
||||
}
|
||||
|
||||
// 动态创建获取用户信息按钮
|
||||
function createUserInfoBtnByImg (left, top, imgUrl, width, height, callBack) {
|
||||
return wxApi.createUserInfoBtnByImg(left, top, imgUrl, width, height, callBack);
|
||||
}
|
||||
|
||||
// 动态创建反馈按钮
|
||||
function createFeedbackButtonByImg (left, top, imgUrl, width, height, callBack) {
|
||||
return wxApi.createFeedbackButtonByImg(left, top, imgUrl, width, height, callBack);
|
||||
}
|
||||
|
||||
function loadVideoAd (cb) {
|
||||
wxApi.loadVideoAd('adunit-402549102d44db42', cb);
|
||||
}
|
||||
|
||||
function loadBannerAd () {
|
||||
wxApi.loadBannerAd('adunit-3b1dc39cca18d23b');
|
||||
}
|
||||
|
||||
function showBannerAd () {
|
||||
wxApi.showBannerAd();
|
||||
}
|
||||
|
||||
function hideBannerAd () {
|
||||
wxApi.hideBannerAd();
|
||||
}
|
||||
|
||||
function post (postUrl, params) {
|
||||
return wxApi.post(postUrl, params);
|
||||
}
|
||||
|
||||
function uploadScore (score) {
|
||||
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
||||
return wxApi.uploadScore(score);
|
||||
}
|
||||
}
|
||||
|
||||
function showGameClub(visable) {
|
||||
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
||||
return wxApi.showGameClub(visable);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
initCloud: initCloud,
|
||||
getSetting: getSetting,
|
||||
login: login,
|
||||
getUserInfo: getUserInfo,
|
||||
showShareMenu: showShareMenu,
|
||||
onShareAppMessage: onShareAppMessage,
|
||||
shareAppMessage: shareAppMessage,
|
||||
createUserInfoBtnByImg: createUserInfoBtnByImg,
|
||||
createFeedbackButtonByImg: createFeedbackButtonByImg,
|
||||
loadVideoAd: loadVideoAd,
|
||||
loadBannerAd: loadBannerAd,
|
||||
showBannerAd: showBannerAd,
|
||||
hideBannerAd: hideBannerAd,
|
||||
showModal: showModal,
|
||||
showLoading: showLoading,
|
||||
hideLoading: hideLoading,
|
||||
post: post,
|
||||
callFunction: callFunction,
|
||||
uploadScore: uploadScore,
|
||||
showGameClub,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "8447114b-16a8-4cb3-aba8-41754825f614",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
482
WechatGame_login_v2/assets/Script/common/Utils.js
Normal file
482
WechatGame_login_v2/assets/Script/common/Utils.js
Normal file
@@ -0,0 +1,482 @@
|
||||
/**
|
||||
* @author Javen
|
||||
* @copyright 2018-11-13 18:36:04 javendev@126.com
|
||||
* @description 常用的工具方法
|
||||
*/
|
||||
var Global = require("./Global");
|
||||
/**
|
||||
* 日志输出
|
||||
*/
|
||||
function log () {
|
||||
if (Global.isDebug) {
|
||||
for (let msg in arguments) {
|
||||
console.log(arguments[msg]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setImg (imgNode, spriteFrame) {
|
||||
imgNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
|
||||
}
|
||||
|
||||
function loadImgByUrl (imgNode, remoteUrl, imageType) {
|
||||
if (!imageType) {
|
||||
imageType = "png";
|
||||
}
|
||||
cc.loader.load({
|
||||
url: remoteUrl,
|
||||
type: imageType
|
||||
}, function(err, texture) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
setImg(imgNode, new cc.SpriteFrame(texture));
|
||||
});
|
||||
}
|
||||
|
||||
function loadLocal (imgNode, absolutePath) {
|
||||
cc.loader.load(absolutePath, function(err, texture) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
setImg(imgNode, new cc.SpriteFrame(texture));
|
||||
});
|
||||
}
|
||||
|
||||
function isArray (value) {
|
||||
if (typeof Array.isArray === "function") {
|
||||
return Array.isArray(value);
|
||||
} else {
|
||||
return Object.prototype.toString.call(value) === "[Object Array]";
|
||||
}
|
||||
}
|
||||
|
||||
function bigNumObj (unit, value) {
|
||||
let temp = {
|
||||
unit: unit, //单位
|
||||
value: value //数值
|
||||
};
|
||||
return temp;
|
||||
}
|
||||
|
||||
function bigNum (bigNum) { //12.5K
|
||||
let bigNumStr = bigNum.replace(/\s+/g, "");
|
||||
let unit = 0;
|
||||
let value = 0;
|
||||
let unitStr = bigNumStr.match('[a-zA-Z]+$');
|
||||
if (unitStr) {
|
||||
value = parseFloat(bigNumStr.substring(0, bigNumStr.indexOf(unitStr)));
|
||||
} else {
|
||||
value = parseFloat(bigNumStr);
|
||||
}
|
||||
|
||||
switch (unitStr + "") {
|
||||
case 'K':
|
||||
unit = 1;
|
||||
break;
|
||||
case 'M':
|
||||
unit = 2;
|
||||
break;
|
||||
case 'B':
|
||||
unit = 3;
|
||||
break;
|
||||
case 'T':
|
||||
unit = 4;
|
||||
break;
|
||||
case 'aa':
|
||||
unit = 5;
|
||||
break;
|
||||
case 'ab':
|
||||
unit = 6;
|
||||
break;
|
||||
case 'ac':
|
||||
unit = 7;
|
||||
break;
|
||||
case 'ad':
|
||||
unit = 8;
|
||||
break;
|
||||
case 'ae':
|
||||
unit = 9;
|
||||
break;
|
||||
case 'af':
|
||||
unit = 10;
|
||||
break;
|
||||
case 'ag':
|
||||
unit = 11;
|
||||
break;
|
||||
case 'ah':
|
||||
unit = 12;
|
||||
break;
|
||||
case 'aj':
|
||||
unit = 15;
|
||||
break;
|
||||
case 'al':
|
||||
unit = 16;
|
||||
break;
|
||||
case 'am':
|
||||
unit = 17;
|
||||
break;
|
||||
case 'an':
|
||||
unit = 18;
|
||||
break;
|
||||
case 'ao':
|
||||
unit = 19;
|
||||
break;
|
||||
case 'ap':
|
||||
unit = 20;
|
||||
break;
|
||||
case 'aq':
|
||||
unit = 21;
|
||||
break;
|
||||
case 'ar':
|
||||
unit = 22;
|
||||
break;
|
||||
case 'as':
|
||||
unit = 23;
|
||||
break;
|
||||
case 'at':
|
||||
unit = 24;
|
||||
break;
|
||||
case 'au':
|
||||
unit = 25;
|
||||
break;
|
||||
case 'av':
|
||||
unit = 26;
|
||||
break;
|
||||
case 'aw':
|
||||
unit = 27;
|
||||
break;
|
||||
case 'ax':
|
||||
unit = 28;
|
||||
break;
|
||||
case 'ay':
|
||||
unit = 29;
|
||||
break;
|
||||
case 'az':
|
||||
unit = 30;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return bigNumObj(unit, value);
|
||||
}
|
||||
|
||||
function bigNumAdd (bigNumA, bigNumB) {
|
||||
let limit = 4; //限制字母单位差值为4
|
||||
let tempUnit = 0;
|
||||
let tempValue = 0;
|
||||
if (bigNumA.unit == bigNumB.unit) {
|
||||
tempUnit = bigNumA.unit;
|
||||
tempValue = bigNumA.value + bigNumB.value;
|
||||
} else if (bigNumA.unit > bigNumB.unit) {
|
||||
if (bigNumA.unit - bigNumB.unit <= limit) {
|
||||
tempUnit = bigNumA.unit;
|
||||
tempValue = bigNumA.value + bigNumB.value / Math.pow(1000, bigNumA.unit - bigNumB.unit);
|
||||
} else if (bigNumA.unit - bigNumB.unit > limit) {
|
||||
tempUnit = bigNumA.unit;
|
||||
tempValue = bigNumA.value;
|
||||
}
|
||||
} else if (bigNumA.unit < bigNumB.unit) {
|
||||
if (bigNumB.unit - bigNumA.unit <= limit) {
|
||||
tempUnit = bigNumB.unit;
|
||||
tempValue = bigNumA.value / Math.pow(1000, bigNumB.unit - bigNumA.unit) + bigNumB.value;
|
||||
} else if (bigNumB.unit - bigNumA.unit > limit) {
|
||||
tempUnit = bigNumBB.unit;
|
||||
tempValue = bigNumB.value;
|
||||
}
|
||||
}
|
||||
return bigNumObj(tempUnit, tempValue);
|
||||
}
|
||||
|
||||
function bigNumSub (bigNumA, bigNumB) {
|
||||
let limit = 4; //限制字母单位差值为4
|
||||
let tempUnit = 0;
|
||||
let tempValue = 0;
|
||||
if (bigNumA.unit == bigNumB.unit) { //字符单位相等时
|
||||
if (bigNumA.unit == 0) {
|
||||
tempUnit = 0;
|
||||
tempValue = bigNumA.value - bigNumB.value;
|
||||
} else {
|
||||
if (bigNumA.value - bigNumB.value > 1) {
|
||||
tempUnit = bigNumA.unit;
|
||||
tempValue = bigNumA.value - bigNumB.value;
|
||||
} else {
|
||||
tempUnit = bigNumA.unit - 1;
|
||||
tempValue = (bigNumA.value - bigNumB.value) * 1000;
|
||||
}
|
||||
}
|
||||
} else if (bigNumA.unit > bigNumB.unit) {
|
||||
if (bigNumA.unit - bigNumB.unit <= limit) {
|
||||
tempUnit = bigNumA.unit;
|
||||
tempValue = bigNumA.value - bigNumB.value / Math.pow(1000, bigNumA.unit - bigNumB.unit);
|
||||
} else if (bigNumA.unit - bigNumB.unit > limit) {
|
||||
tempUnit = bigNumA.value;
|
||||
tempValue = bigNumA.value;
|
||||
}
|
||||
} else if (bigNumA.unit < bigNumB.unit) {
|
||||
if (bigNumB.unit - bigNumA.unit <= limit) {
|
||||
tempUnit = bigNumB.unit;
|
||||
tempValue = bigNumA.value / Math.pow(1000, bigNumB.unit - bigNumA.unit) - bigNumB.value;
|
||||
} else if (bigNumB.unit - bigNumA.unit > limit) {
|
||||
tempUnit = bigNumB.unit;
|
||||
tempValue = -bigNumB.value;
|
||||
}
|
||||
}
|
||||
return bigNumObj(tempUnit, tempValue);
|
||||
|
||||
}
|
||||
|
||||
function getBigChar (value) {
|
||||
let temp = "";
|
||||
switch (value) {
|
||||
case 1:
|
||||
temp = "K";
|
||||
break;
|
||||
case 2:
|
||||
temp = "M";
|
||||
break;
|
||||
case 3:
|
||||
temp = "B";
|
||||
break;
|
||||
case 4:
|
||||
temp = "T";
|
||||
break;
|
||||
case 5:
|
||||
temp = "aa";
|
||||
break;
|
||||
case 6:
|
||||
temp = "ab";
|
||||
break;
|
||||
case 7:
|
||||
temp = "ac";
|
||||
break;
|
||||
case 8:
|
||||
temp = "ad";
|
||||
break;
|
||||
case 9:
|
||||
temp = "ae";
|
||||
break;
|
||||
case 11:
|
||||
temp = "af";
|
||||
break;
|
||||
case 12:
|
||||
temp = "ag";
|
||||
break;
|
||||
case 13:
|
||||
temp = "ah";
|
||||
break;
|
||||
case 14:
|
||||
temp = "ai";
|
||||
break;
|
||||
case 15:
|
||||
temp = "aj";
|
||||
break;
|
||||
case 16:
|
||||
temp = "ak";
|
||||
break;
|
||||
case 17:
|
||||
temp = "al";
|
||||
break;
|
||||
case 18:
|
||||
temp = "am";
|
||||
break;
|
||||
case 19:
|
||||
temp = "an";
|
||||
break;
|
||||
case 20:
|
||||
temp = "ao";
|
||||
break;
|
||||
case 21:
|
||||
temp = "ap";
|
||||
break;
|
||||
case 22:
|
||||
temp = "aq";
|
||||
break;
|
||||
case 23:
|
||||
temp = "ar";
|
||||
break;
|
||||
case 24:
|
||||
temp = "as";
|
||||
break;
|
||||
case 25:
|
||||
temp = "at";
|
||||
break;
|
||||
case 26:
|
||||
temp = "au";
|
||||
break;
|
||||
case 27:
|
||||
temp = "av";
|
||||
break;
|
||||
case 26:
|
||||
temp = "aw";
|
||||
break;
|
||||
case 28:
|
||||
temp = "ax";
|
||||
break;
|
||||
case 29:
|
||||
temp = "ay";
|
||||
break;
|
||||
case 30:
|
||||
temp = "az";
|
||||
break;
|
||||
|
||||
default:
|
||||
temp = "";
|
||||
break;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将秒转化为 "00:02:30"
|
||||
* @param {*} value
|
||||
*/
|
||||
function formatSeconds (value) {
|
||||
let secondTime = parseInt(value); // 秒
|
||||
let minuteTime = 0; // 分
|
||||
let hourTime = 0; // 小时
|
||||
if (secondTime > 60) { //如果秒数大于60,将秒数转换成整数
|
||||
//获取分钟,除以60取整数,得到整数分钟
|
||||
minuteTime = parseInt(secondTime / 60);
|
||||
//获取秒数,秒数取佘,得到整数秒数
|
||||
secondTime = parseInt(secondTime % 60);
|
||||
//如果分钟大于60,将分钟转换成小时
|
||||
if (minuteTime > 60) {
|
||||
//获取小时,获取分钟除以60,得到整数小时
|
||||
hourTime = parseInt(minuteTime / 60);
|
||||
//获取小时后取佘的分,获取分钟除以60取佘的分
|
||||
minuteTime = parseInt(minuteTime % 60);
|
||||
}
|
||||
}
|
||||
if (secondTime < 10) {
|
||||
secondTime = "0" + secondTime;
|
||||
}
|
||||
if (minuteTime < 10) {
|
||||
minuteTime = "0" + minuteTime;
|
||||
}
|
||||
if (hourTime < 10) {
|
||||
hourTime = "0" + hourTime;
|
||||
}
|
||||
return hourTime + ":" + minuteTime + ":" + secondTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将秒转化为 "2.30"
|
||||
* @param {*} value
|
||||
*/
|
||||
function formatMilliSecond (value) {
|
||||
if (value > 3600) {
|
||||
return;
|
||||
}
|
||||
let milliSecondTime = parseInt(value); // 毫秒
|
||||
let secondTime = 0; // 秒
|
||||
if (milliSecondTime > 60) {
|
||||
secondTime = parseInt(milliSecondTime / 60);
|
||||
milliSecondTime = parseInt(milliSecondTime % 60);
|
||||
}
|
||||
|
||||
if (milliSecondTime < 10) {
|
||||
milliSecondTime = "0" + milliSecondTime;
|
||||
}
|
||||
return secondTime + ":" + milliSecondTime;
|
||||
}
|
||||
|
||||
|
||||
function stringTodo (str, len) {
|
||||
let reg = /[\u4e00-\u9fa5]/g,
|
||||
slice = str.substring(0, len),
|
||||
chineseCharNum = (~~(slice.match(reg) && slice.match(reg).length)),
|
||||
realen = slice.length * 2 - chineseCharNum;
|
||||
return str.substr(0, realen) + (realen < str.length ? "..." : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定范围的随机数,不包括最大值
|
||||
* @param {*} min
|
||||
* @param {*} max
|
||||
*/
|
||||
function getRandomInt (min, max) {
|
||||
return Math.floor(Math.random() * (max - min)) + min;
|
||||
}
|
||||
|
||||
function getRandom (min, max) {
|
||||
return Math.floor((Math.random() * (max - min) + min) * 100) / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成与指定数不相等的随机数
|
||||
* @param {*} min
|
||||
* @param {*} max
|
||||
* @param {*} random
|
||||
*/
|
||||
function getDistinctRandomInt (min, max, random) {
|
||||
var tempNum = getRandomInt(min, max);
|
||||
if (tempNum == random) {
|
||||
tempNum = getDistinctRandomInt(min, max, random);
|
||||
return tempNum;
|
||||
} else {
|
||||
return tempNum;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成与指定数组中不相等的随机数
|
||||
* @param {*} min
|
||||
* @param {*} max
|
||||
* @param {*} array
|
||||
*/
|
||||
function getDistinctRandomByArray (min, max, array) {
|
||||
var tempNum = getRandomInt(min, max);
|
||||
if (cc.js.array.contains(array, tempNum)) {
|
||||
tempNum = getRandomInt(min, max);
|
||||
return tempNum;
|
||||
} else {
|
||||
return tempNum;
|
||||
}
|
||||
}
|
||||
|
||||
function compareVersion (v1, v2) {
|
||||
v1 = v1.split('.');
|
||||
v2 = v2.split('.');
|
||||
let len = Math.max(v1.length, v2.length);
|
||||
|
||||
while (v1.length < len) {
|
||||
v1.push('0');
|
||||
}
|
||||
while (v2.length < len) {
|
||||
v2.push('0');
|
||||
}
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
let num1 = parseInt(v1[i]);
|
||||
let num2 = parseInt(v2[i]);
|
||||
|
||||
if (num1 > num2) {
|
||||
return 1;
|
||||
} else if (num1 < num2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
module.exports = {
|
||||
log: log,
|
||||
loadImgByUrl: loadImgByUrl,
|
||||
loadLocal: loadLocal,
|
||||
setImg: setImg,
|
||||
isArray: isArray,
|
||||
formatMilliSecond: formatMilliSecond,
|
||||
formatSeconds: formatSeconds,
|
||||
bigNumObj: bigNumObj,
|
||||
bigNum: bigNum,
|
||||
bigNumSub: bigNumSub,
|
||||
bigNumAdd: bigNumAdd,
|
||||
stringTodo: stringTodo,
|
||||
getBigChar: getBigChar,
|
||||
getRandomInt: getRandomInt,
|
||||
getRandom: getRandom,
|
||||
getDistinctRandomInt: getDistinctRandomInt,
|
||||
getDistinctRandomByArray: getDistinctRandomByArray,
|
||||
compareVersion: compareVersion,
|
||||
};
|
||||
9
WechatGame_login_v2/assets/Script/common/Utils.js.meta
Normal file
9
WechatGame_login_v2/assets/Script/common/Utils.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "255a02a6-8b4b-4789-9d17-5059b237d8ef",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
449
WechatGame_login_v2/assets/Script/common/WxApi.js
Normal file
449
WechatGame_login_v2/assets/Script/common/WxApi.js
Normal file
@@ -0,0 +1,449 @@
|
||||
/**
|
||||
* @author Javen
|
||||
* @copyright 2019-03-07 19:22:21 javendev@126.com
|
||||
* @description 微信接口
|
||||
*/
|
||||
let Global = require('../common/Global');
|
||||
|
||||
var WxApi = function () {
|
||||
|
||||
}
|
||||
|
||||
WxApi.prototype.initCloud = function (envId) {
|
||||
wx.cloud.init({
|
||||
env: envId,
|
||||
traceUser: true
|
||||
});
|
||||
|
||||
//初始化数据库
|
||||
Global.wxDb = wx.cloud.database({
|
||||
env: envId
|
||||
});
|
||||
|
||||
this.showShareMenu();
|
||||
this.onShareAppMessage();
|
||||
}
|
||||
|
||||
|
||||
WxApi.prototype.callFunction = function (funcName, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.cloud.callFunction({
|
||||
name: funcName,
|
||||
data: params || {},
|
||||
success: res => {
|
||||
resolve(res)
|
||||
console.log(`[云函数 ${funcName}] 调用成功: `, res);
|
||||
},
|
||||
fail: err => {
|
||||
resolve(null)
|
||||
console.log(`[云函数 ${funcName}] 调用失败: `, err);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
WxApi.prototype.getSetting = function (scope) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
if (res.authSetting[scope]) {
|
||||
resolve('已授权');
|
||||
} else {
|
||||
reject('未授权');
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
WxApi.prototype.getUserInfo = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
wx.getUserInfo({
|
||||
withCredentials: true,
|
||||
success(res) {
|
||||
resolve(res);
|
||||
},
|
||||
fail(error) {
|
||||
reject(error);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
WxApi.prototype.login = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
wx.login({
|
||||
success(res) {
|
||||
if (res.code) {
|
||||
resolve(res.code);
|
||||
} else {
|
||||
reject(res.errMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
reject('非微信环境');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
WxApi.prototype.createUserInfoBtnByImg = function (left, top, imgUrl, width, height, callBack) {
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
let button = wx.createUserInfoButton({
|
||||
type: imgUrl ? 'image' : 'text',
|
||||
image: imgUrl,
|
||||
text: imgUrl ? '' : '登录',
|
||||
style: {
|
||||
left: left,
|
||||
top: top,
|
||||
width: width,
|
||||
height: height,
|
||||
lineHeight: height * 0.5,
|
||||
backgroundColor: '',
|
||||
color: '#ffffff',
|
||||
textAlign: 'center',
|
||||
fontSize: 16,
|
||||
borderRadius: 4
|
||||
}
|
||||
});
|
||||
button.onTap((res) => {
|
||||
if (callBack) {
|
||||
callBack(res);
|
||||
}
|
||||
});
|
||||
button.show();
|
||||
return button;
|
||||
} else {
|
||||
console.log("createUserInfoBtnByImg 非微信环境...");
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.createFeedbackButtonByImg = function (left, top, imgUrl, width, height, callBack) {
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
|
||||
let button = wx.createFeedbackButton({
|
||||
type: 'image',
|
||||
image: imgUrl,
|
||||
style: {
|
||||
left: left,
|
||||
top: top,
|
||||
width: width,
|
||||
height: height,
|
||||
}
|
||||
});
|
||||
button.onTap((res) => {
|
||||
if (callBack) {
|
||||
callBack(res);
|
||||
}
|
||||
});
|
||||
button.show();
|
||||
return button;
|
||||
} else {
|
||||
console.log("createFeedbackButtonByImg 非微信环境...");
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.getShareInfo = function (title, imageUrl, openId) {
|
||||
if (!title) {
|
||||
title = '星星爱消除,牵手双人行';
|
||||
}
|
||||
if (!imageUrl) {
|
||||
imageUrl = "https://7265-release-8b47d-1259790919.tcb.qcloud.la/share/share2.png?sign=89e1b65cd3166ff6d9982923f617d3a1&t=1565297847";
|
||||
}
|
||||
let query = "";
|
||||
if (!openId) {
|
||||
query = 'openId=' + openId;
|
||||
}
|
||||
return {
|
||||
title: title,
|
||||
imageUrl: imageUrl,
|
||||
query: query,
|
||||
success(res) {
|
||||
console.log("分享完成...", res);
|
||||
},
|
||||
fail(res) {
|
||||
console.log("分享失败...", res);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
WxApi.prototype.showShareMenu = function () {
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
wx.showShareMenu({
|
||||
withShareTicket: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.onShareAppMessage = function (shareInfo) {
|
||||
if (!shareInfo) {
|
||||
shareInfo = this.getShareInfo();
|
||||
}
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
//转发·小程序
|
||||
wx.onShareAppMessage(function () {
|
||||
return shareInfo;
|
||||
});
|
||||
} else {
|
||||
console.log("onShareAppMessage 非微信环境...");
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.shareAppMessage = function (shareInfo) {
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
if (!shareInfo) {
|
||||
shareInfo = this.getShareInfo();
|
||||
}
|
||||
//主动分享
|
||||
wx.shareAppMessage(shareInfo);
|
||||
} else {
|
||||
console.log("shareAppMessage 非微信环境...");
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.showModal = function (title, content) {
|
||||
wx.showModal({
|
||||
title: title,
|
||||
content: content
|
||||
});
|
||||
}
|
||||
|
||||
WxApi.prototype.showLoading = function (title) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
wx.showLoading({
|
||||
title: title,
|
||||
mask: true,
|
||||
success(res) {
|
||||
resolve(res);
|
||||
},
|
||||
fail(error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
reject('非微信平台');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
WxApi.prototype.hideLoading = function () {
|
||||
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
wx.hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.showToast = function (msg) {
|
||||
wx.showToast({
|
||||
title: msg,
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
WxApi.prototype.loadVideoAd = function (adUnitId, cb) {
|
||||
if (!Global.videoAd && cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
let rewardedVideoAd = wx.createRewardedVideoAd({
|
||||
adUnitId: adUnitId
|
||||
});
|
||||
rewardedVideoAd.onLoad(() => {
|
||||
console.log('激励视频 广告加载成功');
|
||||
Global.videoAd = rewardedVideoAd;
|
||||
Global.videoAdLoadCount = 0;
|
||||
});
|
||||
// rewardedVideoAd.onClose(res => {
|
||||
// console.log('激励视频 广告关闭');
|
||||
// Global.videoAd = undefined;
|
||||
// });
|
||||
rewardedVideoAd.onError(err => {
|
||||
console.log('激励视频 广告加载失败');
|
||||
Global.viewAdLoadCount += 1;
|
||||
if (Global.viewAdLoadCount < 4) {
|
||||
rewardedVideoAd.load();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.loadBannerAd = function (adUnitId) {
|
||||
if (!Global.bannerAd && cc.sys.platform == cc.sys.WECHAT_GAME) {
|
||||
let frameSize = cc.view.getFrameSize();
|
||||
let bannerAd = wx.createBannerAd({
|
||||
adUnitId: adUnitId,
|
||||
style: {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: frameSize.width
|
||||
}
|
||||
});
|
||||
bannerAd.onError(err => {
|
||||
console.log('Banner 广告加载失败', err);
|
||||
Global.bannerAdLoadCount += 1;
|
||||
if (Global.bannerAdLoadCount < 4) {
|
||||
this.loadBannerAd();
|
||||
}
|
||||
});
|
||||
bannerAd.onLoad(() => {
|
||||
console.log('banner 广告加载成功');
|
||||
Global.bannerAd = bannerAd;
|
||||
this.showBannerAd();
|
||||
Global.viewAdLoadCount = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.showBannerAd = function () {
|
||||
if (Global.bannerAd) {
|
||||
let frameSize = cc.view.getFrameSize();
|
||||
Global.bannerAd.style.left = (frameSize.width - Global.bannerAd.style.width) / 2;
|
||||
Global.bannerAd.style.top = frameSize.height - Global.bannerAd.style.realHeight;
|
||||
Global.bannerAd.show();
|
||||
} else {
|
||||
this.loadBannerAd();
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.hideBannerAd = function () {
|
||||
if (Global.bannerAd) {
|
||||
// Global.bannerAd.hide();
|
||||
Global.bannerAd.destroy();
|
||||
Global.bannerAd = undefined;
|
||||
this.loadBannerAd();
|
||||
} else {
|
||||
console.log('不存在资源,无需关闭');
|
||||
}
|
||||
}
|
||||
|
||||
WxApi.prototype.post = function (postUrl, params) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
wx.request({
|
||||
url: postUrl,
|
||||
method: 'POST',
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
data: params || {},
|
||||
success: function (res) {
|
||||
resolve(res)
|
||||
console.log(`[post ${postUrl}] 调用成功: `, res);
|
||||
},
|
||||
fail: function (error) {
|
||||
reject(error);
|
||||
console.log(`[post ${postUrl}] 调用失败: `, error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
WxApi.prototype.setUserCloudStorage = function (score) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
wx.setUserCloudStorage({
|
||||
KVDataList: [{
|
||||
key: "score",
|
||||
value: score + ""
|
||||
}],
|
||||
success(res) {
|
||||
console.log("数据上报成功:", res);
|
||||
resolve(res);
|
||||
},
|
||||
fail(err) {
|
||||
console.log("数据上报失败:", err);
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log("数据上报完成");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
WxApi.prototype.uploadScore = function (score) {
|
||||
let that = this;
|
||||
// 1、查询成绩
|
||||
// 2、如果没有数据就添加
|
||||
// 3、如果有数据判断是否是新纪录
|
||||
return new Promise(function (resolve, reject) {
|
||||
Global.wxDb.collection('scores').where({
|
||||
_openid: Global.openId,
|
||||
}).get({
|
||||
success(res) {
|
||||
if (res.data.length > 0) {
|
||||
let data = res.data[0];
|
||||
let oldScore = data.score;
|
||||
|
||||
if (oldScore < score) {
|
||||
// 新纪录 更新
|
||||
Global.wxDb.collection('scores').doc(data._id).update({
|
||||
data: {
|
||||
score: score,
|
||||
updateDate: Global.wxDb.serverDate()
|
||||
},
|
||||
success(res) {
|
||||
that.setUserCloudStorage(score);
|
||||
// 新纪录
|
||||
resolve(1);
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
resolve(-1);
|
||||
}
|
||||
} else {
|
||||
// 无纪录添加数据
|
||||
Global.wxDb.collection('scores').add({
|
||||
data: {
|
||||
score: score,
|
||||
nickName: Global.nickName,
|
||||
avatarUrl: Global.avatarUrl,
|
||||
createDate: Global.wxDb.serverDate(),
|
||||
updateDate: Global.wxDb.serverDate()
|
||||
},
|
||||
success(res) {
|
||||
cc.log(res);
|
||||
that.setUserCloudStorage(score);
|
||||
// 新纪录
|
||||
resolve(1);
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
WxApi.prototype.showGameClub = function (visible) {
|
||||
if (!visible) {
|
||||
if (Global.clubButton) {
|
||||
Global.clubButton.hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (Global.clubButton) {
|
||||
Global.clubButton.show();
|
||||
return;
|
||||
}
|
||||
|
||||
let frameSize = cc.view.getFrameSize();
|
||||
Global.clubButton = wx.createGameClubButton({
|
||||
icon: 'green',
|
||||
style: {
|
||||
left: frameSize.width * 0.85,
|
||||
top: frameSize.height * 0.085,
|
||||
width: 40,
|
||||
height: 40
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = WxApi;
|
||||
9
WechatGame_login_v2/assets/Script/common/WxApi.js.meta
Normal file
9
WechatGame_login_v2/assets/Script/common/WxApi.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "fa215e04-93ca-473d-84da-c15bd2d56d8e",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
WechatGame_login_v2/assets/Texture.meta
Normal file
6
WechatGame_login_v2/assets/Texture.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
BIN
WechatGame_login_v2/assets/Texture/HelloWorld.png
Normal file
BIN
WechatGame_login_v2/assets/Texture/HelloWorld.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
34
WechatGame_login_v2/assets/Texture/HelloWorld.png.meta
Normal file
34
WechatGame_login_v2/assets/Texture/HelloWorld.png.meta
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"ver": "2.3.3",
|
||||
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"HelloWorld": {
|
||||
"ver": "1.0.4",
|
||||
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
|
||||
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 195,
|
||||
"height": 270,
|
||||
"rawWidth": 195,
|
||||
"rawHeight": 270,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
WechatGame_login_v2/assets/Texture/singleColor.png
Normal file
BIN
WechatGame_login_v2/assets/Texture/singleColor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 82 B |
34
WechatGame_login_v2/assets/Texture/singleColor.png.meta
Normal file
34
WechatGame_login_v2/assets/Texture/singleColor.png.meta
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"ver": "2.3.3",
|
||||
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"singleColor": {
|
||||
"ver": "1.0.4",
|
||||
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
|
||||
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 2,
|
||||
"height": 2,
|
||||
"rawWidth": 2,
|
||||
"rawHeight": 2,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
WechatGame_login_v2/assets/resources.meta
Normal file
7
WechatGame_login_v2/assets/resources.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "8dcfe823-04d3-4cd8-b45e-f07492f6dea2",
|
||||
"isSubpackage": false,
|
||||
"subpackageName": "",
|
||||
"subMetas": {}
|
||||
}
|
||||
BIN
WechatGame_login_v2/assets/resources/btn_l_idlogin.png
Normal file
BIN
WechatGame_login_v2/assets/resources/btn_l_idlogin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
34
WechatGame_login_v2/assets/resources/btn_l_idlogin.png.meta
Normal file
34
WechatGame_login_v2/assets/resources/btn_l_idlogin.png.meta
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"ver": "2.3.3",
|
||||
"uuid": "8b285b40-95bf-4935-a847-8ff15827ac9c",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"genMipmaps": false,
|
||||
"packable": true,
|
||||
"platformSettings": {},
|
||||
"subMetas": {
|
||||
"btn_l_idlogin": {
|
||||
"ver": "1.0.4",
|
||||
"uuid": "83c0eb26-0355-41d3-997a-74162dbb5450",
|
||||
"rawTextureUuid": "8b285b40-95bf-4935-a847-8ff15827ac9c",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 392,
|
||||
"height": 110,
|
||||
"rawWidth": 392,
|
||||
"rawHeight": 110,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
24667
WechatGame_login_v2/creator.d.ts
vendored
Normal file
24667
WechatGame_login_v2/creator.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
WechatGame_login_v2/jsconfig.json
Normal file
15
WechatGame_login_v2/jsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode",
|
||||
"library",
|
||||
"local",
|
||||
"settings",
|
||||
"temp"
|
||||
]
|
||||
}
|
||||
6
WechatGame_login_v2/project.json
Normal file
6
WechatGame_login_v2/project.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"engine": "cocos2d-html5",
|
||||
"packages": "packages",
|
||||
"version": "2.2.0",
|
||||
"id": "07aa9f2f-88ea-438d-a91f-8536757dcd41"
|
||||
}
|
||||
43
WechatGame_login_v2/settings/builder.json
Normal file
43
WechatGame_login_v2/settings/builder.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"orientation": {
|
||||
"landscapeLeft": true,
|
||||
"landscapeRight": true,
|
||||
"portrait": false,
|
||||
"upsideDown": false
|
||||
},
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "hello_world",
|
||||
"webOrientation": "auto",
|
||||
"includeSDKBox": false,
|
||||
"inlineSpriteFrames": true,
|
||||
"inlineSpriteFrames_native": true,
|
||||
"mergeStartScene": false,
|
||||
"optimizeHotUpdate": false,
|
||||
"md5Cache": false,
|
||||
"encryptJs": true,
|
||||
"xxteaKey": "7c97f22e-5349-4b",
|
||||
"zipCompressJs": true,
|
||||
"fb-instant-games": {},
|
||||
"android": {
|
||||
"packageName": "org.cocos2d.helloworld"
|
||||
},
|
||||
"ios": {
|
||||
"packageName": "org.cocos2d.helloworld"
|
||||
},
|
||||
"mac": {
|
||||
"packageName": "org.cocos2d.helloworld"
|
||||
},
|
||||
"win32": {},
|
||||
"android-instant": {
|
||||
"REMOTE_SERVER_ROOT": "",
|
||||
"host": "",
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"pathPattern": "",
|
||||
"recordPath": "",
|
||||
"scheme": "https",
|
||||
"skipRecord": false
|
||||
},
|
||||
"appBundle": false
|
||||
}
|
||||
7
WechatGame_login_v2/settings/builder.panel.json
Normal file
7
WechatGame_login_v2/settings/builder.panel.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"platform": "web-mobile",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "HelloWorld"
|
||||
}
|
||||
35
WechatGame_login_v2/settings/project.json
Normal file
35
WechatGame_login_v2/settings/project.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"collision-matrix": [
|
||||
[
|
||||
true
|
||||
]
|
||||
],
|
||||
"excluded-modules": [],
|
||||
"group-list": [
|
||||
"default"
|
||||
],
|
||||
"start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"design-resolution-width": 960,
|
||||
"design-resolution-height": 640,
|
||||
"fit-width": false,
|
||||
"fit-height": true,
|
||||
"use-project-simulator-setting": false,
|
||||
"simulator-orientation": false,
|
||||
"use-customize-simulator": false,
|
||||
"simulator-resolution": {
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"last-module-event-record-time": 1585378860833,
|
||||
"assets-sort-type": "name",
|
||||
"facebook": {
|
||||
"enable": false,
|
||||
"appID": "",
|
||||
"live": {
|
||||
"enable": false
|
||||
},
|
||||
"audience": {
|
||||
"enable": false
|
||||
}
|
||||
}
|
||||
}
|
||||
6
WechatGame_login_v2/settings/services.json
Normal file
6
WechatGame_login_v2/settings/services.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"game": {
|
||||
"name": "未知游戏",
|
||||
"appid": "UNKNOW"
|
||||
}
|
||||
}
|
||||
7
WechatGame_login_v2/settings/wechatgame.json
Normal file
7
WechatGame_login_v2/settings/wechatgame.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"appid": "wx6ac3f5090a6b99c5",
|
||||
"orientation": "portrait",
|
||||
"separate_engine": false,
|
||||
"REMOTE_SERVER_ROOT": "",
|
||||
"subContext": ""
|
||||
}
|
||||
BIN
WechatGame_login_v2/template-banner.png
Normal file
BIN
WechatGame_login_v2/template-banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
5
WechatGame_login_v2/template.json
Normal file
5
WechatGame_login_v2/template.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "TEMPLATES.helloworld.name",
|
||||
"desc": "TEMPLATES.helloworld.desc",
|
||||
"banner": "template-banner.png"
|
||||
}
|
||||
Reference in New Issue
Block a user