Commit 4613f5fe by zeyang

优化视频统计

parent 89f44337
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
api.loginVerification({ "loginType": 3, "mobile": mobile.value, "code": code.value, "password": null, "loginSystem": "1" }).then((res) => { api.loginVerification({ "loginType": 3, "mobile": mobile.value, "code": code.value, "password": null, "loginSystem": "1" }).then((res) => {
if (res['success']) { 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('uni-token', res['data']['token']);
uni.setStorageSync('isLogin', '1'); uni.setStorageSync('isLogin', '1');
uni.setStorageSync('loginType', 'codelogin'); uni.setStorageSync('loginType', 'codelogin');
...@@ -162,14 +162,14 @@ ...@@ -162,14 +162,14 @@
}) })
} }
const next = () => { const next = () => {
uni.navigateTo({ uni.redirectTo({
url: '/myPackageA/videoProject/videoDetail?videoId=' + videoId.value url: '/myPackageA/videoProject/videoDetail?videoId=' + videoId.value
}) })
}; };
onLoad(option => { onLoad(option => {
videoId.value = option.videoId ?? null; videoId.value = option.videoId ?? null;
if (uni.getStorageSync('cffp_userId')) { if (uni.getStorageSync('video_userId')) {
next(); next();
} }
}) })
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="content"> <view class="content">
<view class="video"> <view class="video">
<video id="myVideo" :src="courseInfo.filePathOss" :poster="courseInfo.fileFirstImage" object-fit="contain" <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> @timeupdate="timeupdate" @play="playVideo" @pause="pause"></video>
</view> </view>
<scroll-view id="scrollView" scroll-y="true" :style="{height:scrollViewHeight+'px'}" <scroll-view id="scrollView" scroll-y="true" :style="{height:scrollViewHeight+'px'}"
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
相关视频 相关视频
</view> </view>
</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 class="relatedVideoItem" v-for="item in relatedCourseList" @click="play(item)">
<view style="width: 46.5vw;"> <view style="width: 46.5vw;">
<image style="height: 46.5vw;border-radius: 16rpx;" :src="item.displayImage" <image style="height: 46.5vw;border-radius: 16rpx;" :src="item.displayImage"
...@@ -55,6 +55,10 @@ ...@@ -55,6 +55,10 @@
</view> </view>
</view> </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> --> <!-- <uni-load-more iconType="circle" :status="moreStatus"></uni-load-more> -->
</view> </view>
</scroll-view> </scroll-view>
...@@ -64,7 +68,7 @@ ...@@ -64,7 +68,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted } from "vue"; import { ref } from "vue";
import api from "@/api/api"; import api from "@/api/api";
import { cffpURL } from "@/environments/environment"; import { cffpURL } from "@/environments/environment";
import common from '../../common/common'; import common from '../../common/common';
...@@ -126,8 +130,9 @@ ...@@ -126,8 +130,9 @@
// 相关列表点击播放 // 相关列表点击播放
const play = async item => { const play = async item => {
videoContext.value.pause();
if (videoId.value != item.fileId) { if (videoId.value != item.fileId) {
videoContext.value.pause();
// 当点击的课程和当前播放的课程不一致时,执行此方法 // 当点击的课程和当前播放的课程不一致时,执行此方法
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中'
...@@ -140,6 +145,11 @@ ...@@ -140,6 +145,11 @@
if (isPauseFlag) { if (isPauseFlag) {
pause(); pause();
} }
} else {
uni.showToast({
title: '当前播放已是此视频',
icon: 'none'
})
} }
} }
...@@ -309,34 +319,37 @@ ...@@ -309,34 +319,37 @@
}) })
} }
onLoad(option => { onLoad(option => {
console.log(2);
//视频Id //视频Id
if (option.videoId) { if (option.videoId && option.videoId!='null') {
uni.setStorageSync('cffp_videoId', option.videoId); uni.setStorageSync('cffp_videoId', option.videoId);
videoId.value = option.videoId; videoId.value = option.videoId;
} else { } else {
videoId.value = uni.getStorageSync('cffp_videoId'); videoId.value = uni.getStorageSync('cffp_videoId');
} }
//用户Id //用户Id
userId.value = uni.getStorageSync('cffp_userId'); userId.value = uni.getStorageSync('video_userId');
if (!userId.value) { })
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({ uni.showToast({
title: '登录过期,请重新登录' title: '登录过期,请重新登录',
icon: 'none'
}); });
uni.reLaunch({ uni.reLaunch({
url: '/myPackageA/videoProject/login?videoId=' + videoId.value url: '/myPackageA/videoProject/login?videoId=' + videoId.value
}); });
return; return;
}else{
accessLogSave();
loadCourseDetail();
} }
accessLogSave();
loadCourseDetail();
})
onReady(() => {
}) })
onUnload(() => { onUnload(() => {
if (viewTime.value != 0) { if (viewTime.value != 0) {
...@@ -347,19 +360,6 @@ ...@@ -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> </script>
<style lang="scss"> <style lang="scss">
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
} }
api.wxLogin(param).then((res) => { api.wxLogin(param).then((res) => {
if (res['success']) { 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('uni-token', res['data']['token']);
uni.setStorageSync('isLogin', '1'); uni.setStorageSync('isLogin', '1');
uni.setStorageSync('loginType', 'codelogin'); uni.setStorageSync('loginType', 'codelogin');
uni.navigateTo({ uni.redirectTo({
url:'/myPackageA/videoProject/videoDetail?videoId='+option.fileId url:'/myPackageA/videoProject/videoDetail?videoId='+option.fileId
}) })
} else { } else {
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
duration: 2000, duration: 2000,
icon: 'none' icon: 'none'
}) })
uni.navigateTo({ uni.redirectTo({
url:'/myPackageA/videoProject/login?videoId='+option.fileId 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