| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import { _decorator, Component, Node, Sprite, Label, Animation, SystemEventType, SpriteFrame, ImageAsset, Texture2D } from 'cc';
- import { Http } from '../../core/net/Http';
- import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
- import { OpenWindow } from '../../core/ui/window/OpenWindow';
- import { WindowManager } from '../../core/ui/window/WindowManager';
- import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode';
- import { g } from '../../Data/g';
- import { ISJSB, platform } from '../../Data/platform';
- import { FsUtils } from '../../FsUtils/FsUtils';
- const { ccclass, property } = _decorator;
- @ccclass('ShenTaiRole')
- export class ShenTaiRole extends Component {
- @property({ type: Sprite, tooltip: "神将图片" })
- roleImg: Sprite;
- @property({ type: Node, tooltip: "好友头像组" })
- headGroup: Node;
- @property({ type: Sprite, tooltip: "好友头像" })
- friendHead: Sprite;
- @property({ type: Label, tooltip: "好友名称" })
- friendName: Label;
- @property({ type: Label, tooltip: "好友贡献" })
- contribute: Label;
- @property({ type: Node, tooltip: "奖励信息组" })
- giftGroup: Node;
- @property({ type: Label, tooltip: "奖励信息" })
- giftNum: Label;
- @property({ type: Animation, tooltip: "神将台动画" })
- animation: Animation;
- @property({ tooltip: "是否播放动画" })
- isPlayAaimation: Boolean = true;
- userInfoWin: OpenWindow;
- @property({ type: Http, tooltip: "消息控制" })
- http: Http;
- public data: any;
- private friednLv: number = 0;
- start() {
- if (this.isPlayAaimation) {
- this.scheduleOnce(() => {
- this.animation.play();
- }, Math.random());
- }
- }
- public async onInvite() {
- //邀请
- let result = await this.http.send("/api/app/share", {});
- if (result.code == 0) {
- platform.wxShare(result.data.url, result.data.title, result.data.descroption);
- } else {
- WindowManager.showTips("分享信息获取失败,请稍后再试");
- }
- }
- public async selectFriendInfo() {
- WindowManager.open("Prefabs/Friend/FriendInfoWindow", WindowOpenMode.NotCloseAndAdd, { friednLv: this.friednLv, data: this.data });
- }
- public async setData(data?: any, friendLv?: number) {
- if (data) {
- this.friednLv = friendLv;
- this.data = data;
- this.headGroup.active = true;
- this.contribute.node.active = true;
- this.roleImg.node.active = true;
- this.data.totalRevenueAmount = this.data.totalRevenueAmount || 0;
- this.contribute.string = '总贡献:' + this.data.totalRevenueAmount.toFixed(0);
- this.giftGroup.active = this.data.revenueAmount > 0;
- this.data.revenueAmount = this.data.revenueAmount || 0;
- this.giftNum.string = this.data.revenueAmount.toFixed(0);
- let lv = this.data.lv ? this.data.lv : 1;
- this.friendName.string = this.data.nickname;
- this.roleImg.spriteFrame = await ResourcesUtils.load(`Roles/${lv}/spriteFrame`, SpriteFrame, this.node);
- if (ISJSB && data.avatar) {
- let img = await ResourcesUtils.loadRemote<ImageAsset>(data.avatar, { ext: ".png" }, this);
- const spriteFrame = new SpriteFrame();
- const texture = new Texture2D();
- texture.image = img;
- spriteFrame.texture = texture;
- this.friendHead.spriteFrame = spriteFrame;
- }
- } else {
- this.headGroup.active = false;
- this.contribute.node.active = false;
- }
- }
- //领取贡献
- private async getContribute() {
- let result = await this.http.send("/api/fission/ReceiveFission", { receiveUserID: this.data.userID });
- if (!result.code) {//
- g.userData.contribution += result.data.addTotalContribution;
- g.gameData.updateMyFessiongDatas([{ userID: this.data.userID }], false);
- WindowManager.showTips('贡献领取成功');
- this.giftGroup.active = false;
- } else {
- WindowManager.showTips(g.CodeMsg[result.code]);
- }
- }
- }
|