Commit 54356fc9 authored by jyx's avatar jyx

代码优化

parent da038380
......@@ -3,12 +3,12 @@
<swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true" duration="300">
<swiper-item v-for="(list, index) in displaySwiperList" :key="index">
<view v-if="Math.abs(displayIndex-index)==0" style="height: 100%;" @click="tapVideoHover()">
<tt-video-player v-if="Math.abs(displayIndex-index)==0" :id="list.vedioId" class="tsvideo"
<tt-video-player v-if="Math.abs(displayIndex-index)==0" :id="'remmend'+list.vedioId" class="tsvideo"
:album-id="list.douyinAlbumId" :cover-id="list.douyinCoverId" :episode-id="list.douyinEpisodeId"
:cloud-type="1" version="1" object-fit="cover" :controls="controls" :poster="data.coverImage"
:loop="!isplay" :autoplay="true" :enable-progress-gesture="false" :show-loading="true"
@play="startPlay" :show-fullscreen-btn="false" @controlstoggle="controlstoggle"
@timeupdate="timeUpdate" @ended="ended">
:loop="!isplay" :autoplay="false" :enable-progress-gesture="false" :show-loading="true"
:show-fullscreen-btn="false" @controlstoggle="controlstoggle" @timeupdate="timeUpdate"
@ended="ended">
</tt-video-player>
</view>
<view v-if="!isqp" class="userInfo flex">
......@@ -54,9 +54,8 @@
import common from '@/mixins/common';
import ttVideoPlayer from '@/ttcomponents/tt-video-player/index.js'
import {
navigateTo,
navigateTo,
message
} from '@/utils/fun.js';
......@@ -92,19 +91,12 @@
this.windowHeight = uni.getSystemInfoSync().windowHeight
},
methods: {
hide() {
try {
this.$refs.recommendVideo.stop();
} catch {
}
},
reShare() {
var href = ''
// #ifdef H5
uni.setClipboardData({
data: href,
complete() {
complete() {
message.notify("分享连接已复制到剪贴板")
}
})
......@@ -135,11 +127,13 @@
this.isFirstLoad = false
this.queryList()
} else {
tt.createVideoContext('' + this.originList[this.originIndex].vedioId, this).play();
this.videoContext.play()
}
},
stop() {
tt.createVideoContext('' + this.originList[this.originIndex].vedioId, this).pause();
hide() {
if (this.videoContext) {
this.videoContext.pause()
}
},
queryList() {
// 推荐
......@@ -199,26 +193,19 @@
if (this.oid < 0) {
this.oid = this.originList.length - 1
}
// console.log('++++++++++++上一条播放数据 Index:', this.oid)
// // audo.pause()
// this.videoContext = uni.createVideoContext("" + this.originList[this.oid].vedioId, this)
// this.videoContext.pause()
// this.videoContext.stop()
console.log('++++++++++++上一条播放数据 Index:', this.oid)
tt.createVideoContext('' + this.originList[this.oid].vedioId, this).pause();
if (this.videoContext) {
this.videoContext.pause()
this.videoContext.stop()
}
setTimeout(() => {
console.log('qqqqqq:', this.originList[originIndex].vedioId)
tt.createVideoContext('' + this.originList[originIndex].vedioId, this).play();
// this.commitVideo()
this.videoContext = tt.createVideoContext('remmend' + this.originList[originIndex].vedioId)
this.videoContext.play()
}, 500)
// setTimeout(() => {
// console.log('qqqqqq:', this.originList[originIndex].vedioId)
// this.videoContext = uni.createVideoContext("" + this.originList[originIndex].vedioId, this)
// this.videoContext.play()
// }, 500)
var pCount = this.originList.length - this.playCount
if (originIndex == pCount) {
this.queryList()
......@@ -273,8 +260,8 @@
showLoading: false,
success: ({
data
}) => {
message.notify("收藏成功")
}) => {
message.notify("收藏成功")
}
});
},
......@@ -289,8 +276,8 @@
showLoading: false,
success: ({
data
}) => {
message.notify("取消收藏")
}) => {
message.notify("取消收藏")
}
});
},
......
......@@ -155,6 +155,22 @@
// 渲染完成 初始化首页数据
this.loadComponentData();
},
onHide() {
try {
// 在子组件重写show()代替onShow()
if (this.currentPage == 0) {
this.$refs.index.hide();
} else if (this.currentPage == 1) {
this.$refs.recommend.hide();
} else if (this.currentPage == 2) {
this.$refs.follow.hide();
} else if (this.currentPage == 3) {
this.$refs.user.hide();
}
} catch (e) {
}
},
methods: {
tabChange(index) {
if (this.currentPage == index) return
......
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