jiuyiUniapp/jiuyi2/unpackage/dist/dev/mp-weixin/pages/mine/collectsVideo.js

90 lines
2.4 KiB
JavaScript
Raw Normal View History

2024-12-18 15:46:27 +08:00
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_js_util = require("../../common/js/util.js");
const api_index = require("../../api/index.js");
if (!Math) {
videoMenu();
}
const videoMenu = () => "../../components/index/videoMenu.js";
const _sfc_main = {
__name: "collectsVideo",
setup(__props) {
const userId = common_vendor.ref("");
const collectId = common_vendor.reactive([]);
const collectName = common_vendor.ref("");
const list = common_vendor.reactive({
data: [],
pageSize: 12,
pageNum: 1,
total: 0
});
common_vendor.onLoad((option) => {
if (option.userId)
userId.value = option.userId;
if (option.collectId)
collectId.value = option.collectId;
if (option.collectName) {
collectName.value = option.collectName;
common_vendor.index.setNavigationBarTitle({
title: collectName.value
});
}
getList();
});
common_vendor.onPullDownRefresh(() => {
refreshList();
});
common_vendor.onReachBottom(() => {
getMoreList();
});
function refreshList() {
list.pageNum = 1;
list.total = 0;
getList();
}
function getMoreList() {
if (list.data.length >= list.rows)
return;
list.pageNum++;
getList();
}
function getList() {
api_index.api.video.getCollectVideoList({
query: {
// 收藏夹id
collectId: collectId.value,
// 用户id
userId: userId.value || "",
pageSize: list.pageSize,
pageNum: list.pageNum
}
}).then((rs) => {
if (rs.code == 200) {
if (list.pageNum == 1)
list.data.length = [];
list.data.push(...rs.rows.map((item) => {
item.format_videoUrl = common_js_util.util.format_url(item.videoUrl, "video");
item.format_imageUrl = common_js_util.util.format_url(item.imageUrl, "img");
return item;
}));
list.total = rs.total;
return;
}
common_js_util.util.alert({
content: rs.msg,
showCancel: false
});
});
}
return (_ctx, _cache) => {
return {
a: common_vendor.t(list.total),
b: common_vendor.p({
list: list.data
})
};
};
}
};
wx.createPage(_sfc_main);