This commit is contained in:
lipenggao 2024-10-16 17:56:25 +08:00
parent b61fa0a736
commit c9afb569b1
6 changed files with 59 additions and 32 deletions

View File

@ -56,7 +56,7 @@
<swiper class="_banner_swiper" interval={{4000}} duration={{150}} onChange="{{bannerChange}}"> <swiper class="_banner_swiper" interval={{4000}} duration={{150}} onChange="{{bannerChange}}">
<block a:for="{{pageDataInfo.bannerList}}"> <block a:for="{{pageDataInfo.bannerList}}">
<swiper-item class="" a:key={{item.bookid}}> <swiper-item class="" a:key={{item.bookid}}>
<view class="_ba_swiper_item" onTap="{{toPathVideo}}" data-item="{{item}}"> <view class="_ba_swiper_item" onTap="toPathVideo" data-item="{{item}}">
<image src="{{item.cover}}" mode="aspectFill" class="_is_swiper_img"></image> <image src="{{item.cover}}" mode="aspectFill" class="_is_swiper_img"></image>
</view> </view>
</swiper-item> </swiper-item>

View File

@ -1,3 +1,4 @@
import { objectToQueryString } from '../../utils/utils'
Page({ Page({
data: { data: {
baoxianFlag: false, baoxianFlag: false,
@ -18,15 +19,16 @@ Page({
const sid = query.sid || ''; const sid = query.sid || '';
const id = query.id || ''; const id = query.id || '';
const tid = query.tid || ''; const tid = query.tid || '';
const systemInfo = getApp().globalData.systemInfo; const systemInfo = my.getSystemInfoSync();
const isUrlString = objectToQueryString(query)
if (sid || id || tid) { if (sid || id || tid) {
if (systemInfo.platform == 'android' || systemInfo.platform == 'Android') { if (systemInfo.platform == 'android' || systemInfo.platform == 'Android') {
my.navigateTo({ my.navigateTo({
url: `/pages/videoAndroid/videoAndroid?sid=${sid}&id=${id}&tid=${tid}`, url: `/pages/videoAndroid/videoAndroid?${isUrlString}`,
}); });
} else { } else {
my.navigateTo({ my.navigateTo({
url: `/pages/video/video?sid=${sid}&id=${id}&tid=${tid}` url: `/pages/video/video?${isUrlString}`
}); });
} }
} else { } else {
@ -38,6 +40,10 @@ Page({
}, },
onShow() { onShow() {
// 页面显示 // 页面显示
const systemInfo = my.getSystemInfoSync();
this.setData({
systemInfo,
})
this.isGetList(); this.isGetList();
}, },
@ -117,6 +123,7 @@ Page({
toPathVideo(event) { toPathVideo(event) {
const data = event.target.dataset.item; const data = event.target.dataset.item;
const systemInfo = this.data.systemInfo; const systemInfo = this.data.systemInfo;
console.log(systemInfo, "systemInfo")
if (systemInfo.platform == 'android' || systemInfo.platform == 'Android') { if (systemInfo.platform == 'android' || systemInfo.platform == 'Android') {
my.navigateTo({ my.navigateTo({
url: `/pages/videoAndroid/videoAndroid?sid=${data.id}`, url: `/pages/videoAndroid/videoAndroid?sid=${data.id}`,

View File

@ -11,7 +11,7 @@ Page({
onShow() { onShow() {
const historyData = my.getStorageSync({ key: 'historySearch' }); const historyData = my.getStorageSync({ key: 'historySearch' });
this.setData({ this.setData({
historySearch: historyData.data historySearch: historyData.data || [],
}) })
}, },
@ -36,12 +36,12 @@ Page({
console.log(res, Array.isArray(res.data), "findfind") console.log(res, Array.isArray(res.data), "findfind")
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
historySearch.push(event); historySearch.push(event);
this.setHistorySearch(historySearch);
this.setData({ this.setData({
searchList: res.data, searchList: res.data,
searchKeyword: event, searchKeyword: event,
searchFlag: true searchFlag: true
}) })
this.setHistorySearch(historySearch);
} }
}) })
}, },
@ -90,6 +90,7 @@ Page({
httpRequest(paramenter).then(res => { httpRequest(paramenter).then(res => {
console.log(res, Array.isArray(res.data), "findfind") console.log(res, Array.isArray(res.data), "findfind")
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
console.log(historySearch, 'historySearch')
historySearch.push(item); historySearch.push(item);
this.setHistorySearch(historySearch); this.setHistorySearch(historySearch);
this.setData({ this.setData({

View File

@ -1,4 +1,5 @@
import { imageBasUrl } from '../../utils/config' import { imageBasUrl } from '../../utils/config';
import { objectToQueryString } from '../../utils/utils'
const { httpRequest } = getApp(); const { httpRequest } = getApp();
// import { throttle } from 'lodash'; // import { throttle } from 'lodash';
// import { throttle } from '../../utils/throttle' // import { throttle } from '../../utils/throttle'
@ -28,7 +29,8 @@ Page({
batchAllOrder: 0, batchAllOrder: 0,
batchAllList: [], batchAllList: [],
isThrottle: null, isThrottle: null,
pageHideFlag: true pageHideFlag: true,
initParams: {}
}, },
// 获取其它信息 // 获取其它信息
isOtherFn() { isOtherFn() {
@ -118,24 +120,24 @@ Page({
}, },
// 获取 剧情 // 获取 剧情
async isVideoPaymentFn(sid, id, tid) { async isVideoPaymentFn(params) {
const body = {}; // const body = {};
if (sid) { // if (sid) {
body.sid = sid; // body.sid = sid;
} // }
if (sid) { // if (sid) {
body.id = id; // body.id = id;
} // }
if (sid) { // if (sid) {
body.tid = tid; // body.tid = tid;
} // }
const paramVideo = { const paramVideo = {
path: '/videoread', path: '/videoread',
method: 'POST', method: 'POST',
body: body body: params
} }
const videoRead = await httpRequest(paramVideo); const videoRead = await httpRequest(paramVideo);
@ -198,7 +200,7 @@ Page({
content: res.msg || '购买成功', content: res.msg || '购买成功',
duration: 1000, duration: 1000,
}) })
this.isVideoPaymentFn(sid); this.isVideoPaymentFn({ sid: sid, id: videoInfoObj.id, });
} }
}).catch(err => { }).catch(err => {
if (err.status == 2) { if (err.status == 2) {
@ -334,7 +336,8 @@ Page({
this.setData({ this.setData({
sid: sid, sid: sid,
id: id, id: id,
tid: tid tid: tid,
initParams: query
}) })
}, },
@ -342,8 +345,9 @@ Page({
const sid = this.data.sid; const sid = this.data.sid;
const id = this.data.id; const id = this.data.id;
const tid = this.data.tid; const tid = this.data.tid;
const initParams = this.data.initParams;
this.isOtherFn(); this.isOtherFn();
this.isVideoPaymentFn(sid, id, tid); this.isVideoPaymentFn(initParams);
// const lodash = require('lodash'); // const lodash = require('lodash');
const isThrottle = _.throttle((current) => { const isThrottle = _.throttle((current) => {
let id = ''; let id = '';

View File

@ -1,4 +1,5 @@
import { imageBasUrl } from '../../utils/config' import { imageBasUrl } from '../../utils/config';
import { objectToQueryString } from '../../utils/utils'
const { httpRequest } = getApp(); const { httpRequest } = getApp();
// import { throttle } from 'lodash'; // import { throttle } from 'lodash';
// import { throttle } from '../../utils/throttle' // import { throttle } from '../../utils/throttle'
@ -32,7 +33,8 @@ Page({
videoDuration: '0.00', videoDuration: '0.00',
currentTime: '0.00', currentTime: '0.00',
sliderMax: 100, sliderMax: 100,
sliderValue: 0 sliderValue: 0,
initParams: {}
}, },
// 获取其它信息 // 获取其它信息
isOtherFn() { isOtherFn() {
@ -122,13 +124,11 @@ Page({
}, },
// 获取 剧情 // 获取 剧情
async isVideoPaymentFn(sid) { async isVideoPaymentFn(isBody) {
const paramVideo = { const paramVideo = {
path: '/videoread', path: '/videoread',
method: 'POST', method: 'POST',
body: { body: isBody
sid: sid
}
} }
const videoRead = await httpRequest(paramVideo); const videoRead = await httpRequest(paramVideo);
@ -190,7 +190,7 @@ Page({
content: res.msg || '购买成功', content: res.msg || '购买成功',
duration: 1000, duration: 1000,
}) })
this.isVideoPaymentFn(sid); this.isVideoPaymentFn({ sid, id: videoInfoObj.id, });
} }
}).catch(err => { }).catch(err => {
if (err.status == 2) { if (err.status == 2) {
@ -450,14 +450,16 @@ Page({
onLoad(query) { onLoad(query) {
const sid = query.sid; const sid = query.sid;
this.setData({ this.setData({
sid: sid sid: sid,
initParams: query
}) })
}, },
onShow() { onShow() {
const sid = this.data.sid; const sid = this.data.sid;
const initParams = this.data.initParams;
this.isOtherFn(); this.isOtherFn();
this.isVideoPaymentFn(sid); this.isVideoPaymentFn(initParams);
// const lodash = require('lodash'); // const lodash = require('lodash');
const isThrottle = _.throttle((current) => { const isThrottle = _.throttle((current) => {
let id = ''; let id = '';

View File

@ -15,3 +15,16 @@ export const storageUid = (uid) => {
}, },
}); });
} }
export function objectToQueryString(obj) {
return Object.keys(obj).map(key => {
let value = obj[key];
// 处理数组情况
if (Array.isArray(value)) {
value = value.map(v => encodeURIComponent(v)).join(',');
} else {
value = encodeURIComponent(value);
}
return `${encodeURIComponent(key)}=${value}`;
}).join('&');
}