增加支付解锁,对接抖音前置支付组件

This commit is contained in:
jiaogan 2024-12-12 14:08:45 +08:00
parent 97edfa228c
commit a74091129b
10 changed files with 956 additions and 47 deletions

427
components/charge/charge.js Normal file
View File

@ -0,0 +1,427 @@
// import {
// getVideoList
// } from "../../api/common"
import {httpRequest} from "../../utils/httpReques";
const {
getPlayletManager
} = tt;
Component({
pm: undefined,
data: {
videoResult: {},
adType: '',
platform: '',
unlockAllFlag: false,
unlockAllKb: 0,
emitTimesCharge: 0,
egold: 0,
payList: [],
time: "",
action:0,
iosStatus: 0,
iosIm: '',
payLiClass: {
1: "pay_li_class_1",
2: "pay_li_class_2",
4: "pay_li_class_4",
},
useBytePayment: true,//是否使用抖音支付组件
canIUsePaymentChannel: tt.canIUse('payment-channel-select'),
showPaymentChannelSelect: false,
dySkuList:[], //从接口获取的skulist
skuList:[],//传给支付组件的skulist
},
inject: ["chargeTap"],
observers: {
// 点击组件 A 的 button 后,触发该监听器的执行
chargeTap(val) {
this.setData({
emitTimesCharge: val
})
},
},
async ready() {
tt.getSystemInfo({
success: (res) => {
// console.log(res)
this.setData({
platform: res.platform,
})
}
})
console.log('payment-channel-select',this.data.canIUsePaymentChannel)
const pm = getPlayletManager(this);
this.pm = pm;
pm.onPlay(() => {
console.error('在charge中监听onPlay')
})
// //记录解锁信息
// const {
// playletPluginList
// } = await getVideoList();
// // console.log("playletPluginList",playletPluginList)
// for (let i = 0; i < playletPluginList.length; i++) {
// console.log(playletPluginList[i].ablum_id)
// console.log(this.data.tt_album_id)
// if (playletPluginList[i].ablum_id === this.properties.albumId) {
//
// this.setData({
// allUnlock: playletPluginList[i].allUnlock
// })
// }
// }
},
detached() {
console.log('charge关闭')
},
attached() {
this.getPayList()
const watchInfo = tt.getStorageSync('watchInfo')
this.setData({
videoResult: watchInfo
})
// console.log(this.data.videoResult)
},
methods: {
getPayList() {
httpRequest('/paysetting', 'post', {new_pay:1,is_unit:1}).then((res) => {
if (res.status == 1) {
this.setData({
egold: res?.data?.egold,
payList: res?.data?.list,
dySkuList: [...res?.data?.dy_config?.sku_list]
})
}
this.setCurrentItem()
// //支持且需要官方支付组件时
if(tt.canIUse('payment-channel-select')&&this.data.useBytePayment){
//设置面板
this.setSkuList(this.setCurrentItem());
//显示面板
this.setData({
showPaymentChannelSelect: true
})
// this.data.showPaymentChannelSelect = true;
}
// this.data.time = res?.data?.time;
this.setData({
time: res?.data?.time
})
const videoResult = this.data.videoResult;
if (videoResult.chackpay === 2 || videoResult.chackpay == 3) {
const unlockAllFlag = res.data.list.some((m) => {
if (m.type == 4) {
let unlockAllKb = (videoResult.unlock_data.total_price / parseFloat(m.price)).toFixed(2);
// this.data.unlockAllKb = unlockAllKb;
this.setData({
unlockAllKb: unlockAllKb
})
}
return m.type == 4;
});
this.setData({
unlockAllFlag: unlockAllFlag
})
}
//ios支付
httpRequest('/bs', 'post', {new_pay:1}).then((res) => {
if (res.status == 1) {
this.setData({
iosStatus: res?.data?.status,
})
}
});
//用户数据
httpRequest('/user', 'post', ).then((res) => {
if (res.status == 1) {
this.setData({
iosIm: res?.data?.info.im,
})
}
});
});
},
//选中商品
setCurrentItem(inx){
let cacheInx
//有下标时,直接设置
if(inx){
cacheInx = inx
}else {
//没有下标时从数据def_select设置页面
for (let i = 0; i < this.data.payList.length; i++) {
if (this.data.payList[i].def_select) {
cacheInx = i
}
}
}
this.setData({
action: cacheInx ? cacheInx : 0
})
// this.data.action = cacheInx ? cacheInx : 0;
return this.data.action;
},
//点击商品
payItem(item,index) {
// this.data.action = index
this.setData({
action: index
})
//调用抖音支付组件
if(tt.canIUse('payment-channel-select')&&this.data.useBytePayment&&this.data.showPaymentChannelSelect){
// console.log('item',item)
this.setSkuList(index)
}else{
//打开原tt支付
this.openTtPay(index)
}
},
//设置抖音支付面板数据
setSkuList(inx){
const item = this.data.dySkuList[inx];
let skuList = [];
skuList.push(item);
this.setData({
skuList: skuList
})
console.log('skuList',this.data.skuList)
},
//组件支付下单
async handleRequestOrderByte(event) {
// 下单
// 返回一个 promise
return new Promise(resolve => {
const launchsite = tt.getStorageSync('launchsite') || 1;
const payCurrent = this.data.payList[this.data.action]
const params = {
id: payCurrent.id,
isback: payCurrent.isback === 1 ? 1 : 0,
launchsite,
sid: this.data.videoResult.sid || "",
jid: this.data.videoResult.id || "",
new_pay: 1
}
httpRequest('/Newplaceanorder', 'post', params).then((res) => {
if (res.status == 1) {
const orderData = {
data: res.data.data,
byteAuthorization: res.data.byteAuthorization,
}
resolve(orderData);
}
});
});
},
//组件支付状态
handleGetPaymentResult(event) {
const { status, result } = event.detail;
console.log('handleGetPaymentResult',event.detail)
if (status === 'success') {
const { code } = result;
if (code === 0) {
tt.showToast({
icon: 'none',
title: '支付成功',
});
this.emitChargeInfoToParent('charge','success')
// uni.$emit('chargePaySuccess')
} else if( code === 9) {
// code 为 9开发者自行查询订单状态
} else {
// 支付失败、超时、取消、关闭
tt.showToast({
icon: 'none',
title: '支付失败',
});
}
} else {
// 支付失败
tt.showToast({
icon: 'none',
title: '支付失败',
});
}
},
//组件支付报错
handleGetPaymentError(event){
// errNo错误码对应某种具体报错原因
// errMsg报错信息
const { errNo, errMsg } = event.detail
console.log('errMsg',errMsg)
console.log('errNo',errNo)
const componentInitError = [169007, 20000]
const payError = [169015, 169016, 169017, 169018, 169019, 169020, 20]
if (componentInitError.includes(errNo)) {
//组件初始化错误
this.setData({
showPaymentChannelSelect: false
})
// this.data.showPaymentChannelSelect = false;
} else if(payError.includes(errNo)) {
// 支付流程错误
// 使用 tt.requestOrder + tt.getOrderPayment
// this.showPaymentChannelSelect = false;
this.openTtPay(this.data.action);
}
},
//打开原tt支付
openTtPay(index){
const that = this;
const item = this.data.payList[index];
tt.showLoading({
title: "正在拉起支付",
});
const launchsite = tt.getStorageSync('launchsite') || 1;
if (this.data.platform === "ios" && this.data.iosStatus === 1) {
tt.hideLoading({});
tt.showToast({
title: "暂不支持ios支付",
duration: 2000,
icon: "none",
});
return;
} else {
if (tt.canIUse("getOrderPayment") && tt.canIUse("requestOrder")) {
const params = {
id: item.id,
isback: item.isback === 1 ? 1 : 0,
launchsite,
sid: this.data.videoResult.sid || "",
jid: this.data.videoResult.id || "",
}
httpRequest('/Newplaceanorder', 'post', params).then((res) => {
if (res.status == 1) {
tt.hideLoading({});
tt.requestOrder({
data: res.data.data,
byteAuthorization: res.data.byteAuthorization,
payScene: this.data.platform === "ios" ? "IM" : "",
success: (e) => {
tt.showLoading({
title: "拉起支付中...",
});
tt.getOrderPayment({
orderId: e.orderId,
imId: this.data.platform === "ios" ? this.data.iosIm : "",
success: (payRes) => {
tt.hideLoading({});
tt.showToast({
title: "支付成功",
duration: 2000,
});
that.emitChargeInfoToParent('charge','success')
},
fail: (payError) => {
tt.hideLoading({});
// console.log(payError);
},
});
},
fail: (e) => {
console.log(e);
},
});
}
});
} else {
const params = {
id: item.id,
isback: item.isback === 1 ? 1 : 0,
launchsite,
sid: this.data.videoResult.sid || "",
jid: this.data.videoResult.id || "",
}
httpRequest('/getTiktokpay', 'post', params).then((res) => {
if (res.status == 1) {
tt.hideLoading({});
const orderInfo = {
outOrderNo: res.data.outOrderNo,
totalAmount: res.data.totalAmount,
};
tt.pay({
orderInfo,
service: 5,
success: (res) => {
if (res.code == 0) {
tt.showToast({
title: "支付成功",
duration: 2000,
});
that.emitChargeInfoToParent('charge','success')
// paysetting().then((res) => {
// this.egold = res.egold;
// uni.setStorageSync("isPopup", false);
// this.show = false;
// // this.$emit("paySuccess", "paySuccess");
// uni.$emit('chargePaySuccess')
// });
// 支付成功处理逻辑只有res.code=0时才表示支付成功
// 但是最终状态要以商户后端结果为准
}
},
fail: () => {
tt.showToast({
title: "支付失败,请重新支付",
duration: 2000,
});
},
});
}
});
}
}
},
//接收页面点击
handlePayItem(e){
const item = e.currentTarget.dataset.item
const index = e.currentTarget.dataset.index
// this.emitChargeInfoToParent('charge','success')
this.payItem(item,index)
},
//向父组件传值
emitChargeInfoToParent(val,data) {
const instance = this.selectOwnerComponent();
instance.emitChargeInfoFromChildren(val,data);
this.close()
},
close(){
this.pm.toggleCustomDialog()
},
//支付区域
payThis(e) {
this.pm.toggleCustomDialog('close');
this.pm.setCurrentUnlock();
},
payAll(e) {
this.pm.toggleCustomDialog('close');
this.pm.setCatalog(this.data.allUnlock);
},
adThis(e) {
console.log('广告解锁当前集', e);
this.setData({
adType: 'this',
})
this.ad.show();
// 监听视频播放完成
},
adAll(e) {
console.log('广告解锁全集', e);
this.setData({
adType: 'all',
})
this.ad.show();
},
}
})

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"payment-channel-select": "ext://industry/payment-channel-select"
}
}

View File

@ -0,0 +1,167 @@
<view class="video-footer">
<view class="py-30" style="box-sizing: border-box">
<view style="justify-content: space-between" class="d-flex flex-row px-30">
<view style="display: flex;flex-direction: row;align-items: center;">
<view style="width: 48rpx;height: 48rpx;">
<image src="https://dycqjcweb.jiulingliu.cn/appletStatic/icon/dy_pay_hed_icon.png" mode="scaleToFill" style="width: 48rpx;height: 48rpx;"/>
</view>
<view class="fs-36 ml-20" style="color: #000; font-weight: bold">
抖音支付
</view>
</view>
<view class="flex-center" bindtap="close">
<icon class="tt-icon" type="cancel"></icon>
<!-- <u-icon name="arrow-down" color="#000" size="48rpx"></u-icon>-->
</view>
</view>
<view class="flex-row px-30 mt-24" style="justify-content: space-between;width: 100%">
<view class="fs-26" style="color: #000">
我的K币{{ egold || 0 }}K币
</view>
</view>
<view class="px-30 mt-22 dykefu_warp" style="width: 100%; display: flex; justify-content: space-between" tt:if="{{videoResult.chackpay === 2 || videoResult.chackpay == 3}}">
<view class="fs-26">
未解锁集数:{{ videoResult.unlock_data.num || 0 }}
</view>
<view class="fs-26 mr-20" style="color: #000">
解锁全集消耗:{{ videoResult.unlock_data.total_price || 0 }}K币
</view>
</view>
<view class="px-30 mt-22 dykefu_warp">
<block tt:if="{{platform == 'ios'}}">
<view class="fs-24"> 购买K币1钻=10K币</view>
</block>
<block tt:else>
<view class="fs-24"> 购买K币1元=100K币</view>
</block>
<!-- <view @click="toPathAgreement">-->
<!-- <view class="fs-24" style="color: #fe650f ; text-decoration: underline">-->
<!-- 会员服务协议-->
<!-- </view>-->
<!-- </view>-->
</view>
<view class="px-30 mt-22 dykefu_warp" tt:if="{{unlockAllFlag}}">
<view>
<block tt:if="{{platform == 'ios'}}">
<view class="fs-24" style="color: #000" tt:if="{{unlockAllFlag}}">
解锁全集10钻 ≈ {{ unlockAllKb }} K币
</view>
</block>
<block tt:else>
<view class="fs-24 mr-20" style="color: #000" tt:if="{{unlockAllFlag}}">
解锁全集1元 ≈ {{ unlockAllKb }} K币
</view>
</block>
</view>
<!-- <view @click="getGouM">-->
<!-- <view class="fs-24" style="color: #fe650f ; text-decoration: underline">-->
<!-- 付费须知-->
<!-- </view>-->
<!-- </view>-->
</view>
<view class="px-30 mb-18 dykefu_warp">
<!-- <view class="fs-26" tt:if="{{videoResult.chackpay === 2 || videoResult.chackpay == 3}}">-->
<view class="fs-26">
解锁每集需要:{{ videoResult.price || 0 }}K币
</view>
<button tt:if="{{iosIm}}" open-type="im" data-im-id="{{iosIm}}" class="contact_customer_service">
<!-- <view class="contact_custo_ser_icon">-->
<!-- <image src="/static/customer_service.png" class="__wa_img_no_radius"></image>-->
<!-- </view>-->
<view class="contact_custo_ser_txt">联系客服</view>
</button>
</view>
<scroll-view scroll-y class="content" style="height: {{(canIUsePaymentChannel && useBytePayment) ? 400 : 800 }}rpx">
<view class="flex-row d-flex px-30 pt-20 {{(canIUsePaymentChannel && useBytePayment) ? 'pb-20' : 'pb-60'}}" style="flex-wrap: wrap">
<block tt:for="{{payList}}">
<view class="pay_ul {{(index + 1) % 2 === 0 ? 'pl-10':'pr-10'}}" tt:key="{{item.id}}">
<view class="pay_li_class_default {{item.type==1?'pay_li_class_1':item.type==2?'pay_li_class_2':'pay_li_class_4'}}" data-item="{{item}}" data-index="{{index}}" bind:tap="handlePayItem" @click="payItem(item, index)">
<view class="pay_li_cl_one">
<view class="money__it_wa_ti_price">
<view tt:if="{{platform != 'ios'}}" class="money__it_wa_ti_pr_te_icon">
{{ item.unit }}
</view>
<view class="money__it_wa_ti_pr_text">
{{ item.price }}
</view>
<view tt:if="{{platform == 'ios'}}" class="money__it_wa_ti_pr_te_icon">
{{ item.unit }}
</view>
</view>
<view class="pay_li_cl_description ml-6" tt:if="{{item.description && item.type != 2}}">
<view class="pay_li_cl_desc_i">
<view class="pay_li_cl_de_i_text">
{{ item.description }}
</view>
</view>
</view>
</view>
<view class="pay_li_cl_description mt-20" tt:if="{{item.description && item.type == 2}}">
<view class="pay_li_cl_desc_i">
<view class="pay_li_cl_de_i_text">
{{ item.description }}
</view>
</view>
</view>
<view class="pay_li_cl_desc_kb" tt:elif="{{item.type == 1}}">
<view class="pay_li_cl_desc_k_icon">
<image src="https://dyjyjcweb.hunanjj.cn/dy_images/images/coins.png"
mode="scaleToFill" class="k_icon" />
</view>
<text class="pay_li_cl_desc_k_num">{{ item.egold }}</text>
<text class="pay_li_cl_desc_k_num mx-4">+</text>
<text class="pay_li_cl_desc_k_num">{{ item.giveegold }}赠币</text>
</view>
<view class="pay_li_cl_description mt-20" tt:elif="{{item.type == 4}}">
<view class="pay_li_cl_desc_i">
<view class="pay_li_cl_de_i_text"> 永久解锁全集 </view>
</view>
</view>
<view class="pay_li_cl_poster" tt:if="{{item.poster}}">
<view class="pay_li_cl_pos_text">{{ item.poster }}</view>
</view>
<view class="pay_li_cl_hand" tt:if="{{index == action}}">
<image src="https://dyjyjcweb.hunanjj.cn/dy_images/images/followClick.png" mode="scaleToFill" class="hand_icon" />
</view>
</view>
</view>
</block>
<view class="pay_rule_list">
<view class="pay_rule_li_item">
<block tt:if="{{platform == 'ios'}}">
<text class="pay_rule_li_it_text">1、1钻=10K币k币和会员属于虚拟产品一经购买不可退换</text>
</block>
<block tt:else>
<text class="pay_rule_li_it_text">1、1元=100K币k币和会员属于虚拟产品一经购买不可退换</text>
</block>
</view>
<view class="pay_rule_li_item">
<text class="pay_rule_li_it_text">2、未满18岁的未成年人需要在监护人主导、同意下进行相关付费操作。</text>
</view>
<view class="pay_rule_li_item">
<text class="pay_rule_li_it_text">3、购买时获得的赠币仅{{ time }}有效</text>
</view>
<view class="pay_rule_li_item">
<text class="pay_rule_li_it_text">4、充值K币一般在10分钟内到账如未到账请在“我的”页面联系客服</text>
</view>
</view>
</view>
</scroll-view>
<!--官方支付组件-->
<view tt:if="{{showPaymentChannelSelect}}" style="padding: 0 30rpx 100rpx 30rpx">
<payment-channel-select
sku-list="{{skuList}}"
bind:requestorder="handleRequestOrderByte"
bind:getpaymentresult="handleGetPaymentResult"
bind:error="handleGetPaymentError"
scene="{{platform=='ios' ? 'diamond': 'cash'}}"
>
</payment-channel-select>
</view>
</view>
</view>

View File

@ -0,0 +1,292 @@
.video-footer {
background-color: rgb(255, 255, 255);
height: 1100rpx;
width: 100%;
}
.content {
width: 750rpx;
/*height: 400rpx;*/
box-sizing: border-box;
}
.pay-btn {
width: 558rpx;
height: 104rpx;
line-height: 104rpx;
background: #fa6435;
border-radius: 72rpx;
color: #ffffff;
}
button {
margin: 0 !important;
}
.dykefu_btn {
display: flex !important;
flex-direction: row !important;
align-items: center;
background-color: transparent !important;
padding: 0;
color: transparent;
}
.dykefu_btn::after {
border: none;
}
.dykefu_warp {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.pay_ul {
width: 50%;
}
.pay_li_class_default {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
height: 180rpx;
background: #f1f1f2;
border-radius: 12rpx;
padding: 50rpx 20rpx 30rpx;
margin-bottom: 40rpx;
}
.pay_li_class_1 {
.money__it_wa_ti_pr_text {
color: #333;
}
.money__it_wa_ti_pr_te_icon {
color: #333;
}
}
.pay_li_class_2 {
.money__it_wa_ti_pr_text {
color: #fff;
}
.money__it_wa_ti_pr_te_icon {
color: #fff;
}
.pay_li_cl_poster {
background: linear-gradient(90deg, #705648, #534435);
}
.pay_li_cl_pos_text {
color: #f1cda3;
}
background: url("https://dyjyjcweb.hunanjj.cn/dy_images/images/template_vip.png");
background-size: 100% 100%;
}
.pay_li_class_4 {
.money__it_wa_ti_pr_text {
color: #333;
}
.money__it_wa_ti_pr_te_icon {
color: #333;
}
background: url("https://dyjyjcweb.hunanjj.cn/dy_images/images/template_coins.png");
background-size: 100% 100%;
}
.pay_li_cl_one {
display: flex;
flex-direction: row;
align-items: center;
.pay_li_cl_de_i_text {
font-size: 16rpx;
}
}
.money__it_wa_ti_price {
display: flex;
flex-direction: row;
align-items: center;
}
.money__it_wa_ti_pr_text {
line-height: 1;
font-weight: 600;
font-size: 38rpx;
color: #333;
}
.money__it_wa_ti_pr_te_icon {
line-height: 1;
font-weight: 600;
font-size: 28rpx;
color: #333;
}
.pay_li_cl_description {
display: flex;
flex-direction: row;
}
.pay_li_cl_desc_i {
display: flex;
padding: 8rpx 8rpx;
background-color: #f8dfac;
border-radius: 6rpx;
}
.pay_li_cl_de_i_text {
line-height: 1;
font-size: 20rpx;
color: #ff562a;
}
.pay_li_cl_poster {
position: absolute;
left: 20rpx;
top: 0;
display: flex;
transform: translateY(-50%);
padding: 6rpx 12rpx;
border-radius: 16rpx 0 16rpx 0;
background: linear-gradient(135deg, #ff9d37, #ff6c00);
}
.pay_li_cl_pos_text {
line-height: 1;
font-size: 22rpx;
color: #fff;
}
.pay_li_cl_desc_kb {
display: flex;
flex-direction: row;
align-items: center;
margin-top: 20rpx;
}
.pay_li_cl_desc_k_icon {
width: 32rpx;
height: 32rpx;
margin-right: 6rpx;
.k_icon {
display: block;
width: 100%;
height: 100%;
}
}
.pay_li_cl_desc_k_num {
line-height: 1;
font-size: 26rpx;
color: #ff562a;
}
.pay_li_cl_hand {
position: absolute;
top: 66px;
right: -6px;
width: 40px;
height: 42px;
.hand_icon {
display: block;
width: 100%;
height: 100%;
}
}
.pay_rule_li_item {
margin-bottom: 10rpx;
}
.pay_rule_li_it_text {
line-height: 1.5;
font-size: 24rpx;
color: #999;
}
.py-30 {
padding-top: 15px;
padding-bottom: 15px;
}
.px-30 {
padding-left: 15px;
padding-right: 15px;
}
.d-flex {
display: flex !important;
}
.fs-36 {
font-size: 18px !important;
}
.ml-20 {
margin-left: 10px !important;
}
.fs-26 {
font-size: 13px !important;
}
.mt-18 {
margin-top: 9px !important;
}
.mt-22 {
margin-top: 11px !important;
}
.fs-26 {
font-size: 13px !important;
}
.fs-24 {
font-size: 12px !important;
}
.mt-24 {
margin-top: 12px !important;
}
.pl-10{
padding-left: 10px !important;
}
.pr-10{
padding-right: 10px !important;
}
.pt-40{
padding-top: 40px !important;
}
.pt-20{
padding-top: 20px !important;
}
.pb-60{
padding-bottom: 60px !important;
}
.pb-20{
padding-bottom: 20px !important;
}
.contact_customer_service {
padding: 0;
background: none;
/*background: #ff562a;*/
}
.contact_customer_service::after {
content: none;
}
.contact_custo_ser_icon {
width: 50rpx;
height: 50rpx;
}
.contact_custo_ser_txt {
color: #ff562a;
font-size: 26rpx !important;
}

View File

@ -16,6 +16,9 @@ Component({
pm.onPlay((e) => {
console.log("触发开始播放onPlay回调时间是:", new Date());
this.setData({
lockStatus: false
})
});
pm.onPause((e) => {
console.log('触发暂停播放onPause回调', e)
@ -33,7 +36,23 @@ Component({
})
pm.onChangeEpisode((e) => {
console.log('切换回调', e)
//当前切换到的集
tt.setStorageSync('currentvideo', {'album_id': e.albumId,episode_id:e.episodeId, seq:e.seq,status: e.status, scene: e.scene});
//当前切换到的解锁集,播放记录用
if(e.status=='free'){
tt.setStorageSync('lastfreevideo', {'album_id': e.albumId,episode_id:e.episodeId, seq:e.seq,status: e.status, scene: e.scene});
}
let lock = false;
// let watchInfo = tt.getStorageSync('watchInfo')
// if(e.scene =='first_play' && watchInfo?.album_id != e.albumId){
// watchInfo = tt.getStorageSync('watchInfo')
// console.log('1')
// }
// const checklock = watchInfo?.isvip != 0 && (watchInfo?.chackpay == 2 || watchInfo?.chackpay == 3)
// console.log(watchInfo)
// console.log(checklock)
// if(e.status =='lock' || (e.scene =='first_play' && checklock)){
if(e.status =='lock'){
lock = true;
}
@ -43,6 +62,10 @@ Component({
videoAlbumId: e.albumId,
videoEpisodeId: e.episodeId,
})
//storage有延时第一次进入锁定剧集时需要刷新
if(e.status =='lock'){
this.emitInfoToParent('change',{album_id: this.data.videoAlbumId,episode_id:this.data.videoEpisodeId})
}
})
pm.onShareSuccess((res) => {
@ -121,5 +144,8 @@ Component({
// res: any console.log("视频广告展示");
});
},
}
openPay() {
this.pm.toggleCustomDialog()
},
},
})

View File

@ -2,10 +2,11 @@
<view style="width: 100%;height: 100%">
<view class="unlock_in_con_wa_operate">
<view class="unlock_in_con_wa_oper_left">
<!-- <view class="unlock_in_con_wa_i_vip" @tap="openPay">
<text class="unlock_in_con_wa_i_vi_text">立即充值</text>
</view> -->
<view class="unlock_in_con_wa_oper_right" style="width: auto">
<view class="unlock_in_con_wa_i_vip" bindtap="openPay">
<text class="unlock_in_con_wa_i_vi_text">免广告解锁</text>
</view>
</view>
<view class="unlock_in_con_wa_oper_right">
<view class="unlock_in_con_wa_i_btn" bindtap="adOpen">
<text class="unlock_in_con_wa_i_tepp">
<text class="unlock_in_con_wa_i_vi_text">看广告解锁</text>
@ -13,7 +14,6 @@
</view>
<text>{{lockStatuss}}</text>
</view>
</view>
</view>
</view>
</view>

View File

@ -1,10 +1,10 @@
.unlock_in_con_wa_operate {
z-index: 9;
z-index: 0;
/* background-color: yellow; */
bottom: 5rem;
width: 100%;
position: fixed;
padding: 0 2rem;
display : flex;
flex-direction : row;
justify-content: space-between;

View File

@ -1,7 +1,9 @@
{
"extends": "ext://industry/playlet-plugin",
"usingComponents": {
"player": "/components/player/player"
"player": "/components/player/player",
"charge": "/components/charge/charge",
"payment-channel-select": "ext://industry/payment-channel-select"
},
"isPageExtension": true,
"enablePullDownRefresh": false,

View File

@ -15,12 +15,26 @@ PlayletExtension({
nextbatchList: [],
},
methods: {
//监听player的值
emitInfoFromChildren(val,data) {
console.log('收到消息', val)
console.log('收到消息', data)
if(val=="advunlock"){
this.init('advunlock',data)
}
if(val=="change"){
this.init('change',data)
}
},
//监听charge的值
emitChargeInfoFromChildren(val,data) {
console.log('收到消息', val)
console.log('收到消息', data)
console.log(val=="charge"&& data == "success")
if(val=="charge"&& data == "success"){
const data = tt.getStorageSync('currentvideo')
this.init('charge',data)
}
},
onLoad(options) {
const caniuse = !!tt.canIUse('PlayletExtension');
@ -29,6 +43,8 @@ PlayletExtension({
// console.error('caniuse', caniuse);
const pm = getPlayletManager();
this.pm = pm;
// tid=2334
// options.tid = 2334
this.options = options;
this.setData({
tt_album_id: options.tt_album_id,
@ -92,7 +108,6 @@ PlayletExtension({
});
this.init();
// this.getNext();
},
async init(status?:string,data?:any) {
console.log("data",data)
@ -106,8 +121,13 @@ PlayletExtension({
tt_episode_id: null,
adunlocking: status == 'advunlock' ? 1 : null
}
console.log('params', params)
//初始化目录
const res = await httpRequest('/douyinNewRead', 'post', params);
//添加历史记录时,后面不用执行了
if(status == 'addhistory') {
return
}
//设置剧集上锁状态
const _freeList = res.data.freelist != null ? res.data.freelist : []
const _lockList = res.data.locklist != null ? res.data.locklist : []
@ -124,26 +144,8 @@ PlayletExtension({
this.setData({
watchInfo: _watchinfo
})
tt.setStorageSync('watchInfo', _watchinfo);
},
async getNext(){
// 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,
// }
let nextbatchList = [];
const nextbatchRes: any = await httpRequest('/nextbatch', 'POST', this.options);
if (nextbatchRes.status == 1 && Array.isArray(nextbatchRes.data)) {
nextbatchList = nextbatchRes.data;
}
this.setData({
nextbatchList
})
}
},
lifetimes: {
@ -162,6 +164,10 @@ PlayletExtension({
detached() {
console.log('detached')
const lastfreevideo = tt.getStorageSync('lastfreevideo')
if(lastfreevideo.status == 'free'){
this.init('addhistory',lastfreevideo)
}
},
},

View File

@ -1,18 +1 @@
{
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"autoCompile": true,
"compileHotReLoad": true,
"nativeCompile": true,
"useCompilerPlugins": [
"typescript"
]
},
"appid": "tte8719ecc7742e53d01",
"projectname": "古言剧场",
"douyinProjectType": "native"
}
{"setting":{"urlCheck":true,"es6":true,"postcss":true,"minified":true,"newFeature":true,"autoCompile":true,"compileHotReLoad":true,"nativeCompile":true,"useCompilerPlugins":["typescript"]},"appid":"tte8719ecc7742e53d01","projectname":"古言剧场","douyinProjectType":"native"}