generated from JX3BOX/jx3box-vue-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:JX3BOX/pvx into dev
- Loading branch information
Showing
10 changed files
with
409 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
<template> | ||
<div v-if="reputationList.length" class="m-reputation-list"> | ||
<a | ||
class="u-reputation" | ||
v-for="item in reputationList" | ||
:key="item.id" | ||
:href="getItemLink(item.id)" | ||
target="_blank" | ||
> | ||
<el-tooltip class="box-item" effect="dark" :content="item.Desc" placement="top"> | ||
<div class="u-reputation-item"> | ||
<div class="u-reputation-icon" :class="`u-quality-${item.Quality}`"> | ||
<img :src="iconLink(item.IconID)" :alt="item.Name" /> | ||
</div> | ||
<span class="u-reputation-name">{{ item.Name }}</span> | ||
</div> | ||
</el-tooltip> | ||
</a> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import dayjs from "@/plugins/day"; | ||
import { getHomeReputation, getItems } from "@/service/spider"; | ||
import { iconLink } from "@jx3box/jx3box-common/js/utils"; | ||
export default { | ||
name: "Reputation", | ||
data() { | ||
return { | ||
reputation: {}, | ||
}; | ||
}, | ||
computed: { | ||
reputationList() { | ||
return this.reputation?.list || []; | ||
}, | ||
date() { | ||
// 当7点以前,请求前面一天的日常 当7~24点,请求当天的日常 | ||
const hour = dayjs.tz().get("hours"); | ||
return 0 <= hour && hour < 7 | ||
? dayjs.tz().subtract(1, "day").format("YYYY-MM-DD") | ||
: dayjs.tz().format("YYYY-MM-DD"); | ||
}, | ||
client() { | ||
return "std"; | ||
}, | ||
}, | ||
watch: { | ||
date: { | ||
immediate: true, | ||
handler() { | ||
if (this.client === "std") { | ||
this.loadReputation(); | ||
} | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
iconLink, | ||
getItemLink(id) { | ||
return `/item/view/${id}`; | ||
}, | ||
// 家园声望 | ||
loadReputation() { | ||
const cache = sessionStorage.getItem(`index_reputation_items`); | ||
if (cache) { | ||
const obj = JSON.parse(cache); | ||
if (obj.date === this.date) { | ||
this.reputation = obj; | ||
return; | ||
} | ||
} | ||
getHomeReputation(this.date, this.$store.state.server).then((res) => { | ||
const list = res.data?.data?.list || []; | ||
if (list.length) { | ||
const ids = list.map((item) => { | ||
return item.item_type_id + "_" + item.item_id; | ||
}); | ||
this.loadItems(ids); | ||
} | ||
}); | ||
}, | ||
loadItems(ids) { | ||
// 读取本地数据 | ||
if (!ids.length) return; | ||
getItems(ids).then((res) => { | ||
const list = res.data?.list || []; | ||
let newData = { | ||
date: this.date, | ||
list: list.map((item) => { | ||
return { | ||
id: item.id, | ||
Name: item.Name.replace("声望·", ""), | ||
IconID: item.IconID, | ||
Quality: item.Quality, | ||
Desc: /中(.*)\\\\\\/.exec(item.Desc)[1].trim(), | ||
}; | ||
}), | ||
}; | ||
this.reputation = newData; | ||
sessionStorage.setItem(`index_reputation_items`, JSON.stringify(newData)); | ||
}); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
<style lang="less"> | ||
.m-reputation-list { | ||
padding: 10px; | ||
width: 100%; | ||
height: 119px; | ||
-webkit-box-sizing: border-box; | ||
box-sizing: border-box; | ||
background: #ffffff; | ||
border-radius: 10px; | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); | ||
margin-bottom: 10px; | ||
overflow-y: auto; | ||
.scrollbar(); | ||
.u-reputation-item { | ||
.flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 2px 5px; | ||
gap: 5px; | ||
&:hover { | ||
background: @bg-gray; | ||
.u-reputation-name { | ||
color: #ffa500; | ||
} | ||
} | ||
} | ||
.u-desc { | ||
color: #999; | ||
} | ||
.u-reputation { | ||
display: flex; | ||
gap: 10px; | ||
align-items: center; | ||
font-size: 14px; | ||
color: #000; | ||
} | ||
.u-reputation-icon { | ||
@s: 38px; | ||
.size(@s); | ||
overflow: hidden; | ||
.mr(5px); | ||
img { | ||
.size(100%); | ||
.db; | ||
&:hover { | ||
filter: brightness(110%) saturate(110%); | ||
} | ||
} | ||
.db; | ||
.pr; | ||
&:after { | ||
content: ""; | ||
.db; | ||
.size(100%); | ||
.pa; | ||
.lt(0); | ||
border: 1px solid transparent; | ||
box-sizing: border-box; | ||
.r(100%); | ||
} | ||
&.u-quality-2:after { | ||
border-color: #00d24b; | ||
} | ||
&.u-quality-3:after { | ||
border-color: #007eff; | ||
} | ||
&.u-quality-4:after { | ||
border-color: #ff2dff; | ||
} | ||
&.u-quality-5:after { | ||
border-color: #ffa500; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { $next, $node } from "@jx3box/jx3box-common/js/https"; | ||
// 家园声望 | ||
function getHomeReputation(date, server = "梦江南") { | ||
const params = { | ||
server: server, // 所有服务器数据一致 | ||
upload_time: date + " 07:00:00", | ||
// 上传时间, 查询时请格式化为 2006-01-02 07:00:00,表示查询当天上报的物价 | ||
}; | ||
return $next().get("/api/next2/npc-shop/list", { | ||
params, | ||
}); | ||
} | ||
// 批量获取物品 | ||
function getItems(ids, client = "std") { | ||
const per = ids.length || 15; | ||
const params = { | ||
client, | ||
per, | ||
}; | ||
const idString = ids.join(","); | ||
if (!idString) return; | ||
return $node().get(`/item_merged/id/${idString}`, { | ||
params, | ||
}); | ||
} | ||
export { getHomeReputation, getItems }; |
Oops, something went wrong.