头像增加icon

This commit is contained in:
cebgcontract 2022-06-21 15:54:48 +08:00
parent 3e30c18d2f
commit 670f9d95c5
3 changed files with 716 additions and 526 deletions

View File

@ -27,20 +27,23 @@
}, },
{ {
"__id__": 13 "__id__": 13
},
{
"__id__": 16
} }
], ],
"_active": true, "_active": true,
"_level": 1, "_level": 1,
"_components": [ "_components": [
{ {
"__id__": 16 "__id__": 19
}, },
{ {
"__id__": 17 "__id__": 20
} }
], ],
"_prefab": { "_prefab": {
"__id__": 18 "__id__": 21
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -226,7 +229,7 @@
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_level": 5, "_level": 2,
"_components": [ "_components": [
{ {
"__id__": 7 "__id__": 7
@ -331,7 +334,108 @@
"asset": { "asset": {
"__uuid__": "e4b00542-5961-4a6a-8ae5-c19d30ac84a2" "__uuid__": "e4b00542-5961-4a6a-8ae5-c19d30ac84a2"
}, },
"fileId": "1a8x2zZmNOU6glyFKwUfHp", "fileId": "fd0Vfdt29Jh45d3VK9MwnT",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "rect-line",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 11
}
],
"_prefab": {
"__id__": 12
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 46,
"height": 46
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": -180,
"y": 0,
"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,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
},
"_enabled": true,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "f8a72ecb-343d-4c53-9429-112006b05c75"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_state": 0,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "e4b00542-5961-4a6a-8ae5-c19d30ac84a2"
},
"fileId": "76S2+7P2NLToxBZanaF82q",
"sync": false "sync": false
}, },
{ {
@ -346,11 +450,11 @@
"_level": 5, "_level": 5,
"_components": [ "_components": [
{ {
"__id__": 11 "__id__": 14
} }
], ],
"_prefab": { "_prefab": {
"__id__": 12 "__id__": 15
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -401,7 +505,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 10 "__id__": 13
}, },
"_enabled": true, "_enabled": true,
"_useOriginalSize": false, "_useOriginalSize": false,
@ -444,11 +548,11 @@
"_level": 5, "_level": 5,
"_components": [ "_components": [
{ {
"__id__": 14 "__id__": 17
} }
], ],
"_prefab": { "_prefab": {
"__id__": 15 "__id__": 18
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -499,7 +603,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 13 "__id__": 16
}, },
"_enabled": true, "_enabled": true,
"_useOriginalSize": false, "_useOriginalSize": false,
@ -567,10 +671,10 @@
}, },
"_enabled": true, "_enabled": true,
"symbolLabel": { "symbolLabel": {
"__id__": 11 "__id__": 14
}, },
"countLabel": { "countLabel": {
"__id__": 14 "__id__": 17
}, },
"icon": { "icon": {
"__id__": 7 "__id__": 7

View File

@ -33,20 +33,19 @@ export default class OneToken extends WalletBase {
this.data = _data this.data = _data
} }
private updateInfo() { private async updateInfo() {
if (this.data.symbol) { if (this.data.symbol) {
this.symbolLabel.string = this.data.symbol this.symbolLabel.string = this.data.symbol
} else { } else {
// TODO: get from remote // TODO: get from remote
let symbol = await this.wallet.erc20Standard.getTokenSymbol(this.data.address)
this.data.symbol = symbol
} }
this.icon.init(this.data.address) this.icon.init(this.data.address)
if (this.data.decimal === undefined && this.data.type !== ETH_TYPE) { if (this.data.decimal === undefined && this.data.type !== ETH_TYPE) {
// get from chain // get from chain
this.wallet.erc20Standard.getTokenDecimals(this.data.address) let decimal = await this.wallet.erc20Standard.getTokenDecimals(this.data.address)
.then(sysmbol => { this.data.decimal = parseInt(decimal)
this.data.symbol = sysmbol
this.showBalance()
})
} }
if (this.data.balance !== undefined) { if (this.data.balance !== undefined) {
@ -55,19 +54,15 @@ export default class OneToken extends WalletBase {
this.countLabel.string = '-' this.countLabel.string = '-'
} }
if (this.data.type === ETH_TYPE) { if (this.data.type === ETH_TYPE) {
this.wallet.getBalance() let balance = await this.wallet.getBalance()
.then(balance => {
this.data.balance = balance this.data.balance = balance
this.showBalance()
})
} else { } else {
const account = this.wallet.currentAccount().address const account = this.wallet.currentAccount().address
this.wallet.erc20Standard.getBalanceOf(this.data.address, account) let balance = await this.wallet.erc20Standard.getBalanceOf(this.data.address, account)
.then(balance => {
this.data.balance = balance this.data.balance = balance
this.showBalance()
})
} }
this.showBalance()
} }
private showBalance() { private showBalance() {

File diff suppressed because it is too large Load Diff