jiuyiUniapp/jiuyi2/unpackage/dist/dev/.nvue/pages/index/videoDetail.js

208 lines
6.0 KiB
JavaScript

import { getCurrentInstance, ref, reactive, openBlock, createElementBlock, createElementVNode, createCommentVNode, 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, { expose: __expose }) {
__expose();
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", (item) => {
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(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.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;
}
util.alert({
content: rs.msg,
showCancel: false
});
});
}
function detailMenu(item) {
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();
}
});
}
const __returned__ = { proxy, videoId, detail, isMine, getVideoDetail, handleShowCommentAlt, handleShowCollectAlt, handleShowShareFirend, videoLike, detailMenu, ref, getCurrentInstance, reactive, get onLoad() {
return onLoad;
}, get onHide() {
return onHide;
}, get util() {
return util;
}, get api() {
return api;
}, indexVideo, commentAlt, collectAlt, shareFirendAlt };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("scroll-view", {
scrollY: true,
showScrollbar: true,
enableBackToTop: true,
bubble: "true",
style: { flexDirection: "column" }
}, [
createElementVNode("view", { class: "page f1" }, [
createCommentVNode(" "),
createVNode($setup["indexVideo"], {
ref: "indexVideo",
item: $setup.detail,
tabIndex: 0,
isMine: $setup.isMine,
index: 0,
current: 0,
mode: "detail",
onShowComment: $setup.handleShowCommentAlt,
onShowCollect: $setup.handleShowCollectAlt,
onShowShareFirend: $setup.handleShowShareFirend,
onLike: $setup.videoLike,
onDetailMenu: $setup.detailMenu
}, null, 8, ["item", "isMine"]),
createCommentVNode(" 评论弹窗 "),
createVNode(
$setup["commentAlt"],
{ ref: "commentRef" },
null,
512
/* NEED_PATCH */
),
createCommentVNode(" 收藏弹窗 "),
createVNode(
$setup["collectAlt"],
{ ref: "collectRef" },
null,
512
/* NEED_PATCH */
),
createCommentVNode(" 分享到好友弹窗 "),
createVNode(
$setup["shareFirendAlt"],
{ ref: "shareFirendRef" },
null,
512
/* NEED_PATCH */
)
])
]);
}
const videoDetail = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["styles", [_style_0]], ["__file", "D:/document/九亿商城/jy/jiuyi2/pages/index/videoDetail.nvue"]]);
export {
videoDetail as default
};