import { getCurrentInstance, ref, reactive, openBlock, createElementBlock, createElementVNode, createVNode } from "vue"; import { o as onLoad, d as onHide } from "../../uni-app.es.js"; import { b as api, u as util, i as indexVideo, e as commentAlt, f as collectAlt, g as shareFirendAlt } from "../../shareFirend.js"; import { _ as _export_sfc } from "../../_plugin-vue_export-helper.js"; const _style_0 = {}; const _sfc_main = { __name: "videoDetail", setup(__props) { const { proxy } = getCurrentInstance(); const videoId = ref(""); const detail = reactive({}); const isMine = ref(false); onLoad((option) => { if (option.videoId) videoId.value = option.videoId; if (option.isMine && option.isMine != "false") isMine.value = option.isMine; getVideoDetail(); uni.$on("updateVideo", (item2) => { if (!item2 && !item2.videoId) return; if (item2.videoId == detail.videoId) Object.assign(detail, item2); }); uni.$on("focusUser", (param) => { if (!item && !item.videoId) return; if (item.videoId == detail.videoId) Object.assign(detail, item); }); }); onHide(() => { proxy.$refs.indexVideo.pause(); }); function getVideoDetail() { api.video.getVideoById({ query: { videoId: videoId.value } }).then((rs) => { if (rs.code == 200) { const result = rs.data; result.format_videoUrl = util.format_url(result.videoUrl, "video"); result.format_header = util.format_url(result.header, "img"); Object.assign(detail, result); proxy.$refs.indexVideo.play(); return; } util.alert({ content: rs.msg, showCancel: false }); }); } function handleShowCommentAlt(item2) { proxy.$refs.commentRef.open(item2); proxy.$refs.indexVideo.pause(); } function handleShowCollectAlt(item2) { proxy.$refs.collectRef.open(item2); } function handleShowShareFirend() { proxy.$refs.shareFirendRef.open(); } function videoLike(param) { const { index, isLike } = param; const item2 = detail; let type = 1; if (item2.isLike == 0) type = isLike; api.video.videoLike({ query: { // 0赞1取消赞 3私密赞 type, // 视频id videoId: item2.videoId } }).then((rs) => { if (rs.code == 200) { item2.isLike = { 0: 1, 1: 0, 3: 3 }[type]; type == 1 ? item2.likes-- : item2.likes++; return; } util.alert({ content: rs.msg, showCancel: false }); }); } function detailMenu(item2) { let menu = [ { name: "编辑", fn: function() { uni.navigateTo({ url: util.setUrl("/pages/release/video", { videoId: detail.videoId }) }); } }, { name: "删除", fn: () => { util.alert({ content: "删除后不可恢复。确认删除?" }).then((rs) => { if (rs.confirm) api.video.updateVideo({ data: { videoId: detail.videoId, isDeleted: 1 } }).then((rs2) => { if (rs2.code == 200) { uni.$emit("deleteVideo", detail.videoId); uni.navigateBack(); return; } util.alert({ content: rs2.msg, showCancel: false }); }); }); } } ]; uni.showActionSheet({ itemList: menu.map((node) => node.name), success: (rs) => { menu[rs.tapIndex].fn(); } }); } return (_ctx, _cache) => { return openBlock(), createElementBlock("scroll-view", { scrollY: true, showScrollbar: true, enableBackToTop: true, bubble: "true", style: { flexDirection: "column" } }, [ createElementVNode("view", { class: "page f1" }, [ createVNode(indexVideo, { ref: "indexVideo", item: detail, tabIndex: 0, isMine: isMine.value, index: 0, current: 0, mode: "detail", onShowComment: handleShowCommentAlt, onShowCollect: handleShowCollectAlt, onShowShareFirend: handleShowShareFirend, onLike: videoLike, onDetailMenu: detailMenu }, null, 8, ["item", "isMine"]), createVNode(commentAlt, { ref: "commentRef" }, null, 512), createVNode(collectAlt, { ref: "collectRef" }, null, 512), createVNode(shareFirendAlt, { ref: "shareFirendRef" }, null, 512) ]) ]); }; } }; const videoDetail = /* @__PURE__ */ _export_sfc(_sfc_main, [["styles", [_style_0]]]); export { videoDetail as default };