支持一键三连&支持查看最近10条历史记录
This commit is contained in:
+42
-9
@@ -299,6 +299,22 @@ class BilibiliClient {
|
||||
return response.data.data
|
||||
}
|
||||
|
||||
// 使用视频bvid检测视频是否被点赞
|
||||
async isVideoLikedByBVID(bvid: string): Promise<boolean> {
|
||||
const url = `https://api.bilibili.com/x/web-interface/archive/has/like?bvid=${bvid}`
|
||||
const response = await this.getRequest(url);
|
||||
|
||||
return response.data.data
|
||||
}
|
||||
|
||||
// 使用视频bvid检测视频是否被投币
|
||||
async isVideoCoinedByBVID(bvid: string): Promise<boolean> {
|
||||
const url = `https://api.bilibili.com/x/web-interface/archive/coins?bvid=${bvid}`
|
||||
const response = await this.getRequest(url);
|
||||
|
||||
return response.data.data.multiply
|
||||
}
|
||||
|
||||
// 使用视频bvid检测视频是否被收藏
|
||||
async isVideoStaredByBVID(bvid: string): Promise<boolean> {
|
||||
const url = `https://api.bilibili.com/x/v2/fav/video/favoured?aid=${bvid}`
|
||||
@@ -397,7 +413,7 @@ class BilibiliClient {
|
||||
return false
|
||||
}
|
||||
|
||||
async getSearchHotwords(): Promise<any>{
|
||||
async getSearchHotwords(): Promise<any> {
|
||||
const url = "https://s.search.bilibili.com/main/hotword";
|
||||
const response = await this.getRequest(url);
|
||||
console.log(response)
|
||||
@@ -405,16 +421,33 @@ class BilibiliClient {
|
||||
return response.data.list
|
||||
}
|
||||
|
||||
async getWatchHistory(pn: number, ps: number): Promise<any>{
|
||||
const url = `https://api.bilibili.com/x/v2/history?pn=${pn}&ps=${ps}`;
|
||||
const response = await this.getRequest(url);
|
||||
|
||||
return response.data.data
|
||||
}
|
||||
|
||||
async LikeVideo(bvid: string, like: number): Promise<any>{
|
||||
const url = "https://api.bilibili.com/x/web-interface/archive/like"
|
||||
const body = `bvid=${bvid}&like=${like}&csrf=${this.biliJct}`
|
||||
const response = await this.postRequest(url, body, "application/x-www-form-urlencoded");
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
async CoinVideo(bvid: string, multiply: number): Promise<any>{
|
||||
const url = "https://api.bilibili.com/x/web-interface/coin/add"
|
||||
const body = `bvid=${bvid}&multiply=${multiply}&csrf=${this.biliJct}`
|
||||
const response = await this.postRequest(url, body, "application/x-www-form-urlencoded");
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
// 退出登录(指在手表上删除存储的账号数据)
|
||||
logOut(): any {
|
||||
logOut() {
|
||||
storage.delete({
|
||||
key: "bilibili_account",
|
||||
success: (data) => {
|
||||
return true;
|
||||
},
|
||||
fail: (data, code) => {
|
||||
return false;
|
||||
}
|
||||
key: "bilibili_account"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -70,6 +70,9 @@
|
||||
},
|
||||
"pages/introduction": {
|
||||
"component": "introduction"
|
||||
},
|
||||
"pages/history": {
|
||||
"component": "history"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<import name="title-bar" src="../../components/TitleBar/TitleBar.ux"></import>
|
||||
<import name="videoshow" src="../../components/Video/Video.ux"></import>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<title-bar title="历史记录"></title-bar>
|
||||
<image style="position: absolute; margin-top: 245px" if="{{show_loading}}" src="{{anims.loading_src.value}}">
|
||||
</image>
|
||||
<list style="margin-top: 15px" class="historylist">
|
||||
<list-item type="history"
|
||||
class="historyvid_listitem"
|
||||
style="height: {{calcSpace($item.title, true)}}"
|
||||
for="{{history}}">
|
||||
<videoshow video={{$item}}></videoshow>
|
||||
<text style="margin-top: {{calcSpace($item.title, false)}}; height: 0px"></text>
|
||||
</list-item>
|
||||
</list>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
private: {
|
||||
history: null,
|
||||
show_loading: false,
|
||||
anims: {
|
||||
loading: null,
|
||||
loading_src: {value: "/common/seqanims/loadingWhite/icons8-loading_颜色反转-1.png"}
|
||||
}
|
||||
},
|
||||
calcSpace(vid_title, isListItem) {
|
||||
const isLastItem = vid_title === this.history[this.history.length - 1]?.title
|
||||
if (isListItem) {
|
||||
return isLastItem ? "270px" : "170px"
|
||||
}
|
||||
return isLastItem ? "80px" : "0px"
|
||||
},
|
||||
async LoadHistory(){
|
||||
this.show_loading = true
|
||||
this.history = []
|
||||
this.anims.loading.start()
|
||||
|
||||
try {
|
||||
const medialist = await this.$app.$def.biliclient.getWatchHistory(
|
||||
1,
|
||||
15
|
||||
)
|
||||
const videoInfoPromises = medialist.map((media) =>
|
||||
this.$app.$def.biliclient.getVideoInfoByBVID(media.bvid)
|
||||
)
|
||||
this.history = await Promise.all(videoInfoPromises)
|
||||
} catch (error) {
|
||||
console.error("加载历史记录时发生错误:", error)
|
||||
} finally {
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
}
|
||||
},
|
||||
onInit(){
|
||||
this.anims.loading = new this.$app.$def.animengine.SequenceAnim(
|
||||
"folderVideosPage",
|
||||
this.anims.loading_src,
|
||||
28,
|
||||
"/common/seqanims/loadingWhite/icons8-loading_颜色反转-*.png",
|
||||
1000,
|
||||
true
|
||||
)
|
||||
|
||||
this.LoadHistory()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.historylist {
|
||||
width: 77%;
|
||||
height: 75%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.historyvid_listitem {
|
||||
height: 170px;
|
||||
width: 100%;
|
||||
margin-top: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
@@ -18,6 +18,7 @@ export default {
|
||||
"/common/guides/circle/3_enterSearch.png",
|
||||
"/common/guides/circle/4_videoDetailMoreFeatures.png",
|
||||
"/common/guides/circle/5_replyMoreFeatures.png",
|
||||
"/common/guides/circle/6_dontsupportvideoplay.png"
|
||||
],
|
||||
"pill-shaped": [
|
||||
"/common/guides/pill-shaped/1_welcome.png",
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<text class="btntext">我的收藏</text>
|
||||
<image src="/common/arrow_right.png"></image>
|
||||
</div>
|
||||
<div class="btnbase" style="margin-top: 10px" @click="WIPTips()">
|
||||
<div class="btnbase" style="margin-top: 10px" @click="GoHistory()">
|
||||
<image class="btnimg" src="/common/mypage_history.png"></image>
|
||||
<text class="btntext">历史记录</text>
|
||||
<image src="/common/arrow_right.png"></image>
|
||||
@@ -47,6 +47,11 @@ export default {
|
||||
is_senior_member: false,
|
||||
accountInfo: {}
|
||||
},
|
||||
GoHistory(){
|
||||
router.push({
|
||||
uri: "pages/history"
|
||||
})
|
||||
},
|
||||
GoMyFavFolders(){
|
||||
router.push({
|
||||
uri: "pages/favfolders",
|
||||
|
||||
@@ -59,16 +59,23 @@ export default {
|
||||
})
|
||||
},
|
||||
ShowSecReplies() {
|
||||
router.push({
|
||||
uri: "pages/replys",
|
||||
params: {
|
||||
type: this.type,
|
||||
oid: this.oid,
|
||||
replycount: this.reply.rcount,
|
||||
rootrpid: this.reply.rpid,
|
||||
secmode: true
|
||||
}
|
||||
})
|
||||
if(this.reply.rcount > 0){
|
||||
router.push({
|
||||
uri: "pages/replys",
|
||||
params: {
|
||||
type: this.type,
|
||||
oid: this.oid,
|
||||
replycount: this.reply.rcount,
|
||||
rootrpid: this.reply.rpid,
|
||||
secmode: true
|
||||
}
|
||||
})
|
||||
}
|
||||
else{
|
||||
prompt.showToast({
|
||||
message: "没人回复这条评论哦!"
|
||||
})
|
||||
}
|
||||
},
|
||||
onInit() {
|
||||
this.reply = JSON.parse(this.reply)
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<scroll scroll-x="true" class="vidtoolbar" style="margin-top: 25px">
|
||||
<div class="vidtool" style="margin-left: 0px" @click="DisabledFeaturesWarning()">
|
||||
<div class="vidtool" style="margin-left: 0px" @click="LikeClick()" @longpress="PowerIt()">
|
||||
<image class="vidtoolimg" src="{{likesrc}}"></image>
|
||||
<text class="vidtooltext">{{ this.$app.$def.tools.formatNumber(vid.stat.like) }}</text>
|
||||
</div>
|
||||
<div class="vidtool" @click="DisabledFeaturesWarning()">
|
||||
<div class="vidtool" @click="CoinClick()">
|
||||
<image class="vidtoolimg" src="{{coinsrc}}"></image>
|
||||
<text class="vidtooltext">{{ this.$app.$def.tools.formatNumber(vid.stat.coin) }}</text>
|
||||
</div>
|
||||
@@ -55,8 +55,8 @@
|
||||
</div>
|
||||
<image src="/common/featurebtn_replyarea.png" style="margin-top: 15px" @click="GoReplyArea()"></image>
|
||||
</scroll>
|
||||
<full-screen-input style="position: absolute" input_text="{{input_text}}" if="{{replymode}}" @complete="InputComplete" @delete="InputDelete"
|
||||
@send="SendReply" @exit="ExitInput"></full-screen-input>
|
||||
<full-screen-input style="position: absolute" input_text="{{input_text}}" if="{{replymode}}" @complete="InputComplete"
|
||||
@delete="InputDelete" @send="SendReply" @exit="ExitInput"></full-screen-input>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -88,6 +88,8 @@ export default {
|
||||
},
|
||||
async UpdateVideoToolbarStatus() {
|
||||
this.stared = await this.$app.$def.biliclient.isVideoStaredByBVID(this.bvid)
|
||||
this.liked = await this.$app.$def.biliclient.isVideoLikedByBVID(this.bvid)
|
||||
this.coined = await this.$app.$def.biliclient.isVideoCoinedByBVID(this.bvid)
|
||||
this.UpdateToolBarIconSrc()
|
||||
},
|
||||
UpdateToolBarIconSrc() {
|
||||
@@ -95,8 +97,31 @@ export default {
|
||||
this.coinsrc = this.coined ? "/common/vidtool_coined.png" : "/common/vidtool_coin.png"
|
||||
this.starsrc = this.stared ? "/common/vidtool_stared.png" : "/common/vidtool_star.png"
|
||||
},
|
||||
formatNumber(num) {
|
||||
return this.$app.$def.tools.formatNumber(num)
|
||||
async PowerIt(){
|
||||
prompt.showToast({message: "一键三连中!"})
|
||||
this.LikeClick()
|
||||
this.CoinClick()
|
||||
this.AddToFav()
|
||||
},
|
||||
async LikeClick() {
|
||||
var result = await this.$app.$def.biliclient.LikeVideo(this.vid.bvid, 1)
|
||||
const message =
|
||||
result.code === 0 ? "点赞成功" : `点赞失败,错误代码:${result.code} 原因:${result.message}`
|
||||
prompt.showToast({
|
||||
message,
|
||||
duration: result.code === 0 ? 2000 : 4000
|
||||
})
|
||||
this.UpdateVideoToolbarStatus()
|
||||
},
|
||||
async CoinClick() {
|
||||
var result = await this.$app.$def.biliclient.CoinVideo(this.vid.bvid, 1)
|
||||
const message =
|
||||
result.code === 0 ? "投币成功" : `投币失败,错误代码:${result.code} 原因:${result.message}`
|
||||
prompt.showToast({
|
||||
message,
|
||||
duration: result.code === 0 ? 2000 : 4000
|
||||
})
|
||||
this.UpdateVideoToolbarStatus()
|
||||
},
|
||||
async SendReply() {
|
||||
this.replymode = false
|
||||
@@ -183,7 +208,7 @@ export default {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.vidpic {
|
||||
|
||||
Reference in New Issue
Block a user