iOS 跳转页面配置

适配 iOS 的视频播放大小
This commit is contained in:
GYJ 2024-12-19 11:39:43 +08:00
parent 66e9d9a460
commit 444b897528
4 changed files with 141 additions and 53 deletions

31
main.js
View File

@ -21,7 +21,7 @@ Vue.use(uView);
const app = new Vue({
...App
...App
})
// http拦截器将此部分放在new Vue()和app.$mount()之间才能App.vue中正常使用
@ -33,3 +33,32 @@ import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
app.$mount()
console.log(uni);
// #ifdef APP
const sysInfo = uni.getSystemInfoSync();
let isIos = sysInfo.platform == 'ios'
if (isIos) {
const originNavigateTo = uni.navigateTo
uni.navigateTo = (params) => {
console.log("自定义 navigate 。。。。。。。。。。");
let jsonParam = JSON.parse(JSON.stringify(params))
if (isIos && jsonParam.url.includes('/me/detail/detail')) {
console.log('iOS 跳转视频也');
jsonParam.url = jsonParam.url.replace('/me/detail/detail', '/me/detail/detailIOS')
}
originNavigateTo(jsonParam)
}
}
// #endif

View File

@ -402,6 +402,7 @@
}
},
onShow() {
console.log('ios video on nvue');
console.log('onSHow video');
//当应用从后台进入前台时自动播放
if (this.videoContext) {

View File

@ -1,5 +1,5 @@
<template>
<view class="detail">
<view class="detail" :style="{paddingBottom:paddingBottom}">
<swiper @longpress="openBs()" :circular="true" class="swipers" @change="change" :current="current"
:vertical="true" :indicator-dots="false" :autoplay="false" :interval="3000" :duration="300">
<swiper-item class="swipers-item" v-for="(item,index) in swiperList" :key="item.courseDetailsId">
@ -8,8 +8,7 @@
<video :show-fullscreen-btn="false" @controlstoggle="controlstoggles" object-fit="contain"
v-if="current === index && item.videoUrl" :play-strategy="2" :show-loading="true"
codec="software" :muted="false" :show-center-play-btn="true" :loop="true" @ended="ended"
@timeupdate="timeupdate"
@play="videoPlay('myVideo'+item.courseDetailsId, item.courseDetailsId)"
@timeupdate="timeupdate" @play="videoPlay('myVideo'+item.courseDetailsId, item.courseDetailsId)"
:enable-progress-gesture="false" :poster="item.titleImg" :ref="'myVideo'+item.courseDetailsId"
:id="'myVideo'+item.courseDetailsId" :src="item.videoUrl" :autoplay="item.autoPlay"
class="swipers-items-video"></video>
@ -17,7 +16,8 @@
mode="aspectFill">
</image>
<!-- 返回图标 -->
<image v-if="showBack" src="../static/nvueIcon/backs.png" @click="goBack()" class="swipers-items-back" mode="">
<image v-if="showBack" src="../static/nvueIcon/backs.png" @click="goBack()"
class="swipers-items-back" mode="">
</image>
<!-- 右边操作 -->
<view class="swipers-items-right" :style="rightTop" v-if="showControls">
@ -143,7 +143,8 @@
<image class="list-title-rs" src="../../static/images/me/closeIconss.png" mode=""></image>
</view>
</view>
<text class="" style="font-size: 24rpx;color: #999;padding: 0 34rpx;margin: 20rpx 0; auto;text-align: left;width: 100%;">
<text class=""
style="font-size: 24rpx;color: #999;padding: 0 34rpx;margin: 20rpx 0; auto;text-align: left;width: 100%;">
{{this.courseDetailsId}}
</text>
<view class="pay-content">
@ -303,7 +304,7 @@
export default {
data() {
return {
showBack:false,
showBack: true,
nowBs: 1, //当前倍速
subList: [{
name: '0.5x',
@ -353,7 +354,7 @@
zongPrice: 0, //整部价格
countPrice: 0, //单集价格
wallCurr: 0,
wallet: [],·
wallet: [],
productId: '', //默认苹果内购商品ID
productIds: ['sixzuan', 'shierzuan'], //苹果内购商品
openLists: [],
@ -365,9 +366,9 @@
iosPayId: '',
isCollect: false,
playFlag: false,
getRedEnvelopeTips: ''
getRedEnvelopeTips: '',
scale: 1,
paddingBottom: '0',
};
},
computed: {
@ -388,6 +389,7 @@
}
},
onShow() {
console.log("走了iOS播放器。。。。。。。。。。。。。。。");
//当应用从后台进入前台时自动播放
if (this.videoContext) {
this.videoContext.play()
@ -438,46 +440,58 @@
// }];
// this.openWay = 3;
// } else {
this.openLists = [
// {
// image: '/static/images/pay/weixin.png',
// text: '微信',
// id: 2
// },
{
image: '/static/images/pay/zhifubao.png',
text: '支付宝',
id: 1
},
];
this.openWay = 1;
let syPaySel = uni.getStorageSync('syPaySel')
// if (syPaySel === '是') {
// let openListsItem = {
// image: '/static/images/pay/shouyi.png',
// text: '收益余额',
// id: 4
// };
// this.openLists.push(openListsItem)
// }
this.openLists = [
// {
// image: '/static/images/pay/weixin.png',
// text: '微信',
// id: 2
// },
{
image: '/static/images/pay/zhifubao.png',
text: '支付宝',
id: 1
},
];
this.openWay = 1;
let syPaySel = uni.getStorageSync('syPaySel')
// if (syPaySel === '是') {
// let openListsItem = {
// image: '/static/images/pay/shouyi.png',
// text: '收益余额',
// id: 4
// };
// this.openLists.push(openListsItem)
// }
// }
}
// #endif
this.$nextTick(()=>{
this.$nextTick(() => {
this.closePopusPay()
})
if(this.courseId){
if (this.courseId) {
this.getDataList(this.courseId, this.courseDetailsId);
}
httpsRequest.getT('app/course/getRedEnvelopeTips').then(res => {
if (res.code == 0) {
this.getRedEnvelopeTips= res.data
this.getRedEnvelopeTips = res.data
}
})
this.getScale()
const sysInfo = uni.getSystemInfoSync()
console.log(sysInfo);
const padB = sysInfo.safeAreaInsets.bottom;
console.log('win height == ' + padB);
if (padB && padB > 0) {
this.paddingBottom = padB + 'px'
} else {
this.paddingBottom = '0'
}
console.log('this bottom padding = ' + this.paddingBottom);
},
onLoad(e) {
let that = this
@ -511,17 +525,17 @@
/**
* 获取金币比例
*/
getScale () {
getScale() {
httpsRequest.getT("app/common/type/914", {}).then(res => {
if (res.code == 0) {
this.scale = Number(res.data.value)
}
}
});
},
//播放时的回掉
videoPlay(videoId,courseDetailsId) {
videoPlay(videoId, courseDetailsId) {
this.courseDetailsId = courseDetailsId
if ( !this.playFlag ) {
if (!this.playFlag) {
this.playFlag = true
httpsRequest.getT('app/course/viewCourse', {
courseId: this.courseId,
@ -531,13 +545,13 @@
console.log('播放开始')
})
}
},
//播放进度变化回掉
timeupdate(e) {
if (e.detail.currentTime > e.detail.duration*0.9) {
if ( this.playFlag) {
if (e.detail.currentTime > e.detail.duration * 0.9) {
if (this.playFlag) {
this.playFlag = false
httpsRequest.getT('app/course/viewCourse', {
courseId: this.courseId,
@ -548,7 +562,7 @@
})
}
}
},
//选集弹窗的回调
changeXj(e) {
@ -691,12 +705,12 @@
this.isCheckPay(ret.code, 'wxpay', JSON.stringify(ret.data));
});
} else if (this.openWay == 1) {
let paytype='h5'
let paytype = 'h5'
// #ifdef APP
paytype='app'
paytype = 'app'
// #endif
// APP支付宝支付
httpsRequest.getT("/app/wuyou/payOrder/"+ this.ordersId+'?payType='+paytype, {}).then(ret => {
httpsRequest.getT("/app/wuyou/payOrder/" + this.ordersId + '?payType=' + paytype, {}).then(ret => {
plus.runtime.openURL(ret.data.h5Url)
// this.isCheckPay(ret.code, 'wxpay', JSON.stringify(ret.data));
});
@ -855,7 +869,7 @@
//显示/隐藏适配控制器的回调
controlstoggles(e) {
this.showControls = e.detail.show
this.showBack=!this.showBack
this.showBack = this.showControls
console.log(e.detail.show, '显示/隐藏控制栏')
},
//打开倍速弹框
@ -934,22 +948,22 @@
let data = {
courseId: this.courseId
}
data.courseDetailsId = this.videoList[this.current].courseDetailsId
httpsRequest.getT('/app/order/insertCourseOrders', data).then(res => {
if (res.code == 0) {
this.ordersId = res.data.orders.ordersId //记录订单id
this.payMoney = res.data.orders.payMoney //记录订单价格
if (type == 1) { //金币
this.payOrder(res.data.orders.ordersId, res.data.orders.payMoney)
} else if(type == 2){ //支付宝
} else if (type == 2) { //支付宝
this.closePay() //关闭购买选择弹窗
this.payPrice = res.data.orders.payMoney //需要支付的价格
this.openPopusPay() //显示充值弹窗
}
// this.payOrder(res.data.orders.ordersId, res.data.orders.payMoney)
} else {
uni.showToast({

View File

@ -490,6 +490,50 @@
}
}, {
"path": "detail/detailIOS",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#000000",
"style": {
"safeAreaInsetBottom": "none"
},
"app-plus": {
// "subNVues": [{
// "id": "pay", //
// "path": "detail/subNvue/pay", //
// // "type": "popup",
// "style": {
// "position": "popup",
// "dock": "bottom",
// "width": "750rpx",
// "height": "150rpx",
// "background": "#fff"
// }
// }],
"bounce": "none",
"safearea": {
"bottom": {
"offset": "none"
}
}
}
// #ifndef MP-TOUTIAO
,
"navigationStyle": "custom"
// #endif
// #ifdef MP-TOUTIAO
,
"usingComponents": {
"video-player": "ext://industry/video-player"
}
// #endif
}
}, {
"path": "wallet/wallet",
"style": {