Commit b455e75d authored by haiyoucuv's avatar haiyoucuv

整理一下代码

parent 3ef0cea9
......@@ -114,8 +114,10 @@ export class HomeScene extends Scene {
Tween.stopAllByTarget(this.startBtn);
}
if (rank === 0 || rank === -1 || rank > 999) {
this.currentRankLabel.string = '999+';
if (rank === 0 || rank === -1) {
this.currentRankLabel.string = '-';
} else if (rank > 1000) {
this.currentRankLabel.string = '1000+';
} else {
this.currentRankLabel.string = `${rank}`;
}
......@@ -165,7 +167,7 @@ export class HomeScene extends Scene {
/** 奖励排行 */
clickRank = async () => {
await changeScene(RankScene)
await changeScene(RankScene);
}
/** 任务 */
......@@ -201,16 +203,14 @@ export class HomeScene extends Scene {
/** 规则 */
clickRule = async () => {
showPanel(RulePanel)
showPanel(RulePanel);
}
/** 返回 */
clickShare = async () => {
if (!this.checkActStatus()) return false;
}
update(deltaTime: number) {
}
}
import { _decorator, Label, Node, view, Widget, UITransform, Prefab, instantiate, assetManager, ImageAsset, SpriteFrame, Texture2D, Sprite, UIOpacity } from "cc";
import {
_decorator,
Label,
Node,
view,
Widget,
UITransform,
Prefab,
instantiate,
assetManager,
ImageAsset,
SpriteFrame,
Texture2D,
Sprite,
UIOpacity
} from "cc";
import Scene from "db://assets/Module/Scene";
import { changeScene } from "db://assets/Module/UIFast";
import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene";
import { ScrollList, SCROLL_VERTICAL } from "db://assets/Scripts/ScrollList/ScrollList";
import { strFormat } from "db://assets/Scripts/Utils/Utils";
import { sendWebNet, WebNetName } from "db://assets/Scripts/Utils/WebNet/WebNet";
const { ccclass, property } = _decorator;
const {ccclass, property} = _decorator;
@ccclass("RankScene")
export class RankScene extends Scene {
static skin: string = "RankScene";
static group: string[] = ["RankScene"];
static skin: string = "RankScene";
static group: string[] = ["RankScene"];
@property({ type: ScrollList, tooltip: "竖行滚动容器" })
private vScroll: ScrollList;
@property({type: ScrollList, tooltip: "竖行滚动容器"})
private vScroll: ScrollList;
/** 排行榜类别 */
private _type: string = "2";
/** 排行榜类别 */
private _type: string = "2";
get type() {
return this._type;
}
get type() {
return this._type;
}
set type(type: string) {
this._type = type;
}
set type(type: string) {
this._type = type;
}
/** 我的排名 */
@property(Node)
myRnak: Node = null;
/** 我的排名 */
@property(Node)
myRnak: Node = null;
/** 奖品展览区域 */
@property(Node)
prizeBox: Node = null;
/** 奖品展览区域 */
@property(Node)
prizeBox: Node = null;
/** 奖品对象 */
@property(Prefab)
prizeItem: Prefab = null;
/** 奖品对象 */
@property(Prefab)
prizeItem: Prefab = null;
onLoad() {
}
onLoad() {
}
start() {
console.log("%c RankScene", "font-size: 20px");
this.getRankInfo();
}
start() {
console.log("%c RankScene", "font-size: 20px");
this.getRankInfo();
}
/** 排名处理 */
rankIndexFormat(rank) {
if (rank == 0 || !!!rank) {
return "999+";
/** 排名处理 */
rankIndexFormat(rank) {
if (rank > 1000) {
return "1000+";
}
if (rank == -1 || rank == 0 || !!!rank) {
return "-";
}
return rank;
}
if (rank == -1) {
return "999+"
/** 获取排行榜首页信息 */
async getRankInfo() {
const res = await sendWebNet(WebNetName.rank, {type: this.type});
const {success, data} = res;
const {myRank, myRankScore, myNickName, rankInfo = [], prizeInfo = []} = data || {};
if (success) {
/** 我的排名 - 更新 */
this.myRnak.getChildByName("MyRankIndex").getComponent(Label).string = `${this.rankIndexFormat(myRank)}`;
this.myRnak.getChildByName("MyCredits").getComponent(Label).string = `${myRankScore > 99999 ? "99999+" : myRankScore}`;
this.myRnak.getChildByName("MyName").getComponent(Label).string = `${strFormat(myNickName || "", 12)}(我)`;
/** 排行榜渲染 */
this.rankRender(rankInfo);
/** 奖品区域渲染 */
this.prizeRender(prizeInfo);
}
}
return rank;
}
/** 获取排行榜首页信息 */
async getRankInfo() {
const res = await sendWebNet(WebNetName.rank, {type: this.type});
const { success, data } = res;
const { myRank, myRankScore, myNickName, rankInfo = [], prizeInfo = [] } = data || {};
if (success) {
/** 我的排名 - 更新 */
this.myRnak.getChildByName("MyRankIndex").getComponent(Label).string = `${this.rankIndexFormat(myRank)}`;
this.myRnak.getChildByName("MyCredits").getComponent(Label).string = `${myRankScore > 99999? "99999+": myRankScore}`;
this.myRnak.getChildByName("MyName").getComponent(Label).string = `${strFormat(myNickName || "", 12)}(我)`;
/** 排行榜渲染 */
this.rankRender(rankInfo);
/** 奖品区域渲染 */
this.prizeRender(prizeInfo);
/** 排行榜渲染 */
rankRender(rankInfo = []) {
this.vScroll.setDataList(rankInfo, SCROLL_VERTICAL, [0, 0, 0]);
this.vScroll.scrollToTop(0);
}
}
/** 排行榜渲染 */
rankRender(rankInfo = []) {
this.vScroll.setDataList(rankInfo, SCROLL_VERTICAL, [0, 0, 0]);
this.vScroll.scrollToTop(0);
}
/** 奖品栏渲染 */
async prizeRender(prizeInfo = []) {
this.prizeBox.destroyAllChildren();
for (let i = 0; i < prizeInfo.length; i ++) {
const node = instantiate(this.prizeItem);
node.getChildByName("PrizeName").getComponent(Label).string = strFormat(prizeInfo[i]?.prizeName, 12);
node.getChildByName("RankIndex").getComponent(Label).string = `第${prizeInfo[i]?.prizeRank}`
node.getChildByName("PrizeImg").getComponent(Sprite).spriteFrame = prizeInfo[i]?.prizeImg;
this.prizeBox.addChild(node);
/** 奖品栏渲染 */
async prizeRender(prizeInfo = []) {
this.prizeBox.destroyAllChildren();
for (let i = 0; i < prizeInfo.length; i++) {
const node = instantiate(this.prizeItem);
node.getChildByName("PrizeName").getComponent(Label).string = strFormat(prizeInfo[i]?.prizeName, 12);
node.getChildByName("RankIndex").getComponent(Label).string = `第${prizeInfo[i]?.prizeRank}`
node.getChildByName("PrizeImg").getComponent(Sprite).spriteFrame = prizeInfo[i]?.prizeImg;
this.prizeBox.addChild(node);
}
}
}
/** 回到首页 */
async handleClickBack() {
await changeScene(HomeScene);
}
/** 回到首页 */
async handleClickBack() {
await changeScene(HomeScene);
}
}
......@@ -40,13 +40,13 @@ export default class TaskCenter {
const jumpUrl = url?.split("$$$")?.[1];
/** 邀请任务 */
if (code?.startsWith("it")) {
if (code?.startsWith("it_")) {
beforeDoComplete(item, () => {
ShareCenter.ins.doShare(SHARE_TYPE.INVITE);
});
}
/** 浏览任务 */
else if (code?.startsWith("bt")) {
else if (code?.startsWith("bt_")) {
if (code == "bt_real") {
// 真浏览-浏览长图任务
showPanel(BrowseImgPanel, {
......@@ -79,25 +79,27 @@ export default class TaskCenter {
WebNetName.finishBrowseTask,
{taskCode: code, taskId: id}
);
appJump(jumpUrl);
location.href = jumpUrl;
// appJump(jumpUrl);
});
}
}
/** 行方任务 */
else if (code?.startsWith("tt")) {
else if (code?.startsWith("bank_")) {
beforeDoComplete(item, async () => {
if (!item?.extra || item?.extra == 0) { // 未领取任务 调领取行方任务接口
await sendWebNetWithToken(
WebNetName.claimThirdTask,
{taskCode: code, taskId: id}
);
}
const type = code.split("_")[1];
if (type == "t") { // 行方交易任务
appJump(jumpUrl)
} else if (type == "s") { // 行方签约任务
appJump(jumpUrl)
}
// if (!item?.extra || item?.extra == 0) { // 未领取任务 调领取行方任务接口
// await sendWebNetWithToken(
// WebNetName.claimThirdTask,
// {taskCode: code, taskId: id}
// );
// }
// const type = code.split("_")[1];
// if (type == "t") { // 行方交易任务
// appJump(jumpUrl)
// } else if (type == "s") { // 行方签约任务
// appJump(ju mpUrl)
// }
location.href = jumpUrl;
})
}
/** 会员等级达标任务 */
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment