Commit d939f3ae authored by jyx's avatar jyx

代码优化

parent 4e9f5989
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
style="width:31%; position: relative; border-radius:20rpx;margin-bottom: 10rpx;margin-left: 14rpx;" style="width:31%; position: relative; border-radius:20rpx;margin-bottom: 10rpx;margin-left: 14rpx;"
@click.stop="click(value)" @longpress.stop="longClick(key)"> @click.stop="click(value)" @longpress.stop="longClick(key)">
<image class="integral-mall-goods" mode="aspectFill" :src="value.coverImage"></image> <image class="integral-mall-goods" mode="aspectFill" :src="value.coverImage"></image>
<view class="text" style="font-size: 26rpx;color: black;">{{value.title}}</view> <view class="text" style="font-size: 26rpx;color: black;height: 36rpx;">{{value.title}}</view>
<view class="text" style="font-size: 22rpx;color: gray;">{{value.vedioDesc}}</view> <view class="text" style="font-size: 22rpx;color: gray;height: 30rpx;">
{{value.vedioDesc}}
</view>
<view v-if="isEditStyle" @click.stop="cbClick(key)" style="position: absolute;background: #000000; opacity: 0.6;width: 92%;height: 100%;top: 0;border-radius:20rpx; <view v-if="isEditStyle" @click.stop="cbClick(key)" style="position: absolute;background: #000000; opacity: 0.6;width: 92%;height: 100%;top: 0;border-radius:20rpx;
padding-left: 20rpx;padding-top: 20rpx;"> padding-left: 20rpx;padding-top: 20rpx;">
<image v-if="value.isChecked" src="@/static/ic_selected.png" <image v-if="value.isChecked" src="@/static/ic_selected.png"
...@@ -74,9 +76,9 @@ ...@@ -74,9 +76,9 @@
}) => { }) => {
this.dataList = data.list; this.dataList = data.list;
if (this.dataList.length > 0) { if (this.dataList.length > 0) {
this.$emit("showEdit", true) this.$emit("showEditR", true)
} else { } else {
this.$emit("showEdit", false) this.$emit("showEditR", false)
} }
} }
}); });
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<swiper class="swiper" @change="swiperChange" :current="current" :disable-touch="showEditBar"> <swiper class="swiper" @change="swiperChange" :current="current" :disable-touch="showEditBar">
<swiper-item class="swiper-item"> <swiper-item class="swiper-item">
<followPage v-on:showEditBarR="showEditBarR" v-on:goRecommend="goRecommend" v-on:showEdit="showEdit" <followPage v-on:showEditBarR="showEditBarR" v-on:goRecommend="goRecommend" v-on:showEditR="showEditR"
ref="follow" /> ref="follow" />
</swiper-item> </swiper-item>
......
...@@ -3,26 +3,19 @@ ...@@ -3,26 +3,19 @@
<swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true" duration="300"> <swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true" duration="300">
<swiper-item v-for="(list, index) in displaySwiperList" :key="index"> <swiper-item v-for="(list, index) in displaySwiperList" :key="index">
<view v-if="Math.abs(displayIndex-index)!=0" style="z-index: 999;height: 100%;">
<video v-if="Math.abs(displayIndex-index)!=0" :id="''+list.vedioId" :controls="controls"
:loop="false" @ended="ended" @controlstoggle="controlstoggle" :show-fullscreen-btn="false"
@click="tapVideoHover()" :style="'width:100%; height:100%;'" :src="list.recommendUrl"
play-btn-position="center" object-fit="fill" />
</view>
<view v-if="Math.abs(displayIndex-index)==0" style="height: 100%;"> <view v-if="Math.abs(displayIndex-index)==0" style="height: 100%;">
<video v-if="Math.abs(displayIndex-index)==0" :id="''+list.vedioId" :controls="controls" <video v-if="Math.abs(displayIndex-index)==0" :id="''+list.vedioId" :controls="isqp" :isplay="true"
:isplay="true" :loop="!isplay" @ended="ended" @controlstoggle="controlstoggle" play-btn-position="center" :show-play-btn="isqp" :show-progress="true" :loop="!isplay"
:show-fullscreen-btn="false" @click="tapVideoHover()" :enable-progress-gesture="false" @ended="ended" @controlstoggle="controlstoggle" :show-fullscreen-btn="false"
:style="'width:100%; height:100%;'" :src="list.recommendUrl" play-btn-position="center" @click="tapVideoHover()" :enable-progress-gesture="false" :style="'width:100%; height:100%;'"
object-fit="fill" /> :src="list.recommendUrl" object-fit="fill" />
</view> </view>
<view v-if="isqp" class="userInfo flex"> <view v-if="!isqp" class="userInfo flex">
<!-- 点赞 --> <!-- 点赞 -->
<view class="flex" @click.stop="cLike(list.collect,list.id,list.mid);" <view class="flex" style="opacity: 0.9; margin-top: 10rpx;">
style="opacity: 0.9; margin-top: 10rpx;"> <image @click.stop="collect(list.vedioId,index)" v-if="list.collect==0"
<image @click="collect(list.vedioId,index)" v-if="list.collect==0"
src="@/static/home_collect_img_0.png" /> src="@/static/home_collect_img_0.png" />
<image @click="cancelCollect(list.vedioId,index)" v-if="list.collect==1" <image @click.stop="cancelCollect(list.vedioId,index)" v-if="list.collect==1"
src="@/static/home_collect_img_1.png" /> src="@/static/home_collect_img_1.png" />
<text <text
style="margin-top: 110rpx;color: #FFFFFF;font-size: 26rpx; text-align: center;font-weight: bold;" style="margin-top: 110rpx;color: #FFFFFF;font-size: 26rpx; text-align: center;font-weight: bold;"
...@@ -39,7 +32,7 @@ ...@@ -39,7 +32,7 @@
</view> </view>
</view> </view>
<!-- 最底下的文字部分 --> <!-- 最底下的文字部分 -->
<view v-if="isqp" class="contentcd flex" @click.stop="detail(list)"> <view v-if="!isqp" class="contentcd flex" @click.stop="detail(list)">
<text class="userName">{{list.title}}</text> <text class="userName">{{list.title}}</text>
<text class="words">{{'第'+list.recommendIndex+'集'}}</text> <text class="words">{{'第'+list.recommendIndex+'集'}}</text>
<view class="wordss2"> <view class="wordss2">
...@@ -81,12 +74,8 @@ ...@@ -81,12 +74,8 @@
oid: 0, oid: 0,
isplay: true, // 是否自动播放下一个视频 isplay: true, // 是否自动播放下一个视频
playCount: 2, // 剩余多少视频加载视频列表 playCount: 2, // 剩余多少视频加载视频列表
nodate: true, // true 有数据
issp: '',
isqp: false, // 是否全屏 isqp: false, // 是否全屏
page: 1,
urls: "https://xjc.demo.hongcd.com/api/video/videoRecommend?page=1&uid=0", urls: "https://xjc.demo.hongcd.com/api/video/videoRecommend?page=1&uid=0",
dataList: [],
isFirstLoad: true, isFirstLoad: true,
videoContext: null videoContext: null
} }
...@@ -94,12 +83,10 @@ ...@@ -94,12 +83,10 @@
onLoad(e) { onLoad(e) {
this.windowWidth = uni.getSystemInfoSync().windowWidth this.windowWidth = uni.getSystemInfoSync().windowWidth
this.windowHeight = uni.getSystemInfoSync().windowHeight this.windowHeight = uni.getSystemInfoSync().windowHeight
this.show()
}, },
methods: { methods: {
reShare() { reShare() {
var href = '/pages/client/video' + '?fxpid=' + this.uid var href = ''
// #ifdef H5 // #ifdef H5
uni.setClipboardData({ uni.setClipboardData({
data: href, data: href,
...@@ -134,7 +121,6 @@ ...@@ -134,7 +121,6 @@
show() { show() {
if (this.isFirstLoad) { if (this.isFirstLoad) {
this.isFirstLoad = false this.isFirstLoad = false
// this.queryRecommend()
this.queryList() this.queryList()
} else { } else {
this.videoContext?.play() this.videoContext?.play()
...@@ -156,33 +142,10 @@ ...@@ -156,33 +142,10 @@
for (let i = 0; i < msg.length; i++) { for (let i = 0; i < msg.length; i++) {
this.originList.push(msg[i]) this.originList.push(msg[i])
} }
if (this.page == 1) {
this.initSwiperData(); this.initSwiperData();
} }
this.page = this.page + 1
}
}); });
}, },
queryRecommend() {
uni.request({
url: this.urls,
success: (res) => {
if (res.data.isempty == 1) {
var msg = res.data.data
//2.这里把视频添加到视频列表
for (let i = 0; i < msg.length; i++) {
this.originList.push(msg[i])
}
if (this.page == 1) {
this.initSwiperData();
}
this.page = this.page + 1
} else {
this.nodate = false
}
}
})
},
tapVideoHover() { tapVideoHover() {
// 控制是否全屏 // 控制是否全屏
this.isqp = !this.isqp this.isqp = !this.isqp
...@@ -234,8 +197,7 @@ ...@@ -234,8 +197,7 @@
this.videoContext.play() this.videoContext.play()
}, 500) }, 500)
var pCount = this.originList.length - this.playCount var pCount = this.originList.length - this.playCount
if (originIndex == pCount && this.nodate) { if (originIndex == pCount) {
// this.queryRecommend()
this.queryList() this.queryList()
} }
}, },
...@@ -264,26 +226,17 @@ ...@@ -264,26 +226,17 @@
this.oid = this.originIndex + 1 this.oid = this.originIndex + 1
this.initSwiperData(this.originIndex); this.initSwiperData(this.originIndex);
} }
this.isqp = true this.isqp = false
}, },
controlstoggle(e) { controlstoggle(e) {
console.log(e.detail.show); console.log(e.detail.show);
this.issp = e.detail.show
}, },
detail(detail) { detail(detail) {
navigateTo(`/pagesC/video/videoDetail?data=` + encodeURIComponent(JSON.stringify(detail)) + navigateTo(`/pagesC/video/videoDetail?data=` + encodeURIComponent(JSON.stringify(detail)) +
`&playNext=1`) `&playNext=1`)
}, },
cLike(sss, vid, mid) {
if (uni.getStorageSync("userinfo")) {
} else {
this.loginTips()
return false
}
},
collect(vedioId, index) { collect(vedioId, index) {
this.dataList[index].collect = 1 this.originList[index].collect = 1
// 收藏 // 收藏
this.post({ this.post({
url: '/vedio/collect', url: '/vedio/collect',
...@@ -293,11 +246,15 @@ ...@@ -293,11 +246,15 @@
showLoading: false, showLoading: false,
success: ({ success: ({
data data
}) => {} }) => {
uni.showToast({
title: "收藏成功"
})
}
}); });
}, },
cancelCollect(vedioId, index) { cancelCollect(vedioId, index) {
this.dataList[index].collect = 0 this.originList[index].collect = 0
// 取消收藏 // 取消收藏
this.post({ this.post({
url: '/vedio/cancelCollect', url: '/vedio/cancelCollect',
...@@ -307,7 +264,11 @@ ...@@ -307,7 +264,11 @@
showLoading: false, showLoading: false,
success: ({ success: ({
data data
}) => {} }) => {
uni.showToast({
title: "取消收藏"
})
}
}); });
}, },
loginTips() { loginTips() {
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
<swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true"> <swiper class="swiper" circular @change="swiperChange" :current="current" :vertical="true">
<swiper-item v-for="(list, index) in displaySwiperList" :key="index" :style="'width:100%; height:100%;'"> <swiper-item v-for="(list, index) in displaySwiperList" :key="index" :style="'width:100%; height:100%;'">
<view :style="'width:100%; height:100%;'"> <view :style="'width:100%; height:100%;'">
<video v-if="Math.abs(displayIndex-index)==0 && list.vedioUrl" :id="list.vedioId" <video v-if="Math.abs(displayIndex-index)==0 && list.vedioUrl" :id="list.vedioIndex"
:controls="controls" :loop="!isplay" :enable-progress-gesture="false" :auto-play="true" :controls="isqp" :loop="!isplay" :enable-progress-gesture="false" :auto-play="true"
:show-center-play-btn="false" :show-loading="true" :show-fullscreen-btn="false" @ended="ended" :show-play-btn="isqp" :show-loading="true" :show-fullscreen-btn="false" @ended="ended"
@controlstoggle="controlstoggle" @click="tapVides()" @timeupdate="timeupdate" @controlstoggle="controlstoggle" @click="tapVides()" @timeupdate="timeupdate"
:style="'width:100%; height:100%;'" :src="list.vedioUrl" :poster="data.coverImage" :style="'width:100%; height:100%;'" :src="list.vedioUrl" :poster="data.coverImage"
class="tsvideo" play-btn-position="center" object-fit="fill" /> class="tsvideo" play-btn-position="center" object-fit="fill" />
...@@ -42,11 +42,11 @@ ...@@ -42,11 +42,11 @@
<image class="wordsss" src="@/static/up.png" /> <image class="wordsss" src="@/static/up.png" />
</view> </view>
</view> </view>
<view v-if="Math.abs(displayIndex-index)!=0 || !list.vedioUrl" class="videoHover tsimg" <view v-if="originIndex>=data.unlockIndex || !list.vedioUrl" class="videoHover tsimg"
@click.stop="tapVideoHover(index,list.pays)" @click.stop="tapVideoHover(index,list.pays)"
:style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'"> :style="'width: '+ windowWidth +'px; height:'+100+'%;'">
<image :src="data.coverImage" <image :src="data.coverImage"
:style="'width: 100%; height:'+heightxw+'%; background-color: #000; position: absolute;'" :style="'width: 100%; height:'+100+'%; background-color: #000; position: absolute;'"
mode="aspectFit" /> mode="aspectFit" />
<image class="playState" src="@/static/video/play.png" /> <image class="playState" src="@/static/video/play.png" />
</view> </view>
...@@ -58,8 +58,7 @@ ...@@ -58,8 +58,7 @@
<view v-if="fenji==1" <view v-if="fenji==1"
:style="'width: '+ windowWidth +'px; height: 860rpx; background-color: #202020; border-top-left-radius: 20rpx; border-top-right-radius: 20rpx;'"> :style="'width: '+ windowWidth +'px; height: 860rpx; background-color: #202020; border-top-left-radius: 20rpx; border-top-right-radius: 20rpx;'">
<view style="height: 70rpx;display: flex; flex-direction: row;align-items: center;"> <view style="height: 70rpx;display: flex; flex-direction: row;align-items: center;">
<image src="@/static/video/layers.png" style="width: 40rpx; height: 40rpx; margin-left: 20rpx;"> <image src="@/static/video/layers.png" style="width: 40rpx; height: 40rpx; margin-left: 20rpx;" />
</image>
<view <view
:style="'font-size: 30rpx; font-weight: bold; color: #FFFFFF; margin-left: 20rpx; overflow: hidden;'"> :style="'font-size: 30rpx; font-weight: bold; color: #FFFFFF; margin-left: 20rpx; overflow: hidden;'">
当前播放第{{ Number(originIndex+1) }} 当前播放第{{ Number(originIndex+1) }}
...@@ -86,7 +85,8 @@ ...@@ -86,7 +85,8 @@
<block v-for="(list,index2) in subList[index1]"> <block v-for="(list,index2) in subList[index1]">
<view @click.stop="selectThisVideo(index2 + (index1%30*30))" <view @click.stop="selectThisVideo(index2 + (index1%30*30))"
style="position: relative;width:16%;height: 120rpx; background: gray;border-radius: 10rpx;margin-left: 5rpx;margin-bottom: 5rpx;"> style="position: relative;width:16%;height: 120rpx; background: gray;border-radius: 10rpx;margin-left: 5rpx;margin-bottom: 5rpx;">
<image v-if="(index+1)>data.unlockIndex" src="@/static/video/lock.png" <image v-if="(index2+1 + (index1%30*30))>data.unlockIndex"
src="@/static/video/lock.png"
style="width:30rpx;height:30rpx;position:absolute;right:5rpx;top:5rpx;" /> style="width:30rpx;height:30rpx;position:absolute;right:5rpx;top:5rpx;" />
<view class="flex" <view class="flex"
style="width:100%;height:100%;align-items:center;justify-content:center;"> style="width:100%;height:100%;align-items:center;justify-content:center;">
...@@ -117,7 +117,10 @@ ...@@ -117,7 +117,10 @@
style="width: 50rpx; height: 50rpx; margin:0 20rpx 0 auto; "> style="width: 50rpx; height: 50rpx; margin:0 20rpx 0 auto; ">
</image> </image>
</view> </view>
<view @click="govip()" class="gdfgjh mt-30">开通VIP</view> <view style="color: white;text-align: center;">
{{'解锁 '+data.title+' 全集'}}
</view>
<view @click="govip()" class="button" style="margin:30rpx auto 50rpx auto;color: white;">开通VIP</view>
</view> </view>
</uni-popup> </uni-popup>
...@@ -204,37 +207,35 @@ ...@@ -204,37 +207,35 @@
this.windowWidth = uni.getSystemInfoSync().windowWidth this.windowWidth = uni.getSystemInfoSync().windowWidth
this.windowHeight = uni.getSystemInfoSync().windowHeight - this.safeArea - this.ttuop this.windowHeight = uni.getSystemInfoSync().windowHeight - this.safeArea - this.ttuop
console.log(this.windowHeight) console.log(this.windowHeight)
this.getData();
}, },
onShow() { onShow() {
this.getData() this.getData()
}, },
methods: { methods: {
govip() { govip() {
navigateTo(`/pagesA/vipPay/vipPay`)
}, },
timeupdate(event) { timeupdate(event) {
if (event.detail.currentTime > 0 && this.originList[this.originIndex].vedioIndex > this.data.unlockIndex) { if (event.detail.currentTime > 0 && this.originList[this.originIndex].vedioIndex > this.data.unlockIndex) {
uni.createVideoContext(this.originList[this.originIndex].vedioId, this).seek(0); uni.createVideoContext(this.originList[this.originIndex].vedioIndex, this).seek(0);
uni.createVideoContext(this.originList[this.originIndex].vedioId, this).pause(); uni.createVideoContext(this.originList[this.originIndex].vedioIndex, this).pause();
this.fenji = 2 this.fenji = 2
this.$refs.select.open('bottom'); this.$refs.select.open('bottom');
} }
}, },
selectThisVideo(index, pays) { selectThisVideo(index, pays) {
this.down(); this.down();
// if (pays == 1) { if (this.originList[this.originIndex].vedioIndex > this.data.unlockIndex) {
// this.fenji = 2 this.fenji = 2
// this.$refs.select.open('bottom'); this.$refs.select.open('bottom');
// } else { } else {
this.duration = 20; this.duration = 20;
this.originIndex = index this.originIndex = index
this.initSwiperData(index); this.initSwiperData(index);
setTimeout(() => { setTimeout(() => {
this.duration = 500; this.duration = 500;
}, 500) }, 500)
// } }
}, },
down() { down() {
this.$refs.select.close(); this.$refs.select.close();
...@@ -277,12 +278,11 @@ ...@@ -277,12 +278,11 @@
this.originIndex = this.data.unlockIndex - 1 this.originIndex = this.data.unlockIndex - 1
} }
} }
if (this.originIndex > this.data.vedioTotal || this.originIndex <= 0) { if (this.originIndex >= this.data.vedioTotal || this.originIndex < 0) {
this.originIndex = 0 this.originIndex = 0
} }
this.data = data.vedioMsg this.data = data.vedioMsg
this.initSwiperData(this.originIndex); this.initSwiperData(this.originIndex);
this.initEpisode() this.initEpisode()
} }
}); });
...@@ -296,7 +296,7 @@ ...@@ -296,7 +296,7 @@
} else { } else {
this.current = 0 this.current = 0
} }
this.isqp = true this.isqp = false
console.log('显示swiper Index:', this.displayIndex) console.log('显示swiper Index:', this.displayIndex)
} }
}, },
...@@ -329,19 +329,18 @@ ...@@ -329,19 +329,18 @@
this.oid = this.originList.length - 1 this.oid = this.originList.length - 1
} }
console.log('++++++++++++上一条播放数据 Index:', this.oid) console.log('++++++++++++上一条播放数据 Index:', this.oid)
uni.createVideoContext("" + this.originList[this.oid].vedioId, this).stop(); uni.createVideoContext("" + this.originList[this.oid].vedioIndex, this).stop();
if (this.originList[originIndex].vedioIndex > this.data.unlockIndex) { if (this.originList[originIndex].vedioIndex > this.data.unlockIndex) {
this.isqp = true this.isqp = false
this.fenji = 2 this.fenji = 2
this.$refs.select.open('bottom'); this.$refs.select.open('bottom');
} else { } else {
setTimeout(() => { setTimeout(() => {
this.isqp = true this.isqp = false
console.log('qqqqqq:', this.originList[originIndex + 1].vedioId) console.log('qqqqqq:', this.originList[originIndex].vedioIndex)
// audo.play() // audo.play()
uni.createVideoContext("" + this.originList[originIndex + 1].vedioId, this).play(); uni.createVideoContext("" + this.originList[originIndex].vedioIndex, this).play();
this.commitVideo() this.commitVideo()
}, 500) }, 500)
} }
...@@ -359,7 +358,7 @@ ...@@ -359,7 +358,7 @@
this.originIndex = this.originIndex =
this.originIndex + 1 == originListLength ? 0 : this.originIndex + 1; this.originIndex + 1 == originListLength ? 0 : this.originIndex + 1;
this.displayIndex = this.displayIndex + 1 == 3 ? 0 : this.displayIndex + 1; this.displayIndex = this.displayIndex + 1 == 3 ? 0 : this.displayIndex + 1;
//console.log('+++',this.originIndex) console.log('+++', this.originIndex)
this.oid = this.originIndex - 1 this.oid = this.originIndex - 1
this.initSwiperData(this.originIndex); this.initSwiperData(this.originIndex);
} }
...@@ -367,7 +366,7 @@ ...@@ -367,7 +366,7 @@
else if (this.displayIndex - current == -2 || this.displayIndex - current == 1) { else if (this.displayIndex - current == -2 || this.displayIndex - current == 1) {
this.originIndex = this.originIndex - 1 == -1 ? originListLength - 1 : this.originIndex - 1; this.originIndex = this.originIndex - 1 == -1 ? originListLength - 1 : this.originIndex - 1;
this.displayIndex = this.displayIndex - 1 == -1 ? 2 : this.displayIndex - 1; this.displayIndex = this.displayIndex - 1 == -1 ? 2 : this.displayIndex - 1;
//console.log('---',this.originIndex) console.log('---', this.originIndex)
this.oid = this.originIndex + 1 this.oid = this.originIndex + 1
this.initSwiperData(this.originIndex); this.initSwiperData(this.originIndex);
} }
...@@ -467,12 +466,14 @@ ...@@ -467,12 +466,14 @@
.videoHover { .videoHover {
position: absolute; position: absolute;
top: 0px; top: 0;
left: 0; left: 0;
flex: 1; display: flex;
background-color: rgba(0, 0, 0, 0.1); background-color: rgba(0, 0, 0, 0.1);
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.tsimg {}
} }
.playState { .playState {
...@@ -548,10 +549,11 @@ ...@@ -548,10 +549,11 @@
.contentcd { .contentcd {
z-index: 99; z-index: 99;
width: 100%; left: 4%;
width: 92%;
position: absolute; position: absolute;
// bottom: 36px; // bottom: 36px;
bottom: 0; bottom: 30rpx;
color: #ffffff; color: #ffffff;
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: flex-start;
......
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