This commit is contained in:
cwt
2026-07-24 18:18:27 +08:00
parent faeb976e04
commit df2199cf57
11 changed files with 1541 additions and 1502 deletions
+60 -116
View File
@@ -6,7 +6,7 @@
<view class="recharge" v-else> <view class="recharge" v-else>
<view class="header_top"> <view class="header_top">
<text style="font-size: 32rpx;">解锁后可继续观看</text> <text style="font-size: 32rpx;">解锁后可继续观看</text>
<image @tap="close_pay_box" src="https://wx.yaohe.hnjrdzkj.xyz/static/wechat/static/fanhui.png" <image @tap="close_pay_box" :src="config.webUrl + '/static/wechat/static/fanhui.png'"
style="width: 36rpx;height: 36rpx;"></image> style="width: 36rpx;height: 36rpx;"></image>
</view> </view>
<view class="vider_juji"> <view class="vider_juji">
@@ -38,9 +38,9 @@
<text class="depict" v-if="item.pay_give_num && item.pay_type == 2"> <text class="depict" v-if="item.pay_give_num && item.pay_type == 2">
{{ item.pay_num }}金豆+{{ item.pay_give_num }}豆 {{ item.pay_num }}金豆+{{ item.pay_give_num }}豆
</text> </text>
<text class="depict" v-if="!item.pay_give_num && item.pay_type == 2"> <text class="depict" v-if="!item.pay_give_num && item.pay_type == 2">
{{ item.pay_num }}金豆 {{ item.pay_num }}金豆
</text> </text>
<view class="explainText" v-if="item.pay_type != 2"> <view class="explainText" v-if="item.pay_type != 2">
<text v-if="item.pay_type == 1" style="color: #333333;">全部影片免费观看</text> <text v-if="item.pay_type == 1" style="color: #333333;">全部影片免费观看</text>
<text v-if="item.pay_type == 3" style="color: #FF6900;">本剧订阅全集</text> <text v-if="item.pay_type == 3" style="color: #FF6900;">本剧订阅全集</text>
@@ -68,10 +68,11 @@
<view :class="['vipCarFooter',{'footerRedColor':item.is_red!=1}]"> <view :class="['vipCarFooter',{'footerRedColor':item.is_red!=1}]">
{{ item.remark ? item.remark : '' }} {{ item.remark ? item.remark : '' }}
</view> </view>
<image v-if="item.is_finger" class="hands" <image v-if="item.is_finger" class="hands" :src="config.webUrl + '/static/wechat/static/hands.gif'"
src="https://wx.yaohe.hnjrdzkj.xyz/static/wechat/static/hands.gif" mode=""></image> mode=""></image>
</view> </view>
</view> </view>
<view class="adBox" v-if="adLoaded" @click="showAd">看广告解锁</view>
<view class="explainList"> <view class="explainList">
<text class="explainItem"> 充值代表接受 <text class="explainItem"> 充值代表接受
<text class="explainText" @click="goAgreement(1)">《充值/退款协议》</text> <text class="explainText" @click="goAgreement(1)">《充值/退款协议》</text>
@@ -81,23 +82,7 @@
<text class="explainItem"> 本小程序共有{{ allVideoNum }}部剧正在热播</text> <text class="explainItem"> 本小程序共有{{ allVideoNum }}部剧正在热播</text>
</view> </view>
<uni-popup ref="back_ref" type="center">
<view class="teamPupCont">
<view class="closeIcon" @click="closePup">
<uni-icons type="closeempty" size="16" color="#ffffff"></uni-icons>
</view>
<view class="textBox">
<view class="textLine">用户只能发起一次邀请</view>
<view class="textLine">有效时间为24小时</view>
<view class="textLine">分享好友拼团,拼成退差价</view>
</view>
<button open-type="share" class="inviteBtn">立即邀请</button>
</view>
</uni-popup>
</view> </view>
</view> </view>
</template> </template>
@@ -107,6 +92,8 @@
} from '@/utils/request' } from '@/utils/request'
import PAY from '@/utils/pay' import PAY from '@/utils/pay'
const playletPlugin = requirePlugin('playlet-plugin') const playletPlugin = requirePlugin('playlet-plugin')
import config from "@/utils/config";
import insertAd from '@/utils/insertAd'
export default { export default {
name: "payDom", name: "payDom",
props: { props: {
@@ -145,7 +132,8 @@
payItemData: {}, payItemData: {},
g_order_id: "", g_order_id: "",
is_check: false, is_check: false,
allVideoNum: 0 allVideoNum: 0,
adLoaded: false
} }
}, },
watch: { watch: {
@@ -154,10 +142,10 @@
this.is_check = uni.getStorageSync('config').is_check == 1 ? true : false; this.is_check = uni.getStorageSync('config').is_check == 1 ? true : false;
this.userInfo = uni.getStorageSync('userinfo'); this.userInfo = uni.getStorageSync('userinfo');
this.system = uni.getSystemInfoSync().osName; this.system = uni.getSystemInfoSync().osName;
this.initChargeDialog(); this.initChargeDialog();
this.getVideoData(); this.getVideoData();
this.getAllVideoNum(); this.getPayList();
this.getPayList(); this.initAd();
}, },
playerId(newValue, oldvalue) { playerId(newValue, oldvalue) {
console.log('this.initChargeDialog', newValue) console.log('this.initChargeDialog', newValue)
@@ -165,6 +153,31 @@
}, },
methods: { methods: {
// 初始化广告
initAd() {
let pms = this.getPlayerManager();
// 监听加载成功 → 显示按钮
insertAd.insertAdonLoad(() => {
this.adLoaded = true;
});
// 监听加载失败 → 隐藏按钮
insertAd.insertAdonError(() => {
this.adLoaded = false;
});
// 监听关闭
insertAd.insertAdonClose((isEnded) => {
if (isEnded) {
console.log('广告看完,发放奖励');
// TODO: 调用你的解锁接口
pms.emitCustomEvent('adEnd', this.im)
}
});
// 开始加载广告
insertAd.insertAdload();
},
showAd() {
insertAd.insertAdshow();
},
goAgreement(num) { goAgreement(num) {
const pm = this.getPlayerManager() const pm = this.getPlayerManager()
pm.navigateTo({ pm.navigateTo({
@@ -200,16 +213,16 @@
return playletPlugin.PlayletManager.getPageManager(this.playerId); return playletPlugin.PlayletManager.getPageManager(this.playerId);
}, },
onShowChargeDialog() { onShowChargeDialog() {
console.log('onShowChargeDialog bbs') console.log('onShowChargeDialog bbs')
this.getPayList(); this.getPayList();
}, },
onHideChargeDialog() { onHideChargeDialog() {
// this.$refs.back_ref.close(); // this.$refs.back_ref.close();
}, },
close_pay_box(){ close_pay_box() {
const pm = this.getPlayerManager() const pm = this.getPlayerManager()
pm.hideChargeDialog(); pm.hideChargeDialog();
}, },
getAllVideoNum() { getAllVideoNum() {
httpRequest({ httpRequest({
url: "/api/video/videoCount", url: "/api/video/videoCount",
@@ -249,15 +262,15 @@
video_list_id: this.vid video_list_id: this.vid
} }
}).then(res => { }).then(res => {
if(res.code == 1){ if (res.code == 1) {
this.payListGroupId = uni.getStorageSync('config').pay_tpl; this.payListGroupId = uni.getStorageSync('config').pay_tpl;
// this.payListGroupId = 2; // this.payListGroupId = 2;
this.list_pay = res.data this.list_pay = res.data
}else if(res.code ==50){ } else if (res.code == 50) {
this.is_check = true; this.is_check = true;
} }
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
}, },
@@ -381,89 +394,20 @@
}) })
}, },
// wxxcx_xuni(data) {
// console.log(data)
// let that = this,
// pms = that.getPlayerManager();
// uni.requestVirtualPayment({
// signData: JSON.stringify({
// buyQuantity: data.signData.buyQuantity,
// currencyType: data.signData.currencyType,
// env: data.signData.env,
// goodsPrice: data.signData.goodsPrice,
// offerId: data.signData.offerId,
// outTradeNo: data.signData.outTradeNo,
// platform: data.signData.platform,
// productId: data.signData.productId,
// attach: data.signData.attach,
// }),
// paySig: data.paySig,
// signature: data.signature,
// mode: 'short_series_coin',
// success(res) {
// let payParam = {
// status: 'paySuccess',
// serialNo: that.serialNo,
// gOrderId: "",
// vid: that.vid,
// oid: data.oid
// }
// if (that.payItemData.pay_type == 4) {
// // that.$refs.back_ref.open('center');
// that.payEnd(payParam)
// } else {
// pms.emitCustomEvent('chargeEnd', payParam)
// }
// },
// fail({errMsg, errCode}) {
// console.log(errMsg, errCode, data.signature)
// },
// })
// },
// wxxcx(data) {
// let that = this,
// pms = that.getPlayerManager();
// uni.requestPayment({
// "provider": 'wxpay',
// "appId": data.appId,
// "timeStamp": data.timeStamp + '',
// "nonceStr": data.nonceStr,
// "package": data.package,
// "signType": 'MD5',
// "paySign": data.sign,
// success: function (res1) {
// let payParam = {
// status: 'paySuccess',
// serialNo: that.serialNo,
// gOrderId: "",
// vid: that.vid,
// oid: data.oid
// }
// if (that.payItemData.pay_type == 4) {
// // that.$refs.back_ref.open('center');
//
// that.payEnd(payParam)
// } else {
// pms.emitCustomEvent('chargeEnd', payParam)
// }
// console.log('success:' + JSON.stringify(res1));
// },
// fail: function (err1) {
// console.log('fail:' + JSON.stringify(err1));
// }
// });
// },
closePup() {
// this.$refs.back_ref.close();
}
}, },
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.adBox {
width: 100%;
height: 56rpx;
background: linear-gradient(to right, #FF5205, #FF0591);
color: #fff;
border-radius: 48rpx;
}
.noRecharge { .noRecharge {
font-size: 40rpx; font-size: 40rpx;
line-height: 200rpx; line-height: 200rpx;
+1 -1
View File
@@ -60,7 +60,7 @@
"quickapp" : {}, "quickapp" : {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin" : {
"appid" : "wx94a6522b1d640c3b", "appid" : "wx6de5fc276420b278",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"postcss" : true, "postcss" : true,
+12 -12
View File
@@ -31,18 +31,18 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
// { {
// "path": "pages/tabs/recommend", "path": "pages/tabs/recommend",
// "style": { "style": {
// "navigationStyle": "custom", "navigationStyle": "custom",
// "enablePullDownRefresh": false, "enablePullDownRefresh": false,
// // #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// "usingComponents": { "usingComponents": {
// "drama-feed-list": "plugin://playlet-plugin/drama-feed-list" "drama-feed-list": "plugin://playlet-plugin/drama-feed-list"
// } }
// // #endif // #endif
// } }
// }, },
{ {
"path": "pages/tabs/bingeWatch", "path": "pages/tabs/bingeWatch",
"style": { "style": {
+5 -32
View File
@@ -124,7 +124,7 @@
</view> </view>
<view class="u-flex-col u-col-bottom"> <view class="u-flex-col u-col-bottom">
<u-icon @click="show=false" stop name="close" color="#999" size="16"></u-icon> <u-icon @click="show=false" stop name="close" color="#999" size="16"></u-icon>
<view @click.stop="govideo(LookInfo.vl_id)" <view @click.stop="govideo(LookInfo.vid)"
class="u-bnt-tabbar-FF5205-FF0591 u-radius-40 u-p-l-20 u-p-r-20 u-p-t-10 u-p-b-10 u-font-24 u-m-t-10"> class="u-bnt-tabbar-FF5205-FF0591 u-radius-40 u-p-l-20 u-p-r-20 u-p-t-10 u-p-b-10 u-font-24 u-m-t-10">
继续播放</view> 继续播放</view>
</view> </view>
@@ -382,37 +382,10 @@
}, },
// 进入短剧播放页面 // 进入短剧播放页面
govideo(vlid) { govideo(vlid) {
if (tt.canIUse('video-player')) { uni.navigateTo({
uni.navigateTo({ url: '/pagesA/player/detailPlayer?vid=' + vlid + '&mid=' + 0
url: '/pagesA/index/VideoPlayer?vl_id=' + vlid })
}) },
return
this.$api.videoGroupInfo({
vl_id: vlid,
}).then(res => {
if (res.code == 1) {
if (res.data.video_look == false) {
uni.navigateTo({
url: '/pages/index/VideoPlayer?tt_album_id=' + res.data.album_id +
'&tt_episode_id=' + res.data.video_info[0].episode_id + '&vl_id=' +
vlid
})
} else {
uni.navigateTo({
url: '/pages/index/VideoPlayer?tt_album_id=' + res.data.album_id +
'&tt_episode_id=' + res.data.video_info[res.data.video_look.weigh -
1].episode_id + '&vl_id=' + vlid
})
}
} else {
this.$getMsg(res.msg)
}
})
} else {
this.$getMsg('当前版本过低,请升级抖音后观看')
}
}
} }
} }
</script> </script>
+7 -37
View File
@@ -42,10 +42,10 @@
<scroll-view scroll-y style="height: 51vh;" v-if="list.length>0" @scrolltolower="getbottom()"> <scroll-view scroll-y style="height: 51vh;" v-if="list.length>0" @scrolltolower="getbottom()">
<view class="u-p-l-20 u-p-r-20 u-p-b-30"> <view class="u-p-l-20 u-p-r-20 u-p-b-30">
<view v-if="current == 0" class="u-flex u-m-t-30" v-for="(item,index) in list" :key="index"> <view v-if="current == 0" class="u-flex u-m-t-30" v-for="(item,index) in list" :key="index">
<u-image :src="item.img" @click="govideo(item.vl_id)" width="100rpx" height="140rpx" <u-image :src="item.img" @click="govideo(item.vid,item.mid)" width="100rpx" height="140rpx"
radius="5"></u-image> radius="5"></u-image>
<view class="u-flex-1 u-m-l-20 u-flex u-row-between"> <view class="u-flex-1 u-m-l-20 u-flex u-row-between">
<view @click="govideo(item.vl_id)"> <view @click="govideo(item.vid,item.mid)">
<view class="u-font-28 u-word-break u-line-1">{{item.vname}}</view> <view class="u-font-28 u-word-break u-line-1">{{item.vname}}</view>
<view class="u-font-24 u-m-t-30 u-color-999">{{item.mid}}集</view> <view class="u-font-24 u-m-t-30 u-color-999">{{item.mid}}集</view>
</view> </view>
@@ -53,7 +53,7 @@
</view> </view>
<view v-else class="u-flex u-flex-wrap u-col-top"> <view v-else class="u-flex u-flex-wrap u-col-top">
<view class="u-w-200 u-m-t-30 u-m-r-16" v-for="(item,index) in list" :key="index" <view class="u-w-200 u-m-t-30 u-m-r-16" v-for="(item,index) in list" :key="index"
@click="govideo(item.vl_id)"> @click="govideo(item.vid,item.mid)">
<image :src="item.img" class="u-w-200 u-h-280 u-radius-10" mode="aspectFill"> <image :src="item.img" class="u-w-200 u-h-280 u-radius-10" mode="aspectFill">
</image> </image>
<view class="u-word-break u-line-1 u-m-t-10 u-font-26">{{item.vname}}</view> <view class="u-word-break u-line-1 u-m-t-10 u-font-26">{{item.vname}}</view>
@@ -216,40 +216,10 @@
this.$getMsg('已添加成功', 1500, false, 'success') this.$getMsg('已添加成功', 1500, false, 'success')
}, },
// 进入短剧播放页面 // 进入短剧播放页面
govideo(vlid) { govideo(vid, min) {
if (tt.canIUse('video-player')) { uni.navigateTo({
uni.navigateTo({ url: '/pagesA/player/detailPlayer?vid=' + vlid + '&mid=' + min || 0
url: '/pagesA/index/VideoPlayer?vl_id=' + vlid })
})
return
this.$api.videoGroupInfo({
vl_id: vlid,
}).then(res => {
if (res.code == 1) {
if (res.data.video_look == false) {
uni.navigateTo({
url: '/pages/index/VideoPlayer?tt_album_id=' + res.data
.album_id +
'&tt_episode_id=' + res.data.video_info[0].episode_id +
'&vl_id=' +
vlid
})
} else {
uni.navigateTo({
url: '/pages/index/VideoPlayer?tt_album_id=' + res.data
.album_id +
'&tt_episode_id=' + res.data.video_info[res.data
.video_look.weigh -
1].episode_id + '&vl_id=' + vlid
})
}
} else {
this.$getMsg(res.msg)
}
})
} else {
this.$getMsg('当前版本过低,请升级抖音后观看')
}
}, },
getbottom() { getbottom() {
//避免多次触发 //避免多次触发
-1
View File
@@ -127,7 +127,6 @@ export default {
methods: { methods: {
// 获取页面宽高数据& 系统信息 // 获取页面宽高数据& 系统信息
getPageDefault() { getPageDefault() {
console.log(this.system, uni.getSystemInfoSync()) console.log(this.system, uni.getSystemInfoSync())
+1 -1
View File
@@ -167,7 +167,7 @@ export default {
onLoad(e) { onLoad(e) {
console.log(e) console.log(e,999999)
this.userinfo = uni.getStorageSync("userinfo"); this.userinfo = uni.getStorageSync("userinfo");
this.getPageDefault(); this.getPageDefault();
this.checkQueryData(e); this.checkQueryData(e);
File diff suppressed because it is too large Load Diff
+66
View File
@@ -0,0 +1,66 @@
let showtype = false
// 激励视频广告实例(微信小程序)
const rewardedAd = wx.createRewardedVideoAd({
adUnitId: 'adunit-xxxxxxxxxx', // TODO: 替换为你的微信激励广告单元ID
});
// 加载激励视频广告
function insertAdload() {
rewardedAd.load().catch((err) => {
console.log('激励广告加载失败', err);
});
}
// 显示激励视频广告
function insertAdshow() {
if (showtype) {
console.log("显示广告");
rewardedAd.show().catch((err) => {
console.log('激励广告显示失败', err);
rewardedAd.load();
});
}
}
// 监听广告加载成功(支持回调)
function insertAdonLoad(onSuccess) {
rewardedAd.onLoad(() => {
showtype = true;
console.log('激励广告加载成功');
onSuccess && onSuccess();
});
}
// 监听错误(支持回调)
function insertAdonError(onFail) {
rewardedAd.onError((err) => {
console.log('激励广告错误', err);
showtype = false;
onFail && onFail();
setTimeout(() => {
insertAdload();
}, 30000);
});
}
// 监听广告关闭(微信特有:可判断是否看完)
function insertAdonClose(callback) {
rewardedAd.onClose((res) => {
console.log('激励广告关闭', res);
if (res && res.isEnded) {
callback && callback(true);
} else {
callback && callback(false);
}
insertAdload();
});
}
export default {
insertAdload,
insertAdshow,
insertAdonError,
insertAdonLoad,
insertAdonClose
}
+66 -63
View File
@@ -1,66 +1,69 @@
import {
httpRequest
} from "./request.js";
const login = {
wxLogin() {
return new Promise((resolve, reject) => {
uni.login({
provider: 'weixin',
success: (res) => {
httpRequest({
url: '/api/user/getOpenid',
data: {
code: res.code, //wx.login 登录成功后的code
ad_code: uni.getStorageSync('get_ad_code'),
invite: uni.getStorageSync("invite_number")
},
import {httpRequest} from "./request.js"; }).then((opRes) => {
const login={ if (res.code == 1) {
wxLogin(){ uni.setStorageSync("openid", opRes.data.openid)
return new Promise((resolve,reject)=>{ if (opRes.msg == '登录成功') {
uni.login({ uni.setStorageSync("userinfo", opRes.data.userinfo);
provider: 'weixin', uni.setStorageSync("token", opRes.data.userinfo.token);
success: (res) => { uni.setStorageSync("config", opRes.data.config);
httpRequest({ resolve('login success')
url:'/api/user/getOpenid', } else {
data:{ this.Loginops(opRes).then(opRes => {
code: res.code, //wx.login 登录成功后的code resolve('login success')
ad_code: uni.getStorageSync('get_ad_code'), }).catch(logPErr => {
invite: uni.getStorageSync("invite_number") reject(logPErr)
}, })
}
}
}).catch(opErr => {
reject(opErr)
})
},
fail: (err) => {
reject(err)
}
});
}).then((opRes)=>{ })
uni.setStorageSync("openid", opRes.data.openid) },
if (opRes.msg == '登录成功') { Loginops(openData) {
uni.setStorageSync("userinfo", opRes.data.userinfo); return new Promise((resolve, reject) => {
uni.setStorageSync("token", opRes.data.userinfo.token); httpRequest({
uni.setStorageSync("config", opRes.data.config); url: '/api/user/getphone',
resolve('login success') method: 'GET',
} else { data: {
this.Loginops(opRes).then(opRes => { openid: openData.data.openid,
resolve('login success') pid: '0',
}).catch(logPErr => { invite: uni.getStorageSync('invite_number') || '',
reject(logPErr) ad_code: uni.getStorageSync('get_ad_code') || ''
}) },
} }).then(uRes => {
}).catch(opErr=>{ if (uRes.code == 1) {
reject(opErr) uni.setStorageSync("userinfo", uRes.data.userinfo);
}) uni.setStorageSync("token", uRes.data.userinfo.token);
}, uni.setStorageSync("config", uRes.data.config);
fail: (err) => { resolve('login success')
reject(err) }
} }).catch(uErr => {
}); reject(uErr)
})
}) })
}, },
Loginops(openData) {
return new Promise((resolve, reject) => {
httpRequest({
url:'/api/user/getphone',
method: 'GET',
data: {
openid: openData.data.openid,
pid: '0',
invite: uni.getStorageSync('invite_number') ||'',
ad_code: uni.getStorageSync('get_ad_code') || ''
},
}).then(uRes=>{
if(uRes.code ==1){
uni.setStorageSync("userinfo", uRes.data.userinfo);
uni.setStorageSync("token", uRes.data.userinfo.token);
uni.setStorageSync("config", uRes.data.config);
resolve('login success')
}
}).catch(uErr=>{
reject(uErr)
})
})
},
} }
export default login export default login
+479 -393
View File
@@ -1,422 +1,508 @@
var playletPlugin = requirePlugin("playlet-plugin"); var playletPlugin = requirePlugin("playlet-plugin");
var serialNo = null
import configs from '@/utils/config.js'; import configs from '@/utils/config.js';
import {httpRequest} from '@/utils/request' import {
import {login} from './login' httpRequest
} from '@/utils/request'
import {
login
} from './login'
import PAY from '@/utils/pay' import PAY from '@/utils/pay'
// 点击按钮触发此函数跳转到播放器页面 // 点击按钮触发此函数跳转到播放器页面
function navigateToPlayer(obj) { function navigateToPlayer(obj) {
// 下面的${dramaId}变量,需要替换成小程序管理后台的媒资管理上传的剧的dramaId // 下面的${dramaId}变量,需要替换成小程序管理后台的媒资管理上传的剧的dramaId
// 变量${srcAppid}是提审方appid // 变量${srcAppid}是提审方appid
// 变量${serialNo}第几集 // 变量${serialNo}第几集
// 变量${extParam}是分享参数,分享的卡片和二维码会在分享的链接上携带此参数 // 变量${extParam}是分享参数,分享的卡片和二维码会在分享的链接上携带此参数
const { extParam, dramaId, srcAppid=configs.mini_appid,serialNo=1 } = obj const {
wx.navigateTo({ extParam,
url: `plugin-private://wx94a6522b1d640c3b/pages/playlet/playlet?dramaId=${dramaId}&srcAppid=${srcAppid}&serialNo=${serialNo}&extParam=${extParam || ''}` dramaId,
}) srcAppid = configs.mini_appid,
serialNo = 1
} = obj
wx.navigateTo({
url: `plugin-private://wx94a6522b1d640c3b/pages/playlet/playlet?dramaId=${dramaId}&srcAppid=${srcAppid}&serialNo=${serialNo}&extParam=${extParam || ''}`
})
} }
function deepClone(obj) { function deepClone(obj) {
if (typeof obj !== 'object' || !obj) return obj if (typeof obj !== 'object' || !obj) return obj
let newObj = obj instanceof Array ? [] : {} let newObj = obj instanceof Array ? [] : {}
for (let key in obj) { for (let key in obj) {
if (typeof obj[key] === 'object') { if (typeof obj[key] === 'object') {
newObj[key] = deepClone(obj[key]) newObj[key] = deepClone(obj[key])
} else { } else {
newObj[key] = obj[key] newObj[key] = obj[key]
} }
} }
return newObj return newObj
} }
const proto = { const proto = {
data: { // 可通过this.data访问 data: { // 可通过this.data访问
playerId: '',//播放器id playerId: '', //播放器id
arr: [], arr: [],
vid:"",//剧id vid: "", //剧id
info:{}, info: {},
mid:"",//剧集id mid: "", //剧集id
userInfo:{}, userInfo: {},
is_record:0,//是否追剧 0未追 1已追 is_record: 0, //是否追剧 0未追 1已追
pay_oid:'', pay_oid: '',
}, },
_onPlayerLoad(info) { _onPlayerLoad(info) {
let that = this, let that = this,
shareInterval = null; shareInterval = null;
console.log("_onPlayerLoad",info); console.log("_onPlayerLoad", info);
if(info.extParam){ if (info.extParam) {
if(info.extParam.indexOf("%")<0){ if (info.extParam.indexOf("%") < 0) {
this.data.info = info; this.data.info = info;
}else if(info.extParam){ } else if (info.extParam) {
info.extParam = decodeURIComponent(info.extParam ) info.extParam = decodeURIComponent(info.extParam)
this.data.info = info; this.data.info = info;
}else{} } else {}
this.data.vid = JSON.parse(info.extParam).vid; this.data.vid = JSON.parse(info.extParam).vid;
if(JSON.parse(info.extParam).g_order_id){//存储分享后的gid if (JSON.parse(info.extParam).g_order_id) { //存储分享后的gid
uni.setStorageSync('g_order_id',JSON.parse(info.extParam).g_order_id); uni.setStorageSync('g_order_id', JSON.parse(info.extParam).g_order_id);
uni.setStorageSync('g_order_vid',JSON.parse(info.extParam).vid); uni.setStorageSync('g_order_vid', JSON.parse(info.extParam).vid);
} }
} }
this.data.playerId = info.playerId this.data.playerId = info.playerId
const pm = playletPlugin.PlayletManager.getPageManager(info.playerId) const pm = playletPlugin.PlayletManager.getPageManager(info.playerId)
this.pm = pm this.pm = pm
let user = uni.getStorageSync('userinfo'); let user = uni.getStorageSync('userinfo');
if(user.token){ if (user.token) {
this.data.userInfo = uni.getStorageSync('userinfo'); this.data.userInfo = uni.getStorageSync('userinfo');
console.log('onPlayerLoad info', info, 'data', this.data) console.log('onPlayerLoad info', info, 'data', this.data)
that.getVideoId(); that.getVideoId();
that.getEncryptData({serialNo: info.serialNo}).then(setRes => { that.getEncryptData({
// encryptedData是后台加密后的数据,具体实现见官方文档的加密章节 serialNo: info.serialNo
let lists = [setRes.data]; }).then(setRes => {
pm.setCanPlaySerialList({ // encryptedData是后台加密后的数据,具体实现见官方文档的加密章节
data: setRes.encryptedData, let lists = [setRes.data];
freeList:lists pm.setCanPlaySerialList({
// freeList: [{ // 1~10集是免费剧,data里面的字段也必须至少设置1~10集可播放 data: setRes.encryptedData,
// start_serial_no: setRes.data.start_serial_no, freeList: lists
// end_serial_no: setRes.data.end_serial_no // freeList: [{ // 1~10集是免费剧,data里面的字段也必须至少设置1~10集可播放
// }], // start_serial_no: setRes.data.start_serial_no,
}) // end_serial_no: setRes.data.end_serial_no
}); // }],
}else{ })
login.wxLogin().then(res=>{ });
this.data.userInfo = uni.getStorageSync('userinfo'); } else {
console.log('onPlayerLoad info', info, 'data', this.data) login.wxLogin().then(res => {
that.getVideoId(); this.data.userInfo = uni.getStorageSync('userinfo');
that.getEncryptData({serialNo: info.serialNo}).then(setRes => { console.log('onPlayerLoad info', info, 'data', this.data)
// encryptedData是后台加密后的数据,具体实现见官方文档的加密章节 that.getVideoId();
let lists = [setRes.data]; that.getEncryptData({
pm.setCanPlaySerialList({ serialNo: info.serialNo
data: setRes.encryptedData, }).then(setRes => {
freeList:lists // encryptedData是后台加密后的数据,具体实现见官方文档的加密章节
}) let lists = [setRes.data];
}); pm.setCanPlaySerialList({
}); data: setRes.encryptedData,
} freeList: lists
})
});
});
}
// 需要解锁的事件 // 需要解锁的事件
pm.onCheckIsCanPlay(this.onCheckIsCanPlay); pm.onCheckIsCanPlay(this.onCheckIsCanPlay);
// 页面返回事件 // 页面返回事件
pm.onBack(this.pageBack) pm.onBack(this.pageBack)
// 支付回调事件 // 支付回调事件
pm.onCustomEvent('chargeEnd', this.chargeEnd) pm.onCustomEvent('chargeEnd', this.chargeEnd)
pm.setVisualEffectOnCapture({ pm.setVisualEffectOnCapture({
visualEffect: 'none', visualEffect: 'none',
}) })
// 参考文档章节“数据上报” // 参考文档章节“数据上报”
pm.onDataReport((obj) => { pm.onDataReport((obj) => {
if(obj.event === playletPlugin.REPORT_DATA_EVENTS.LIKE || obj.event === playletPlugin.REPORT_DATA_EVENTS.UNLIKE){//监听点赞、取消点赞操作 if (obj.event === playletPlugin.REPORT_DATA_EVENTS.LIKE || obj.event === playletPlugin
console.log("user like") .REPORT_DATA_EVENTS.UNLIKE) { //监听点赞、取消点赞操作
this.userLikeChange(); console.log("user like")
}else if(obj.event === playletPlugin.REPORT_DATA_EVENTS.FAV || obj.event === playletPlugin.REPORT_DATA_EVENTS.UNFAV){//监听在追,取消在追操作 this.userLikeChange();
console.log("user zhui ju") } else if (obj.event === playletPlugin.REPORT_DATA_EVENTS.FAV || obj.event === playletPlugin
this.changeStar() .REPORT_DATA_EVENTS.UNFAV) { //监听在追,取消在追操作
}else if(obj.event === playletPlugin.REPORT_DATA_EVENTS.CHANGE_SERIAL){//监听切换剧集操作 console.log("user zhui ju")
console.log("user changePlay log") this.changeStar()
this.changePlayLog() } else if (obj.event === playletPlugin.REPORT_DATA_EVENTS.CHANGE_SERIAL) { //监听切换剧集操作
}else if(obj.event === playletPlugin.REPORT_DATA_EVENTS.SHARE){//监听分享操作 console.log("user changePlay log")
console.log("user share") this.changePlayLog()
}else { } else if (obj.event === playletPlugin.REPORT_DATA_EVENTS.SHARE) { //监听分享操作
// console.log("其他操作") console.log("user share")
} } else {
// console.log("其他操作")
}
}) })
// 设置右侧固定运营位置跳转路径 // 设置右侧固定运营位置跳转路径
pm.setActivityInfo({ pm.setActivityInfo({
url: '' url: ''
}) })
// 设置运营区域 // 设置运营区域
pm.updateOpenArea({ pm.updateOpenArea({
showLeft: false, showLeft: false,
showRight: false, showRight: false,
leftsideAreaList: [ leftsideAreaList: [{
{ left: 16, // 类似绝对定位的样式
left: 16, // 类似绝对定位的样式 top: 20,
top: 20, width: 72,
width: 72, height: 32
height: 32 }, ],
}, ext: 'extInfo',
], })
ext: 'extInfo', },
}) _initShare() {
}, const pm = this.pm
_initShare() { // 关于分享的处理
const pm = this.pm // 开启分享以及withShareTicket
// 关于分享的处理 pm.setDramaFlag({
// 开启分享以及withShareTicket share: true,
pm.setDramaFlag({ withShareTicket: true
share: true, })
withShareTicket: true // 获取分享参数,页面栈只有短剧播放器一个页面的时候可获取到此参数
}) // 例如从分享卡片进入、从投流广告直接跳转到播放器页面,从二维码直接进入播放器页面等情况
// 获取分享参数,页面栈只有短剧播放器一个页面的时候可获取到此参数 playletPlugin.getShareParams().then(res => {
// 例如从分享卡片进入、从投流广告直接跳转到播放器页面,从二维码直接进入播放器页面等情况 console.log('getLaunch options query res', res)
playletPlugin.getShareParams().then(res => { // 关于extParam的处理,需要先做decodeURIComponent之后才能得到原值
console.log('getLaunch options query res', res) const extParam = decodeURIComponent(res.extParam)
// 关于extParam的处理,需要先做decodeURIComponent之后才能得到原值 console.log('getLaunch options extParam', extParam)
const extParam = decodeURIComponent(res.extParam) // 如果设置了withShareTicket为true,可通过文档的方法获取更多信息
console.log('getLaunch options extParam', extParam) // https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html
// 如果设置了withShareTicket为true,可通过文档的方法获取更多信息 const enterOptions = wx.getEnterOptionsSync()
// https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html console.log('getLaunch options shareTicket', enterOptions.shareTicket)
const enterOptions = wx.getEnterOptionsSync() }).catch(err => {
console.log('getLaunch options shareTicket', enterOptions.shareTicket) console.log('getLaunch options query err', err)
}).catch(err => { })
console.log('getLaunch options query err', err) this.getVideoId()
}) // 设置分享参数
this.getVideoId() pm.setExtParam(JSON.stringify({
// 设置分享参数 vid: this.data.vid,
pm.setExtParam(JSON.stringify({ fxpid: this.data.userInfo.id,
vid:this.data.vid, invite: this.data.userInfo.invite || ''
fxpid:this.data.userInfo.id, }))
invite:this.data.userInfo.invite||'' },
})) // 检测是否可以播放
}, onCheckIsCanPlay(param) {
// 检测是否可以播放 var that = this;
onCheckIsCanPlay(param) { let intervalTime = null;
var that = this; serialNo = param.serialNo
let intervalTime=null; console.log('onCheckIsCanPlay param', param);
console.log('onCheckIsCanPlay param',param); if (uni.getStorageSync('userinfo').token) {
if(uni.getStorageSync('userinfo').token){ that.getVideoId().then(video => {
that.getVideoId().then(video=>{ that.beansPay(video.data.id, param.serialNo);
that.beansPay(video.data.id,param.serialNo); })
}) } else {
}else{ intervalTime = setInterval(() => {
intervalTime = setInterval(()=>{ if (uni.getStorageSync('userinfo').token) {
if(uni.getStorageSync('userinfo').token){ clearInterval(intervalTime)
clearInterval(intervalTime) that.getVideoId().then(video => {
that.getVideoId().then(video=>{ that.beansPay(video.data.id, param.serialNo);
that.beansPay(video.data.id,param.serialNo); })
}) } else {
}else { console.log('no users login')
console.log('no users login')} }
},100) }, 100)
} }
}, },
getEncryptData(obj) { getEncryptData(obj) {
const {code, serialNo } = obj; const {
let that = this; code,
// TODO: 此接口请求后台,返回下面的setCanPlaySerialList接口需要的加密参数 serialNo
const { srcAppid, dramaId } = this.pm.getInfo() } = obj;
let that = this;
// TODO: 此接口请求后台,返回下面的setCanPlaySerialList接口需要的加密参数
const {
srcAppid,
dramaId
} = this.pm.getInfo()
console.log('getEncryptData start', srcAppid, dramaId, serialNo) console.log('getEncryptData start', srcAppid, dramaId, serialNo)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 获取免费剧集列表(包含用户已经支付的 ) // 获取免费剧集列表(包含用户已经支付的 )
wx.login({ wx.login({
success(res) { success(res) {
// console.log('code',res.code) // console.log('code',res.code)
httpRequest({ httpRequest({
url:"/api/video/videoInfoWechatV1", url: "/api/video/videoInfoWechatV1",
method:"GET", method: "GET",
data:{ data: {
code:res.code, code: res.code,
vid:that.data.vid, vid: that.data.vid,
oid:that.data.pay_oid oid: that.data.pay_oid
} }
}).then(res=>{ }).then(res => {
console.log('videoPlayer getCanPlayList res', res) console.log('videoPlayer getCanPlayList res', res)
resolve({ resolve({
data:res.data.data, data: res.data.data,
encryptedData: res.data.enData encryptedData: res.data.enData
}) })
}).catch(err=>{ }).catch(err => {
reject(err) reject(err)
console.log(err) console.log(err)
}) })
} }
}) })
}) })
}, },
pageBack(){ pageBack() {
let that = this; let that = this;
if(that.data.is_record==1){ if (that.data.is_record == 1) {
// that.pm.navigateBack() // that.pm.navigateBack()
that.pm.switchTab({ that.pm.switchTab({
url: '/pages/tabs/home' url: '/pages/tabs/home'
}) })
}else{ } else {
uni.showModal({ uni.showModal({
title:"提示", title: "提示",
content:"是否将此剧加入追剧列表", content: "是否将此剧加入追剧列表",
success(modelRes){ success(modelRes) {
if(modelRes.confirm){ if (modelRes.confirm) {
console.log('success'); console.log('success');
that.changeStar(); that.changeStar();
} }
that.pm.switchTab({ that.pm.switchTab({
url: '/pages/tabs/home' url: '/pages/tabs/home'
}) })
} }
}) })
} }
}, },
getVideoId(){ getVideoId() {
let that = this; let that = this;
let infos = this.pm.getInfo(); let infos = this.pm.getInfo();
console.log('getVideoId start',infos); console.log('getVideoId start', infos);
// 获取当前需支付剧集ID(媒资库的ID不能用,需要用我们自己的剧集ID) // 获取当前需支付剧集ID(媒资库的ID不能用,需要用我们自己的剧集ID)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
httpRequest({ httpRequest({
url:"/api/video/dramaIdToVideoId", url: "/api/video/dramaIdToVideoId",
method:"GET", method: "GET",
data:{ data: {
drama_id:infos.dramaId, drama_id: infos.dramaId,
no:infos.serialNo no: infos.serialNo
} }
}).then(res=>{ }).then(res => {
this.data.mid = res.data.id; this.data.mid = res.data.id;
if(res.data.drama_vid != that.data.vid){ if (res.data.drama_vid != that.data.vid) {
that.data.vid = res.data.drama_vid that.data.vid = res.data.drama_vid
} }
this.data.is_record = res.data.is_record this.data.is_record = res.data.is_record
resolve(res) resolve(res)
}).catch(err=>{ }).catch(err => {
console.log(err) console.log(err)
reject(err) reject(err)
}) })
}) })
}, },
// 金豆购买剧集 // 金豆购买剧集
beansPay(mid,serialNo){ beansPay(mid, serialNo) {
let buyData = uni.getStorageSync("buydata"); let buyData = uni.getStorageSync("buydata");
let that = this; let that = this;
console.log('beansPay begin',mid,serialNo) console.log('beansPay begin', mid, serialNo)
let upData={ let upData = {
sum:1, sum: 1,
buytype:"金豆", buytype: "金豆",
pricebuy:buyData.isvip ==2?buyData.vippriceq:buyData.priceq, pricebuy: buyData.isvip == 2 ? buyData.vippriceq : buyData.priceq,
token:uni.getStorageSync("userinfo").token, token: uni.getStorageSync("userinfo").token,
uid:uni.getStorageSync("userinfo").id, uid: uni.getStorageSync("userinfo").id,
ad_code:uni.getStorageSync('get_ad_code'), ad_code: uni.getStorageSync('get_ad_code'),
lx:2,//1 全章购买 2单集购买 lx: 2, //1 全章购买 2单集购买
smid:mid,//单集ID smid: mid, //单集ID
wxlx:'wxxcx', wxlx: 'wxxcx',
id:that.data.vid ,//剧ID id: that.data.vid, //剧ID
openid: uni.getStorageSync("openid") openid: uni.getStorageSync("openid")
} }
// 支付 // 支付
PAY.pays.beansPay(upData).then((res)=>{ PAY.pays.beansPay(upData).then((res) => {
console.log('beansPay res',res) console.log('beansPay res', res)
that.getEncryptData({serialNo: serialNo}).then(enRes => { that.getEncryptData({
that.pm.isCanPlay({ serialNo: serialNo
data: enRes.encryptedData, }).then(enRes => {
serialNo: serialNo, that.pm.isCanPlay({
status:res.code ==1?1:2 data: enRes.encryptedData,
}) serialNo: serialNo,
}) status: res.code == 1 ? 1 : 2
}).catch(err=>{ })
if(err.msg =='金豆不足'){ })
that.getEncryptData({serialNo: serialNo}).then(enRes => { }).catch(err => {
that.pm.isCanPlay({ if (err.msg == '金豆不足') {
data: enRes.encryptedData, that.getEncryptData({
serialNo: serialNo, serialNo: serialNo
status:2 }).then(enRes => {
}) that.pm.isCanPlay({
}) data: enRes.encryptedData,
} serialNo: serialNo,
console.log('jinDouPay fail',err) status: 2
}) })
})
}
console.log('jinDouPay fail', err)
})
},
// 更新喜欢状态
userLikeChange() {
let that = this;
that.getVideoId({
dramaId: that.data.info.dramaId,
serialNo: that.data.info.serialNo
}).then(res => {
httpRequest({
url: "/api/user/tapLove",
method: "GET",
data: {
vid: that.data.vid,
mid: res.data.id
}
}).then(res => {
console.log('userLikeChange res', res)
})
})
},
// 更新追剧状态
changeStar() {
let that = this;
let subData = {
vid: that.data.vid,
token: uni.getStorageSync("userinfo").token,
uid: uni.getStorageSync("userinfo").id,
mid: ""
}
that.getVideoId({
dramaId: that.data.info.dramaId,
serialNo: that.data.info.serialNo
}).then(res => {
}, httpRequest({
// 更新喜欢状态 url: "/api/user/videorecord",
userLikeChange(){ method: "GET",
let that = this; data: {
that.getVideoId({dramaId:that.data.info.dramaId,serialNo:that.data.info.serialNo}).then(res=>{ vid: that.data.vid,
httpRequest({ mid: res.data.id
url:"/api/user/tapLove", }
method:"GET", }).then(rest => {
data:{ console.log('userLikeChange res', rest)
vid:that.data.vid, }).catch(errs => {
mid:res.data.id console.log(errs)
} })
}).then(res=>{
console.log('userLikeChange res',res)
})
})
},
// 更新追剧状态
changeStar(){
let that = this;
let subData = {
vid:that.data.vid,
token:uni.getStorageSync("userinfo").token,
uid:uni.getStorageSync("userinfo").id,
mid:""
}
that.getVideoId({dramaId:that.data.info.dramaId,serialNo:that.data.info.serialNo}).then(res=>{
httpRequest({ })
url:"/api/user/videorecord", },
method:"GET", // 更新播放记录
data:{ changePlayLog() {
vid:that.data.vid, let that = this;
mid:res.data.id that.getVideoId({
} dramaId: that.data.info.dramaId,
}).then(rest=>{ serialNo: that.data.info.serialNo
console.log('userLikeChange res',rest) }).then(res => {
}).catch(errs=>{ console.log('changePlayLog mid', res)
console.log(errs) httpRequest({
}) url: "/api/video/bfjl",
method: "GET",
data: {
vid: that.data.vid,
mid: res.data.id
}
}).then(rest => {
console.log('changePlayLog res', rest)
}).catch(errs => {
console.log('change PlayLog fail', errs)
})
})
},
}) adEnd(mid) {
}, let buyData = uni.getStorageSync("buydata");
// 更新播放记录 let that = this;
changePlayLog(){ let upData = {
let that = this; sum: 1,
that.getVideoId({dramaId:that.data.info.dramaId,serialNo:that.data.info.serialNo}).then(res=>{ buytype: 'adUnlock'
console.log('changePlayLog mid',res) pricebuy: buyData.isvip == 2 ? buyData.vippriceq : buyData.priceq,
httpRequest({ token: uni.getStorageSync("userinfo").token,
url:"/api/video/bfjl", uid: uni.getStorageSync("userinfo").id,
method:"GET", ad_code: uni.getStorageSync('get_ad_code'),
data:{ lx: 2, //1 全章购买 2单集购买
vid:that.data.vid, smid: mid, //单集ID
mid:res.data.id wxlx: 'wxxcx',
} id: that.data.vid, //剧ID
}).then(rest=>{ openid: uni.getStorageSync("openid")
console.log('changePlayLog res',rest) }
}).catch(errs=>{ // 支付
console.log('change PlayLog fail',errs) PAY.pays.beansPay(upData).then((res) => {
}) console.log('beansPay res', res)
}) that.getEncryptData({
}, serialNo: serialNo.serialNo
// 支付完 }).then(enRes => {
chargeEnd(payRes){ that.pm.isCanPlay({
let that = this; data: enRes.encryptedData,
console.log("paySuccess",payRes) serialNo: serialNo.serialNo,
let share_g_order_vid = uni.getStorageSync('g_order_vid'); status: res.code == 1 ? 1 : 2
if(payRes.status == "paySuccess"){ })
that.data.pay_oid = payRes.oid; })
this.onCheckIsCanPlay({dramaId:that.data.info.dramaId,serialNo:payRes.serialNo,oid:payRes.oid }) }).catch(err => {
that.pm.setExtParam(JSON.stringify({ if (err.msg == '金豆不足') {
vid:this.data.vid, that.getEncryptData({
fxpid:this.data.userInfo.id, serialNo: serialNo.serialNo
invite:this.data.userInfo.invite||'', }).then(enRes => {
g_order_id:payRes.gOrderId, that.pm.isCanPlay({
g_order_vid:payRes.vid data: enRes.encryptedData,
serialNo: serialNo.serialNo,
status: 2
})
})
}
console.log('jinDouPay fail', err)
})
},
})) // 支付完
that.pm.hideChargeDialog(); chargeEnd(payRes) {
if(payRes.gOrderId && share_g_order_vid != payRes.vid){ let that = this;
that.pm.updateOpenArea({showLeft: true}); console.log("paySuccess", payRes)
} let share_g_order_vid = uni.getStorageSync('g_order_vid');
if (payRes.status == "paySuccess") {
that.data.pay_oid = payRes.oid;
this.onCheckIsCanPlay({
dramaId: that.data.info.dramaId,
serialNo: payRes.serialNo,
oid: payRes.oid
})
that.pm.setExtParam(JSON.stringify({
vid: this.data.vid,
fxpid: this.data.userInfo.id,
invite: this.data.userInfo.invite || '',
g_order_id: payRes.gOrderId,
g_order_vid: payRes.vid
} }))
}, that.pm.hideChargeDialog();
if (payRes.gOrderId && share_g_order_vid != payRes.vid) {
that.pm.updateOpenArea({
showLeft: true
});
}
}
},
} }
function PlayerManager() { function PlayerManager() {
var newProto = Object.assign({}, proto) var newProto = Object.assign({}, proto)
for (const k in newProto) { for (const k in newProto) {
if (typeof newProto[k] === 'function') { if (typeof newProto[k] === 'function') {
this[k] = newProto[k].bind(this) this[k] = newProto[k].bind(this)
} else if (typeof newProto[k] === 'object') { } else if (typeof newProto[k] === 'object') {
if (!newProto[k]) { if (!newProto[k]) {
this[k] = newProto[k] this[k] = newProto[k]
} else { } else {
this[k] = deepClone(newProto[k]) this[k] = deepClone(newProto[k])
} }
} }
} }
} }
PlayerManager.navigateToPlayer = navigateToPlayer PlayerManager.navigateToPlayer = navigateToPlayer