Преглед изворни кода

Merge branch 'dev' into chen

chenxiong пре 3 година
родитељ
комит
9c29cb0231

+ 35 - 13
src/pages/goods-detail/bank-detail.vue

@@ -187,19 +187,33 @@
                         <ul class="list">
                           <li
                             class="course-item"
-                            v-for="(item, index) in 5"
+                            v-for="(itemy, index) in compyRecommend(
+                              recommendList.goodsList
+                            )"
                             :key="index"
-                            @click="goodsDetail()"
                           >
-                            <div class="course-item__img">
-                              <div class="note">2022</div>
+                            <div
+                              class="course-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="course-item__title">
-                              2022年二建建设工程法规及相关知识(黄金基础班)
+                              {{ itemy.goodsName }}
                             </div>
                             <div class="course-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>
@@ -217,7 +231,11 @@
 
         <div
           class="section__footer"
-          v-if="recommendList.goodsList && recommendList.goodsList.length"
+          v-if="
+            recommendList.goodsList &&
+            recommendList.goodsList.length &&
+            activeName == 1
+          "
         >
           <div class="recommend">
             <div class="recommend__header">
@@ -1041,11 +1059,13 @@ export default {
     compyRecommend: function () {
       return function (array) {
         let ary = [];
-        for (let i = 0; i < array.length; i++) {
-          if (i >= 4) {
-            break;
-          } else {
-            ary.push(array[i]);
+        if (array) {
+          for (let i = 0; i < array.length; i++) {
+            if (i >= 4) {
+              break;
+            } else {
+              ary.push(array[i]);
+            }
           }
         }
         return ary;
@@ -1992,6 +2012,8 @@ export default {
                     background: rgba(122, 136, 246, 1);
                     overflow: hidden;
 
+                    background: no-repeat center center;
+                    background-size: 280px 178px;
                     .note {
                       width: 80px;
                       height: 24px;

+ 37 - 15
src/pages/goods-detail/course-detail.vue

@@ -226,25 +226,40 @@
                       </div>
                       <div class="right-box">
                         <div class="title">
-                          推荐题库
-                          <span class="more">更多></span>
+                          推荐课程
+                          <span class="more" @click="comeMoreList">更多></span>
                         </div>
                         <ul class="list">
                           <li
                             class="course-item"
-                            v-for="(item, index) in 5"
+                            v-for="(itemy, index) in compyRecommend(
+                              recommendList.goodsList
+                            )"
                             :key="index"
                             @click="goodsDetail()"
                           >
-                            <div class="course-item__img">
-                              <div class="note">2022</div>
+                            <div
+                              class="course-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="course-item__title">
-                              2022年二建建设工程法规及相关知识(黄金基础班)
+                              {{ itemy.goodsName }}
                             </div>
                             <div class="course-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>
@@ -262,7 +277,11 @@
 
         <div
           class="section__footer"
-          v-if="recommendList.goodsList && recommendList.goodsList.length"
+          v-if="
+            recommendList.goodsList &&
+            recommendList.goodsList.length &&
+            activeName == 1
+          "
         >
           <div class="recommend">
             <div class="recommend__header">
@@ -484,11 +503,13 @@ export default {
     compyRecommend: function () {
       return function (array) {
         let ary = [];
-        for (let i = 0; i < array.length; i++) {
-          if (i >= 4) {
-            break;
-          } else {
-            ary.push(array[i]);
+        if (array) {
+          for (let i = 0; i < array.length; i++) {
+            if (i >= 4) {
+              break;
+            } else {
+              ary.push(array[i]);
+            }
           }
         }
         return ary;
@@ -1664,7 +1685,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;

+ 111 - 10
src/pages/payment-success/index.vue

@@ -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;

+ 7 - 5
src/pages/person-center/my-bank/bank-detail/index.vue

@@ -627,11 +627,13 @@ export default {
     compyRecommend: function () {
       return function (array) {
         let ary = [];
-        for (let i = 0; i < array.length; i++) {
-          if (i >= 4) {
-            break;
-          } else {
-            ary.push(array[i]);
+        if (array) {
+          for (let i = 0; i < array.length; i++) {
+            if (i >= 4) {
+              break;
+            } else {
+              ary.push(array[i]);
+            }
           }
         }
         return ary;