Merge branch 'test' of e.coding.net:g-cphe0354/duanju/new_app into gyq

This commit is contained in:
gyq 2025-01-13 15:52:11 +08:00
commit 4775d0d24d
7 changed files with 533 additions and 294 deletions

View File

@ -66,3 +66,47 @@ export function tuijianVideo(data){
}
})
}
//解锁10集视频
export function buyTenVideo(data){
return http.request({
url: 'order/insertCourseOrders/limit10',
method:'GET',
data:data
})
}
//解锁单集或者全部视频
export function buyVideo(data){
return http.request({
url: 'order/insertCourseOrders',
method:'GET',
data:data
})
}
//订单支付
export function payOrder(data){
let payType='h5'
// #ifdef APP
payType='app'
// #endif
return http.request({
url: 'wuyou/payOrder/'+data.orderId+'?payType='+payType,
method:'GET'
})
}
//获取订单支付状态
export function getOrderInfo(data){
return http.request({
url: 'wuyou/queryOrder/'+data.orderId,
method:'GET'
})
}
//金币解锁
export function goldPay(data){
return http.request({
url: 'order/payOrders',
method:'POST',
data:{...data,header:{
'content-type':'application/x-www-form-urlencoded'
}}
})
}

View File

@ -2,14 +2,14 @@
<view class="item" @appear="appear" @disappear="disappear" @click.stop>
<video class="u-flex-1 video" :show-fullscreen-btn="false" @controlstoggle="controlstoggles" v-if="showVideo"
@waiting="waiting()" object-fit="cover"
@pause="onpause"
@waiting="waiting()" object-fit="cover" @pause="onpause" @click="videoClick()"
@play="videoPlay('myVideo'+item.courseDetailsId,item.courseDetailsId)" :play-strategy="2"
:show-loading="true" codec="software" :muted="false" :show-center-play-btn="true" :loop="false"
:enable-progress-gesture="false" :poster="item.titleImg" :ref="'myVideo'+item.courseDetailsId"
:autoplay="autoplay" @ended="ended" :id="'myVideo'+item.courseDetailsId" :src="item.videoUrl"></video>
<image class="poster" v-else @click="!item.videoUrl?popupShow('pay'):''" :src="item.titleImg" mode="aspectFill">
<image class="poster" v-else @click="!item.videoUrl?popupShow('pay',item):''" :src="item.titleImg"
mode="aspectFill">
</image>
<view class="info" v-if="!isCommand" :style="infoStyle">
@ -43,8 +43,8 @@
<text class="text color-fff u-font-24">分享</text>
</view>
<view class="zhuiju u-m-b-40 u-flex u-flex-xy-center u-flex-col u-text-center" @click="zhuijuClick">
<image class="icon" v-if="isCollect" src="@/static/images/shuqian.png" mode=""></image>
<image class="icon" v-else src="@/static/images/shuqian_s.png" mode=""></image>
<image class="icon" v-if="isCollect" src="@/static/images/shuqian_s.png" mode=""></image>
<image class="icon" v-else src="@/static/images/shuqian.png" mode=""></image>
<text class="text color-fff u-font-24">{{isCollect?'已追':'追剧'}}</text>
</view>
</view>
@ -70,19 +70,19 @@
}
}
},
rightStyle:{
type:Object,
default:()=>{
rightStyle: {
type: Object,
default: () => {
return {
}
}
},
infoStyle:{
type:Object,
default:()=>{
infoStyle: {
type: Object,
default: () => {
return {
}
}
},
@ -124,7 +124,7 @@
type: Number,
default: 1
},
showControls:{
showControls: {
type: Boolean,
default: true
}
@ -132,11 +132,10 @@
let autoplay = ref(props.item.videoUrl ? true : false)
const emits = defineEmits(['controlstoggles', 'disappear', 'appear', 'waiting', 'videoPlay', 'ended', 'dianzanClick',
'share', 'zhuijuClick', 'popupShow', 'itemMounted', 'toDetail'
'share', 'zhuijuClick', 'popupShow', 'itemMounted', 'toDetail', 'showInfo'
])
function controlstoggles(e) {
console.log(e);
emits('controlstoggles', e)
}
@ -151,23 +150,38 @@
}
function videoPlay() {
// #ifdef H5
emits('controlstoggles', {
detail:{show:true}
})
// #endif
}
let isPlying = ref(false)
watch(() => isPlying.value, (newval) => {
console.log(newval);
emits('showInfo', newval)
})
function onpause(){
function videoPlay() {
isPlying.value = true
// #ifdef H5
emits('controlstoggles', {
detail:{show:false}
detail: {
show: true
}
})
// #endif
}
function onpause() {
isPlying.value = false
// #ifdef H5
emits('controlstoggles', {
detail: {
show: false
}
})
// #endif
}
function ended() {
}
@ -188,6 +202,17 @@
emits('popupShow', key)
}
function videoClick() {
console.log('videoClick');
if (video) {
if (isPlying.value) {
video.pause()
} else {
video.play()
}
}
}
let first = true
function appear() {
@ -227,6 +252,8 @@
if (props.item.videoUrl && showVideo.value) {
video = uni.createVideoContext('myVideo' + props.item.courseDetailsId)
video.playbackRate(props.playSpeeds)
video.play()
console.log('init play');
}
} catch (error) {
console.error('------')
@ -240,13 +267,28 @@
}
})
watch(() => showVideo.value, (newval) => {
console.log('showVideo change:'+newval);
if (newval) {
init()
nextTick(()=>{
init()
})
} else {
video = null
}
})
const infoStyle = computed(() => {
return {
transform: `translateX(${(!isPlying.value||!props.item.videoUrl)?0:'-110%'})`
}
})
const rightStyle = computed(() => {
return {
transform: `translateX(${(!isPlying.value||!props.item.videoUrl)?'0':60}px)`
}
})
</script>
<style lang="scss" scoped>
@ -330,7 +372,7 @@
}
.right {
transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
position: absolute !important;
right: 20rpx;
/* #ifdef H5 */

View File

@ -5,12 +5,11 @@
@change="swiperChange" :current="current" :circular="true" vertical class="u-flex-1"
@transition="transition" :indicator-dots="false" :autoplay="false" :interval="0" :duration="200">
<swiper-item v-for="(item,index) in videoList" :key="index">
<list-item-vue :total="list.length" :item="item" :isCommand="isCommand"
:rightStyle="rightStyle" :infoStyle="infoStyle"
:showControls="control.showControls" :current="current" :isCollect="isCollect"
@toDetail="toDetail(item,index)" @controlstoggles="controlstoggles" :playSpeeds="playSpeeds"
:index="index" :nowIndex="nowIndex" @dianzanClick="dianzanClick(item,index)" @share="share(item)"
@zhuijuClick="zhuijuClick(item)" @popupShow="popupShow"></list-item-vue>
<list-item-vue :total="list.length" :item="item" :isCommand="isCommand" :showControls="control.showControls" :current="current"
:isCollect="isCollect" @toDetail="toDetail(item,index)" @controlstoggles="controlstoggles"
:playSpeeds="playSpeeds" :index="index" :nowIndex="nowIndex"
@dianzanClick="dianzanClick(item,index)" @share="share(item)" @zhuijuClick="zhuijuClick(item)"
@popupShow="popupShow($event,item,index)"></list-item-vue>
</swiper-item>
</swiper>
</view>
@ -22,12 +21,12 @@
<cell v-for="(item,index) in list" :key="item.courseDetailsId" :ref="setRefList(index)">
<view class="swipers-items" :style="boxStyle" @longpress="popupShow('speed')">
<list-item-vue :total="list.length" :item="item" :current="current" :isCollect="isCollect"
:rightStyle="rightStyle" :infoStyle="infoStyle"
:isCommand="isCommand" :showControls="control.showControls" @toDetail="toDetail(item,index)"
@itemMounted="itemMounted" @controlstoggles="controlstoggles" :index="index" :instance="instance"
:nowIndex="nowIndex" @appear="appear($event,item,index)" :playSpeeds="playSpeeds"
@disappear="disappear(item,index)" @dianzanClick="dianzanClick(item,index)" @share="share(item)"
@zhuijuClick="zhuijuClick(item)" @popupShow="popupShow"></list-item-vue>
:isCommand="isCommand"
:showControls="control.showControls" @toDetail="toDetail(item,index)" @itemMounted="itemMounted"
@controlstoggles="controlstoggles" :index="index" :instance="instance" :nowIndex="nowIndex"
@appear="appear($event,item,index)" :playSpeeds="playSpeeds" @disappear="disappear(item,index)"
@dianzanClick="dianzanClick(item,index)" @share="share(item)" @zhuijuClick="zhuijuClick(item)"
@popupShow="popupShow($event,item,index)"></list-item-vue>
</view>
</cell>
</list>
@ -80,15 +79,19 @@
<text class=" color-999 u-font-24">每日前10次付款均可获取抽奖机会抽奖保底抽中付款金额等额红包红包可直接提现当前为第1次付款</text>
</view>
<view class="colo-333 pay-list font-bold u-font-28 u-m-t-20">
<view class="pay-list-item" v-if="info&&info.price" @click="payBtnClick">
<view class="pay-list-item" v-if="info&&info.price" @click="payBtnClick('money','all')">
<image class="hot" src="@/static/images/hot.png" mode=""></image>
<text class="u-font-28 font-bold">{{info.price}}元解锁全剧</text>
</view>
<view class="pay-list-item" @click="payBtnClick">
<view class="pay-list-item" v-if="info&&info.wholesalePrice" @click="payBtnClick('money',10)">
<image class="hot" src="@/static/images/hot.png" mode=""></image>
<text class="u-font-28 font-bold">{{info.price}}元解锁全剧</text>
</view>
<view class="pay-list-item" @click="payBtnClick('gold',1)">
<image class="hot" src="@/static/images/hot.png" mode=""></image>
<text class="u-font-28 font-bold">{{nowDanjiPrice*jinbiBili}}金币解锁单集视频</text>
</view>
<view class="pay-list-item" @click="payBtnClick">
<view class="pay-list-item" @click="payBtnClick('money',1)">
<!-- <image class="hot" src="@/static/images/hot.png" mode=""></image> -->
<text class="u-font-28 font-bold">{{nowDanjiPrice}}元解锁单集视频</text>
</view>
@ -121,7 +124,8 @@
</view>
<view class="u-flex u-flex-row u-m-t-30 u-flex-y-center u-font-28">
<view class="u-flex-y-center">
<up-checkbox usedAlone shape="circle" v-model="isAgree" :activeColor="color.main"></up-checkbox>
<up-checkbox usedAlone shape="circle" v-model:checked="isAgree"
:activeColor="color.main"></up-checkbox>
</view>
<view class="u-flex u-flex-row u-flex-y-center">
<text class="u-font-28 color-333">我已经阅读并同意</text>
@ -129,7 +133,7 @@
</view>
</view>
<view class="u-m-t-30 my-bg-main payConfirm">
<view class="u-m-t-30 my-bg-main payConfirm" @click="payConfirm">
<text class="u-font-28 color-fff">确认支付</text>
</view>
</view>
@ -209,7 +213,7 @@
showControls: true
})
// #ifdef APP
control.showControls=false
control.showControls = false
// #endif
const customStyle = computed(() => {
@ -225,9 +229,7 @@
function controlstoggles(e) {
control.showControls = e.detail.show
console.log(control.showControls );
control.showBack = control.showControls
console.log(control);
}
const speeds = reactive({
@ -287,7 +289,9 @@
show: false,
pay: false,
payTips: false,
speed: false
speed: false,
data: null,
payType: null
})
@ -313,21 +317,83 @@
console.log('disappear nowIndex' + nowIndex.value);
console.log('cacheIndex' + cacheIndex);
nowIndex.value = cacheIndex
const item=props.list[nowIndex.value]
if (!item.videoUrl) {
popupShow('pay', item, nowIndex.value)
}
cacheIndex = null
console.log('disappear,nowIndex=' + nowIndex.value);
}
}
//
async function payOrder(data) {
const res = await Api.payOrder(data)
if (res) {
// #ifdef APP
uni.navigateTo({
url: '/pages/pays/pays?orderId=' + data.orderId + '&url=' + res.h5Url
});
// #endif
// #ifdef H5
window.location.href = res.h5Url
// #endif
}
}
//
async function goldPay(data) {
console.log(popup.index);
const res = await Api.goldPay(data)
if (res) {
uni.showToast({
title: '解锁成功',
icon: 'none'
})
popupClose()
emits('update', {
index: popup.index
})
}
}
//
function payConfirm() {
async function payConfirm() {
if (!isAgree.value) {
return infoBox.showToast('请阅读并同意 《付费须知说明》')
}
const [type, num] = popup.payType.split('-');
console.log(type, num);
let data = {
courseId: popup.data.courseId
}
if (num == 1) {
data.courseDetailsId = popup.data.courseDetailsId
}
const res = num == '10' ? await Api.buyTenVideo(data) : await Api.buyVideo(data)
if (res) {
if (type == 'gold') {
goldPay({
orderId: res.orders.ordersId
})
} else {
payOrder({
orderId: res.orders.ordersId
})
}
} else {
}
}
function payBtnClick() {
popupClose()
function payBtnClick(type, num) {
console.log(type, num);
popup.payType = `${type}-${num}`
popupClose('show')
popupShow('payTips')
}
@ -354,10 +420,13 @@
};
}
//
let positonmer = null
function goListPosition(index) {
clearTimeout(positonmer)
console.log('goListPosition:' + index)
const el = refList.value[index]
if ($mountedComponents[props.list.length - 1]) {
if ($mountedComponents[props.list.length - 1] && $mountedComponents[index]) {
domModule.scrollToElement(el, {
animated: false
})
@ -366,9 +435,10 @@
setVideoList(item)
insertHistory()
} else {
setTimeout(() => {
//
positonmer = setTimeout(() => {
goListPosition(index)
}, 30)
}, 200)
}
}
@ -384,8 +454,13 @@
}
}
function popupShow(key = 'show') {
function popupShow(key = 'show', item, index) {
console.log(item);
popup[key] = true
if (item) {
popup.data = item
popup.index = index
}
}
@ -419,22 +494,6 @@
}
const posterData = reactive({
show: false,
//
name: '小明',
//
logo: '/static/images/share.png',
//
title: '精美时尚苹果手机一部',
//
money: '5200.90',
// ()
img: '',
//
url: 'https://www.apple.com.cn/iphone/'
})
let nowIndex = ref(0)
let current = ref(0)
let videoList = ref([])
@ -537,10 +596,6 @@
}
function posterHide() {
posterData.show = false
}
const insertHistory = debounce(() => {
@ -603,7 +658,7 @@
}
console.log(videoList.value);
if (!item.videoUrl) {
popupShow('pay')
popupShow('pay', item, index)
}
}
@ -633,30 +688,7 @@
const nowDanjiPrice = computed(() => {
return videoList.value[current.value].price
})
const rightStyle=computed(()=>{
// #ifdef H5
return {
transform: `translateX(${!control.showControls?'0':60}px)`
}
// #endif
// #ifdef APP
return {
transform: `translateX(${control.showControls?'0':60}px)`
}
// #endif
})
const infoStyle=computed(()=>{
// #ifdef H5
return {
transform: `translateX(${!control.showControls?0:'-110%'})`
}
// #endif
// #ifdef APP
return {
transform: `translateX(${control.showControls?0:'-110%'})`
}
// #endif
})
function loadmore() {
console.log('loadmore');
}
@ -666,6 +698,16 @@
'width': '750rpx',
}
})
function videoListUpdata(){
videoList.value=videoList.value.map(v=>{
const item=props.list.find(listItem=>listItem.courseDetailsId==v.courseDetailsId)
return item?item:v
})
}
defineExpose({
videoListUpdata
})
</script>
<style lang="scss" scoped>

View File

@ -1,152 +1,161 @@
// 导入全局属性
import { sm4DecryptByResData } from "@/utils/encryptUtil.js";
import {
sm4DecryptByResData
} from "@/utils/encryptUtil.js";
import infoBox from "@/utils/infoBox.js";
import { reject } from "lodash";
import {
reject
} from "lodash";
import config from "@/commons/config.js";
// 测试服
let baseUrl = config.baseApiUrl + "app";
const loadingShowTime = 200;
function getHeader() {
const headerObject = {};
headerObject["token"] = uni.getStorageSync("token");
return headerObject;
function getHeader(data) {
const header = data ? data.header : {}
const headerObject = {
...header
};
headerObject["token"] = uni.getStorageSync("token");
return headerObject;
}
// 通用处理逻辑
function commonsProcess(showLoading, httpReqCallback,isreturm) {
// 判断是否请求完成(用作 是否loading
// 包括: 'ing', 'ingLoading', 'finish'
let reqState = "ing";
// 是否已经提示的错误信息
let isShowErrorToast = false;
// 请求完成, 需要处理的动作
let reqFinishFunc = () => {
if (reqState == "ingLoading") {
// 关闭loading弹层
infoBox.hideLoading();
}
reqState = "finish"; // 请求完毕
};
// 明确显示loading
if (showLoading) {
// xx ms内响应完成不提示loading
setTimeout(() => {
if (reqState == "ing") {
reqState = "ingLoading";
infoBox.showLoading();
}
}, loadingShowTime);
}
function commonsProcess(showLoading, httpReqCallback, isreturm) {
// 判断是否请求完成(用作 是否loading
// 包括: 'ing', 'ingLoading', 'finish'
let reqState = "ing";
// 是否已经提示的错误信息
let isShowErrorToast = false;
// 请求完成, 需要处理的动作
let reqFinishFunc = () => {
if (reqState == "ingLoading") {
// 关闭loading弹层
infoBox.hideLoading();
}
reqState = "finish"; // 请求完毕
};
// 明确显示loading
if (showLoading) {
// xx ms内响应完成不提示loading
setTimeout(() => {
if (reqState == "ing") {
reqState = "ingLoading";
infoBox.showLoading();
}
}, loadingShowTime);
}
return httpReqCallback()
.then((httpData) => {
console.log(1)
reqFinishFunc(); // 请求完毕的动作
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
let { statusCode, data } = httpData;
// 避免混淆重新命名
let bodyData = data;
if(isreturm){
return Promise.resolve(bodyData.data || bodyData.page|| bodyData);
}
if (statusCode == 500) {
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
return httpReqCallback()
.then((httpData) => {
if (statusCode == 401) {
// 提示信息
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
// http响应码不正确
if (statusCode != 200 && statusCode != 204 && statusCode != 201) {
isShowErrorToast = true;
data.message =
data.message == "Bad credentials" ? "用户名或密码错误" : data.message;
infoBox.showToast(data.message || "服务器异常");
return Promise.reject(bodyData); // 跳转到catch函数
}
if (bodyData.code == 401) {
// 提示信息
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
if (bodyData.code == 500) {
// 提示信息
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
if (bodyData.code != 0) {
infoBox.showToast(data.message);
return;
}
reqFinishFunc(); // 请求完毕的动作
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
let {
statusCode,
data
} = httpData;
// 避免混淆重新命名
let bodyData = data;
if (isreturm) {
return Promise.resolve(bodyData.data || bodyData.page || bodyData);
}
if (statusCode == 500) {
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
// 加密数据
if (!bodyData.data && bodyData.encryptData) {
return Promise.resolve({
bizData: sm4DecryptByResData(bodyData.encryptData),
code: bodyData.code,
});
}
// 构造请求成功的响应数据
return Promise.resolve(bodyData.data || bodyData.page|| bodyData);
})
.catch((res) => {
console.log(2)
if (res.status == 404) {
infoBox.showToast("接口404").then(() => {});
reject();
return;
}
if (statusCode == 401) {
// 提示信息
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
// http响应码不正确
if (statusCode != 200 && statusCode != 204 && statusCode != 201) {
isShowErrorToast = true;
data.message =
data.message == "Bad credentials" ? "用户名或密码错误" : data.message;
infoBox.showToast(data.message || "服务器异常");
return Promise.reject(bodyData); // 跳转到catch函数
}
if (bodyData.code == 401) {
// 提示信息
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
if (bodyData.code == 500) {
// 提示信息
isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数
}
if (bodyData.code != 0) {
infoBox.showToast(data.message);
return;
}
if (res.code == 401) {
infoBox.showToast(res.message || "请登录").then(() => {
uni.redirectTo({
url: "/pages/login/login",
});
reject();
});
}
if (res.code != 0) {
infoBox.showToast(res.msg).then(() => {});
reject();
}
if (res.code == 500) {
infoBox.showToast(res.msg || "服务器异常").then(() => {});
reject();
}
reqFinishFunc(); // 请求完毕的动作
// 加密数据
if (!bodyData.data && bodyData.encryptData) {
return Promise.resolve({
bizData: sm4DecryptByResData(bodyData.encryptData),
code: bodyData.code,
});
}
// 如果没有提示错误, 那么此处提示 异常。
if (!isShowErrorToast) {
infoBox.showToast(`请求网络异常`);
}
// 构造请求成功的响应数据
return Promise.resolve(bodyData.data || bodyData.page || bodyData);
})
.catch((res) => {
return Promise.reject(res);
})
.finally(() => {
// finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
});
if (res.status == 404) {
infoBox.showErrorToast("接口404").then(() => {});
reject();
return;
}
if (res.code == 401) {
infoBox.showErrorToast(res.message || "请登录").then(() => {
uni.redirectTo({
url: "/pages/login/login",
});
reject();
});
}
if (res.code != 0) {
infoBox.showErrorToast(res.msg).then(() => {});
reject();
}
if (res.code == 500) {
infoBox.showErrorToast(res.msg || "服务器异常").then(() => {});
reject();
}
reqFinishFunc(); // 请求完毕的动作
// 如果没有提示错误, 那么此处提示 异常。
if (!isShowErrorToast) {
infoBox.showErrorToast(`请求网络异常`);
}
return Promise.reject(res);
})
.finally(() => {
// finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
});
}
// 默认 显示loading(控制 xxs 内 不提示loading )
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
return commonsProcess(showLoading, () => {
return uni.request(
Object.assign(
{
url: baseUrl + uri,
data: data,
method: method,
header: getHeader(),
},
extParams
)
);
});
return commonsProcess(showLoading, () => {
return uni.request(
Object.assign({
url: baseUrl + uri,
data: data,
method: method,
header: getHeader(data),
},
extParams
)
);
});
}
// 默认 显示loading(控制 xxs 内 不提示loading )
@ -158,16 +167,17 @@ function request(args) {
method = "GET",
showLoading = true,
extParams = {},
isreturm=false
isreturm = false
} = args
if (params) {
let result = ''
Object.keys(params).forEach((key) => {
if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON.stringify(params[key]), '{}')) {
result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + "&"
}
if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON
.stringify(params[key]), '{}')) {
result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + "&"
}
})
url = url+'?'+(result.slice(0,result.length-1))
url = url + '?' + (result.slice(0, result.length - 1))
params = null
}
let headerObject = {}
@ -177,60 +187,59 @@ function request(args) {
url: slash(baseUrl, url),
data: params || data,
method: method,
header: getHeader()
header: getHeader(data)
}, extParams)
)
},isreturm)
}, isreturm)
}
// 处理/
function slash(baseUrl, url) {
let u = "";
if (baseUrl[baseUrl.length - 1] == "/") {
u += baseUrl;
} else {
u = u + baseUrl + "/";
}
if (url[0] == "/") {
u = u + url.slice(1);
} else {
u = u + url;
}
return u;
let u = "";
if (baseUrl[baseUrl.length - 1] == "/") {
u += baseUrl;
} else {
u = u + baseUrl + "/";
}
if (url[0] == "/") {
u = u + url.slice(1);
} else {
u = u + url;
}
return u;
}
// 上传
function upload(uri, data, file, showLoading = true, extParams = {}) {
// 放置token
let headerObject = {};
return commonsProcess(showLoading, () => {
return uni
.uploadFile(
Object.assign(
{
url: baseUrl + uri,
formData: data,
name: "file",
filePath: file.path || file.url,
header: getHeader(),
},
extParams
)
)
.then((httpData) => {
// uni.upload 返回bodyData 的是 string类型。 需要解析。
httpData.data = JSON.parse(httpData.data);
return Promise.resolve(httpData);
})
.catch((err) => {
uni.hideLoading();
infoBox.showToast(`上传失败`);
});
});
// 放置token
let headerObject = {};
return commonsProcess(showLoading, () => {
return uni
.uploadFile(
Object.assign({
url: baseUrl + uri,
formData: data,
name: "file",
filePath: file.path || file.url,
header: getHeader(data),
},
extParams
)
)
.then((httpData) => {
// uni.upload 返回bodyData 的是 string类型。 需要解析。
httpData.data = JSON.parse(httpData.data);
return Promise.resolve(httpData);
})
.catch((err) => {
uni.hideLoading();
infoBox.showErrorToast(`上传失败`);
});
});
}
export default {
req: req,
request,
upload: upload,
};
req: req,
request,
upload: upload,
};

View File

@ -192,6 +192,13 @@
{
"navigationBarTitleText" : "抽奖"
}
},
{
"path" : "pages/pays/pays",
"style" :
{
"navigationBarTitleText" : ""
}
}
],
"globalStyle": {

87
pages/pays/pays.vue Normal file
View File

@ -0,0 +1,87 @@
<template>
<view style="width: 100%;">
<web-view id="webview" :src="state.url" style="width: 100%;"></web-view>
</view>
</template>
<script setup>
import {
reactive
} from 'vue'
import {
onShow,onHide,onUnload,onLoad
} from '@dcloudio/uni-app'
import {
getOrderInfo
} from '@/api/video/index.js'
const state = reactive({
orderId: '',
timer: null,
maxAjaxNum: 5,
ajaxNum: 0,
url: null, //
viewerUrl: '/hybrid/html/web/viewer.html',
webviewStyles: {
width: '750px',
height: '100%',
}
})
function getOrder() {
getOrderInfo({
orderId: state.orderId
}).then(res => {
console.log(res);
if (res.data == 1) {
uni.hideLoading()
const sysInfo = uni.getSystemInfoSync();
let isIos = sysInfo.platform == 'ios'
if (isIos) {
uni.navigateBack()
uni.showToast({
title: '支付成功',
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
uni.showToast({
title: '支付成功',
icon: 'none'
})
state.timer = setTimeout(() => {
clearTimeout(state.timer)
uni.navigateBack()
}, 500)
}
} else {
// #ifdef APP
uni.showLoading({
title: '支付中'
})
// #endif
}
});
}
onShow(() => {
getOrder()
})
onHide(() => {
uni.hideLoading()
})
onUnload(() => {
uni.hideLoading()
})
onLoad((option) => {
console.log(option);
state.url = option.url
state.orderId = option.orderId
})
</script>
<style lang="scss">
.webview {
width: 100%;
height: 100%;
}
</style>

View File

@ -1,8 +1,7 @@
<template>
<view class="min-page">
<my-video-list v-if="state.list.length" @swiperChange="swiperChange" :list="state.list" @update="update"
:info="state"
></my-video-list>
<my-video-list ref="refVideoList" v-if="state.list.length" @swiperChange="swiperChange" :list="state.list" @update="update"
:info="state"></my-video-list>
</view>
</template>
@ -13,13 +12,13 @@
} from '@dcloudio/uni-app'
import * as Api from '@/api/video/index.js'
import {
reactive
reactive, ref
} from 'vue'
import {
slice
} from 'lodash'
const boxStyle={
height:'835px'
const boxStyle = {
height: '835px'
}
let options = {}
const state = reactive({
@ -29,6 +28,7 @@
price: 0,
title: ''
})
const refVideoList=ref(null)
async function init() {
try {
const res = await Api.getVideoDetail(options)
@ -44,23 +44,31 @@
// }
}
}
function update({index,item}){
state.list[index]=item
async function update({
index,
item
}) {
if(item){
state.list[index] = item
}else{
await init()
refVideoList.value.videoListUpdata()
}
}
onLoad((opt) => {
Object.assign(options, opt)
init()
})
function swiperChange({
current,
direction,
data
}) {
}
}) {}
onShow(() => {
init()
})
</script>
@ -71,8 +79,8 @@
background-color: #000;
overflow: hidden;
}
.u-popup{
.u-popup {
position: fixed;
}
</style>