116 lines
2.6 KiB
JavaScript
116 lines
2.6 KiB
JavaScript
/**
|
|
* Web唐明明
|
|
* 匆匆数载恍如梦,岁月迢迢华发增。
|
|
* 碌碌无为枉半生,一朝惊醒万事空。
|
|
*/
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
videoList : [], //获取短视频列表
|
|
videoIndex : 0, //当前播放视频的下标
|
|
videoId : "", //当前播放的视频id
|
|
playState : true, //视频播放状态
|
|
rooms : [], //直播列表
|
|
sysInfo : {}, //系统信息
|
|
showLive : false //直播层状态
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad() {
|
|
wx.$api.video.videos().then(res => {
|
|
this.setData({
|
|
videoList: res,
|
|
videoId: res[0].video_id
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow(){
|
|
// 获取直播间列表
|
|
wx.$api.live.rooms().then(res=>{
|
|
this.setData({
|
|
rooms : res.list,
|
|
sysInfo : wx.getSystemInfoSync().safeArea
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 展示直播数量
|
|
*/
|
|
onLiveLay(e){
|
|
if(e.currentTarget.dataset.type == "video"){
|
|
if(this.data.showLive){
|
|
this.setData({
|
|
showLive: false
|
|
})
|
|
}
|
|
}else{
|
|
this.setData({
|
|
showLive: !this.data.showLive
|
|
})
|
|
}
|
|
},
|
|
|
|
/***
|
|
* 视频的播放状态
|
|
*/
|
|
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) {
|
|
|
|
console.log(e.detail.current)
|
|
|
|
this.setData({
|
|
videoIndex: e.detail.current
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 点赞视频
|
|
*/
|
|
binLike() {
|
|
let hasLogin = wx.getStorageSync("token")
|
|
|
|
if (hasLogin == "") {
|
|
wx.navigateTo({
|
|
url: "/pages/login/login"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: "点赞成功"
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* 跳转到企业主页
|
|
*/
|
|
goCompany(e) {
|
|
wx.navigateTo({
|
|
url: '/pages/home/index?companyId='+e.currentTarget.dataset.id ,
|
|
})
|
|
wx.setStorageSync('company_id', e.currentTarget.dataset.id)
|
|
}
|
|
}) |