Tang 3 лет назад
Родитель
Сommit
8f912eef31
2 измененных файлов с 95 добавлено и 16 удалено
  1. 95 15
      src/pages/course-detail/index.vue
  2. 0 1
      src/pages/goods-detail/course-detail.vue

+ 95 - 15
src/pages/course-detail/index.vue

@@ -1237,19 +1237,35 @@
                           <ul class="list">
                             <li
                               class="course-item"
-                              v-for="(item, index) in 4"
+                              v-for="(itemy, index) in compyRecommend(
+                                recommendList.goodsList
+                              )"
                               :key="index"
-                              @click="courseDetail()"
                             >
-                              <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.stop="addCart(true, itemy.goodsId)"
+                                  >加购物车</a
+                                >
                               </div>
                             </li>
                           </ul>
@@ -1321,7 +1337,7 @@
                                     v-if="item.userId !== userInfo.userId"
                                     @click="answerBack(item)"
                                   >
-                                  <el-button type="text">回复</el-button>
+                                    <el-button type="text">回复</el-button>
                                   </div>
                                   <div
                                     class="del"
@@ -2137,7 +2153,7 @@
 import Footer from "@/components/footer/index";
 import Header from "@/components/header/index";
 import ToolBar from "@/components/toolbar/index";
-import { mapGetters } from "vuex";
+import { mapGetters,mapMutations } from "vuex";
 import * as baseUrls from "@/axios.js";
 import pdf from "vue-pdf";
 import print from "print-js";
@@ -2265,6 +2281,7 @@ export default {
         idcard_national_photo: "",
         commitment_electr_signature: "",
       },
+      recommendList:[],
       rules: {
         name: [
           {
@@ -2459,6 +2476,22 @@ export default {
   },
   computed: {
     ...mapGetters(["userInfo"]),
+
+    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.courseId = +this.$route.query.courseId || "";
@@ -2534,6 +2567,47 @@ export default {
     clearInterval(this.livingTimer);
   },
   methods: {
+    ...mapMutations(["getCartCount"]),
+    /**
+     * 
+     获取推荐列表
+     */
+    getRecommend() {
+      this.$request
+        .appCommonActivityRecommendList({
+          businessId: this.goodsData.businessId,
+          type: 1,
+        })
+        .then((res) => {
+          if (res.rows.length) {
+            this.recommendList = res.rows[0];
+          }
+        });
+    },
+    addCart(status, goodsId) {
+      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,
+      });
+    },
     async takeOk() {
       this.loading = true;
       let compareFaceData = await this.faceRecognition();
@@ -4084,6 +4158,8 @@ export default {
             { name: "2", label: "课程答疑" },
             { name: "3", label: "笔记讲义" },
           ];
+          console.log(res, "res111");
+          this.getRecommend();
         } else {
           this.tabList = [
             { name: "1", label: "课程答疑" },
@@ -5583,13 +5659,16 @@ export default {
       this.$prompt(`${row.realname}:${row.answerText}`, "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
+        inputErrorMessage: "输入不能为空",
+        inputValidator: (value) => {
+          let str = value.replace(/^ +| +$/g, "");
+          // 点击按钮时,对文本框里面的值进行验证
+          if (!str) {
+            return "输入不能为空";
+          }
+        },
       })
         .then(({ value }) => {
-          if (!value) {
-            this.$message.warning("请输入回复内容");
-            return;
-          }
-
           let data = {
             assignUserId: row.userId,
             assignAnswerId: row.answerId,
@@ -6202,7 +6281,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;

+ 0 - 1
src/pages/goods-detail/course-detail.vue

@@ -236,7 +236,6 @@
                               recommendList.goodsList
                             )"
                             :key="index"
-                            @click="goodsDetail()"
                           >
                             <div
                               class="course-item__img"