Browse Source

画刊订阅

natasha 1 năm trước cách đây
mục cha
commit
6d50379538
1 tập tin đã thay đổi với 144 bổ sung80 xóa
  1. 144 80
      src/views/bookStore/Subscribe.vue

+ 144 - 80
src/views/bookStore/Subscribe.vue

@@ -169,8 +169,11 @@
                   <li
                     v-for="item in orderList"
                     :key="item.value"
-                    :class="[orderTotalNumber === item.value ? 'active' : '']"
-                    @click="changeOrderNumber(item)"
+                    :class="[
+                      orderTotalNumber === item.value ? 'active' : '',
+                      totalLength < item.value ? 'disabled' : '',
+                    ]"
+                    @click="changeOrderNumber(item, totalLength < item.value)"
                   >
                     {{ item.label }}
                   </li>
@@ -318,13 +321,13 @@
                 >
               </div>
             </div>
-            <div class="info-item order-item" v-if="bookType === 'huakan'">
+            <!-- <div class="info-item order-item" v-if="bookType === 'huakan'">
               <label>结算价格</label>
               <div class="order-content">
                 <span class="OPPOSans">¥28.80</span>
                 <span class="old-price">¥30.20</span>
               </div>
-            </div>
+            </div> -->
           </div>
           <div class="btn-box">
             <el-button
@@ -611,6 +614,7 @@ export default {
       settlement: null, // 结算价格
       createOrderLoading: false,
       valid_period_id: null,
+      totalLength: 0,
     };
   },
   //计算属性 类似于data概念
@@ -646,12 +650,15 @@ export default {
       this.paymentShow = false;
     },
     // 详情
-    getInfo() {
+    getInfo(flag) {
       this.loading = true;
+      if (flag) {
+      }
       if (this.bookType === "baozhi") {
         let MethodName =
           "/ShopServer/Client/ReservationQuery/GetReservationInfo_Issue";
         let data = {
+          goods_type: 2,
           study_phase: this.studyType,
           period_count:
             this.orderTotalNumber !== -1
@@ -688,78 +695,98 @@ export default {
           .catch(() => {
             this.loading = false;
           });
-        this.handleOrderPrice();
+        if (
+          this.totalLength >=
+          (this.orderTotalNumber !== -1
+            ? this.orderTotalNumber
+            : this.customOrderNumberList.length)
+        ) {
+          this.handleOrderPrice();
+        } else {
+          this.settlement = null;
+        }
       } else if (this.bookType === "huakan") {
         this.loading = false;
-        this.info = {
-          issue_no_end: "928",
-          issue_no_school_year_list: [],
-          issue_info: {
-            period_desc: "每月出版,2月、 8月休刊",
-            age_desc: "5-8 岁",
-            price: 10,
-            organizer: "中国日报社《二十一世纪学生英文报》",
-            page_count_desc: "24 页",
-          },
-          price_reservation: 10,
-          issue_no_begin: "929",
-          issue_no_list: [
-            {
-              shelve_date: "2024-07-31",
-              issue_no: "929",
-              price: 2.4,
-            },
-            {
-              shelve_date: "2025-07-10",
-              issue_no: "931",
-              price: 2.4,
-            },
-            {
-              shelve_date: "2025-08-07",
-              issue_no: "928",
-              price: 2.4,
-            },
-          ],
-        };
-        // let MethodName =
-        //   "/ShopServer/Client/ReservationQuery/GetReservationInfo_Issue";
-        // let data = {
-        //   period_count:
-        //     this.orderTotalNumber !== -1
-        //       ? this.orderTotalNumber
-        //       : this.customOrderNumberList.length,
-        //   is_custom_select_issue_no:
-        //     this.orderTotalNumber !== -1 ? "false" : "true",
+        // this.info = {
+        //   issue_no_end: "928",
+        //   issue_no_school_year_list: [],
+        //   issue_info: {
+        //     period_desc: "每月出版,2月、 8月休刊",
+        //     age_desc: "5-8 岁",
+        //     price: 10,
+        //     organizer: "中国日报社《二十一世纪学生英文报》",
+        //     page_count_desc: "24 页",
+        //   },
+        //   price_reservation: 10,
+        //   issue_no_begin: "929",
+        //   issue_no_list: [
+        //     {
+        //       shelve_date: "2024-07-31",
+        //       issue_no: "929",
+        //       price: 2.4,
+        //     },
+        //     {
+        //       shelve_date: "2025-07-10",
+        //       issue_no: "931",
+        //       price: 2.4,
+        //     },
+        //     {
+        //       shelve_date: "2025-08-07",
+        //       issue_no: "928",
+        //       price: 2.4,
+        //     },
+        //   ],
         // };
-        // getLogin(MethodName, data)
-        //   .then((res) => {
-        //     this.loading = false;
-        //     if (res.status === 1) {
-        //       this.info = res;
-        //       this.orderTable = res.issue_no_list;
-        //       res.issue_no_school_year_list.forEach((item) => {
-        //         item.issue_no_list.forEach((items, indexs) => {
-        //           const regex = /[\u4e00-\u9fa5]/g;
-        //           if (regex.test(items.issue_no)) {
-        //             items.width = Math.ceil(items.issue_no.length / 3);
-        //             items.number = item.issue_no_list[indexs - 1]
-        //               ? item.issue_no_list[indexs - 1].number +
-        //                 Math.ceil(items.issue_no.length / 3)
-        //               : Math.ceil(items.issue_no.length / 3);
-        //           } else {
-        //             items.width = 1;
-        //             items.number = item.issue_no_list[indexs - 1]
-        //               ? item.issue_no_list[indexs - 1].number + 1
-        //               : 1;
-        //           }
-        //         });
-        //       });
-        //     }
-        //   })
-        //   .catch(() => {
-        //     this.loading = false;
-        //   });
-        // this.handleOrderPrice();
+        let MethodName =
+          "/ShopServer/Client/ReservationQuery/GetReservationInfo_Issue";
+        let data = {
+          goods_type: 4,
+          study_phase: 1,
+          period_count:
+            this.orderTotalNumber !== -1
+              ? this.orderTotalNumber
+              : this.customOrderNumberList.length,
+          is_custom_select_issue_no:
+            this.orderTotalNumber !== -1 ? "false" : "true",
+        };
+        getLogin(MethodName, data)
+          .then((res) => {
+            this.loading = false;
+            if (res.status === 1) {
+              this.info = res;
+              this.orderTable = res.issue_no_list;
+              res.issue_no_school_year_list.forEach((item) => {
+                item.issue_no_list.forEach((items, indexs) => {
+                  const regex = /[\u4e00-\u9fa5]/g;
+                  if (regex.test(items.issue_no)) {
+                    items.width = Math.ceil(items.issue_no.length / 3);
+                    items.number = item.issue_no_list[indexs - 1]
+                      ? item.issue_no_list[indexs - 1].number +
+                        Math.ceil(items.issue_no.length / 3)
+                      : Math.ceil(items.issue_no.length / 3);
+                  } else {
+                    items.width = 1;
+                    items.number = item.issue_no_list[indexs - 1]
+                      ? item.issue_no_list[indexs - 1].number + 1
+                      : 1;
+                  }
+                });
+              });
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+        if (
+          this.totalLength >=
+          (this.orderTotalNumber !== -1
+            ? this.orderTotalNumber
+            : this.customOrderNumberList.length)
+        ) {
+          this.handleOrderPrice();
+        } else {
+          this.settlement = null;
+        }
       } else {
         let MethodName =
           "/ShopServer/Client/ReservationQuery/GetReservationValidPeriodList_Iread";
@@ -793,11 +820,12 @@ export default {
       }
     },
     // 计算结算价格
-    handleOrderPrice() {
+    handleOrderPrice(flag) {
       this.loading = true;
       let MethodName =
         "/ShopServer/Client/ReservationQuery/ComputeReservationSettlementPrice_Issue";
       let data = {
+        goods_type: this.bookType === "huakan" ? 4 : 2,
         study_phase: this.studyType,
         period_count:
           this.orderTotalNumber !== -1
@@ -834,13 +862,14 @@ export default {
       }
       this.handleOrderPrice();
     },
-    changeStudy(item) {
+    async changeStudy(item) {
       this.studyType = item.study_phase;
       this.studyTypeName = item.study_phase_name;
       this.customOrderNumberList = [];
-      this.getInfo();
+      await this.handleIssueLength();
     },
-    changeOrderNumber(item) {
+    changeOrderNumber(item, flag) {
+      if (flag) return false;
       this.orderTotalNumber = item.value;
       this.getInfo();
     },
@@ -950,9 +979,34 @@ export default {
         })
         .catch(() => {});
     },
+    // 获取已发行期数
+    handleIssueLength() {
+      let MethodName =
+        "/ShopServer/Client/ReservationQuery/GetReservationInfo_Issue";
+      let data = {
+        goods_type: this.bookType === "baozhi" ? 2 : 4,
+        study_phase: this.bookType === "baozhi" ? this.studyType : 1,
+        period_count:
+          this.orderTotalNumber !== -1
+            ? this.orderTotalNumber
+            : this.customOrderNumberList.length,
+        is_custom_select_issue_no: "true",
+      };
+      getLogin(MethodName, data)
+        .then((res) => {
+          if (res.status === 1) {
+            this.totalLength = 0;
+            res.issue_no_school_year_list.forEach((item) => {
+              this.totalLength += item.issue_no_list.length;
+            });
+            this.getInfo();
+          }
+        })
+        .catch(() => {});
+    },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
-  created() {
+  async created() {
     if (this.config) {
       let arr = this.config.split("&&&");
       this.LoginNavIndex = arr[0] * 1;
@@ -961,7 +1015,11 @@ export default {
       this.headerBg = arr[3] ? arr[3] : "#00ADEF";
       this.previousPage = arr[4] ? arr[4] : "商城";
     }
-    this.getInfo();
+    if (this.bookType === "baozhi" || this.bookType === "huakan") {
+      await this.handleIssueLength();
+    } else {
+      this.getInfo();
+    }
     this.getDiscountRule();
     let date1 =
       new Date().getFullYear() +
@@ -1182,6 +1240,12 @@ export default {
                     background: #ffffff;
                     border-color: #ea5939;
                   }
+                  &.disabled {
+                    cursor: not-allowed;
+                    background: #f2f3f5;
+                    color: #bababa;
+                    border-color: #f2f3f5;
+                  }
                 }
               }
               .el-table {