测试短视频功能

This commit is contained in:
唐明明
2020-12-02 17:06:42 +08:00
parent 034b7906fa
commit dcc406f6a1
21 changed files with 401 additions and 183 deletions

View File

@@ -0,0 +1,67 @@
Page({
/**
* 页面的初始数据
*/
data: {
videoList : [], //获取短视频列表
videoIndex : 0, //当前播放视频的下标
videoId : "", //当前播放的视频id
playState : true, //视频播放状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.$api.video.videos().then(res=>{
this.setData({
videoList: res,
videoId : res[0].video_id
})
})
},
/***
* 视频的播放状态
*/
videoPlay(e){
if(e.detail.playType == "play" && this.data.playState == false){
this.setData({
playState : true,
videoId : e.detail.videoId
})
}else if(e.detail.playType == "pause" && this.data.playState == true){
this.setData({
playState : false
})
}
},
/**
* 获取视频下标
*/
swiperIndex(e){
this.setData({
videoIndex: e.detail.current
})
},
/**
* 点赞视频
*/
binLike(){
let hasLogin = wx.getStorageSync("token")
if(hasLogin == ""){
wx.navigateTo({
url: "/pages/login/login"
})
}else{
wx.showToast({
title: "点赞成功"
})
}
}
})