Commit 424be25b authored by liujiangnan's avatar liujiangnan

feat: 金币

parent 6359057d
...@@ -81,19 +81,19 @@ ...@@ -81,19 +81,19 @@
"__id__": 41 "__id__": 41
}, },
{ {
"__id__": 49 "__id__": 53
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 80 "__id__": 84
}, },
{ {
"__id__": 81 "__id__": 85
}, },
{ {
"__id__": 82 "__id__": 86
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2007,18 +2007,21 @@ ...@@ -2007,18 +2007,21 @@
}, },
{ {
"__id__": 44 "__id__": 44
},
{
"__id__": 46
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 46 "__id__": 50
}, },
{ {
"__id__": 47 "__id__": 51
}, },
{ {
"__id__": 48 "__id__": 52
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2155,7 +2158,7 @@ ...@@ -2155,7 +2158,7 @@
"_isSystemFontUsed": true, "_isSystemFontUsed": true,
"_spacingX": 0, "_spacingX": 0,
"_batchAsBitmap": false, "_batchAsBitmap": false,
"_styleFlags": 0, "_styleFlags": 1,
"_underlineHeight": 0, "_underlineHeight": 0,
"_N$horizontalAlign": 0, "_N$horizontalAlign": 0,
"_N$verticalAlign": 1, "_N$verticalAlign": 1,
...@@ -2258,6 +2261,199 @@ ...@@ -2258,6 +2261,199 @@
"_atlas": null, "_atlas": null,
"_id": "93AkchfING+49fJM2+uZLo" "_id": "93AkchfING+49fJM2+uZLo"
}, },
{
"__type__": "cc.Node",
"_name": "goldBg",
"_objFlags": 0,
"_parent": {
"__id__": 41
},
"_children": [
{
"__id__": 47
}
],
"_active": true,
"_components": [
{
"__id__": 49
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 267,
"height": 51
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
208.087,
-21.783,
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": "a7fpWuiAhEi5GesBeiaBj5"
},
{
"__type__": "cc.Node",
"_name": "goldLabel",
"_objFlags": 0,
"_parent": {
"__id__": 46
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 48
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 22.25,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
4.156,
-1.039,
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": "91ogOmqLNM4bVdCa/jZWX9"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 47
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "0",
"_N$string": "0",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "200w9NIntGE7LmsqEqObdU"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 46
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "440ac7d0-d364-4c1c-9bae-09297f0d8ca1"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "6duHpdMAJDoYH38Mtoqigr"
},
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
...@@ -2396,19 +2592,19 @@ ...@@ -2396,19 +2592,19 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 50 "__id__": 54
}, },
{ {
"__id__": 54 "__id__": 58
}, },
{ {
"__id__": 75 "__id__": 79
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 79 "__id__": 83
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2464,19 +2660,19 @@ ...@@ -2464,19 +2660,19 @@
"_name": "bg", "_name": "bg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 49 "__id__": 53
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 51 "__id__": 55
}, },
{ {
"__id__": 52 "__id__": 56
}, },
{ {
"__id__": 53 "__id__": 57
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2532,7 +2728,7 @@ ...@@ -2532,7 +2728,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 50 "__id__": 54
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2564,7 +2760,7 @@ ...@@ -2564,7 +2760,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 50 "__id__": 54
}, },
"_enabled": true, "_enabled": true,
"alignMode": 2, "alignMode": 2,
...@@ -2591,7 +2787,7 @@ ...@@ -2591,7 +2787,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 50 "__id__": 54
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -2659,32 +2855,32 @@ ...@@ -2659,32 +2855,32 @@
"_name": "frame", "_name": "frame",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 49 "__id__": 53
}, },
"_children": [ "_children": [
{ {
"__id__": 55 "__id__": 59
},
{
"__id__": 57
}, },
{ {
"__id__": 61 "__id__": 61
}, },
{ {
"__id__": 63 "__id__": 65
}, },
{ {
"__id__": 65 "__id__": 67
}, },
{ {
"__id__": 69 "__id__": 69
},
{
"__id__": 73
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 74 "__id__": 78
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2740,13 +2936,13 @@ ...@@ -2740,13 +2936,13 @@
"_name": "headBack", "_name": "headBack",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 54 "__id__": 58
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 56 "__id__": 60
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2802,7 +2998,7 @@ ...@@ -2802,7 +2998,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 55 "__id__": 59
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2834,17 +3030,17 @@ ...@@ -2834,17 +3030,17 @@
"_name": "mask", "_name": "mask",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 54 "__id__": 58
}, },
"_children": [ "_children": [
{ {
"__id__": 58 "__id__": 62
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 60 "__id__": 64
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2900,13 +3096,13 @@ ...@@ -2900,13 +3096,13 @@
"_name": "headImg", "_name": "headImg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 57 "__id__": 61
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 59 "__id__": 63
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2962,7 +3158,7 @@ ...@@ -2962,7 +3158,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 58 "__id__": 62
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2994,7 +3190,7 @@ ...@@ -2994,7 +3190,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 57 "__id__": 61
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3016,13 +3212,13 @@ ...@@ -3016,13 +3212,13 @@
"_name": "headTop", "_name": "headTop",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 54 "__id__": 58
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 62 "__id__": 66
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3078,7 +3274,7 @@ ...@@ -3078,7 +3274,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 61 "__id__": 65
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3110,13 +3306,13 @@ ...@@ -3110,13 +3306,13 @@
"_name": "nickname", "_name": "nickname",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 54 "__id__": 58
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 64 "__id__": 68
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3172,7 +3368,7 @@ ...@@ -3172,7 +3368,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 63 "__id__": 67
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3205,17 +3401,17 @@ ...@@ -3205,17 +3401,17 @@
"_name": "goldBg", "_name": "goldBg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 54 "__id__": 58
}, },
"_children": [ "_children": [
{ {
"__id__": 66 "__id__": 70
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 68 "__id__": 72
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3271,13 +3467,13 @@ ...@@ -3271,13 +3467,13 @@
"_name": "goldNumber", "_name": "goldNumber",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 65 "__id__": 69
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 67 "__id__": 71
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3333,7 +3529,7 @@ ...@@ -3333,7 +3529,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 66 "__id__": 70
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3366,7 +3562,7 @@ ...@@ -3366,7 +3562,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 65 "__id__": 69
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3398,20 +3594,20 @@ ...@@ -3398,20 +3594,20 @@
"_name": "BtnLogout", "_name": "BtnLogout",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 54 "__id__": 58
}, },
"_children": [ "_children": [
{ {
"__id__": 70 "__id__": 74
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 72 "__id__": 76
}, },
{ {
"__id__": 73 "__id__": 77
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3467,13 +3663,13 @@ ...@@ -3467,13 +3663,13 @@
"_name": "New Label", "_name": "New Label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 69 "__id__": 73
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 71 "__id__": 75
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3529,7 +3725,7 @@ ...@@ -3529,7 +3725,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 70 "__id__": 74
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3562,7 +3758,7 @@ ...@@ -3562,7 +3758,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 69 "__id__": 73
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3594,7 +3790,7 @@ ...@@ -3594,7 +3790,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 69 "__id__": 73
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -3662,7 +3858,7 @@ ...@@ -3662,7 +3858,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 54 "__id__": 58
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3694,19 +3890,19 @@ ...@@ -3694,19 +3890,19 @@
"_name": "btnClose", "_name": "btnClose",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 49 "__id__": 53
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 76 "__id__": 80
}, },
{ {
"__id__": 77 "__id__": 81
}, },
{ {
"__id__": 78 "__id__": 82
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3762,7 +3958,7 @@ ...@@ -3762,7 +3958,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 75 "__id__": 79
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3794,7 +3990,7 @@ ...@@ -3794,7 +3990,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 75 "__id__": 79
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -3862,7 +4058,7 @@ ...@@ -3862,7 +4058,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 75 "__id__": 79
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -3889,7 +4085,7 @@ ...@@ -3889,7 +4085,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 49 "__id__": 53
}, },
"_enabled": true, "_enabled": true,
"alignMode": 2, "alignMode": 2,
......
...@@ -64,39 +64,45 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -64,39 +64,45 @@ export default class SceneComponent extends MyCocosSceneComponent {
const kidInfo = await middleLayer.getComponent('middleLayer').getUserInfo(); const kidInfo = await middleLayer.getComponent('middleLayer').getUserInfo();
if (kidInfo.nick_name) { if (kidInfo.nick_name) {
cc.find("Canvas/avatar_border/nick_name").getComponent(cc.Label).string = kidInfo.nick_name; cc.find("Canvas/avatar_border/nick_name").getComponent(cc.Label).string = kidInfo.nick_name;
const golds = await this.getGolds(kidInfo);
cc.find('Canvas/avatar_border/goldBg/goldLabel').getComponent(cc.Label).string = golds+"";
} }
const avatarUrl = middleLayer.getComponent('middleLayer').getHeadUrl(kidInfo.avatar_url || kidInfo.id); const avatarUrl = middleLayer.getComponent('middleLayer').getHeadUrl(kidInfo.avatar_url || kidInfo.id);
getSpriteFrimeByUrl(avatarUrl, (spriteFrame) => { getSpriteFrimeByUrl(avatarUrl, (spriteFrame) => {
cc.find("Canvas/avatar_border/defaulte_avatar").getComponent(cc.Sprite).spriteFrame = spriteFrame; cc.find("Canvas/avatar_border/defaulte_avatar").getComponent(cc.Sprite).spriteFrame = spriteFrame;
}); });
this.initUserInfoView(); this.initUserInfoView(kidInfo);
} }
async initUserInfoView() { async getGolds(kidInfo) {
const goldDataStr = await asyncCallNetworkApiGet(`/api/oxford/v1/kid/${kidInfo.id}/golds`, {
token: cc.sys.localStorage.getItem('token')
});
if (goldDataStr) {
return JSON.parse(goldDataStr).data;
}
return 0;
}
async initUserInfoView(kidInfo) {
const middleLayer = cc.find('middleLayer'); const middleLayer = cc.find('middleLayer');
if (!middleLayer) { if (!middleLayer) {
return; return;
} }
const middleLayerComponent = middleLayer.getComponent('middleLayer'); const middleLayerComponent = middleLayer.getComponent('middleLayer');
const userInfo = await middleLayerComponent.getUserInfo();
console.log('userInfo = ', userInfo);
const goldDataStr = await asyncCallNetworkApiGet(`/api/oxford/v1/kid/${userInfo.id}/golds`, { const golds = await this.getGolds(kidInfo);
token: cc.sys.localStorage.getItem('token')
});
console.log('goldDataStr = ', goldDataStr);
const goldData = JSON.parse(goldDataStr);
const goldNumber = cc.find('Canvas/userInfo/frame/goldBg/goldNumber'); const goldNumber = cc.find('Canvas/userInfo/frame/goldBg/goldNumber');
goldNumber.getComponent(cc.Label).string = goldData.data; goldNumber.getComponent(cc.Label).string = golds+"";
const nickname = cc.find('Canvas/userInfo/frame/nickname'); const nickname = cc.find('Canvas/userInfo/frame/nickname');
if (userInfo.nick_name) { if (kidInfo.nick_name) {
nickname.getComponent(cc.Label).string = userInfo.nick_name; nickname.getComponent(cc.Label).string = kidInfo.nick_name;
} }
if (userInfo.avatar_url) { } if (kidInfo.avatar_url) { }
const headUrl = middleLayerComponent.getHeadUrl(userInfo.avatar_url || userInfo.id); const headUrl = middleLayerComponent.getHeadUrl(kidInfo.avatar_url || kidInfo.id);
const headImg = cc.find('Canvas/userInfo/frame/mask/headImg'); const headImg = cc.find('Canvas/userInfo/frame/mask/headImg');
cc.assetManager.loadRemote(headUrl, (err, tex) => { cc.assetManager.loadRemote(headUrl, (err, tex) => {
headImg.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(tex); headImg.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(tex);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 718, "width": 718,
"height": 518, "height": 485,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"frame": { "frame": {
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 648, "width": 86,
"height": 209, "height": 108,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"headImg": { "headImg": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment