2024-05-20 09:36:39 +08:00

78 lines
1.9 KiB
TypeScript

// e:\project\dy_video_all\初晴剧场\pages\recommend\recommend.ts
import { httpRequest } from "../../utils/httpReques"
Page({
data: {
videoCanIUse: false,
videoInfo: {},
videoList: [],
batchList: [],
videoPlayerCurrent: 0,
videoPlayernum: 4,
},
onLoad: function (options: any) {
const videoCanIUse = tt.canIUse('video-player');
this.setData({
videoCanIUse,
})
this.initFn();
},
onShow() { },
async initFn() {
const params = {
"uid": 127457025,
"platform": "devtools",
"is_b": 2,
"sid": "2"
}
const videoreadRes: any = await httpRequest('/videoread', 'POST', params);
let videoInfo: any = {}
if (videoreadRes.status == 1 && Array.isArray(videoreadRes.data)) {
videoInfo = videoreadRes.data[0];
}
const batchlistRes: any = await httpRequest('/batchlist', 'POST', params);
let batchList: any = [];
if (batchlistRes.status == 1 && Array.isArray(batchlistRes.data)) {
batchList = batchlistRes.data;
}
this.setData({
batchList,
videoInfo
})
},
handelSeiperChange(ev: any) {
const current = ev.detail.current;
const videoPlayerCurrent = this.data.videoPlayerCurrent;
const batchList: any = this.data.batchList;
const id = batchList[videoPlayerCurrent]?.id;
const nextId = batchList[current]?.id;
const context: any = tt.createVideoContext(`${id}`);
const nextContext: any = tt.createVideoContext(`${nextId}`);
context?.pause?.();
nextContext?.play?.();
this.selectComponent(`#${nextId}`, (res: any) => {
console.log(res, "resres")
res?.hidePauseIcon()
});
this.setData({
videoPlayerCurrent: current
})
},
videoPlayerEnded() {
console.log('videoPlayerEnded')
const videoPlayerCurrent = this.data.videoPlayerCurrent;
this.setData({
videoPlayerCurrent: videoPlayerCurrent + 1
})
}
})