Browse Source

卡券直充,指定价格与抵扣金额

DaMowang 2 years ago
parent
commit
425ea1ff3b
2 changed files with 49 additions and 25 deletions
  1. 33 16
      src/pagesB/directCharge/coupon.vue
  2. 16 9
      src/pagesB/directCharge/payment.vue

+ 33 - 16
src/pagesB/directCharge/coupon.vue

@@ -6,14 +6,22 @@
                     <image :src="i.cover_url" class="p_img" mode="aspectFill" />
                     <image :src="i.cover_url" class="p_img" mode="aspectFill" />
                     <div class="p_con">
                     <div class="p_con">
                         <div class="t">{{ i.product_name }}</div>
                         <div class="t">{{ i.product_name }}</div>
-                        <div class="p">{{ egralfun(i.official_price) }}</div>
-                        <div class="fp">官方价¥{{ $h.Div(i.official_price, 100) }}</div>
+                        <div class="p" v-if="i.custom_price>0">{{ $h.Sub($h.Div(i.custom_price, 100), i.custom_integral) }}</div>
+                        <div class="p" v-else>{{ egralfun(i.official_price) }}</div>
+                        <div class="fp" v-if="i.custom_price>0">官方价¥{{ $h.Div(i.custom_price, 100) }}</div>
+                        <div class="fp" v-else>官方价¥{{ $h.Div(i.official_price, 100) }}</div>
                         <span v-if="i.checked" class="colg iconfont">&#xe62c;</span>
                         <span v-if="i.checked" class="colg iconfont">&#xe62c;</span>
                     </div>
                     </div>
                 </div>
                 </div>
             </scroll-view>
             </scroll-view>
         </div>
         </div>
         <div class="product_con">
         <div class="product_con">
+            <div class="card">
+                <div class="li flex_r flex_jb">
+                    <span>使用账号</span>
+                    <input v-model="mobile" placeholder="请输入需要使用的账号" class="inp" />
+                </div>
+            </div>
             <div class="card">
             <div class="card">
                 <div class="li flex_r flex_jb">
                 <div class="li flex_r flex_jb">
                     <span>购买数量</span>
                     <span>购买数量</span>
@@ -26,7 +34,7 @@
                     <span>¥{{ cartTotal || 0 }}</span>
                     <span>¥{{ cartTotal || 0 }}</span>
                 </div>
                 </div>
                 <div class="li flex_r flex_jb">
                 <div class="li flex_r flex_jb">
-                    <span>消费金抵扣<span class="corg">{{Integral}}%</span></span>
+                    <span>消费金抵扣<span class="corg" v-if="selectitem.custom_price==0">{{Integral}}%</span></span>
                     <span class="corg">-¥{{ deduction || 0 }}</span>
                     <span class="corg">-¥{{ deduction || 0 }}</span>
                 </div>
                 </div>
                 <div class="li flex_r flex_jb">
                 <div class="li flex_r flex_jb">
@@ -67,6 +75,7 @@ export default {
             actuallypaid: 0,
             actuallypaid: 0,
             chabao: 0,
             chabao: 0,
             stock_num: 1,
             stock_num: 1,
+            mobile: uni.getStorageSync("userinfo").mobile,
         };
         };
     },
     },
     methods: {
     methods: {
@@ -91,6 +100,14 @@ export default {
                 }
                 }
             })
             })
         },
         },
+        // 获取产品详情
+        getproductInfo(va){
+            post("local/coupon/productInfo", { product_no: va, type: 0 }).then(res => {
+                if (res.code == 0 && res.data.code == 200) {
+                    this.stock_num = res.data.data.stock_num;
+                }
+            })
+        },
         ontag(key) {
         ontag(key) {
             let da = this.products;
             let da = this.products;
             da.forEach(value => this.$set(value, 'checked', false));
             da.forEach(value => this.$set(value, 'checked', false));
@@ -100,11 +117,16 @@ export default {
             this.getproductInfo(da[key].product_no);
             this.getproductInfo(da[key].product_no);
         },
         },
         egralf() {
         egralf() {
-            let i1 = this.egral.integral,
-                i2 = this.egral.chabao;
+            let i1 = this.egral.integral, i2 = this.egral.chabao;
             this.Integral = this.$h.Mul(i1, 100);
             this.Integral = this.$h.Mul(i1, 100);
-            this.cartTotal = this.$h.Mul(this.$h.Div(this.selectitem.official_price, 100), this.count)
-            this.deduction = this.$h.Mul(this.cartTotal, i1);
+            if(this.selectitem.custom_price > 0){
+                this.cartTotal = this.$h.Mul(this.$h.Div(this.selectitem.custom_price, 100), this.count)
+                this.deduction = this.$h.Mul(this.selectitem.custom_integral, this.count);
+            }
+            else {
+                this.cartTotal = this.$h.Mul(this.$h.Div(this.selectitem.official_price, 100), this.count)
+                this.deduction = this.$h.Mul(this.cartTotal, i1);
+            }
             this.actuallypaid = this.$h.Sub(this.cartTotal, this.deduction);
             this.actuallypaid = this.$h.Sub(this.cartTotal, this.deduction);
             this.chabao = this.$h.Mul(this.actuallypaid, i2);
             this.chabao = this.$h.Mul(this.actuallypaid, i2);
         },
         },
@@ -116,7 +138,7 @@ export default {
             let da = {
             let da = {
                 type: 3,
                 type: 3,
                 count: this.count,
                 count: this.count,
-                phone: uni.getStorageSync("userinfo").mobile,
+                phone: this.mobile,
                 product_no: this.selectitem.product_no,
                 product_no: this.selectitem.product_no,
             }
             }
             post("local/coupon/addOrder", da).then(res => {
             post("local/coupon/addOrder", da).then(res => {
@@ -131,14 +153,6 @@ export default {
                     });
                     });
                 }
                 }
             })
             })
-        },
-        // 获取产品详情
-        getproductInfo(va){
-            post("local/coupon/productInfo", { product_no: va, type: 0 }).then(res => {
-                if (res.code == 0 && res.data.code == 200) {
-                    this.stock_num = res.data.data.stock_num;
-                }
-            })
         }
         }
     },
     },
     created() {
     created() {
@@ -250,6 +264,9 @@ export default {
 
 
 .product_con {
 .product_con {
     padding: 28rpx 30rpx;
     padding: 28rpx 30rpx;
+    .inp{
+        text-align: right;
+    }
 }
 }
 
 
 .money {
 .money {

+ 16 - 9
src/pagesB/directCharge/payment.vue

@@ -14,7 +14,8 @@
         <div class="product clearfix">
         <div class="product clearfix">
             <div :class="{li:true,checked:i.checked}" v-for="(i,s) in products" :key="s" @click="ontag(s)" v-show="showfun(i)">
             <div :class="{li:true,checked:i.checked}" v-for="(i,s) in products" :key="s" @click="ontag(s)" v-show="showfun(i)">
                 <div class="p1">{{ i.product_name.replace(checked,"") }}</div>
                 <div class="p1">{{ i.product_name.replace(checked,"") }}</div>
-                <div class="p">{{ $h.Div(i.official_price, 100) }}</div>
+                <div class="p" v-if="i.custom_price>0">{{ $h.Div(i.custom_price, 100) }}</div>
+                <div class="p" v-else>{{ $h.Div(i.official_price, 100) }}</div>
             </div>
             </div>
         </div>
         </div>
         <template v-if="cartTotal>0">
         <template v-if="cartTotal>0">
@@ -24,7 +25,7 @@
                     <span>¥{{ cartTotal || 0 }}</span>
                     <span>¥{{ cartTotal || 0 }}</span>
                 </div>
                 </div>
                 <div class="li flex_r flex_jb">
                 <div class="li flex_r flex_jb">
-                    <span>消费金抵扣<span class="corg">{{Integral}}%</span></span>
+                    <span>消费金抵扣<span class="corg" v-if="selectitem.custom_price==0">{{Integral}}%</span></span>
                     <span class="corg">-¥{{ deduction || 0 }}</span>
                     <span class="corg">-¥{{ deduction || 0 }}</span>
                 </div>
                 </div>
                 <div class="li flex_r flex_jb">
                 <div class="li flex_r flex_jb">
@@ -101,17 +102,23 @@ export default {
         egralfun(){
         egralfun(){
             let i1 = this.egral.integral, i2 = this.egral.chabao;
             let i1 = this.egral.integral, i2 = this.egral.chabao;
             this.Integral = this.$h.Mul(i1,100);
             this.Integral = this.$h.Mul(i1,100);
-            this.cartTotal = this.$h.Div(this.selectitem.official_price, 100)
-            this.deduction = this.$h.Mul(this.cartTotal,i1).toFixed(2);
+            if(this.selectitem.custom_price > 0){
+                this.cartTotal = this.$h.Div(this.selectitem.custom_price, 100);
+                this.deduction = this.$h.Mul(this.selectitem.custom_integral, 1);
+            }
+            else {
+                this.cartTotal = this.$h.Div(this.selectitem.official_price, 100)
+                this.deduction = this.$h.Mul(this.cartTotal,i1).toFixed(2);
+            }
             this.actuallypaid = this.$h.Sub(this.cartTotal,this.deduction);
             this.actuallypaid = this.$h.Sub(this.cartTotal,this.deduction);
             this.chabao = this.$h.Mul(this.actuallypaid,i2).toFixed(2);
             this.chabao = this.$h.Mul(this.actuallypaid,i2).toFixed(2);
         },
         },
         pay() {
         pay() {
-            var reg =/^0?1[3|4|5|6|7|8][0-9]\d{8}$/;
-            if(!reg.test(this.phone)){
-                uni.showToast({title: `请输入正确的${this.topupBrand.name}账号`, icon: "none"})
-                return;
-            }
+            // var reg =/^0?1[3|4|5|6|7|8][0-9]\d{8}$/;
+            // if(!reg.test(this.phone)){
+            //     uni.showToast({title: `请输入正确的${this.topupBrand.name}账号`, icon: "none"})
+            //     return;
+            // }
             let da = {
             let da = {
                 type: 2,
                 type: 2,
                 count: 1,
                 count: 1,