65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
|
|
import { _decorator, Button, Component, Label, Node, sys, Tween, tween, Vec3 } from 'cc';
|
|
import { LocalSaveMgr } from '../framework/data/LocalSaveMgr';
|
|
import { UIManager } from '../framework/ui/UIManager';
|
|
import { UISwitcher } from '../framework/ui/UISwitcher';
|
|
import { AudioMgr } from '../framework/audio/AudioMgr';
|
|
import { PanelBase } from '../framework/ui/PanelBase';
|
|
import { AssetController } from '../AssetController';
|
|
import { GameController } from '../GameController';
|
|
import { SdkMgr } from '../framework/sdk/SdkMgr';
|
|
import { WXSdk } from '../framework/sdk/WXSdk';
|
|
import { MainPanel } from './MainPanel';
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('SharePanel')
|
|
export class SharePanel extends PanelBase {
|
|
|
|
static instance: SharePanel;
|
|
|
|
@property({ type: Button })
|
|
shareBtn: Button = null;
|
|
|
|
@property({ type: Button })
|
|
closeBtn: Button = null;
|
|
|
|
onLoad() {
|
|
SharePanel.instance = this;
|
|
this.closeBtn.node.on(Button.EventType.CLICK, this.closeBtnCallBack, this);
|
|
this.shareBtn.node.on(Button.EventType.CLICK, this.shareCallBack, this);
|
|
}
|
|
|
|
activeShareBtn() {
|
|
const date: Date = new Date();
|
|
const dayOfMonth: number = date.getDate();
|
|
if (LocalSaveMgr.instance.playerData.day == dayOfMonth) {
|
|
this.shareBtn.node.active = false
|
|
} else {
|
|
this.shareBtn.node.active = true
|
|
}
|
|
}
|
|
|
|
shareCallBack() {
|
|
AudioMgr.inst.playOneShot(AssetController.instance.click)
|
|
if (sys.platform == sys.Platform.WECHAT_GAME)
|
|
WXSdk.instance.initativeShare()
|
|
let fromeMoney = LocalSaveMgr.instance.playerData.coin
|
|
LocalSaveMgr.instance.addCoin(200)
|
|
LocalSaveMgr.instance.setShareTime()
|
|
let endMoney = LocalSaveMgr.instance.playerData.coin
|
|
MainPanel.instance.flyShareMoney(fromeMoney, endMoney)
|
|
UIManager.instance.closePanel(SharePanel)
|
|
}
|
|
|
|
closeBtnCallBack(button: Button) {
|
|
AudioMgr.inst.playOneShot(AssetController.instance.click)
|
|
UIManager.instance.closePanel(SharePanel)
|
|
}
|
|
start() {
|
|
this.activeShareBtn()
|
|
}
|
|
}
|
|
|
|
|