2024-11-22 09:48:59 +08:00

154 lines
5.6 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.

import {httpRequest} from "../../utils/httpReques";
const {
PlayletExtension,
getPlayletManager
} = tt;
// 可以使用tt.canIUse('PlayletExtension')判断是否可用不可用可调用tt.navigateTo等跳转离开
PlayletExtension({
pm: undefined,
options: undefined,
data: {
watchInfo: null,
},
methods: {
emitInfoFromChildren(val,data) {
console.log('收到消息', val)
console.log('收到消息', data)
if(val=="advunlock"){
this.init('advunlock',data)
}
},
onLoad(options) {
const caniuse = !!tt.canIUse('PlayletExtension');
// console.log('行业SDK版本号', tt.getIndustrySdkInfo().version);
// console.log('TMAR版本号', tt.getSystemInfoSync().SDKUpdateVersion);
// console.error('caniuse', caniuse);
const pm = getPlayletManager();
this.pm = pm;
this.options = options;
this.setData({
tt_album_id: options.tt_album_id,
tt_episode_id: options.tt_episode_id,
seq: options.seq,
})
},
async onReady() {
console.log('页面完成Ready', JSON.stringify(options))
const pm = getPlayletManager();
const options = this.options;
// 初始化自定义组件
// this.pm.setConfig({
// activityInfo: [
// {
// icon: "https://dyxykjweb.hunanjj.cn/sta_images/icon/welfare_gift_icon.png",
// title: "福利",
// },
// ],
// objectFit: 'contain'
// });
//是否展示解锁页
this.pm.setConfig({
showLockPage: true
});
//播放器分享按钮
this.pm.onTapShare((e) => {
console.log(`/pages/videoByte/videoByte?is_continue=0&tt_album_id=${ this.data?.watchInfo?.album_id}&tt_episode_id=${ this.data?.watchInfo?.episode_id}&tid=${ this.options?.tid || ""}&launchsite=${ this.options?.launchsite || ""}`)
return { // 分享数据
title: "古言剧场",
desc: "精彩剧情,尽在古言剧场",
path: `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${ this.data?.watchInfo?.album_id}&tt_episode_id=${ this.data?.watchInfo?.episode_id}&tid=${ this.options?.tid || ""}&launchsite=${ this.options?.launchsite || ""}`,
imageUrl: this.data?.watchInfo?.cover,
}
})
//初始化页面分享内容
this.pm.getPlayletInfo().then(res => {
console.log('getPlayletInfo', res)
this.setData({
tt_album_id: res.albumId,
tt_episode_id: res.episodeId,
seq: res.seq
})
this.pm.setConfig({
shareParam: { // 分享数据
title: "古言剧场",
desc: "精彩剧情,尽在古言剧场",
path: `/pages/videoByte/videoByte?is_continue=0&tt_album_id=${ this.data?.watchInfo?.album_id}&tt_episode_id=${ this.data?.watchInfo?.episode_id}&tid=${ this.options?.tid || ""}&launchsite=${ this.options?.launchsite || ""}`,
imageUrl: this.data?.watchInfo?.cover,
}
// title: this.watchInfo.title,
// imageUrl: this.watchInfo.cover,
// desc: `精彩剧情,尽在${this.pageGlobalData.appName}`,
// path: `/pages/videobyte/index?tt_album_id=${this.$store.state.currentVideoInfo.album_id}&tt_episode_id=${this.$store.state.currentVideoInfo.episode_id}&is_continue=0&tid=${this.$store.state.linkParams.tid || ""}&launchsite=${this.$store.state.linkParams.launchsite || ""}`,
});
});
this.init();
},
async init(status?:string,data?:any) {
console.log("data",data)
let params = {
...this.options,
album_id: !!data ? data.album_id : this.options.tt_album_id,
episode_id: !!data ? data.episode_id : this.options.tt_episode_id,
sid: null,
id: null,
tt_album_id: null,
tt_episode_id: null,
adunlocking: status == 'advunlock' ? 1 : null
}
//初始化目录
const res = await httpRequest('/douyinNewRead', 'post', params);
//设置剧集上锁状态
const _freeList = res.data.freelist != null ? res.data.freelist : []
const _lockList = res.data.locklist != null ? res.data.locklist : []
console.log('res',res);
this.pm.setCatalog({
freeList: _freeList,
lockList: _lockList
})
const _watchinfo = {
...res.data.library,
...res.data.video,
...res.data.read_data
}
this.setData({
watchInfo: _watchinfo
})
}
},
lifetimes: {
ready() {
console.log('ready')
},
created() {
console.log('created')
},
attached() {
console.log('attached')
},
detached() {
console.log('detached')
},
},
pageLifetimes: {
hide() {
console.log('触发hide')
},
}
});