"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) { (indexVideo + commentAlt + collectAlt + shareFirendAlt)(); } const indexVideo = () => "../../components/index/indexVideo.js"; const commentAlt = () => "../../components/index/commentArea.js"; const collectAlt = () => "../../components/index/collect.js"; const shareFirendAlt = () => "../../components/index/shareFirend.js"; const _sfc_main = { __name: "videoDetail", setup(__props) { const { proxy } = common_vendor.getCurrentInstance(); const videoId = common_vendor.ref(""); const detail = common_vendor.reactive({}); const isMine = common_vendor.ref(false); common_vendor.onLoad((option) => { if (option.videoId) videoId.value = option.videoId; if (option.isMine && option.isMine != "false") isMine.value = option.isMine; getVideoDetail(); common_vendor.index.$on("updateVideo", (item) => { if (!item && !item.videoId) return; if (item.videoId == detail.videoId) Object.assign(detail, item); }); }); common_vendor.onHide(() => { proxy.$refs.indexVideo.pause(); }); function getVideoDetail() { api_index.api.video.getVideoById({ query: { videoId: videoId.value } }).then((rs) => { if (rs.code == 200) { const result = rs.data; result.format_videoUrl = common_js_util.util.format_url(result.videoUrl, "video"); result.format_header = common_js_util.util.format_url(result.header, "img"); Object.assign(detail, result); proxy.$refs.indexVideo.play(); return; } common_js_util.util.alert({ content: rs.msg, showCancel: false }); }); } function handleShowCommentAlt(item) { proxy.$refs.commentRef.open(item); proxy.$refs.indexVideo.pause(); } function handleShowCollectAlt(item) { proxy.$refs.collectRef.open(item); } function handleShowShareFirend() { proxy.$refs.shareFirendRef.open(); } function videoLike(param) { const { index, isLike } = param; const item = detail; let type = 1; if (item.isLike == 0) type = isLike; api_index.api.video.videoLike({ query: { // 0赞1取消赞 3私密赞 type, // 视频id videoId: item.videoId } }).then((rs) => { if (rs.code == 200) { item.isLike = { 0: 1, 1: 0, 3: 3 }[type]; type == 1 ? item.likes-- : item.likes++; return; } common_js_util.util.alert({ content: rs.msg, showCancel: false }); }); } function detailMenu(item) { let menu = [ { name: "编辑", fn: function() { common_vendor.index.navigateTo({ url: common_js_util.util.setUrl("/pages/release/video", { videoId: detail.videoId }) }); } }, { name: "删除", fn: () => { common_js_util.util.alert({ content: "删除后不可恢复。确认删除?" }).then((rs) => { if (rs.confirm) api_index.api.video.updateVideo({ data: { videoId: detail.videoId, isDeleted: 1 } }).then((rs2) => { if (rs2.code == 200) { common_vendor.index.$emit("deleteVideo", detail.videoId); common_vendor.index.navigateBack(); return; } common_js_util.util.alert({ content: rs2.msg, showCancel: false }); }); }); } } ]; common_vendor.index.showActionSheet({ itemList: menu.map((node) => node.name), success: (rs) => { menu[rs.tapIndex].fn(); } }); } return (_ctx, _cache) => { return { a: common_vendor.sr(indexVideo, "7541f511-0", { "k": "indexVideo" }), b: common_vendor.o$1(handleShowCommentAlt), c: common_vendor.o$1(handleShowCollectAlt), d: common_vendor.o$1(handleShowShareFirend), e: common_vendor.o$1(videoLike), f: common_vendor.o$1(detailMenu), g: common_vendor.p({ item: detail, tabIndex: 0, isMine: isMine.value, index: 0, current: 0, mode: "detail" }), h: common_vendor.sr("commentRef", "7541f511-1"), i: common_vendor.sr("collectRef", "7541f511-2"), j: common_vendor.sr("shareFirendRef", "7541f511-3") }; }; } }; wx.createPage(_sfc_main);