| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- cc.Class({
- extends: cc.Component,
- properties: {
- GoldenLabel: cc.Node,
- Diamondlabel: {
- default: null,
- type: cc.Node,
- },
- ManageUI: cc.Node,
- //5个神农呗兑1个cnt
- CNTNode: {
- default: null,
- type: cc.Node,
- },
- SNBNode: {
- default: null,
- type: cc.Node,
- },
- },
- InitManageGlodenUI() {
- this.GoldenLabel.getComponent(cc.Label).string = this.formatPrice(
- GlobalD.GameData.GetGolden().toString()
- )
- this.Diamondlabel.getComponent(cc.Label).string = this.formatPrice(
- GlobalD.GameData.GetDiamond().toString()
- )
- this.CNTNode.getComponent(cc.Label).string = this.formatPrice(
- GlobalD.GameData.GetCNT().toString()
- )
- // console.log(" GlobalD.GameData.GetSNB() = ", GlobalD.GameData.GetSNB());
- this.SNBNode.getComponent(cc.Label).string = this.formatPrice(
- GlobalD.GameData.GetSNB().toString()
- )
- },
- formatPrice(price) {
- return String(price).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
- },
- FormatMoney(s, n) {
- n = n > 0 && n <= 20 ? n : 2
- s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + ''
- var l = s.split('.')[0].split('').reverse(),
- r = s.split('.')[1]
- let t = ''
- for (let i = 0; i < l.length; i++) {
- t += l[i] + ((i + 1) % 3 == 0 && i + 1 != l.length ? ',' : '')
- }
- return t.split('').reverse().join('') //+ "." + r;
- },
- })
|