Commit 4613f5fe by zeyang

优化视频统计

parent 89f44337
......@@ -129,7 +129,7 @@
api.loginVerification({ "loginType": 3, "mobile": mobile.value, "code": code.value, "password": null, "loginSystem": "1" }).then((res) => {
if (res['success']) {
uni.setStorageSync('cffp_userId', String(res['data']['userId']));
uni.setStorageSync('video_userId', String(res['data']['userId']));
uni.setStorageSync('uni-token', res['data']['token']);
uni.setStorageSync('isLogin', '1');
uni.setStorageSync('loginType', 'codelogin');
......@@ -162,14 +162,14 @@
})
}
const next = () => {
uni.navigateTo({
uni.redirectTo({
url: '/myPackageA/videoProject/videoDetail?videoId=' + videoId.value
})
};
onLoad(option => {
videoId.value = option.videoId ?? null;
if (uni.getStorageSync('cffp_userId')) {
if (uni.getStorageSync('video_userId')) {
next();
}
})
......
......@@ -2,7 +2,7 @@
<view class="content">
<view class="video">
<video id="myVideo" :src="courseInfo.filePathOss" :poster="courseInfo.fileFirstImage" object-fit="contain"
:title="courseInfo.fileTitle" style="width: 100vw;height: 500rpx;" :initial-time="viewTime"
:title="courseInfo.fileTitle" style="width: 100vw;height: 312.5rpx;" :initial-time="viewTime"
@timeupdate="timeupdate" @play="playVideo" @pause="pause"></video>
</view>
<scroll-view id="scrollView" scroll-y="true" :style="{height:scrollViewHeight+'px'}"
......@@ -44,7 +44,7 @@
相关视频
</view>
</view>
<view class="relatedVideoList">
<view class="relatedVideoList" v-if="relatedCourseList.length>0">
<view class="relatedVideoItem" v-for="item in relatedCourseList" @click="play(item)">
<view style="width: 46.5vw;">
<image style="height: 46.5vw;border-radius: 16rpx;" :src="item.displayImage"
......@@ -55,6 +55,10 @@
</view>
</view>
</view>
<view v-else
style="text-align: center;font-weight: 600;font-size: 42rpx;margin-top:50rpx;color: #8c8c8c;">
暂无相关视频
</view>
<!-- <uni-load-more iconType="circle" :status="moreStatus"></uni-load-more> -->
</view>
</scroll-view>
......@@ -64,7 +68,7 @@
</template>
<script lang="ts" setup>
import { ref, onMounted } from "vue";
import { ref } from "vue";
import api from "@/api/api";
import { cffpURL } from "@/environments/environment";
import common from '../../common/common';
......@@ -126,8 +130,9 @@
// 相关列表点击播放
const play = async item => {
videoContext.value.pause();
if (videoId.value != item.fileId) {
videoContext.value.pause();
// 当点击的课程和当前播放的课程不一致时,执行此方法
uni.showLoading({
title: '加载中'
......@@ -140,6 +145,11 @@
if (isPauseFlag) {
pause();
}
} else {
uni.showToast({
title: '当前播放已是此视频',
icon: 'none'
})
}
}
......@@ -309,34 +319,37 @@
})
}
onLoad(option => {
console.log(2);
//视频Id
if (option.videoId) {
if (option.videoId && option.videoId!='null') {
uni.setStorageSync('cffp_videoId', option.videoId);
videoId.value = option.videoId;
} else {
videoId.value = uni.getStorageSync('cffp_videoId');
}
//用户Id
userId.value = uni.getStorageSync('cffp_userId');
if (!userId.value) {
userId.value = uni.getStorageSync('video_userId');
})
onReady(() => {
videoContext.value = uni.createVideoContext('myVideo');
//窗口高度
windowHeight.value = uni.getSystemInfoSync().windowHeight;
//元素距离顶部距离
uni.createSelectorQuery().select('#scrollView').boundingClientRect(data => {
scrollViewHeight.value = windowHeight.value - data['top'];
}).exec();
if (!userId.value || !videoId.value) {
uni.showToast({
title: '登录过期,请重新登录'
title: '登录过期,请重新登录',
icon: 'none'
});
uni.reLaunch({
url: '/myPackageA/videoProject/login?videoId=' + videoId.value
});
return;
}else{
accessLogSave();
loadCourseDetail();
}
accessLogSave();
loadCourseDetail();
})
onReady(() => {
})
onUnload(() => {
if (viewTime.value != 0) {
......@@ -347,19 +360,6 @@
}
}
})
onMounted(() => {
userId.value = uni.getStorageSync('cffp_userId');
if (userId.value) {
videoContext.value = uni.createVideoContext('myVideo');
//窗口高度
windowHeight.value = uni.getSystemInfoSync().windowHeight;
//元素距离顶部距离
uni.createSelectorQuery().select('#scrollView').boundingClientRect(data => {
scrollViewHeight.value = windowHeight.value - data['top'];
}).exec();
}
})
</script>
<style lang="scss">
......
......@@ -14,11 +14,11 @@
}
api.wxLogin(param).then((res) => {
if (res['success']) {
uni.setStorageSync('cffp_userId', String(res['data']['userId']));
uni.setStorageSync('video_userId', String(res['data']['userId']));
uni.setStorageSync('uni-token', res['data']['token']);
uni.setStorageSync('isLogin', '1');
uni.setStorageSync('loginType', 'codelogin');
uni.navigateTo({
uni.redirectTo({
url:'/myPackageA/videoProject/videoDetail?videoId='+option.fileId
})
} else {
......@@ -27,7 +27,7 @@
duration: 2000,
icon: 'none'
})
uni.navigateTo({
uni.redirectTo({
url:'/myPackageA/videoProject/login?videoId='+option.fileId
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment