|
@@ -3,6 +3,8 @@ import BaseUI from "../../scripts/base/BaseUI";
|
|
|
import { Hall } from "../hall/Hall";
|
|
|
import { RichText } from "cc";
|
|
|
import { Label } from "cc";
|
|
|
+import PayM from "../../scripts/mgr/PayM";
|
|
|
+import ShareM from "../../scripts/mgr/ShareM";
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
export class TipsData {
|
|
@@ -13,6 +15,7 @@ export class TipsData {
|
|
|
onCancel: () => void = null;
|
|
|
singleName: string = "";
|
|
|
link: string = null;
|
|
|
+ shareLink: string = null;
|
|
|
}
|
|
|
|
|
|
export interface OnConfirm {
|
|
@@ -21,7 +24,11 @@ export interface OnConfirm {
|
|
|
|
|
|
@ccclass("TipsLayer")
|
|
|
export class TipsLayer extends BaseUI {
|
|
|
- static confirm(title: string, content: string): Promise<boolean> {
|
|
|
+ static confirm(
|
|
|
+ title: string,
|
|
|
+ content: string,
|
|
|
+ shareLink: string = null
|
|
|
+ ): Promise<boolean> {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let tipsData: TipsData = {
|
|
|
title: title,
|
|
@@ -36,14 +43,14 @@ export class TipsLayer extends BaseUI {
|
|
|
},
|
|
|
forceConfirm: true,
|
|
|
singleName: null,
|
|
|
+ shareLink: shareLink,
|
|
|
};
|
|
|
TipsLayer.show(tipsData);
|
|
|
});
|
|
|
}
|
|
|
- private onConfirm: OnConfirm = null;
|
|
|
private static single: Map<string, Node> = new Map();
|
|
|
static async show(data: TipsData): Promise<TipsLayer> {
|
|
|
- if (data.singleName) {
|
|
|
+ if (data.singleName && data.singleName != "") {
|
|
|
if (TipsLayer.single.has(data.singleName)) {
|
|
|
return TipsLayer.single.get(data.singleName).getComponent(TipsLayer);
|
|
|
}
|
|
@@ -52,7 +59,7 @@ export class TipsLayer extends BaseUI {
|
|
|
let layer = await Hall.ins.showLayer("prefab/layer/TipsLayer");
|
|
|
let comp = layer.getComponent(TipsLayer);
|
|
|
comp.init(data);
|
|
|
- if (data.singleName) {
|
|
|
+ if (data.singleName && data.singleName != "") {
|
|
|
TipsLayer.single.set(data.singleName, layer);
|
|
|
}
|
|
|
return comp;
|
|
@@ -76,21 +83,25 @@ export class TipsLayer extends BaseUI {
|
|
|
private data: TipsData;
|
|
|
init(data: TipsData) {
|
|
|
this.data = data;
|
|
|
+ let self = this;
|
|
|
if (data.title == null || data.title == "") {
|
|
|
this.FindNode("lbl_title").active = false;
|
|
|
} else {
|
|
|
this.setText("lbl_title", data.title);
|
|
|
}
|
|
|
- // this.setText("lbl_content", data.content);
|
|
|
|
|
|
this.FindAs("lbl_content", RichText).string = data.content;
|
|
|
|
|
|
if (data.forceConfirm) {
|
|
|
- this.FindNode("tap_close").active = false;
|
|
|
- this.FindNode("btn_close").active = false;
|
|
|
- this.FindNode("btn_close_button").active = false;
|
|
|
+ setTimeout(() => {
|
|
|
+ self.FindNode("tap_close").active = false;
|
|
|
+ self.FindNode("btn_close").active = false;
|
|
|
+ self.FindNode("btn_close_button").active = false;
|
|
|
+ }, 500);
|
|
|
}
|
|
|
|
|
|
+ this.FindNode("btn_share").active = data.shareLink && data.shareLink != "";
|
|
|
+
|
|
|
this.FindNode("btn_link").active = data.link != null;
|
|
|
this.FindNode("btn_link").getComponent(Label).string = data.link;
|
|
|
// this.setText("btn_link", data.link);
|
|
@@ -112,6 +123,12 @@ export class TipsLayer extends BaseUI {
|
|
|
this.data?.onConfirm?.();
|
|
|
this.closePage();
|
|
|
}
|
|
|
+
|
|
|
+ switch (name) {
|
|
|
+ case "btn_share":
|
|
|
+ ShareM.ins.share(this.data.shareLink);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
protected onDestroy(): void {
|
|
|
if (this.data?.singleName) {
|