479 lines
11 KiB
JavaScript
479 lines
11 KiB
JavaScript
import { imageBasUrl } from '../../utils/config'
|
|
const { httpRequest } = getApp();
|
|
// import { throttle } from 'lodash';
|
|
// import { throttle } from '../../utils/throttle'
|
|
var _ = require('underscore');
|
|
|
|
|
|
Page({
|
|
data: {
|
|
imageBasUrl,
|
|
// swiperItemHeight: 0,
|
|
orderList: [],
|
|
videoInfoObj: {},
|
|
posterCover: '',
|
|
activeTab: 0,
|
|
orderPopupShow: false,
|
|
systemInfo: {},
|
|
userInfo: {},
|
|
iosPayment: {},
|
|
swiperList: [],
|
|
swiperCurrent: 0,
|
|
changeCuurent: 0,
|
|
swiperOrder: 0,
|
|
sid: '',
|
|
id: '',
|
|
tid: '',
|
|
popupShow: false,
|
|
batchAllOrder: 0,
|
|
batchAllList: [],
|
|
isThrottle: null,
|
|
pageHideFlag: true
|
|
},
|
|
// 获取其它信息
|
|
isOtherFn() {
|
|
// my.createSelectorQuery().select('#_video_box').boundingClientRect().exec((r) => {
|
|
// this.setData({
|
|
// swiperItemHeight: r[0].height
|
|
// })
|
|
// });
|
|
this.setData({
|
|
userInfo: getApp().globalData.userInfo,
|
|
systemInfo: getApp().globalData.systemInfo
|
|
})
|
|
},
|
|
|
|
// 处理弹框的集数
|
|
handelOrder(isBatchlist) {
|
|
|
|
const num = 30;
|
|
let remain = 0;
|
|
let temp = [];
|
|
const mlist = [];
|
|
let orderObj = {};
|
|
if (Array.isArray(isBatchlist.data)) {
|
|
isBatchlist.data.forEach((m, idx) => {
|
|
if ((num * remain + num) < m.order) {
|
|
remain += 1;
|
|
temp = [];
|
|
}
|
|
temp.push(m);
|
|
orderObj[remain] = {
|
|
firstNum: num * remain + 1,
|
|
lastNum: m.order,
|
|
title: `${num * remain + 1}-${m.order}`,
|
|
temp: temp
|
|
}
|
|
});
|
|
|
|
Object.keys(orderObj).map((m) => {
|
|
mlist.push(orderObj[m]);
|
|
})
|
|
return {
|
|
orderList: mlist,
|
|
batchAllOrder: isBatchlist.data.length,
|
|
batchAllList: isBatchlist.data,
|
|
}
|
|
}
|
|
|
|
return {
|
|
orderList: [],
|
|
batchAllOrder: 0,
|
|
batchAllList: []
|
|
}
|
|
},
|
|
|
|
handelOrderIsVip(resData) {
|
|
const orderList = this.data.orderList;
|
|
const batchAllList = this.data.batchAllList;
|
|
// swiperList.splice(current, 1, resData);
|
|
if (resData.chackpay == 1) {
|
|
const ols = [];
|
|
orderList.forEach((j) => {
|
|
let jb = {
|
|
...j
|
|
}
|
|
const yus = [];
|
|
j.temp.forEach((y) => {
|
|
let yobj = {
|
|
...y,
|
|
}
|
|
if (yobj.id == resData.id) {
|
|
yobj.isvip = 0;
|
|
}
|
|
yus.push(yobj);
|
|
})
|
|
jb.temp = yus;
|
|
ols.push(jb);
|
|
})
|
|
let newBatchAllList = [...batchAllList];
|
|
newBatchAllList[resData.order - 1].isvip = 0;
|
|
this.setData({
|
|
batchAllList: newBatchAllList
|
|
})
|
|
|
|
return ols;
|
|
}
|
|
return orderList;
|
|
},
|
|
|
|
// 获取 剧情
|
|
async isVideoPaymentFn(sid, id, tid) {
|
|
|
|
const body = {};
|
|
|
|
if (sid) {
|
|
body.sid = sid;
|
|
}
|
|
if (sid) {
|
|
body.id = id;
|
|
}
|
|
if (sid) {
|
|
body.tid = tid;
|
|
}
|
|
|
|
const paramVideo = {
|
|
path: '/videoread',
|
|
method: 'POST',
|
|
body: body
|
|
}
|
|
|
|
const videoRead = await httpRequest(paramVideo);
|
|
|
|
if (Array.isArray(videoRead.data)) {
|
|
|
|
const videoInfoObj = videoRead.data[0];
|
|
const paramenter = {
|
|
path: '/batchlist',
|
|
method: 'POST',
|
|
body: {
|
|
sid: videoInfoObj.sid,
|
|
start: 1,
|
|
end: videoInfoObj.total
|
|
}
|
|
}
|
|
const isBatchlist = await httpRequest(paramenter);
|
|
const selectOrderInfo = this.handelOrder(isBatchlist);
|
|
console.log(selectOrderInfo, "selectOrderInfo")
|
|
|
|
this.setData({
|
|
swiperOrder: videoInfoObj.order,
|
|
videoInfoObj: videoInfoObj,
|
|
swiperCurrent: videoInfoObj.order - 1,
|
|
changeCuurent: videoInfoObj.order - 1,
|
|
posterCover: videoInfoObj.videocover || videoInfoObj.cover,
|
|
orderList: selectOrderInfo.orderList,
|
|
batchAllOrder: selectOrderInfo.batchAllList,
|
|
batchAllList: selectOrderInfo.batchAllList,
|
|
})
|
|
|
|
my.setNavigationBar({
|
|
title: videoInfoObj.title,
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
toPathPlayAllOrder() {
|
|
|
|
const videoInfoObj = this.data.videoInfoObj;
|
|
const sid = this.data.sid;
|
|
|
|
const paramVideo = {
|
|
path: '/buyall',
|
|
method: 'POST',
|
|
body: {
|
|
sid: sid,
|
|
id: videoInfoObj.id,
|
|
allprice: videoInfoObj.allprice
|
|
},
|
|
errShowT: true
|
|
}
|
|
|
|
httpRequest(paramVideo).then(res => {
|
|
if (res.status == 1) {
|
|
my.showToast({
|
|
type: 'none',
|
|
content: res.msg || '购买成功',
|
|
duration: 1000,
|
|
})
|
|
this.isVideoPaymentFn(sid);
|
|
}
|
|
}).catch(err => {
|
|
if (err.status == 2) {
|
|
my.confirm({
|
|
title: '温馨提示',
|
|
content: err.msg,
|
|
confirmButtonText: '去充值',
|
|
cancelButtonText: '取消',
|
|
success: (result) => {
|
|
if (result.confirm) {
|
|
this.setData({
|
|
popupShow: true,
|
|
})
|
|
}
|
|
},
|
|
});
|
|
}
|
|
})
|
|
},
|
|
|
|
handelswiperCurrent(ev) {
|
|
const current = ev.detail.current;
|
|
const isThrottle = this.data.isThrottle;
|
|
isThrottle(current);
|
|
},
|
|
|
|
videoErrorFn(e) {
|
|
console.log(e, "eee")
|
|
},
|
|
|
|
videoEndedFn() {
|
|
const videoInfoObj = this.data.videoInfoObj;
|
|
const sid = this.data.sid;
|
|
// const swiperList = this.data.swiperList;
|
|
const id = videoInfoObj.nextid;
|
|
// const current = videoInfoObj.order;
|
|
const paramVideo = {
|
|
path: '/videoread',
|
|
method: 'POST',
|
|
body: {
|
|
sid: sid,
|
|
id: id
|
|
}
|
|
}
|
|
|
|
httpRequest(paramVideo).then(res => {
|
|
// swiperList.map()
|
|
const resData = res.data[0];
|
|
const ols = this.handelOrderIsVip(resData);
|
|
// swiperList.splice(current, 1, resData);
|
|
this.setData({
|
|
// swiperList: swiperList,
|
|
swiperCurrent: resData.order - 1,
|
|
changeCuurent: resData.order - 1,
|
|
videoInfoObj: resData,
|
|
orderList: ols,
|
|
// swiperOrder: resData.order
|
|
})
|
|
})
|
|
},
|
|
|
|
//显示 选择集数
|
|
selectEpisodesFn() {
|
|
this.setData({
|
|
orderPopupShow: true
|
|
})
|
|
},
|
|
|
|
// 关闭 选择集数
|
|
closeOrderPopup() {
|
|
this.setData({
|
|
orderPopupShow: false
|
|
})
|
|
},
|
|
|
|
// 切换 级数的
|
|
handleTabClick(ev) {
|
|
// console.log(e, "handleTabClickhandleTabClick")
|
|
this.setData({
|
|
activeTab: ev.index
|
|
})
|
|
|
|
},
|
|
|
|
handleOrderCurrent(ev) {
|
|
const item = ev.target.dataset.item;
|
|
// const orderList = this.data.orderList;
|
|
// const batchAllOrder = this.data.batchAllOrder;
|
|
const batchAllList = this.data.batchAllList;
|
|
if (item.order != 1) {
|
|
const nextVideoObj = batchAllList[item.order - 2];
|
|
if (nextVideoObj.isvip == 1) {
|
|
my.showToast({
|
|
type: 'info',
|
|
content: '为了保证剧情连贯,请按顺序观看'
|
|
})
|
|
return;
|
|
}
|
|
}
|
|
// const current = item.order - 1;
|
|
const sid = this.data.sid;
|
|
// const swiperList = this.data.swiperList;
|
|
const paramVideo = {
|
|
path: '/videoread',
|
|
method: 'POST',
|
|
body: {
|
|
sid: sid,
|
|
id: item.id
|
|
}
|
|
}
|
|
|
|
httpRequest(paramVideo).then(res => {
|
|
// swiperList.map()
|
|
const resData = res.data[0];
|
|
const ols = this.handelOrderIsVip(resData);
|
|
this.setData({
|
|
// swiperList: swiperList,
|
|
// swiperCurrent: current,
|
|
videoInfoObj: resData,
|
|
// swiperOrder: resData.order,
|
|
orderPopupShow: false,
|
|
orderList: ols,
|
|
swiperCurrent: resData.order - 1,
|
|
changeCuurent: resData.order - 1,
|
|
})
|
|
})
|
|
},
|
|
|
|
onLoad(query) {
|
|
const sid = query.sid;
|
|
const id = query.id || '';
|
|
const tid = query.tid || '';
|
|
this.setData({
|
|
sid: sid,
|
|
id: id,
|
|
tid: tid
|
|
})
|
|
},
|
|
|
|
onShow() {
|
|
const sid = this.data.sid;
|
|
const id = this.data.id;
|
|
const tid = this.data.tid;
|
|
this.isOtherFn();
|
|
this.isVideoPaymentFn(sid, id, tid);
|
|
// const lodash = require('lodash');
|
|
const isThrottle = _.throttle((current) => {
|
|
let id = '';
|
|
const changeCuurent = this.data.changeCuurent;
|
|
const videoInfoObj = this.data.videoInfoObj;
|
|
const sid = this.data.sid;
|
|
if (current > changeCuurent) {
|
|
id = videoInfoObj.nextid;
|
|
} else {
|
|
id = videoInfoObj.lastid;
|
|
}
|
|
const paramVideo = {
|
|
path: '/videoread',
|
|
method: 'POST',
|
|
body: {
|
|
sid: sid,
|
|
id: id
|
|
}
|
|
}
|
|
|
|
httpRequest(paramVideo).then(res => {
|
|
// swiperList.map()
|
|
const resData = res.data[0]
|
|
// swiperList.splice(current, 1, resData);
|
|
const ols = this.handelOrderIsVip(resData);
|
|
this.setData({
|
|
// swiperList: swiperList,
|
|
// swiperCurrent: current,
|
|
changeCuurent: current,
|
|
videoInfoObj: resData,
|
|
orderList: ols,
|
|
swiperOrder: resData.order
|
|
})
|
|
})
|
|
}, 300, { trailing: false });
|
|
this.setData({
|
|
isThrottle: isThrottle,
|
|
pageHideFlag: true
|
|
})
|
|
},
|
|
|
|
toPathPlayPage() {
|
|
this.setData({
|
|
popupShow: true,
|
|
})
|
|
},
|
|
|
|
onClosePopup(mi) {
|
|
const videoInfoObj = this.data.videoInfoObj;
|
|
if (mi.resultCode == 9000 && videoInfoObj.chackpay == 2) {
|
|
const sid = this.data.sid;
|
|
const paramVideo = {
|
|
path: '/videoread',
|
|
method: 'POST',
|
|
body: {
|
|
sid: sid,
|
|
id: videoInfoObj.id
|
|
}
|
|
}
|
|
|
|
httpRequest(paramVideo).then(res => {
|
|
const resData = res.data[0];
|
|
const ols = this.handelOrderIsVip(resData);
|
|
this.setData({
|
|
popupShow: false,
|
|
videoInfoObj: resData,
|
|
orderList: ols
|
|
})
|
|
})
|
|
|
|
} else {
|
|
this.setData({
|
|
popupShow: false,
|
|
})
|
|
}
|
|
},
|
|
// 添加追剧
|
|
addChasingDramasFn() {
|
|
const videoInfoObj = this.data.videoInfoObj;
|
|
if (videoInfoObj.iskeep == 0) {
|
|
|
|
const paramenter = {
|
|
path: '/addkeep',
|
|
method: 'POST',
|
|
body: {
|
|
sid: videoInfoObj.sid
|
|
}
|
|
}
|
|
httpRequest(paramenter).then(() => {
|
|
my.showToast({
|
|
icon: 'none',
|
|
content: '追剧成功',
|
|
duration: 1000,
|
|
});
|
|
this.setData({
|
|
videoInfoObj: {
|
|
...videoInfoObj,
|
|
iskeep: 1
|
|
}
|
|
})
|
|
})
|
|
|
|
} else {
|
|
const paramenter = {
|
|
path: '/chasingdramadel',
|
|
method: 'POST',
|
|
body: {
|
|
sid: videoInfoObj.sid
|
|
}
|
|
}
|
|
httpRequest(paramenter).then(() => {
|
|
my.showToast({
|
|
type: 'none',
|
|
content: '取消成功',
|
|
duration: 1000,
|
|
});
|
|
this.setData({
|
|
videoInfoObj: {
|
|
...videoInfoObj,
|
|
iskeep: 0
|
|
}
|
|
})
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
onHide() {
|
|
this.setData({
|
|
pageHideFlag: false
|
|
})
|
|
}
|
|
}) |