Selaa lähdekoodia

Update subject-preview.vue

lex 1 vuosi sitten
vanhempi
commit
3d25a3d0e1
1 muutettua tiedostoa jossa 52 lisäystä ja 13 poistoa
  1. 52 13
      src/views/resetTeaming/modals/subject-preview.vue

+ 52 - 13
src/views/resetTeaming/modals/subject-preview.vue

@@ -55,13 +55,18 @@
               </el-col>
               <el-col :span="5">
                 <span style="color: #AAA; font-size: 12px;"
-                  >{{ item.num }}({{ item.period | unitFormat }})</span
+                  >{{ item.num | unitFormatMonth(item.period) }}个月</span
                 >
               </el-col>
               <el-col :span="7" style="text-align: right;">
                 <del style="color: #1A1A1A; font-size: 14px;width: 100%"
                   >¥{{
-                    child.monthPrice | unitFormatPrice(item.period, item.num)
+                    child.monthPrice
+                      | unitFormatPrice(
+                        item.period,
+                        item.num,
+                        child.halfYearPrice
+                      )
                   }}</del
                 >
               </el-col>
@@ -294,25 +299,36 @@ export default {
       formatList: [
         {
           title: "声部云练",
-          monthPrice: 240
+          monthPrice: 240,
+          halfYearPrice: 980
         },
         {
           title: "合奏云练",
-          monthPrice: 160
+          monthPrice: 160,
+          halfYearPrice: 580
         },
         {
           title: "独奏云练",
-          monthPrice: 160
+          monthPrice: 160,
+          halfYearPrice: 580
         },
         {
           title: "考级云练",
-          monthPrice: 160
+          monthPrice: 160,
+          halfYearPrice: 580
         },
         {
           title: "云课程",
-          monthPrice: 240
+          monthPrice: 240,
+          halfYearPrice: 980
         }
-      ]
+      ],
+      tempNum: {
+        YEAR: 12,
+        MONTH: 1,
+        QUARTERLY: 3,
+        YEAR_HALF: 6
+      }
     };
   },
   mounted() {
@@ -902,9 +918,16 @@ export default {
       };
       const num = (tempNum[item.period] || 1) * item.num;
       let price = 0;
-      this.formatList.forEach(format => {
-        price += Number(format.monthPrice * num);
-      });
+      if (num % 6 === 0) {
+        const halfYearNum = Number(num / 6);
+        this.formatList.forEach(format => {
+          price += Number(format.halfYearPrice * halfYearNum);
+        });
+      } else {
+        this.formatList.forEach(format => {
+          price += Number(format.monthPrice * num);
+        });
+      }
 
       return numeral(Number(price)).format("0,0.00");
     }
@@ -919,7 +942,16 @@ export default {
       };
       return template[val];
     },
-    unitFormatPrice(val, type, nums) {
+    unitFormatMonth(val, period) {
+      const tempNum = {
+        YEAR: 12,
+        MONTH: 1,
+        QUARTERLY: 3,
+        YEAR_HALF: 6
+      };
+      return val * (tempNum[period] || 1);
+    },
+    unitFormatPrice(val, type, nums, halfYearPrice) {
       const tempNum = {
         YEAR: 12,
         MONTH: 1,
@@ -927,7 +959,14 @@ export default {
         YEAR_HALF: 6
       };
       const num = (tempNum[type] || 1) * nums;
-      return numeral(Number(val * num)).format("0,0.00");
+      let price = 0;
+      if (num % 6 === 0) {
+        const halfYearNum = Number(num / 6);
+        price += Number(halfYearPrice * halfYearNum);
+      } else {
+        price += Number(val * num);
+      }
+      return numeral(price).format("0,0.00");
     }
   }
 };