This commit is contained in:
liuyuan
2025-10-15 16:31:26 +08:00
parent 3f5804d2b8
commit 1aebb888d6
2 changed files with 140 additions and 33 deletions

View File

@@ -16,7 +16,7 @@
<slot name="otherContent" :showTabs="showTabs"></slot>
<view class="section_box" v-if="allDataList&&allDataList.length>0">
<view class="section" v-for="(v, i) in allDataList"
<view class="section" v-for="(v, i) in allDataList"
:style="`${i == 0 ? `padding-top:${Number(baseHeight)}px;` : ''}`">
<view class="section">
<view :id="v[titleKey]" style="padding: 20rpx"
@@ -25,7 +25,8 @@
</view>
<view class="content section_content_progress">
<view class="content_list">
<slot :name="slotName ? slotName + '_' + v.slotName : 'contentList'" :showTabs="showTabs"
<slot :name="slotName ? slotName + '_' + v.slotName : 'contentList'" :showTabs="showTabs"
:dataList="v[dataListKey]" :data="v" :index="i"></slot>
</view>
</view>
@@ -49,6 +50,8 @@
"allTabList",
"slotName",
"defaultShowTabs",
"data",
],
data() {
return {
@@ -107,6 +110,7 @@
async onShow() {},
methods: {
pageScroll(event) {
// console.log("event at line 213:", event);
// const _this = this;
if (this.isTabChange) {
@@ -152,6 +156,7 @@
// 获取所有元素在当前页面所处的位置信息
getDistanceArr() {
this.distanceArr = [];
if (this.allTabList && this.allTabList.length > 0) {
this.tabList = [...this.allTabList];

View File

@@ -1,7 +1,7 @@
<template>
<view class="commonPageBox commonDetailPage">
<z-nav-bar title="课程详情"></z-nav-bar>
<common-anchor-link style="width: 100%" baseHeight="200" ref="commonAnchorLink" :allDataList="allDataList"
<common-anchor-link style="width: 100%" baseHeight="200" ref="commonAnchorLink" :allDataList="allDataList" v-if="allDataList.length>0"
titleKey="title" dataListKey="courseList" :titleStyle="{}" :tabStyle="{ background: '#fff' }">
<template slot="otherContent" slot-scope="slotProps">
<view v-if="goBuyTitle" class="describe_block">
@@ -66,15 +66,7 @@
<view class="not_purchased"
v-if="curriculumData.adminControl == 1 && slotProps.data.isBuy != 1">
<!-- <view class="spot"></view>
<view>
<text v-if="userVip==null&&slotProps.data.isBuy!=1">未购买</text>
<view v-if="userVip==null&&slotProps.data.isBuy==1">
<text v-if="slotProps.data.endTime" style=" width: 280rpx; margin: 0;">课程有效期截止到<br/>{{slotProps.data.endTime}} </text>
<text v-else>已购买</text>
</view>
<text v-if="userVip!=null">有效期至{{ userVip.endTime }}</text>
</view> -->
</view>
<view class="not_purchased"
v-else-if="curriculumData.adminControl == 1 && slotProps.data.isBuy == 1">
@@ -93,10 +85,10 @@
<text v-if="userVip!=null">有效期至{{ userVip.endTime }}</text>
</view> -->
</view>
<view class="not_purchased" v-else-if="slotProps.data.type != 0 && !showNewPayBtn[0].status">
<view class="not_purchased" v-if="curriculumData.adminControl == 0&&slotProps.data.type != 0 && !showNewPayBtn[slotProps.dataIndex].status">
<view class="spot"></view>
<view>
<text v-if="userVip == null && slotProps.data.isBuy != 1">未购买</text>
<view v-if="userVip == null && slotProps.data.isBuy != 1">未购买</view>
<view v-if="userVip == null && slotProps.data.isBuy == 1">
<text v-if="slotProps.data.endTime"
style=" width: 280rpx; margin: 0;">课程有效期截止到<br />{{ slotProps.data.endTime ?
@@ -105,7 +97,7 @@
<text v-else>已购买</text>
</view>
<text v-if="userVip != null">有效期至{{ userVip.endTime ? userVip.endTime.split(' ')[0] : '' }}</text>
</view>
</view>
<view class="right" v-if="curriculumData.adminControl == 1 && slotProps.data.isBuy != 1">
<!-- //是否咨询 -->
@@ -120,8 +112,42 @@
</view>
<view class="right" v-else>
<!-- //是否咨询 -->
<view class="right" v-if="curriculumData.adminControl == 0&&canGetCourse(slotProps)">
<text
style="color: #fff; font-size: 12px"
class="fdButtonBox aui-text-success"
@click="handleClickGetGoodsList(slotProps.data)">
领取课程
</text>
</view>
<view class="right" v-if="curriculumData.adminControl == 0&&canRepeatCourse(slotProps)">
<text
style=" background: #f42c32; border: 0; padding: 15rpx 30rpx; color: #fff; font-size: 12px"
class="fdButtonBox aui-text-success"
@click="goNewPay(slotProps.data)">
复读
</text>
</view>
<view class="right" v-if="curriculumData.adminControl == 0&&canAddToCart(slotProps)">
<u-icon
@click="handleClickGetGoodsList(slotProps.data)"
class="editIcon"
name="shopping-cart-fill"
color="#FF2B57"
size="28">
</u-icon>
</view>
<!-- 根据计算属性显示按钮 -->
<!-- <view class="right" v-else>
<text v-if="slotProps.data.type == 0 && userVip == null && slotProps.data.isBuy != 1"
@@ -135,7 +161,7 @@
<u-icon v-else-if="userVip == null && slotProps.data.type != 0 && slotProps.data.isBuy != 1"
@click="handleClickGetGoodsList(slotProps.data)" class="editIcon"
name="shopping-cart-fill" color="#FF2B57" size="28"></u-icon>
</view>
</view> -->
</view>
</view>
</view>
@@ -470,6 +496,8 @@ export default {
},
computed: {
...mapState(["userInfo"]),
},
onShow() {
this.protocolShow = false;
@@ -479,6 +507,39 @@ export default {
});
},
methods: {
canGetCourse(slotProps) {
return slotProps.data.type == 0 && this.userVip == null && slotProps.data.isBuy != 1;
},
canRepeatCourse(slotProps) {
if(slotProps.data.type == 0 && this.userVip == null && slotProps.data.isBuy != 1){
return false
}else{
var dataIndex=slotProps.dataIndex
var that=this
console.log(this.showNewPayBtn,dataIndex)
return that.showNewPayBtn[dataIndex] && that.showNewPayBtn[dataIndex].status;
}
},
canAddToCart(slotProps) {
if(slotProps.data.type == 0 && this.userVip == null && slotProps.data.isBuy != 1){
return false
}else if(this.showNewPayBtn[slotProps.dataIndex].status){
return false;
}else{
return this.userVip == null && slotProps.data.type != 0 && slotProps.data.isBuy != 1;
}
},
// 放大图片
previewImage(url) {
console.log(url);
@@ -708,7 +769,8 @@ export default {
}
},
//点击复读
async goNewPay(item) {
async goNewPay(item,slotProps) {
await this.getNewPaymentList(item.id)
if (this.newPaymentProList.length > 0) {
this.goodsList = this.newPaymentProList;
@@ -843,6 +905,7 @@ export default {
method: "POST",
data: {
id: that.options.id,
// id: 133,
},
header: {
"Content-Type": "application/json",
@@ -852,21 +915,49 @@ export default {
that.curriculumData = res.data.course;
that.cateList = [...res.data.catalogues];
for (let i = 0; i < that.cateList.length; i++) {
that.showNewPayBtn[i] = { status: false };
var list = await that.getChapterList(that.cateList[i]);
if (that.cateList[i].isBuy == 0 && that.userVip == null) {
that.showNewPayBtn[i].status = await that.checkRenewPayment(that.cateList[i].id);
console.log("可以复读吗?", that.showNewPayBtn);
}
// for (let i = 0; i < that.cateList.length; i++) {
// that.showNewPayBtn[i] = { status: false };
// var list = await that.getChapterList(that.cateList[i]);
// if (that.cateList[i].isBuy == 0 && that.userVip == null) {
// that.showNewPayBtn[i].status = await that.checkRenewPayment(that.cateList[i].id);
// console.log("可以复读吗?", that.showNewPayBtn);
// }
that.allDataList[i] = {
...that.cateList[i],
courseList: [...list],
};
}
// that.allDataList[i] = {
// ...that.cateList[i],
// courseList: [...list],
// };
// }
// 创建一个用于存储所有 checkRenewPayment 的 Promise 数组
let promises = [];
if (
for (let i = 0; i < that.cateList.length; i++) {
// 初始化 showNewPayBtn 数组
that.showNewPayBtn[i] = { status: false };
// 获取章节列表的 Promise
let listPromise = that.getChapterList(that.cateList[i]);
// 创建 checkRenewPayment 的 Promise 任务并推入 promises 数组
let checkRenewPaymentPromise = (async () => {
if (that.cateList[i].isBuy == 0 && that.userVip == null) {
// 等待 checkRenewPayment 完成
let status = await that.checkRenewPayment(that.cateList[i].id);
that.showNewPayBtn[i].status = status;
console.log("可以复读吗?", that.showNewPayBtn);
}
})();
// 等待 getChapterList 和 checkRenewPayment 都完成
promises.push(Promise.all([listPromise, checkRenewPaymentPromise]).then(([list]) => {
// 等待 checkRenewPayment 完成后再做其他处理
that.allDataList[i] = {
...that.cateList[i],
courseList: [...list],
};
if (
res.data.shopProductList &&
res.data.shopProductList.length > 0
) {
@@ -881,6 +972,17 @@ export default {
setTimeout(() => {
that.$refs.commonAnchorLink.getDistanceArr();
}, 200);
}));
}
// 等待所有的异步操作完成
await Promise.all(promises);
console.log("所有数据已处理完毕", that.allDataList);
that.$forceUpdate();
});
},