Browse Source

多规格完成

xiejiebiao 2 years ago
parent
commit
791d6b8de3

+ 8 - 1
src/apis/common.js

@@ -145,7 +145,14 @@ export default {
       noToken: true
     })
   },
-
+  // 校验商品状态 
+  checkGoodsStatus(data) {
+    return request({
+      url: '/goods/check/goods/status',
+      method: 'post',
+      data
+    })
+  },
   /**
    * 
    * @param {*} data 

+ 4 - 4
src/components/courseTree/CourseTree.vue

@@ -209,7 +209,7 @@
                               class="btn btn--red"
                               v-if="section.learning == 0"
                             >
-                              不合格
+                            不及格(需重考)
                             </div>
                             <div
                               class="btn btn--green"
@@ -247,7 +247,7 @@
                           合格
                         </div>
                         <div class="btn btn--red" v-if="chapter.learning == 0">
-                          不合格
+                          不及格(需重考)
                         </div>
                       </template>
                     </template>
@@ -418,7 +418,7 @@
                               class="btn btn--red"
                               v-if="section.learning == 0"
                             >
-                              不合格
+                            不及格(需重考)
                             </div>
                             <div
                               class="btn btn--green"
@@ -1266,7 +1266,7 @@ export default {
 
           .btn {
             margin-right: 12px;
-            width: 48px;
+            padding: 0 2px;
             height: 20px;
             border: 1px solid #ff3b30;
             background: #ff3b30;

+ 33 - 32
src/components/goodsItem/IndexSkuDialog.vue

@@ -15,7 +15,7 @@
               </div>
             </div>
             <div v-if="index == 1 || specList.length == 1" class="check_box">
-              <el-checkbox-group v-model="checkedAttrs">
+              <el-checkbox-group v-model="checkedAttrs" @change="changeCheck">
                 <el-checkbox v-for="spec in specAttrList" :label="spec.specAttributeId" :key="spec.specAttributeId">
                   <div class="box_centen">{{ spec.name }}<span>{{ spec.standPrice
                       === 0 ?
@@ -87,7 +87,6 @@ export default {
     specAttrList() {
       let arr = []
       let data = this.specList.slice(-1)
-      console.log(data, 9988)
       data[0].specAttrList.forEach(ele => {
         let id = ele.specAttributeId
         if (this.specList.length > 1) {
@@ -113,24 +112,26 @@ export default {
         return a
       }, 0)
     },
+    isSingleChoice() {
+      if (!this.specAttrPriceList.length) {
+        return false
+      }
+      return this.specAttrPriceList[0].goodsType === 1
+    }
   },
   methods: {
+    changeCheck(val) {
+      // 二建变单选
+      if (this.isSingleChoice) {
+        this.checkedAttrs = val.slice(-1)
+      }
+    },
     selectGoodType(index) {
       if (index == this.selectGoodIndex) {
         return
       }
       this.selectGoodIndex = index
     },
-    backPrice(id, index) {
-      // if (this.specList.length > 1) {
-      //   id = this.selectId + ',' + id
-      // }
-      // let item = this.specAttrPriceList.find(e => e.specAttrIds == id)
-      // if (item) {
-      //   return item.standPrice
-      // }
-      // return null
-    },
     cancel() {
       this.$emit("update:skuModal", false);
     },
@@ -158,26 +159,26 @@ export default {
         });
     },
     confirms() {
-      // if (this.skuItem.goodsStatus == 0) {
-      //   this.$message.warning("商品已下架, 请重新选择");
-      //   return;
-      // }
-      // let sysTime = this.$tools.timest();
-      // if (
-      //   sysTime <= this.skuItem.validityStartTime ||
-      //   sysTime >= this.skuItem.validityEndTime
-      // ) {
-      //   this.$message.warning("商品不在有效期, 请重新选择");
-      //   return;
-      // }
-      let goodsIds = this.specAttrList.filter(e => this.checkedAttrs.includes(e.specAttributeId)).map(e => e.goodsId)
-      if (this.isCarOrBuy == 1) {
-        // 加入购物车
-        this.$emit("toShopCart", goodsIds);
-      } else {
-        this.$emit("togoBuy", goodsIds);
-      }
-      this.cancel();
+      let goodsIds = []
+      let goodList = []
+      this.specAttrList.forEach(e => {
+        if (this.checkedAttrs.includes(e.specAttributeId) && !goodsIds.includes(e.goodsId)) {
+          goodsIds.push(e.goodsId)
+          goodList.push(this.specAttrPriceList.find(ele => ele.goodsId == e.goodsId))
+        }
+      })
+      this.$request.checkGoodsStatus({ goodsIds }).then((res) => {
+        if (this.isCarOrBuy == 1) {
+          // 加入购物车
+          this.$emit("toShopCart", goodsIds);
+        } else {
+          this.$emit("togoBuy", goodList);
+        }
+        this.cancel();
+      }).catch((e) => {
+        this.$message.warning(e.msg);
+      })
+
     },
   },
 };

+ 20 - 18
src/components/goodsItem/index.vue

@@ -112,8 +112,11 @@ export default {
       }
       this.toPayment(this.item.goodsId)
     },
-    togoBuy(goodsId) {
-      this.toPayment(goodsId.toString())
+    togoBuy(goodList) {
+      if (goodList.length == 1) {
+        return this.toPayment(goodList[0].goodsId)
+      }
+      this.goPayment(goodList)
     },
     toPayment(goodsId) {
       this.getGoodsDetail(goodsId).then((res) => {
@@ -122,27 +125,26 @@ export default {
             this.$refs.selectClassModal.showModal(res);
           }
           if (res.goodsType === 2 || res.goodsType === 6) {
-            let selectGoodsList = JSON.parse(JSON.stringify([res]));
-            localStorage.setItem(
-              "checkGoodsList",
-              JSON.stringify(selectGoodsList)
-            );
-            this.$router.push({
-              path: "/payment",
-            });
+            this.goPayment(res)
           }
         } else {
-          let selectGoodsList = JSON.parse(JSON.stringify([res]));
-          localStorage.setItem(
-            "checkGoodsList",
-            JSON.stringify(selectGoodsList)
-          );
-          this.$router.push({
-            path: "/payment",
-          });
+          this.goPayment(res)
         }
       });
     },
+    goPayment(data) {
+      if (!Array.isArray(data)) {
+        data = [data]
+      }
+      let selectGoodsList = JSON.parse(JSON.stringify(data));
+      localStorage.setItem(
+        "checkGoodsList",
+        JSON.stringify(selectGoodsList)
+      );
+      this.$router.push({
+        path: "/payment",
+      });
+    },
     /**
      * 加入购物车
      */

+ 68 - 103
src/components/header/index.vue

@@ -2,42 +2,22 @@
   <header class="header">
     <div class="container clearfix">
       <div class="logo logo--no" v-if="header.companyLogo">
-        <img
-          style="cursor: pointer; width: 162px; height: 33px"
-          :src="$tools.splitImgHost(header.companyLogo)"
-          alt=""
-          @click="go('/')"
-        />
+        <img style="cursor: pointer; width: 162px; height: 33px" :src="$tools.splitImgHost(header.companyLogo)" alt=""
+          @click="go('/')" />
       </div>
       <h1 class="logo" v-else @click="go('/')"></h1>
       <nav class="nav">
         <ul class="list">
           <li v-for="(item, index) in showNav(header.Nav)" :key="index">
             <a v-if="item.name == '首页'" @click="go('/index')">首页</a>
-            <a
-              v-if="item.name == '走进祥粤'"
-              @click="go('/about')"
-              :style="$route.path === '/about' ? 'color:red;' : ''"
-              >走进祥粤</a
-            >
-            <a
-              v-if="item.name == '课程'"
-              @click="go('/course-list')"
-              :style="$route.path === '/course-list' ? 'color:red;' : ''"
-              >课程</a
-            >
-            <a
-              v-if="item.name == '直播'"
-              @click="go('/live-list')"
-              :style="$route.path === '/live-list' ? 'color:red;' : ''"
-              >直播</a
-            >
-            <a
-              v-if="item.name == '题库'"
-              @click="go('/bank-list')"
-              :style="$route.path === '/bank-list' ? 'color:red;' : ''"
-              >题库</a
-            >
+            <a v-if="item.name == '走进祥粤'" @click="go('/about')"
+              :style="$route.path === '/about' ? 'color:red;' : ''">走进祥粤</a>
+            <a v-if="item.name == '课程'" @click="go('/course-list')"
+              :style="$route.path === '/course-list' ? 'color:red;' : ''">课程</a>
+            <a v-if="item.name == '直播'" @click="go('/live-list')"
+              :style="$route.path === '/live-list' ? 'color:red;' : ''">直播</a>
+            <a v-if="item.name == '题库'" @click="go('/bank-list')"
+              :style="$route.path === '/bank-list' ? 'color:red;' : ''">题库</a>
           </li>
         </ul>
       </nav>
@@ -50,52 +30,32 @@
             {{ msgData.text }} <el-button style="float:right;" type="text">立即学习</el-button>
           </div>
         </a> -->
-        <el-tooltip
-          placement="bottom-end"
-          v-model="msgShow"
-          :hide-after="0"
-          manual
-          popper-class="tooltipStyle"
-        >
-          <el-badge
-            :is-dot="msgCount > 0 ? true : false"
-            class="item"
-            style="vertical-align: baseline"
-          >
-            <el-button
-              style="font-size: 20px; padding: 0px"
-              icon="el-icon-message-solid"
-              type="text"
-              @click="go('/person-center/my-message')"
-            ></el-button>
+        
+        <!-- <el-tooltip placement="bottom-end" v-model="msgShow" :hide-after="0" manual popper-class="tooltipStyle">
+          <el-badge :is-dot="msgCount > 0 ? true : false" class="item" style="vertical-align: baseline">
+            <el-button style="font-size: 20px; padding: 0px" icon="el-icon-message-solid" type="text"
+              @click="go('/person-center/my-message')"></el-button>
           </el-badge>
           <div slot="content" class="dis_plays">
             <p style="max-width: 247px">{{ msgData.text }}</p>
             <div class="toolbth" @click="newGoToStudy">立即学习</div>
-            <i
-              style="font-size: 18px; cursor: pointer"
-              class="el-icon-close"
-              @click="clearMsg"
-            ></i>
+            <i style="font-size: 18px; cursor: pointer" class="el-icon-close" @click="clearMsg"></i>
           </div>
-        </el-tooltip>
+        </el-tooltip> -->
+        <el-badge :is-dot="msgCount > 0 ? true : false" class="item" style="vertical-align: baseline">
+          <el-button style="font-size: 20px; padding: 0px" icon="el-icon-message-solid" type="text"
+            @click="go('/person-center/my-message')"></el-button>
+        </el-badge>
         <el-dropdown @command="handleCommand">
-          <span
-            class="el-dropdown-link"
-            @click="go('/person-center/my-course')"
-            style="margin-left: 10px; cursor: pointer"
-          >
-            <img
-              style="width: 24px; vertical-align: middle"
-              :src="
-                userInfo
-                  ? userInfo.avatar
-                    ? $tools.splitImgHost(userInfo.avatar, true)
-                    : '@/assets/qrcode.png'
-                  : ''
-              "
-              alt=""
-            />
+          <span class="el-dropdown-link" @click="go('/person-center/my-course')"
+            style="margin-left: 10px; cursor: pointer">
+            <img style="width: 24px; vertical-align: middle" :src="
+              userInfo
+                ? userInfo.avatar
+                  ? $tools.splitImgHost(userInfo.avatar, true)
+                  : '@/assets/qrcode.png'
+                : ''
+            " alt="" />
             <span>{{ userInfo && userInfo.realname }}</span>
           </span>
           <el-dropdown-menu slot="dropdown">
@@ -123,22 +83,13 @@
         </div>
         <div class="search__input">
           <input type="text" v-model="searchKey" autocomplete="off" />
-          <input
-            type="password"
-            autocomplete="new-password"
-            style="display: none"
-          />
+          <input type="password" autocomplete="new-password" style="display: none" />
         </div>
-        <el-button type="primary" @click="search" class="search__btn"
-          >搜索</el-button
-        >
+        <el-button type="primary" @click="search" class="search__btn">搜索</el-button>
       </div>
     </div>
 
-    <RebuildModal
-      ref="rebuildModal"
-      @rebuildSubmit="rebuildSubmit($event)"
-    ></RebuildModal>
+    <RebuildModal ref="rebuildModal" @rebuildSubmit="rebuildSubmit($event)"></RebuildModal>
   </header>
 </template>
 
@@ -177,24 +128,24 @@ export default {
   },
   mounted() {
     if (this.$tools.isLogin()) {
-      this.$request.informUserselectLastUnStudyMsg().then((res) => {
-        if (res.data && res.data.id) {
-          let today = new Date(new Date().toLocaleDateString()).getTime();
-          if (localStorage.getItem("msg")) {
-            let ary = JSON.parse(localStorage.getItem("msg"));
-            if (ary.updateTime === today) {
-              this.msgShow = false;
-              return;
-            }
-          }
-          this.$nextTick(() => {
-            this.msgData = res.data;
-            this.msgShow = true;
-          });
-        } else {
-          this.msgShow = false;
-        }
-      });
+      // this.$request.informUserselectLastUnStudyMsg().then((res) => {
+      //   if (res.data && res.data.id) {
+      //     let today = new Date(new Date().toLocaleDateString()).getTime();
+      //     if (localStorage.getItem("msg")) {
+      //       let ary = JSON.parse(localStorage.getItem("msg"));
+      //       if (ary.updateTime === today) {
+      //         this.msgShow = false;
+      //         return;
+      //       }
+      //     }
+      //     this.$nextTick(() => {
+      //       this.msgData = res.data;
+      //       this.msgShow = true;
+      //     });
+      //   } else {
+      //     this.msgShow = false;
+      //   }
+      // });
       this.getMsgCount();
     }
   },
@@ -300,7 +251,7 @@ export default {
                   .then((_) => {
                     window.open("http://admin.zhujianpeixun.com/", "_blank");
                   })
-                  .catch((_) => {});
+                  .catch((_) => { });
 
                 return;
               } else {
@@ -624,15 +575,18 @@ export default {
     .nav {
       float: left;
       margin-top: 30px;
+
       .list {
         margin-left: 146px;
         display: flex;
 
         li {
           margin: 0 20px;
+
           a {
             color: #333;
           }
+
           a:hover {
             color: #3f8dfd;
           }
@@ -688,6 +642,7 @@ export default {
       margin-top: 30px;
       float: right;
       white-space: nowrap;
+
       a {
         display: inline-block;
         margin-left: 20px;
@@ -701,6 +656,7 @@ export default {
             font-size: 20px;
             color: #3f8dfd;
           }
+
           .pi {
             display: inline-block;
             width: 10px;
@@ -712,6 +668,7 @@ export default {
             top: 0;
             right: 0;
           }
+
           .popover_style {
             position: absolute;
             top: 150%;
@@ -728,6 +685,7 @@ export default {
         &.name {
           position: relative;
           z-index: 99;
+
           img {
             width: 24px;
             vertical-align: middle;
@@ -741,6 +699,7 @@ export default {
             position: absolute;
             top: 55px;
             left: -40px;
+
             li {
               margin-left: 10px;
               border-bottom: 1px solid #eeeeee;
@@ -788,19 +747,23 @@ export default {
   opacity: 0;
   height: 0;
 }
+
 .fade-enter-to,
 .fade-leave {
   opacity: 1;
   height: 122px;
 }
+
 .fade-enter-active,
 .fade-leave-active {
   transition: all 0.3s;
 }
+
 .dis_plays {
   display: flex;
   align-items: center;
 }
+
 .toolbth {
   border-radius: 55px;
   background-color: #fff;
@@ -817,10 +780,12 @@ export default {
   background-color: #3f8dfd !important;
   color: #fff;
 }
+
 .tooltipStyle .popper__arrow {
-  border-bottom-color: #3f8dfd!important;
+  border-bottom-color: #3f8dfd !important;
 }
+
 .tooltipStyle .popper__arrow::after {
-  border-bottom-color: #3f8dfd!important;
+  border-bottom-color: #3f8dfd !important;
 }
 </style>