Переглянути джерело

fix: 增加优惠码字段

wmf 8 місяців тому
батько
коміт
eefdc5cb54
2 змінених файлів з 10 додано та 5 видалено
  1. 2 2
      models/page.js
  2. 8 3
      server/views/pay.html

+ 2 - 2
models/page.js

@@ -28,7 +28,7 @@ const API = {
     if (code) {
       const idata = await inviter.findOne({ where: { code } });
       if (idata) {
-        price = fixPrice(oprice * idata.discount);
+        price = fixPrice(price * idata.discount);
         discount = idata.discount;
       }
     }
@@ -113,7 +113,7 @@ const API = {
       return onError('邀请码不存在');
     }
     const cdata = await course.findOne({ where: { id: cid } });
-    const { oprice } = cdata;
+    const { price: oprice } = cdata;
     const price = fixPrice(oprice * idata.discount);
     const discountPrice = fixPrice(oprice - price);
     return onSuccess({

+ 8 - 3
server/views/pay.html

@@ -76,8 +76,12 @@
                   <span>¥ <%= course.oprice%></span>
                 </li>
                 <li>
-                  <span id="code_sales">优惠:</span>
-                  <span id="code_price">- ¥ <%= course.discount%></span>
+                  <span>优惠:</span>
+                  <span>- ¥ <%= course.discount%></span>
+                </li>
+                <li id="code_sales_item" style="display:none">
+                  <span>推荐码优惠:</span>
+                  <span id="code_price">- ¥ 0</span>
                 </li>
                 <li>
                   <span>应付:</span>
@@ -178,15 +182,16 @@
             success: function (res){
               orderPay.checking = false
               if(res.code){
+                $('#code_sales_item').hide()
                 return $('#err_msg').addClass('error').html(res.msg)
               }
               $('#input_code').attr('disabled','disabled');
               $('#submit_code')[0].disabled=true
               $('#err_msg').addClass('success').html('推荐成功,已更新优惠价格')
               $('#code_price').html('- ¥ ' + res.data.discountPrice)
-              $('#code_sales').html('推荐码优惠:')
               $('#real_price').html(res.data.price)
               $('#price_info').html(res.data.price)
+              $('#code_sales_item').show()
             },
             error: function(err){
               orderPay.checking = false