81 lines
1.5 KiB
JavaScript
81 lines
1.5 KiB
JavaScript
// createBy: "1"
|
|
// createTime: "2024-05-30 20:36:04"
|
|
// delFlag: 0
|
|
// description: "1"
|
|
// extField1: null
|
|
// extField2: null
|
|
// extField3: null
|
|
// extField4: null
|
|
// extField5: null
|
|
// likeCount: 0
|
|
// remark: null
|
|
// title: "1"
|
|
// updateBy: "1"
|
|
// updateTime: "2024-05-30 20:36:04"
|
|
// userId: 1
|
|
// videoId: 1
|
|
// videoUrl: "1"
|
|
viewCount: 0
|
|
export const resDataToList=(data,liks,collections)=>{
|
|
if (liks === undefined || liks === null) {
|
|
liks = null;
|
|
} else {
|
|
liks = liks.map(e => e.videoId);
|
|
console.log("喜欢",liks);
|
|
}
|
|
|
|
if (collections === undefined || collections === null) {
|
|
collections = null;
|
|
} else {
|
|
collections = collections.map(e => e.videoId);
|
|
}
|
|
|
|
return data.map(e=>{
|
|
return{
|
|
src: e.videoUrl,
|
|
// avatar: e.description,
|
|
username: "",
|
|
titleName: e.title,
|
|
description:e.description,
|
|
id: e.videoId,
|
|
createTime: e.createTime,
|
|
isLike: isLike(e,liks),
|
|
isCollection: isCollections(e,collections),
|
|
likeCount:e.likeCount,
|
|
viewCount: e.viewCount,
|
|
}
|
|
})
|
|
}
|
|
/**
|
|
* 根据收藏列表判断是否收藏
|
|
*/
|
|
const isCollections=(data,csIds)=>{
|
|
if(csIds==null){
|
|
return false;
|
|
}
|
|
// console.log("收藏发现喜欢",data,csIds)
|
|
let iss=false;
|
|
csIds.forEach(e=>{
|
|
if(data.videoId==e){
|
|
// console.log("发现喜欢")
|
|
iss=true;
|
|
}
|
|
})
|
|
return iss;
|
|
}
|
|
/**
|
|
* 根据点赞列表判断是否点赞
|
|
*/
|
|
const isLike=(data,caseids)=>{
|
|
if(caseids==null){
|
|
return false;
|
|
}
|
|
let iss=false;
|
|
caseids.forEach(e=>{
|
|
if(data.videoId==e){
|
|
// console.log("发现喜欢")
|
|
iss=true;
|
|
}
|
|
})
|
|
return iss;
|
|
} |