2024-05-24 17:24:28 +08:00

145 lines
3.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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,
videoErrorText: '',
safeAreaBottom: 0,
platform: '',
anthologyFlag: false
},
onLoad: function (options: any) {
const videoCanIUse = tt.canIUse('video-player');
this.setData({
videoCanIUse,
})
this.initFn();
tt.getSystemInfo({
success: (res: any) => {
console.log(res, "------------")
const screenHeight = res.screenHeight;
const statusBarHeight = res.statusBarHeight;
const safeAreaHeight = res.safeArea.height;
const safeAreaBottom = screenHeight - statusBarHeight - safeAreaHeight;
console.log(safeAreaBottom, "safeAreaBottom")
this.setData({
safeAreaBottom,
platform: res.platform
})
}
})
},
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,
videoErrorText: ''
})
},
videError(ev: any) {
const errMsg = ev.detail.errMsg;
let errMsgText = '';
if (errMsg == 'Video is forbidden in playletplease use video-player instead') {
errMsgText = '抱歉,当前抖音版本过低,请升级抖音'
} else {
errMsgText = errMsg;
}
this.setData({
videoErrorText: errMsgText
})
},
videPlayerError(ev: any) {
console.log(ev, "errMsgTexterrMsgText")
const errMsg = ev.detail.errMsg;
let errMsgText = '';
if (errMsg == 'Video is forbidden in playletplease use video-player instead') {
errMsgText = '抱歉,当前抖音版本过低,请升级抖音'
} else {
errMsgText = errMsg;
}
this.setData({
videoErrorText: errMsgText
})
},
toPathVideoDetail() {
tt.navigateTo({
url: `pages/videoDetail/videoDetail`,
});
},
anthologyTap() {
console.log('anthologyTap')
this.setData({
anthologyFlag: true
})
},
handelAnthologyClose() {
this.setData({
anthologyFlag: false
})
}
})