技能培训添加自动播放上次播放进度功能、首页招聘会入口更改
This commit is contained in:
@@ -114,15 +114,15 @@ const generateTabbarList = () => {
|
|||||||
// 求职者用户(包括未登录状态):显示招聘会
|
// 求职者用户(包括未登录状态):显示招聘会
|
||||||
// H5端隐藏招聘会
|
// H5端隐藏招聘会
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
baseItems.splice(1, 0, {
|
// baseItems.splice(1, 0, {
|
||||||
id: 1,
|
// id: 1,
|
||||||
text: '招聘会',
|
// text: '招聘会',
|
||||||
path: '/pages/careerfair/careerfair',
|
// path: '/pages/careerfair/careerfair',
|
||||||
iconPath: '/static/tabbar/post.png',
|
// iconPath: '/static/tabbar/post.png',
|
||||||
selectedIconPath: '/static/tabbar/posted.png',
|
// selectedIconPath: '/static/tabbar/posted.png',
|
||||||
centerItem: false,
|
// centerItem: false,
|
||||||
badge: readMsg.badges[1]?.count || 0,
|
// badge: readMsg.badges[1]?.count || 0,
|
||||||
});
|
// });
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,20 @@
|
|||||||
<view class="video-detail-container">
|
<view class="video-detail-container">
|
||||||
<!-- 视频播放组件 -->
|
<!-- 视频播放组件 -->
|
||||||
<view class="video-wrapper">
|
<view class="video-wrapper">
|
||||||
<video v-if="videoInfo && videoInfo.cover" id="myVideo" :src="videoInfo.currentUrl" :poster="trainVideoImgUrl+ videoInfo.cover" @seeked="onSeeked"
|
<video
|
||||||
|
v-if="videoInfo && videoInfo.cover && isVideoReady"
|
||||||
|
id="myVideo"
|
||||||
|
:src="videoInfo.currentUrl"
|
||||||
|
:poster="trainVideoImgUrl+ videoInfo.cover"
|
||||||
:initial-time="initialTime"
|
:initial-time="initialTime"
|
||||||
preload="metadata"
|
:autoplay="shouldAutoPlay"
|
||||||
enable-danmu controls style="width: 100%;" @pause="onPause" @timeupdate="onTimeupdate" @ended="onEnded"></video>
|
enable-danmu
|
||||||
|
controls
|
||||||
|
style="width: 100%;"
|
||||||
|
@pause="onPause"
|
||||||
|
@timeupdate="onTimeupdate"
|
||||||
|
@ended="onEnded">
|
||||||
|
</video>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="video-info" :style="getItemBackgroundStyle('video-bj2.png')">
|
<view class="video-info" :style="getItemBackgroundStyle('video-bj2.png')">
|
||||||
@@ -134,7 +144,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { inject, reactive,ref, onMounted, onUnmounted, nextTick } from 'vue';
|
import { inject, reactive,ref, onMounted, onUnmounted, nextTick ,watch} from 'vue';
|
||||||
import { onLoad,onHide,onUnload } from '@dcloudio/uni-app';
|
import { onLoad,onHide,onUnload } from '@dcloudio/uni-app';
|
||||||
const { $api, navTo, navBack } = inject('globalFunction');
|
const { $api, navTo, navBack } = inject('globalFunction');
|
||||||
import config from "@/config.js"
|
import config from "@/config.js"
|
||||||
@@ -153,6 +163,8 @@ const totalTime=ref(0)
|
|||||||
const baseUrl = config.imgBaseUrl
|
const baseUrl = config.imgBaseUrl
|
||||||
const pageEnterTime = ref(0)
|
const pageEnterTime = ref(0)
|
||||||
const currentChapter = ref(0)
|
const currentChapter = ref(0)
|
||||||
|
const isVideoReady = ref(false)
|
||||||
|
const shouldAutoPlay = ref(false)
|
||||||
const getItemBackgroundStyle = (imageName) => ({
|
const getItemBackgroundStyle = (imageName) => ({
|
||||||
backgroundImage: `url(${baseUrl}/train/${imageName})`,
|
backgroundImage: `url(${baseUrl}/train/${imageName})`,
|
||||||
backgroundSize: '100% 100%', // 覆盖整个容器
|
backgroundSize: '100% 100%', // 覆盖整个容器
|
||||||
@@ -169,6 +181,25 @@ const params = reactive({
|
|||||||
videoId: '',
|
videoId: '',
|
||||||
userId: ''
|
userId: ''
|
||||||
})
|
})
|
||||||
|
// 监听 initialTime 变化,确保设置完成后再渲染
|
||||||
|
watch(initialTime, (newVal) => {
|
||||||
|
if (newVal >= 0 && videoInfo.value && videoInfo.value.cover) {
|
||||||
|
// 延迟渲染,确保初始时间设置生效
|
||||||
|
nextTick(() => {
|
||||||
|
isVideoReady.value = true
|
||||||
|
shouldAutoPlay.value = newVal > 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 监听 videoInfo 变化
|
||||||
|
watch([videoInfo, initialTime], ([newVideoInfo, newInitialTime]) => {
|
||||||
|
if (newVideoInfo && newVideoInfo.cover && newInitialTime >= 0) {
|
||||||
|
nextTick(() => {
|
||||||
|
isVideoReady.value = true
|
||||||
|
shouldAutoPlay.value = newInitialTime > 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, { deep: true })
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
getHeart()
|
getHeart()
|
||||||
pageEnterTime.value = Date.now() // 记录毫秒时间戳
|
pageEnterTime.value = Date.now() // 记录毫秒时间戳
|
||||||
@@ -180,7 +211,8 @@ onLoad((options) => {
|
|||||||
// reportPageDuration()
|
// reportPageDuration()
|
||||||
// })
|
// })
|
||||||
onUnload(() => {
|
onUnload(() => {
|
||||||
// updateVideoInfo()
|
//updateVideoInfo()
|
||||||
|
saveCurrentChapterProgress()
|
||||||
reportPageDuration()
|
reportPageDuration()
|
||||||
})
|
})
|
||||||
function getData() {
|
function getData() {
|
||||||
@@ -199,8 +231,10 @@ function getData() {
|
|||||||
videoInfo.value.percentage=((videoInfo.value.process/(videoInfo.value.hour*60))*100).toFixed(2)
|
videoInfo.value.percentage=((videoInfo.value.process/(videoInfo.value.hour*60))*100).toFixed(2)
|
||||||
videoInfo.value.uploadTime=videoInfo.value.uploadTime.split(' ')[0]
|
videoInfo.value.uploadTime=videoInfo.value.uploadTime.split(' ')[0]
|
||||||
if(videoInfo.value.process !=null){
|
if(videoInfo.value.process !=null){
|
||||||
latestTime.value=videoInfo.value.process
|
queryModelUserPlay(videoInfo.value.trainClassList[0].classId)
|
||||||
initialTime.value=videoInfo.value.process
|
} else {
|
||||||
|
// 如果没有历史进度,直接准备渲染
|
||||||
|
initialTime.value = 0
|
||||||
}
|
}
|
||||||
updateVideoInfo()
|
updateVideoInfo()
|
||||||
});
|
});
|
||||||
@@ -250,16 +284,18 @@ function getLevelLabelByValue(value) {
|
|||||||
}
|
}
|
||||||
function onPause(e){
|
function onPause(e){
|
||||||
updateVideoInfo()
|
updateVideoInfo()
|
||||||
|
saveCurrentChapterProgress()
|
||||||
}
|
}
|
||||||
function onEnded(e){
|
function onEnded(e){
|
||||||
updateVideoInfo()
|
updateVideoInfo()
|
||||||
|
saveCurrentChapterProgress()
|
||||||
}
|
}
|
||||||
function onTimeupdate(e){
|
function onTimeupdate(e){
|
||||||
latestTime.value = e.detail.currentTime
|
latestTime.value = e.detail.currentTime
|
||||||
}
|
}
|
||||||
function onSeeked(){
|
// function onSeeked(){
|
||||||
updateVideoInfo()
|
// updateVideoInfo()
|
||||||
}
|
// }
|
||||||
// 更新播放时长
|
// 更新播放时长
|
||||||
function updateVideoInfo(){
|
function updateVideoInfo(){
|
||||||
totalTime.value=0
|
totalTime.value=0
|
||||||
@@ -318,8 +354,58 @@ function reportPageDuration() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function chapterChange(video,index){
|
function chapterChange(video,index){
|
||||||
|
saveCurrentChapterProgress()
|
||||||
currentChapter.value=index
|
currentChapter.value=index
|
||||||
videoInfo.value.currentUrl=trainVideoImgUrl+video.url
|
videoInfo.value.currentUrl=trainVideoImgUrl+video.url
|
||||||
|
isVideoReady.value = false
|
||||||
|
shouldAutoPlay.value = false
|
||||||
|
queryModelUserPlay(video.classId)
|
||||||
|
}
|
||||||
|
const updateUserPlayClassHousr = (classId,hour) => {
|
||||||
|
let paramsData={
|
||||||
|
userId:userId.value,
|
||||||
|
classId:classId,
|
||||||
|
hour:hour,
|
||||||
|
dqHour:latestTime.value
|
||||||
|
}
|
||||||
|
let header={
|
||||||
|
'Authorization':uni.getStorageSync('Padmin-Token'),
|
||||||
|
'Content-Type': "application/x-www-form-urlencoded"
|
||||||
|
}
|
||||||
|
$api.myRequest('/train/public/videoUser/updateUserPlayClassHousr', paramsData,'post',9100,header).then((resData) => {
|
||||||
|
if(resData.code == 200){
|
||||||
|
console.log("学习时长更新成功")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const queryModelUserPlay = (classId) => {
|
||||||
|
let queryParams = {
|
||||||
|
classId: classId,
|
||||||
|
userId: userId.value,
|
||||||
|
};
|
||||||
|
let header = {
|
||||||
|
Authorization: uni.getStorageSync("Padmin-Token"),
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
};
|
||||||
|
$api.myRequest("/train/public/videoUser/modelUserPlay", queryParams, "post", 9100, header).then((resData) => {
|
||||||
|
if(resData.code == 200){
|
||||||
|
initialTime.value=Number(resData?.data?.dqHour ?? 0)
|
||||||
|
}else {
|
||||||
|
initialTime.value = 0
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
initialTime.value = 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存当前章节进度
|
||||||
|
function saveCurrentChapterProgress() {
|
||||||
|
if (videoInfo.value.trainClassList && videoInfo.value.trainClassList.length > 0) {
|
||||||
|
const currentVideo = videoInfo.value.trainClassList[currentChapter.value];
|
||||||
|
if (currentVideo) {
|
||||||
|
updateUserPlayClassHousr(currentVideo.classId, currentVideo.hour);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="service-title">薪酬信息</view>
|
<view class="service-title">薪酬信息</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="service-item press-button" @click="handleJobFairClick">
|
||||||
|
<view class="service-icon service-icon-1">
|
||||||
|
<uni-icons type="shop" size="32" color="#FFFFFF"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="service-title">招聘会</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
@@ -760,6 +766,9 @@ const handleLiveClick = () => {
|
|||||||
const handleSalaryInfoClick = () => {
|
const handleSalaryInfoClick = () => {
|
||||||
navTo('/pages/service/salary-info');
|
navTo('/pages/service/salary-info');
|
||||||
};
|
};
|
||||||
|
const handleJobFairClick = () => {
|
||||||
|
navTo('/pages/careerfair/careerfair');
|
||||||
|
};
|
||||||
const handleH5SalaryClick = () => {
|
const handleH5SalaryClick = () => {
|
||||||
const salaryUrl = "https://www.mohrss.gov.cn/SYrlzyhshbzb/laodongguanxi_/fwyd/202506/t20250627_544623.html";
|
const salaryUrl = "https://www.mohrss.gov.cn/SYrlzyhshbzb/laodongguanxi_/fwyd/202506/t20250627_544623.html";
|
||||||
window.location.assign(salaryUrl);
|
window.location.assign(salaryUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user