Skip to content

Commit

Permalink
fix: treasure
Browse files Browse the repository at this point in the history
  • Loading branch information
TiAmo-code committed May 10, 2024
1 parent 453b091 commit 322e38e
Show file tree
Hide file tree
Showing 9 changed files with 719 additions and 298 deletions.
74 changes: 72 additions & 2 deletions src/assets/css/treasure/landscape.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.m-body {
padding: 200px 0;
padding: 100px 0;
position: relative;
}
.m-content {
position: relative;
Expand All @@ -24,7 +25,7 @@
.reelCss {
position: absolute;
top: 50%;
z-index: 4;
z-index: 50;
}
.afterCss {
content: " ";
Expand Down Expand Up @@ -134,6 +135,9 @@
.m-qy__item {
position: relative;
width: 47px;
.u-qy__img {
border-radius: 50%;
}
.u-qy__border {
position: absolute;
left: 0;
Expand Down Expand Up @@ -500,3 +504,69 @@
}
}
}

.m-related-roles {
.fz(12px);
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 30px;
.u-tip {
.mb(10px);
i {
.fz(16px);
.mr(3px);
}
a {
padding: 0 2px;
box-shadow: 0 1px 0 @color-link;
}
}

.el-input__prefix {
left: 1px;
top: 1px;
.r(5px);
}

.u-prefix {
.db;
.h(30px);
.lh(30px);

background-color: #f5f7fa;
color: #909399;

border-right: 1px solid #dcdfe6;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;

padding: 0 10px;
white-space: nowrap;
}

.el-input--prefix .el-input__inner {
padding-left: 75px;
}
}

.m-related-roles-options {
.u-role {
display: flex;
justify-content: space-between;
}
.u-role-name {
.flex;
align-items: center;
}
.u-role-icon {
.size(20px);
.y;
.mr(3px);
.r(50%);
}
.u-role-server {
color: #999;
.fz(12px);
}
}
77 changes: 75 additions & 2 deletions src/assets/css/treasure/portrait.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.m-main {
overflow: hidden;
}
.m-body {
padding-top: 100px;
margin: 0 auto;
position: relative;
}

.m-content {
Expand All @@ -21,7 +25,7 @@
}
.m-bottom {
position: absolute;
z-index: 5;
z-index: 50;
width: 940px;
left: 50%;
transform: translateX(-50%) translateY(100%);
Expand Down Expand Up @@ -370,7 +374,7 @@
}
}
}
.u-no-qy{
.u-no-qy {
width: 200px;
margin: 8px 0;
}
Expand Down Expand Up @@ -405,3 +409,72 @@
}
}
}

.m-related-roles {
.fz(12px);
position: absolute;
left: 0;
right: 0;
top: 30px;
.el-select {
width: 100%;
}
.u-tip {
.mb(10px);
i {
.fz(16px);
.mr(3px);
}
a {
padding: 0 2px;
box-shadow: 0 1px 0 @color-link;
}
}

.el-input__prefix {
left: 1px;
top: 1px;
.r(5px);
}

.u-prefix {
.db;
.h(30px);
.lh(30px);

background-color: #f5f7fa;
color: #909399;

border-right: 1px solid #dcdfe6;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;

padding: 0 10px;
white-space: nowrap;
}

.el-input--prefix .el-input__inner {
padding-left: 75px;
}
}

.m-related-roles-options {
.u-role {
display: flex;
justify-content: space-between;
}
.u-role-name {
.flex;
align-items: center;
}
.u-role-icon {
.size(20px);
.y;
.mr(3px);
.r(50%);
}
.u-role-server {
color: #999;
.fz(12px);
}
}
99 changes: 99 additions & 0 deletions src/assets/js/treasure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { getRoleGameAchievements, getAdventures } from "@/service/treasure.js";

const perfectAchievement = {
111: { hasClass: "zhg", zIndex: 10 },
3: { hasClass: "yylj", zIndex: 12 },
88: { hasClass: "xxjt", zIndex: 14 },
83: { hasClass: "zzwg", zIndex: 16 },
104: { hasClass: "wldg", zIndex: 18 },
78: { hasClass: "tjh", zIndex: 20 },
1: { hasClass: "sssh", zIndex: 22 },
2: { hasClass: "scqf", zIndex: 24 },
126: { hasClass: "swxf", zIndex: 26 },
21: { hasClass: "swbj", zIndex: 28 },
121: { hasClass: "rjg", zIndex: 30 },
106: { hasClass: "qqj", zIndex: 32 },
90: { hasClass: "lnrh", zIndex: 34 },
66: { hasClass: "jcs", zIndex: 36 },
};

let formatDateTime = (dateTimeString) => {
const dateTime = new Date(dateTimeString);
const year = dateTime.getFullYear();
const month = dateTime.getMonth() + 1; // 月份从0开始,需要加1
const date = dateTime.getDate();
const hours = dateTime.getHours();
const minutes = dateTime.getMinutes();
const seconds = dateTime.getSeconds();

const formattedDateTime = `${year}${month}${date}${hours}:${minutes}:${seconds}`;
return formattedDateTime;
};

let getData = (userJx3Id) => {
return new Promise((resolve, reject) => {
var returnData = {
pet: [],
normal: [],
perfect: [],
};

getRoleGameAchievements(userJx3Id).then((res) => {
const achievements = res.data?.data?.achievements || "";
const list = achievements.split(",");
if (res.data?.data?.updated_at) {
returnData.updated_at = formatDateTime(res.data?.data?.updated_at);
} else {
returnData.updated_at = "暂无记录";
}
// 定义奇遇类型数组
const adventureTypes = ["pet", "normal", "perfect"];
// 创建 Promise 数组来存储所有奇遇数据的 Promise
const adventurePromises = adventureTypes.map((type) => {
return getAdventures({
type,
_no_page: 1,
}).then((res) => {
const achievementsList = [];
let actNum = 0;
res.data.list.forEach((item) => {
if (type == "perfect") {
item.isAct = false;
if (list.includes(String(item.dwID))) {
item.isAct = true;
actNum++;
}
achievementsList.push({
...item,
...perfectAchievement[item.dwID],
});
} else {
if (list.includes(String(item.dwID))) {
achievementsList.push(item);
actNum++;
}
}
});
returnData[`${type}AllNum`] = res.data.list.length;
returnData[`${type}NowNum`] = actNum;
returnData[type] = achievementsList;
});
});

// 所有奇遇数据的 Promise 执行完成后,调用 inspectionResult
Promise.all(adventurePromises)
.then(() => {
returnData.progress =
(returnData.petNowNum + returnData.normalNowNum + returnData.perfectNowNum) /
(returnData.petAllNum + returnData.normalAllNum + returnData.perfectAllNum);
returnData.progress = (returnData.progress * 100).toFixed(2);
resolve(returnData);
})
.catch((error) => {
reject(error); // 处理错误
});
});
});
};

export default getData;
36 changes: 36 additions & 0 deletions src/service/treasure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { $cms, $team, $next, $node } from "@jx3box/jx3box-common/js/https";

const client = location.href.includes("origin") ? "origin" : "std";

// 获取用户信息
export function getUserInfo() {
return $cms().get(`api/cms/user/my/info`, {
params: {
client,
},
});
}

// 获取用户角色
export function getUserRoles() {
return $team().get(`api/team/my-game-roles?nopage`);
}

// 获取角色的成就状态
export function getRoleGameAchievements(jx3id) {
return $next().get(`/api/next2/user-achievements`, {
params: {
jx3id,
},
});
}

// 获取奇遇列表
export function getAdventures(params) {
return $node().get(`/serendipities`, {
params: {
...params,
client,
},
});
}
4 changes: 4 additions & 0 deletions src/views/treasure/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@

<script>
import Nav from "@/components/Nav_v4.vue";
import { __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
export default {
name: "Index",
components: {
Nav,
},
provide: {
__imgRoot: __imgPath + "adventure/",
},
data: () => ({
navStatusClass: "is-regular",
}),
Expand Down
Loading

0 comments on commit 322e38e

Please sign in to comment.