增加支付

This commit is contained in:
2025-01-13 13:57:50 +08:00
parent 36028936c7
commit 8728844446
6 changed files with 421 additions and 223 deletions

View File

@@ -5,12 +5,12 @@
@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($event,item,index)"></list-item-vue>
<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($event,item,index)"></list-item-vue>
</swiper-item>
</swiper>
</view>
@@ -22,12 +22,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($event,item,index)"></list-item-vue>
: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($event,item,index)"></list-item-vue>
</view>
</cell>
</list>
@@ -125,7 +125,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:checked="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>
@@ -213,7 +214,7 @@
showControls: true
})
// #ifdef APP
control.showControls=false
control.showControls = false
// #endif
const customStyle = computed(() => {
@@ -229,7 +230,7 @@
function controlstoggles(e) {
control.showControls = e.detail.show
console.log(control.showControls );
console.log(control.showControls);
control.showBack = control.showControls
console.log(control);
}
@@ -292,8 +293,8 @@
pay: false,
payTips: false,
speed: false,
data:null,
payType:null
data: null,
payType: null
})
@@ -325,25 +326,68 @@
}
//非金币支付
async function payOrder(data) {
const res = await Api.payOrder(data)
console.log(res);
if (res) {
uni.navigateTo({
url: '/pages/pays/pays?orderId=' + data.orderId + '&url=' + res.h5Url
});
return
// #ifdef APP
uni.navigateTo({
url: '/pages/pays/pays?orderId=' + res.orderId + '&url=' + res.h5Url
});
// #endif
// #ifdef H5
window.location.href = res.h5Url
// #endif
}
}
//金币支付
async function goldPay(data) {
const res = await Api.goldPay(data)
console.log(res);
}
//确认支付
function payConfirm() {
console.log(isAgree.value);
async function payConfirm() {
if (!isAgree.value) {
return infoBox.showToast('请阅读并同意 《付费须知说明》')
}
const [type, num] = popup.payType.split('-');
console.log(type, num);
let data = {
courseId: this.courseId
courseId: popup.data.courseId
}
if(popup.payType=='all'){
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(type,num) {
popup.payType=`${type}-${num}`
popupClose()
function payBtnClick(type, num) {
console.log(type, num);
popup.payType = `${type}-${num}`
popupClose('show')
popupShow('payTips')
}
@@ -370,7 +414,10 @@
};
}
//滚动到指定位置
let positonmer = null
function goListPosition(index) {
clearTimeout(positonmer)
console.log('goListPosition:' + index)
const el = refList.value[index]
if ($mountedComponents[props.list.length - 1]) {
@@ -382,7 +429,7 @@
setVideoList(item)
insertHistory()
} else {
setTimeout(() => {
positonmer = setTimeout(() => {
goListPosition(index)
}, 30)
}
@@ -400,11 +447,13 @@
}
}
function popupShow(key = 'show',item,index) {
function popupShow(key = 'show', item, index) {
console.log(item);
popup[key] = true
popup['data'] = item
popup['index'] = index
if (item) {
popup['data'] = item
popup['index'] = index
}
}
@@ -602,7 +651,7 @@
}
console.log(videoList.value);
if (!item.videoUrl) {
popupShow('pay',item,index)
popupShow('pay', item, index)
}
}
@@ -632,7 +681,7 @@
const nowDanjiPrice = computed(() => {
return videoList.value[current.value].price
})
const rightStyle=computed(()=>{
const rightStyle = computed(() => {
// #ifdef H5
return {
transform: `translateX(${!control.showControls?'0':60}px)`
@@ -644,7 +693,7 @@
}
// #endif
})
const infoStyle=computed(()=>{
const infoStyle = computed(() => {
// #ifdef H5
return {
transform: `translateX(${!control.showControls?0:'-110%'})`
@@ -656,6 +705,7 @@
}
// #endif
})
function loadmore() {
console.log('loadmore');
}