|
@@ -99,6 +99,18 @@
|
|
|
<view class="tabs">
|
|
|
<view v-for="(item, index) in menu" :key="index" class="tab_item" :class="{nactive: tabNum == index}" @click="tab(index)">{{ item.name }}</view>
|
|
|
</view>
|
|
|
+ <view class="filters">
|
|
|
+ <template v-if="tabNum == 0">
|
|
|
+ <view v-for="(item, index) in courseName" :key="index" class="filter_item" :class="{nactive: couIndex == index}" @click="changeCou(item.recommendId, index)">
|
|
|
+ {{ item.name }}
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+ <template v-if="tabNum == 1">
|
|
|
+ <view v-for="(item, index) in bankName" :key="index" class="filter_item" :class="{nactive: bankIndex == index}" @click="changebank(item.recommendId, index)">
|
|
|
+ {{ item.name }}
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+ </view>
|
|
|
<view class="course-list" v-show="tabCurrent==0">
|
|
|
<template v-if="list1.length">
|
|
|
<navigator hover-class="none" class="list_item" v-for="(item,index) in list1" :key="index" :url="'/pages3/course/detail?id='+item.goodsId">
|
|
@@ -240,7 +252,7 @@ export default {
|
|
|
{
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
- // total: 0,
|
|
|
+ total: 0,
|
|
|
// showStatus: 0,
|
|
|
getUserNum: 1, //是否返回商品购买用户数量 1带 0不带 ,会返回个buyUserNum
|
|
|
goodsType:1
|
|
@@ -249,7 +261,7 @@ export default {
|
|
|
{
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
- // total: 0,
|
|
|
+ total: 0,
|
|
|
// showStatus: 0,
|
|
|
getUserNum: 1,
|
|
|
goodsType:2
|
|
@@ -267,9 +279,14 @@ export default {
|
|
|
// opacity: 1,
|
|
|
isFollow: null, //是否关注过,不是1就是没关注
|
|
|
curClose: true, // 当天时是否关闭过
|
|
|
+ courseName: [],
|
|
|
+ bankName: [],
|
|
|
+ couIndex: 0,
|
|
|
+ bankIndex: 0,
|
|
|
+ courseId: '',
|
|
|
+ bankId: '',
|
|
|
};
|
|
|
},
|
|
|
- onPullDownRefresh() {},
|
|
|
async onLoad(option) {
|
|
|
this.isLogin = this.$method.isLogin()
|
|
|
this.dictObj
|
|
@@ -305,7 +322,7 @@ export default {
|
|
|
this.getInfo() // 判断有没有关注公众号
|
|
|
this.isClickOff() //关注公众号,每天最多显示1次;当天学员关闭弹窗后,无需再显示
|
|
|
uni.removeStorageSync('goPath')
|
|
|
- this.courseList();
|
|
|
+ this.courseLists();
|
|
|
// this.bankList();
|
|
|
if (uni.getStorageSync('updateHome')){
|
|
|
this.init()
|
|
@@ -335,6 +352,35 @@ export default {
|
|
|
path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
|
|
|
};
|
|
|
},
|
|
|
+ async onPullDownRefresh() {
|
|
|
+ if (this.tabNum == 0) {
|
|
|
+ this.paramList[0].pageNum = 1
|
|
|
+ this.list1 = await this.getGoodsList(this.courseId, 0)
|
|
|
+ } else {
|
|
|
+ this.paramList[1].pageNum = 1
|
|
|
+ this.list2 = await this.getGoodsList(this.bankId, 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onReachBottom() {
|
|
|
+ console.log('加载加载--', this.tabNum)
|
|
|
+ console.log(this.paramList[0].total,'total', this.paramList[1].total)
|
|
|
+ console.log(this.list1.length,'length', this.list2.length)
|
|
|
+ if (this.tabNum == 0) {
|
|
|
+ if (this.list1.length < this.paramList[0].total) {
|
|
|
+ this.paramList[0].pageNum++
|
|
|
+ let list1 = await this.getGoodsList(this.courseId, 0)
|
|
|
+ this.list1.push(...list1)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (this.list2.length < this.paramList[1].total) {
|
|
|
+ this.paramList[1].pageNum++
|
|
|
+ let list2 = await this.getGoodsList(this.bankId, 1)
|
|
|
+ this.list1.push(...list2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
computed: {
|
|
|
...mapGetters(['dictObj','userInfo', 'hideBuyState']),
|
|
|
opacitys() {
|
|
@@ -506,8 +552,24 @@ export default {
|
|
|
}
|
|
|
|
|
|
},
|
|
|
+ async changeCou(recommendId, index) {
|
|
|
+ this.couIndex = index
|
|
|
+ this.courseId = recommendId
|
|
|
+ this.paramList[0].pageNum = 1
|
|
|
+ this.list1 = []
|
|
|
+ let list1 = await this.getGoodsList(recommendId, 0)
|
|
|
+ this.list1.push(...list1)
|
|
|
+ },
|
|
|
+ async changebank(recommendId, index) {
|
|
|
+ this.bankIndex = index
|
|
|
+ this.bankId = recommendId
|
|
|
+ this.paramList[1].pageNum = 1
|
|
|
+ this.list2 = []
|
|
|
+ let list2 = await this.getGoodsList(recommendId, 1)
|
|
|
+ this.list1.push(...list2)
|
|
|
+ },
|
|
|
//课程
|
|
|
- courseList() {
|
|
|
+ courseLists() {
|
|
|
// var param = this.paramList[0];
|
|
|
// /app/common/goods/list
|
|
|
this.$http({
|
|
@@ -518,23 +580,37 @@ export default {
|
|
|
status: 1
|
|
|
},
|
|
|
noToken: true
|
|
|
- }).then((res) => {
|
|
|
+ }).then(async (res) => {
|
|
|
if (res.data.code == 200) {
|
|
|
- let goodsList1 = []; //推荐视频商品
|
|
|
- let goodsList2 = []; //推荐题库商品
|
|
|
- res.data.rows.forEach((item) => {
|
|
|
- if (item.type === 1) {
|
|
|
- goodsList1 = goodsList1.concat(item.goodsList)
|
|
|
+ let list = res.data.rows || []
|
|
|
+ //课程
|
|
|
+ this.courseName = list.filter(x => x.type == 1).sort((a,b) => a.sort - b.sort).map(x => {
|
|
|
+ return {
|
|
|
+ name: x.educationName,
|
|
|
+ recommendId: x.recommendId
|
|
|
}
|
|
|
- if (item.type === 2) {
|
|
|
- goodsList2 = goodsList2.concat(item.goodsList)
|
|
|
+ });
|
|
|
+ //题库
|
|
|
+ this.bankName = list.filter(x => x.type == 2).sort((a,b) => a.sort - b.sort).map(x => {
|
|
|
+ return {
|
|
|
+ name: x.educationName,
|
|
|
+ recommendId: x.recommendId
|
|
|
}
|
|
|
});
|
|
|
- this.list1 = goodsList1.sort((a, b) => a.sort - b.sort);
|
|
|
- this.list2 = goodsList2.sort((a, b) => a.sort - b.sort);
|
|
|
- console.log(this.list1, this.list2)
|
|
|
+ if (this.courseName.length) {
|
|
|
+ this.courseId = this.courseName[0].recommendId
|
|
|
+ let list1 = await this.getGoodsList(this.courseName[0].recommendId, 0)
|
|
|
+ this.list1.push(...list1)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.bankName.length) {
|
|
|
+ this.bankId = this.bankName[0].recommendId
|
|
|
+ let list2 = await this.getGoodsList(this.bankName[0].recommendId, 1)
|
|
|
+ this.list2.push(...list2)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
// this.$api.goodsList(param).then(res => {
|
|
|
// if (res.data.code == 200) {
|
|
|
// this.list1 = res.data.rows || []
|
|
@@ -545,20 +621,25 @@ export default {
|
|
|
// }
|
|
|
// });
|
|
|
},
|
|
|
- //题库
|
|
|
- bankList() {
|
|
|
- var param = this.paramList[1];
|
|
|
- this.$api.goodsList(param).then(res => {
|
|
|
- // this.paramList[1].total = res.data.total;
|
|
|
- if (res.data.code == 200) {
|
|
|
- this.list2 = res.data.rows || []
|
|
|
- this.total2 = res.data.total
|
|
|
- if (this.list2.length === res.data.total) {
|
|
|
- // this.paramList[1].showStatus = true;
|
|
|
- this.showStatus2 = true
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ getGoodsList(recommendId, num) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$http({
|
|
|
+ url: `/app/common/activity/recommend/goodsList`,
|
|
|
+ method: 'get',
|
|
|
+ data: {
|
|
|
+ pageNum: this.paramList[num].pageNum,
|
|
|
+ pageSize: this.paramList[num].pageSize,
|
|
|
+ recommendId: recommendId
|
|
|
+ },
|
|
|
+ noToken: true
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ this.paramList[num].total = res.data.total
|
|
|
+ resolve(res.data.rows)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* @param {Object} item
|
|
@@ -732,7 +813,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- onReachBottom() {},
|
|
|
|
|
|
};
|
|
|
</script>
|
|
@@ -1087,6 +1167,27 @@ page {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .filters {
|
|
|
+ padding: 0rpx 16rpx;
|
|
|
+ margin-bottom: 32rpx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .filter_item {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #666666;
|
|
|
+ padding: 12rpx 16rpx;
|
|
|
+ width: 152rpx;
|
|
|
+ height: 56rpx;
|
|
|
+ text-align: center;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ margin-right: 16rpx;
|
|
|
+ &.nactive {
|
|
|
+ color: #3F8DFD;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
// .botms {
|
|
|
// padding-bottom: 100rpx;
|