|
@@ -41,7 +41,10 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="section__footer">
|
|
|
+ <div
|
|
|
+ class="section__footer"
|
|
|
+ v-if="recommendList.goodsList && recommendList.goodsList.length"
|
|
|
+ >
|
|
|
<div class="recommend">
|
|
|
<div class="recommend__header">
|
|
|
<div class="title">相关推荐</div>
|
|
@@ -50,25 +53,36 @@
|
|
|
<ul class="list clearfix">
|
|
|
<li
|
|
|
class="recommend-item"
|
|
|
- v-for="(item, index) in 4"
|
|
|
+ v-for="(itemy, index) in compyRecommend(
|
|
|
+ recommendList.goodsList
|
|
|
+ )"
|
|
|
:key="index"
|
|
|
>
|
|
|
- <div class="recommend-item__img">
|
|
|
- <div class="note">2022</div>
|
|
|
+ <div
|
|
|
+ class="recommend-item__img"
|
|
|
+ :style="`background-image:url(${$tools.splitImgHost(
|
|
|
+ itemy.coverUrl,
|
|
|
+ true
|
|
|
+ )})`"
|
|
|
+ @click="toGoodsDetail(itemy)"
|
|
|
+ >
|
|
|
+ <div class="note" v-if="itemy.year">{{ itemy.year }}</div>
|
|
|
</div>
|
|
|
<div class="recommend-item__title">
|
|
|
- 2022年二建建设工程法规及相关知识(黄金基础班)
|
|
|
+ {{ itemy.goodsName }}
|
|
|
</div>
|
|
|
<div class="recommend-item__desc">
|
|
|
- <div class="price">¥100</div>
|
|
|
- <a class="add">加购物车</a>
|
|
|
+ <div class="price">¥{{ itemy.standPrice }}</div>
|
|
|
+ <a class="add" @click="addCart(true, itemy.goodsId)"
|
|
|
+ >加购物车</a
|
|
|
+ >
|
|
|
</div>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
|
|
|
<div class="recommend__footer">
|
|
|
- <div class="btn">查看更多</div>
|
|
|
+ <div class="btn" @click="comeMoreList">查看更多</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -99,8 +113,27 @@ export default {
|
|
|
goodsId: 0,
|
|
|
gradeId: 0,
|
|
|
orderGoodsId: 0,
|
|
|
+ recommendList: [],
|
|
|
+ goodsDetail: {},
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ compyRecommend: function () {
|
|
|
+ return function (array) {
|
|
|
+ let ary = [];
|
|
|
+ if (array) {
|
|
|
+ for (let i = 0; i < array.length; i++) {
|
|
|
+ if (i >= 4) {
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ ary.push(array[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ary;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.orderSn = this.$route.params.orderSn;
|
|
|
this.total = this.$route.params.total;
|
|
@@ -108,10 +141,77 @@ export default {
|
|
|
this.goodsId = this.$route.params.goodsId;
|
|
|
this.gradeId = this.$route.params.gradeId;
|
|
|
this.orderGoodsId = this.$route.params.orderGoodsId;
|
|
|
-
|
|
|
+ if (this.goodsId) {
|
|
|
+ this.$request
|
|
|
+ .commonGoodsDetail(this.$route.params.goodsId)
|
|
|
+ .then((res) => {
|
|
|
+ this.goodsDetail = res.data;
|
|
|
+ this.getRecommend();
|
|
|
+ });
|
|
|
+ }
|
|
|
console.log(this.$route.params, "this.$route.params");
|
|
|
},
|
|
|
methods: {
|
|
|
+ addCart(status, goodsId) {
|
|
|
+ if (!this.$tools.isLogin()) {
|
|
|
+ this.setCurrentRouter(this.$route);
|
|
|
+ this.$router.push({
|
|
|
+ path: "/login",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$request
|
|
|
+ .addCart({ goodsId: status ? goodsId : this.goodsId })
|
|
|
+ .then((res) => {
|
|
|
+ this.getCartCount();
|
|
|
+ this.$message({
|
|
|
+ message: "加入购物车成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ if (err.code == 500) {
|
|
|
+ this.$message({
|
|
|
+ message: err.msg,
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ toGoodsDetail(item) {
|
|
|
+ this.$router.push({
|
|
|
+ path: "/course-detail/" + item.goodsId,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 查看更多
|
|
|
+ */
|
|
|
+ comeMoreList() {
|
|
|
+ this.$router.push({
|
|
|
+ path: "/course-list",
|
|
|
+ query: {
|
|
|
+ educationId: this.goodsDetail.educationTypeId,
|
|
|
+ projectId: this.goodsDetail.projectId,
|
|
|
+ businessId: this.goodsDetail.businessId,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ 获取推荐列表
|
|
|
+ */
|
|
|
+ getRecommend() {
|
|
|
+ this.$request
|
|
|
+ .appCommonActivityRecommendList({
|
|
|
+ businessId: this.goodsDetail.businessId,
|
|
|
+ type: this.goodsDetail.goodsType,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.rows.length) {
|
|
|
+ this.recommendList = res.rows[0];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
go(path, query) {
|
|
|
this.$router.push({
|
|
|
path,
|
|
@@ -221,7 +321,8 @@ export default {
|
|
|
top: -78px;
|
|
|
background: rgba(122, 136, 246, 1);
|
|
|
overflow: hidden;
|
|
|
-
|
|
|
+ background: no-repeat center center;
|
|
|
+ background-size: 280px 178px;
|
|
|
.note {
|
|
|
width: 80px;
|
|
|
height: 24px;
|