135 lines
4.0 KiB
JavaScript
135 lines
4.0 KiB
JavaScript
|
"use strict";
|
||
|
const common_vendor = require("../../common/vendor.js");
|
||
|
if (!Array) {
|
||
|
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
|
||
|
_easycom_up_icon2();
|
||
|
}
|
||
|
const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
|
||
|
if (!Math) {
|
||
|
_easycom_up_icon();
|
||
|
}
|
||
|
const _sfc_main = {
|
||
|
__name: "VideoView",
|
||
|
props: {
|
||
|
VideoId: {
|
||
|
type: Number,
|
||
|
default: null
|
||
|
},
|
||
|
Videos: {
|
||
|
type: Object,
|
||
|
default: () => ({
|
||
|
id: "",
|
||
|
src: "https://prod-streaming-video-msn-com.akamaized.net/a8c412fa-f696-4ff2-9c76-e8ed9cdffe0f/604a87fc-e7bc-463e-8d56-cde7e661d690.mp4",
|
||
|
titleName: "标题名",
|
||
|
description: "详细描述",
|
||
|
createTime: "日期",
|
||
|
isLike: false,
|
||
|
isCollection: false,
|
||
|
likeCount: 0,
|
||
|
viewCount: 0
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
emits: ["onplay", "ClickCollection", "ClickLike"],
|
||
|
setup(__props, { emit: __emit }) {
|
||
|
const emit = __emit;
|
||
|
const props = __props;
|
||
|
const videoContent = common_vendor.ref(null);
|
||
|
const isExpanded = common_vendor.ref(false);
|
||
|
const info = common_vendor.reactive({
|
||
|
id: null,
|
||
|
src: "",
|
||
|
titleName: "",
|
||
|
description: "",
|
||
|
createTime: "",
|
||
|
isLike: false,
|
||
|
isCollection: false,
|
||
|
likeCount: 0,
|
||
|
viewCount: 0
|
||
|
});
|
||
|
const propsPlay = (e) => {
|
||
|
const videoContext = videoContent.value;
|
||
|
const videoStatus = common_vendor.ref(null);
|
||
|
videoStatus.value = e.target;
|
||
|
console.log("播放视频");
|
||
|
emit("onplay", {
|
||
|
e,
|
||
|
videoStatus,
|
||
|
videoContext
|
||
|
});
|
||
|
};
|
||
|
const toLike = () => {
|
||
|
info.isLike = !info.isLike;
|
||
|
info.isLike ? info.likeCount++ : info.likeCount--;
|
||
|
console.log("id", info.id);
|
||
|
emit("ClickLike", info.id, info.isLike);
|
||
|
};
|
||
|
const toCollection = () => {
|
||
|
info.isCollection = !info.isCollection;
|
||
|
emit("ClickCollection", info.id, info.isCollection);
|
||
|
};
|
||
|
const toggleExpand = () => {
|
||
|
isExpanded.value = !isExpanded.value;
|
||
|
};
|
||
|
common_vendor.onMounted(() => {
|
||
|
videoContent.value = common_vendor.index.createVideoContext("video", this);
|
||
|
console.log("是否传入id", props.Videos.id);
|
||
|
info.id = props.Videos.id;
|
||
|
info.src = props.Videos.src;
|
||
|
info.titleName = props.Videos.titleName;
|
||
|
info.description = props.Videos.description;
|
||
|
info.createTime = props.Videos.createTime;
|
||
|
info.isLike = props.Videos.isLike;
|
||
|
info.isCollection = props.Videos.isCollection;
|
||
|
info.likeCount = props.Videos.likeCount | 0;
|
||
|
info.viewCount = props.Videos.viewCount;
|
||
|
});
|
||
|
return (_ctx, _cache) => {
|
||
|
return common_vendor.e({
|
||
|
a: common_vendor.o(propsPlay),
|
||
|
b: __props.Videos.src,
|
||
|
c: common_vendor.t(__props.Videos.titleName),
|
||
|
d: common_vendor.t(info.createTime),
|
||
|
e: info.isLike
|
||
|
}, info.isLike ? {
|
||
|
f: common_vendor.o(toLike),
|
||
|
g: common_vendor.p({
|
||
|
name: "heart-fill",
|
||
|
color: "#ff0004",
|
||
|
size: "28"
|
||
|
})
|
||
|
} : {
|
||
|
h: common_vendor.o(toLike),
|
||
|
i: common_vendor.p({
|
||
|
name: "heart",
|
||
|
color: "#ff0004",
|
||
|
size: "28"
|
||
|
})
|
||
|
}, {
|
||
|
j: info.isCollection
|
||
|
}, info.isCollection ? {
|
||
|
k: common_vendor.o(toCollection),
|
||
|
l: common_vendor.p({
|
||
|
name: "star-fill",
|
||
|
color: "#ffd700",
|
||
|
size: "28"
|
||
|
})
|
||
|
} : {
|
||
|
m: common_vendor.o(toCollection),
|
||
|
n: common_vendor.p({
|
||
|
name: "star",
|
||
|
color: "#ffd700",
|
||
|
size: "28"
|
||
|
})
|
||
|
}, {
|
||
|
o: info.description,
|
||
|
p: isExpanded.value ? 1 : "",
|
||
|
q: common_vendor.t(isExpanded.value ? "收起" : "展开"),
|
||
|
r: common_vendor.o(toggleExpand)
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3ffa2b55"], ["__file", "D:/uniapp1/gree_leran/components/VideoView/VideoView.vue"]]);
|
||
|
wx.createComponent(Component);
|