import { imageBasUrl } from '../../utils/config' const { httpRequest } = getApp(); Page({ data: { imageBasUrl, // swiperItemHeight: 0, orderList: [], videoInfoObj: {}, posterCover: '', activeTab: 0, orderPopupShow: false, systemInfo: {}, userInfo: {}, iosPayment: {}, swiperList: [], swiperCurrent: 0, swiperOrder: 0, sid: '', popupShow: false, batchAllOrder: 0, batchAllList: [] }, // 获取其它信息 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 }) }, // 处理弹框的集数 async handelOrder(infoObj) { const paramenter = { path: '/batchlist', method: 'POST', body: { sid: infoObj.sid, start: 1, end: infoObj.total } } const isBatchlist = await httpRequest(paramenter); 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]); }) this.setData({ orderList: mlist, batchAllOrder: isBatchlist.data.length, batchAllList: isBatchlist.data, }) } }, 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 temp = [...batchAllList]; temp[resData.order - 1].isvip = 0; this.setData({ batchAllList: temp }) return ols; } return orderList; }, // 获取 剧情 async isVideoPaymentFn(sid) { // const paramenter = { // path: '/iosPayment', // method: 'GET', // } // const iosPayment = await httpRequest(paramenter); // console.log(iosPayment, "iosPayment") const paramVideo = { path: '/videoread', method: 'POST', body: { sid: sid } } const videoRead = await httpRequest(paramVideo); // console.log(videoRead, "videoRead") if (Array.isArray(videoRead.data)) { const videoInfoObj = videoRead.data[0]; // const swiperList = Array.from({ length: videoInfoObj.total }, (v, k) => { // if (videoInfoObj.order == k + 1) { // return { // ...videoInfoObj, // } // } // return { order: k + 1 } // }); // console.log(swiperList, "swiperList") this.setData({ // iosPayment: iosPayment, // swiperOrder: videoInfoObj.order, // swiperList: swiperList, videoInfoObj: videoInfoObj, // swiperCurrent: videoInfoObj.order - 1, posterCover: videoInfoObj.videocover || videoInfoObj.cover }) this.handelOrder(videoInfoObj); 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 }, errObj: { 2: { showToastFlag: 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 swiperCurrent = this.data.swiperCurrent; // const videoInfoObj = this.data.videoInfoObj; // const sid = this.data.sid; // const swiperList = this.data.swiperList; // let id = ''; // if (current > swiperCurrent) { // 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); // this.setData({ // swiperList: swiperList, // swiperCurrent: current, // videoInfoObj: resData, // swiperOrder: resData.order // }) // }) // }, 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: current, 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 }) }) }, onLoad(query) { const sid = query.sid; this.setData({ sid: sid }) }, onShow() { const sid = this.data.sid; this.isOtherFn(); this.isVideoPaymentFn(sid); }, toPathPlayPage() { // my.navigateTo({ // url: '/pages/recharge/recharge' // }); 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 } }) }) } }, })