259 lines
7.6 KiB
JavaScript
259 lines
7.6 KiB
JavaScript
|
"use strict";
|
||
|
const common_vendor = require("../../common/vendor.js");
|
||
|
const common_assets = require("../../common/assets.js");
|
||
|
const common_js_util = require("../../common/js/util.js");
|
||
|
if (!Array) {
|
||
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||
|
_easycom_uni_icons2();
|
||
|
}
|
||
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
||
|
if (!Math) {
|
||
|
(statusBar + _easycom_uni_icons)();
|
||
|
}
|
||
|
const statusBar = () => "../header/statusBar.js";
|
||
|
const _sfc_main = {
|
||
|
__name: "indexVideo",
|
||
|
props: {
|
||
|
// 当前视频对象
|
||
|
item: {
|
||
|
type: Object
|
||
|
},
|
||
|
// 列表中的视频下标
|
||
|
index: {
|
||
|
type: Number
|
||
|
},
|
||
|
// 当前列表的index
|
||
|
current: {
|
||
|
type: Number
|
||
|
},
|
||
|
// 当前tab的index
|
||
|
tabIndex: {
|
||
|
type: Number
|
||
|
},
|
||
|
// 模式 list列表 detail详情
|
||
|
mode: {
|
||
|
type: String,
|
||
|
default: "list"
|
||
|
},
|
||
|
// 是否我自己 0不是 1是
|
||
|
isMine: {
|
||
|
type: [String, Number],
|
||
|
default: 0
|
||
|
}
|
||
|
},
|
||
|
emits: ["showTime", "showComment", "showCollect", "showShareFirend", "onPlay", "onPause", "like", "detailMenu", "onEnd"],
|
||
|
setup(__props, { expose: __expose, emit: __emit }) {
|
||
|
const props = __props;
|
||
|
const emit = __emit;
|
||
|
const videoCtx = common_vendor.ref(null);
|
||
|
const playState = common_vendor.ref(true);
|
||
|
const collectFirst = common_vendor.ref(false);
|
||
|
const videoTime = common_vendor.reactive({
|
||
|
// 总长
|
||
|
duration: 0,
|
||
|
// 当前时间
|
||
|
currentTime: 0
|
||
|
});
|
||
|
let videoCurrentTime = common_vendor.ref(0);
|
||
|
const alarmTime = common_vendor.computed(() => {
|
||
|
let result = common_vendor.index.$store.state.alarmTime;
|
||
|
return result;
|
||
|
});
|
||
|
common_vendor.onMounted(() => {
|
||
|
videoCtx.value = common_vendor.index.createVideoContext(`video${props.tabIndex}${props.index}`);
|
||
|
});
|
||
|
function handleVideo() {
|
||
|
if (playState.value)
|
||
|
pause();
|
||
|
else
|
||
|
play();
|
||
|
}
|
||
|
function play() {
|
||
|
videoCtx.value.play();
|
||
|
}
|
||
|
function pause() {
|
||
|
videoCtx.value.pause();
|
||
|
}
|
||
|
function onVideoPlay() {
|
||
|
playState.value = true;
|
||
|
emit("onPlay");
|
||
|
}
|
||
|
function onVideoPause() {
|
||
|
playState.value = false;
|
||
|
emit("onPause");
|
||
|
}
|
||
|
function handleComment() {
|
||
|
emit("showComment", props.item);
|
||
|
}
|
||
|
function handleTime() {
|
||
|
emit("showTime");
|
||
|
}
|
||
|
function showCollect() {
|
||
|
common_js_util.util.isLogin().then((rs) => {
|
||
|
emit("showCollect", props.item);
|
||
|
}).catch(() => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/login/loginPhone"
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
function handleCollectFirst() {
|
||
|
return;
|
||
|
}
|
||
|
function handleShareFirend() {
|
||
|
common_js_util.util.isLogin().then((rs) => {
|
||
|
emit("showShareFirend", props.item);
|
||
|
}).catch(() => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/login/loginPhone"
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
function handleLike(index, isLike) {
|
||
|
common_js_util.util.isLogin().then((rs) => {
|
||
|
emit("like", {
|
||
|
index,
|
||
|
isLike
|
||
|
});
|
||
|
}).catch(() => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/login/loginPhone"
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
function handlePrivateLike(index) {
|
||
|
common_js_util.util.isLogin().then((rs) => {
|
||
|
common_js_util.util.alert({
|
||
|
title: "提示",
|
||
|
content: "请确认,是否为隐私赞(隐私赞仅自己和作者可见)?",
|
||
|
confirmText: "隐私赞",
|
||
|
cancelText: "公开赞"
|
||
|
}).then((rs2) => {
|
||
|
if (rs2.confirm)
|
||
|
emit("like", {
|
||
|
index,
|
||
|
isLike: 3
|
||
|
});
|
||
|
});
|
||
|
}).catch(() => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/login/loginPhone"
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
function handleDetailMenu(item) {
|
||
|
emit("detailMenu");
|
||
|
}
|
||
|
function handleTimeupdate(ev) {
|
||
|
Object.assign(videoTime, ev.detail);
|
||
|
if (videoTime.duration != 0)
|
||
|
videoCurrentTime.value = videoTime.currentTime / videoTime.duration * 750;
|
||
|
}
|
||
|
function handleEnded() {
|
||
|
videoCurrentTime.value = 750;
|
||
|
videoCtx.value.stop();
|
||
|
play();
|
||
|
emit("onEnd");
|
||
|
}
|
||
|
function handleUser(item) {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: common_js_util.util.setUrl("/pages/index/videoHome", {
|
||
|
userId: item.userId
|
||
|
})
|
||
|
});
|
||
|
}
|
||
|
__expose({
|
||
|
play,
|
||
|
pause,
|
||
|
videoTime,
|
||
|
item: props.item,
|
||
|
playState,
|
||
|
videoCtx: () => videoCtx.value
|
||
|
});
|
||
|
return (_ctx, _cache) => {
|
||
|
return common_vendor.e({
|
||
|
a: "video" + __props.tabIndex + __props.index,
|
||
|
b: __props.item.format_videoUrl,
|
||
|
c: common_vendor.o$1(handleVideo),
|
||
|
d: common_vendor.o$1(onVideoPlay),
|
||
|
e: common_vendor.o$1(onVideoPause),
|
||
|
f: common_vendor.o$1((...args) => _ctx.loadEnd && _ctx.loadEnd(...args)),
|
||
|
g: common_vendor.o$1(handleTimeupdate),
|
||
|
h: common_vendor.o$1(handleEnded),
|
||
|
i: common_vendor.unref(videoCurrentTime) + "rpx",
|
||
|
j: !playState.value
|
||
|
}, !playState.value ? {
|
||
|
k: common_assets._imports_0$15
|
||
|
} : {}, {
|
||
|
l: __props.item.format_header,
|
||
|
m: !__props.item.isAttention
|
||
|
}, !__props.item.isAttention ? {
|
||
|
n: common_assets._imports_1$4
|
||
|
} : {}, {
|
||
|
o: common_vendor.unref(common_js_util.util).setUrl("/pages/index/videoHome", {
|
||
|
userId: __props.item.userId
|
||
|
}),
|
||
|
p: __props.item.isLike == 0
|
||
|
}, __props.item.isLike == 0 ? {
|
||
|
q: common_assets._imports_2$2
|
||
|
} : __props.item.isLike == 1 || __props.item.isLike == 3 ? {
|
||
|
s: common_assets._imports_3
|
||
|
} : {}, {
|
||
|
r: __props.item.isLike == 1 || __props.item.isLike == 3,
|
||
|
t: __props.item.isLike == 3
|
||
|
}, __props.item.isLike == 3 ? {
|
||
|
v: common_assets._imports_4$2
|
||
|
} : {}, {
|
||
|
w: common_vendor.t(__props.item.likes),
|
||
|
x: common_vendor.o$1(($event) => handleLike(__props.index, 0)),
|
||
|
y: common_vendor.o$1(($event) => handlePrivateLike(__props.index)),
|
||
|
z: common_assets._imports_5,
|
||
|
A: common_vendor.t(__props.item.comment),
|
||
|
B: common_vendor.o$1(handleComment),
|
||
|
C: common_vendor.f(5, (item, index, i0) => {
|
||
|
return {
|
||
|
a: index
|
||
|
};
|
||
|
}),
|
||
|
D: common_assets._imports_6,
|
||
|
E: collectFirst.value ? 1 : "",
|
||
|
F: __props.item.isCollect
|
||
|
}, __props.item.isCollect ? {
|
||
|
G: common_assets._imports_7
|
||
|
} : {
|
||
|
H: common_assets._imports_8
|
||
|
}, {
|
||
|
I: common_vendor.t(__props.item.collect),
|
||
|
J: common_vendor.o$1(showCollect),
|
||
|
K: common_vendor.o$1(handleCollectFirst),
|
||
|
L: common_assets._imports_9,
|
||
|
M: common_vendor.o$1(handleShareFirend),
|
||
|
N: __props.mode == "list"
|
||
|
}, __props.mode == "list" ? common_vendor.e({
|
||
|
O: alarmTime.value
|
||
|
}, alarmTime.value ? {
|
||
|
P: common_assets._imports_10
|
||
|
} : {
|
||
|
Q: common_assets._imports_11
|
||
|
}, {
|
||
|
R: common_vendor.o$1(handleTime)
|
||
|
}) : {}, {
|
||
|
S: __props.mode == "detail" && __props.isMine == 1
|
||
|
}, __props.mode == "detail" && __props.isMine == 1 ? {
|
||
|
T: common_vendor.p({
|
||
|
type: "more-filled",
|
||
|
color: "#d8d8d8",
|
||
|
size: "70rpx"
|
||
|
}),
|
||
|
U: common_vendor.o$1(handleDetailMenu),
|
||
|
V: common_vendor.o$1(handleTime)
|
||
|
} : {}, {}, {
|
||
|
Y: common_vendor.t(__props.item.userName),
|
||
|
Z: common_vendor.o$1(($event) => handleUser(__props.item)),
|
||
|
aa: common_vendor.t(__props.item.title)
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
wx.createComponent(_sfc_main);
|