Răsfoiți Sursa

feat:订单详情选择优惠券或权益卡

zhanghui 5 luni în urmă
părinte
comite
4f6dee3909
3 a modificat fișierele cu 147 adăugiri și 64 ștergeri
  1. 11 0
      common/js/api.js
  2. 42 13
      orderPages/orderDetail/index.rpx.scss
  3. 94 51
      orderPages/orderDetail/index.vue

+ 11 - 0
common/js/api.js

@@ -1025,4 +1025,15 @@ export default {
     },
 
 
+    // 订单支付页面选择优惠券或者权益卡列表
+    oneClickPayV2(data) {
+        return request({
+            url: '/business/wechat/order/oneClickPay/v2',
+            method: 'post',
+            data: data
+        })
+    },
+
+
+
 }

+ 42 - 13
orderPages/orderDetail/index.rpx.scss

@@ -374,15 +374,13 @@
   border: 2rpx solid #cccccc;
   border-left: 10rpx solid #cccccc;
   border-radius: 16rpx;
-  padding: 30rpx;
   margin-top: 30rpx;
 }
 
 .icon1{
   background-color: #cccccc;
-  width: 80rpx;
-  height: 80rpx;
-  border-radius: 10rpx;
+  width: 130rpx;
+  height: 120rpx;
 
   color: #F5F5F5;
   text-align: center;
@@ -399,8 +397,14 @@
   border-radius: 10rpx;
   color: #ff5a5f;
   font-size: 28rpx;
-  padding:10rpx 30rpx;
+  padding:5rpx 10rpx;
 }
+
+.couponBtn1{
+  color: #cccccc;
+  font-size: 28rpx;
+}
+
 .couponType{
   padding: 0 10rpx;
   font-size: 24rpx;
@@ -413,25 +417,50 @@
 
 
 .coupon2{
-  border: 2rpx solid #ff5a5f;
-  border-left: 10rpx solid #ff5a5f;
+  border: 2rpx solid #ffe05c;
+  border-left: 10rpx solid #ffe05c;
+  border-radius: 16rpx;
+  margin-top: 30rpx;
+}
+
+.coupon3{
+  border: 2rpx solid #cccccc;
+  border-left: 10rpx solid #cccccc;
   border-radius: 16rpx;
-  padding: 30rpx;
   margin-top: 30rpx;
 }
 
 
 .icon2{
-  background-color: #ff5a5f;
-  width: 80rpx;
+  background-color: #ffe05c;
+  width: 150rpx;
   height: 100%;
-  border-radius: 10rpx;
 
-  color: #F5F5F5;
   text-align: center;
-  font-size: 24rpx;
+  font-size: 30rpx;
+  font-weight: bold;
+}
+
+.icon3{
+  background-color: #cccccc;
+  width: 150rpx;
+  height: 100%;
+
+  text-align: center;
+  font-size: 30rpx;
   font-weight: bold;
 }
+
+.reachPrice{
+  font-size: 24rpx;
+  font-weight: 400;
+  text-align: center;
+}
+
+.couponMsg{
+  padding: 30rpx 0;
+  width: 370rpx;
+}
 .couponValue{
   color: #333333;
   font-size: 24rpx;

+ 94 - 51
orderPages/orderDetail/index.vue

@@ -130,16 +130,18 @@
 						</view>
 					</view>
 
-          <view class="flex-row justify-between key" v-if="item.status == 1 || item.status == 8">
+          <view class="flex-row justify-between key">
             <view class="flex-row">
               <u-icon size="16" name="coupon"></u-icon>
               <text>优惠选择:</text>
             </view>
-            <view class="flex-row justify-between value  flex1" style="height: 100%" @click="openCoupon(item,index)">
+            <view class="flex-row  value  flex1 " style="height: 100%" @click="openCoupon(item,index)">
               <text v-if="item.suggestType == 0">选择优惠券或权益卡</text>
-              <text v-if="item.suggestType == 1">{{ item.suggestCoupon.name }} {{ item.suggestType }}</text>
-              <text v-if="item.suggestType == 2">{{ item.suggestEquityCard.name }} {{ item.suggestType }}</text>
-              <u-icon size="12" name="arrow-right"></u-icon>
+              <text v-if="item.suggestType == 1">{{ item.suggestCoupon.name }} </text>
+              <text v-if="item.suggestType == 2">{{ item.suggestEquityCard.equityCardName }} </text>
+              <view class="flex-col justify-center">
+                <u-icon v-if="order.orderStatus != 1 || order.orderStatus != 3" size="12" name="arrow-right"></u-icon>
+              </view>
             </view>
           </view>
 
@@ -293,17 +295,22 @@
           <text>优惠选择</text>
         </view>
 
-        <view  style="height: 700rpx;overflow: auto" >
+        <scroll-view scroll-y style="height: 700rpx">
           <view class="flex-row justify-between coupon1">
             <view class="flex-row justify-start">
               <view class="flex-col justify-center icon1">
                 <text>0</text>
               </view>
-              <view class="flex-col justify-center couponName">
-                <text>不选择优惠</text>
+
+              <view class="flex-col justify-center couponMsg">
+                <view class="flex-col justify-center couponName">
+                  <text>不选择优惠</text>
+                </view>
               </view>
+
+
             </view>
-            <view class="flex-col justify-center " >
+            <view class="flex-col justify-center " style="margin-right: 30rpx">
               <text class="couponBtn"  @click="use(item,0)">选择</text>
             </view>
           </view>
@@ -318,12 +325,14 @@
             </view>
           </view>
 
-          <view class="flex-row justify-between coupon2" v-for="(item,index) in availableCouponList" :key="index">
+          <view class="flex-row justify-start" :class="[item.canUse? 'coupon2' : 'coupon3']"  v-for="(item,index) in availableCouponList" :key="index">
             <view class="flex-row justify-start">
-              <view class="flex-col justify-center icon2">
-                <text>{{item.discountsPrice}}</text>
+              <view class="flex-col justify-center " :class="[item.canUse? 'icon2' : 'icon3']">
+                <text  v-if="item.discountsType == 1">减{{item.discountsPrice}}</text>
+                <text  v-if="item.discountsType == 2">{{item.discount}}折</text>
+                <text class="reachPrice">满{{item.reachPrice}}可用</text>
               </view>
-              <view class="flex-col justify-center">
+              <view class="flex-col justify-center couponMsg">
                 <view class="flex-col justify-center couponName">
                   <text>{{item.name}}</text>
                 </view>
@@ -331,13 +340,21 @@
                   <text>使用项目:{{item.useServiceDesc}}</text>
                 </view>
                 <view class="flex-col justify-center couponValue">
-                  <text>使用金额:{{item.reachPrice}}</text>
+                  <text>可用门店:{{item.useStoreDesc}}</text>
+                </view>
+                <view class="flex-col justify-center couponValue" v-if="!item.canUse">
+                  <text>不可用原因:{{item.unavailabilityReason}}</text>
                 </view>
               </view>
             </view>
-            <view class="flex-col justify-center" >
+            <view class="flex-col justify-center" v-if="item.canUse">
               <text class="couponBtn" @click="use(item,1)">立即使用</text>
             </view>
+
+            <view class="flex-col justify-center" v-else>
+              <text class="couponBtn1">不可用</text>
+            </view>
+
           </view>
 
 
@@ -351,27 +368,44 @@
             </view>
           </view>
 
-          <view class="flex-row justify-between coupon2" v-for="(item,index) in availableEquityCardList" :key="index">
+          <view class="flex-row justify-start " :class="[item.canUse? 'coupon2' : 'coupon3']" v-for="(item,index) in availableEquityCardList" :key="index">
             <view class="flex-row justify-start">
-              <view class="flex-col justify-center icon2">
+              <view class="flex-col justify-center" :class="[item.canUse? 'icon2' : 'icon3']">
                 <text>{{item.faceValue}}</text>
               </view>
 
-              <view class="flex-col justify-center">
+              <view class="flex-col justify-center couponMsg">
                 <view class="flex-col justify-center couponName">
-                  <text>{{item.title}}</text>
+                  <text>{{item.equityCardName}}</text>
+                </view>
+                <view class="flex-col justify-center couponValue">
+                  <text>适用项目:{{item.serviceProjectName || ''}}</text>
+                </view>
+                <view class="flex-col justify-center couponValue">
+                  <text>适用门店:{{ item.useStoreDesc || '' }}</text>
                 </view>
                 <view class="flex-col justify-center couponValue">
-                  <text>使用项目:{{item.serviceProjectName}}</text>
+                  <text>绑定对象:{{item.serviceObjectName}}</text>
+                </view>
+                <view class="flex-col justify-center couponValue">
+                  <text>结束期限:{{item.effectiveEndTime.substring(0,10)}}</text>
+                </view>
+                <view class="flex-col justify-center couponValue" v-if="!item.canUse">
+                  <text>不可用原因:{{item.unavailabilityReason}}</text>
                 </view>
               </view>
             </view>
-            <view class="flex-col justify-center" >
-              <text class="couponBtn" @click="use(item,2)">立即使用</text>
+            <view class="flex-col justify-center" v-if="item.canUse">
+              <text class="couponBtn"  @click="use(item,2)">立即使用</text>
+            </view>
+
+            <view class="flex-col justify-center" v-else>
+              <text class="couponBtn1">不可用</text>
             </view>
+
           </view>
 
-        </view>
+        </scroll-view>
 
       </view>
     </uni-popup>
@@ -422,19 +456,31 @@
       use(item,suggestType){
 
         if (suggestType == 1){
+          //使用优惠券
+          this.availableChild.suggestEquityCard = null
           this.availableChild.suggestType = 1
           this.availableChild.suggestCoupon = item
-          this.availableChild.discountAmount = item.discountsPrice
-          this.availableChild.payAmount =  this.availableChild.servicePrice - item.discountsPrice
+          if (item.discountsType == 1){
+            //满减优惠券
+            this.availableChild.discountAmount = item.discountsPrice
+            this.availableChild.payAmount =  this.availableChild.servicePrice - item.discountsPrice
+          }else {
+            //折扣券
+            this.availableChild.discountAmount = (this.availableChild.servicePrice * (item.discounts / 10).toFixed(2)).toFixed(2)
+            this.availableChild.payAmount =  this.availableChild.servicePrice - this.availableChild.discountAmount
+          }
         }else if (suggestType == 2){
+          //使用权益卡
+          this.availableChild.suggestCoupon = null
           this.availableChild.suggestType = 2
           this.availableChild.suggestEquityCard = item
-          this.availableChild.discountAmount = item.faceValue
-          this.availableChild.payAmount =  this.availableChild.servicePrice - item.faceValue
+          this.availableChild.discountAmount = this.availableChild.servicePrice - item.faceValue
+          this.availableChild.payAmount =  item.faceValue
         }else {
+          //不使用优惠
           this.availableChild.suggestType =  0
-          this.availableChild.suggestCoupon = []
-          this.availableChild.suggestEquityCard = []
+          this.availableChild.suggestCoupon = null
+          this.availableChild.suggestEquityCard = null
           this.availableChild.discountAmount = 0
           this.availableChild.payAmount =  this.availableChild.servicePrice
         }
@@ -457,6 +503,10 @@
       },
 
       openCoupon(item,index){
+        if (this.order.orderStatus == 1 ||  this.order.orderStatus == 3){
+          return
+        }
+
         console.log(item)
         this.availableIndex = index
         this.availableChild = item
@@ -628,33 +678,26 @@
 			},
 
 			qenPayInfo(){
-				//
-				// for(let i=0;i<this.order.child.length;i++){
-				// 	if (this.order.child[i].status==3){
-				// 		uni.$u.toast('子订单未审核结束')
-				// 		return
-				// 	}
-				// }
-				// let orderServiceIds = []
-				// this.order.child.forEach(i=>{
-				// 	if (i.status !=5){ //排除审核通过的子订单
-				// 		orderServiceIds.push(i.orderServiceId)
-				// 	}
-				// })
-				this.$api.oneClickPay({
-					orderId:this.order.orderId
+
+        let childArr = []
+        for (const child of this.order.child) {
+          console.log('+++++++++++++++++++++',child)
+          let c = {
+            orderServiceId:child.orderServiceId,
+            couponId: child.suggestCoupon ? child.suggestCoupon.id : null,
+            equityCardId: child.suggestEquityCard ? child.suggestEquityCard.id : null,
+          }
+          childArr.push(c)
+        }
+
+				this.$api.oneClickPayV2({
+					orderId:this.order.orderId,
+          serviceChildren:childArr
 				}).then(res=>{
 					this.tradeNo = res.data.data.tradeNo
 					this.$refs.popup.open()
 				})
 
-				// this.$api.qenPayInfo({
-				// 	orderServiceIds:orderServiceIds,
-				// 	orderNo:this.order.orderNo
-				// }).then(res=>{
-				// 	this.tradeNo=res.data.data.tradeNo
-				// 	this.$refs.popup.open()
-				// })
 			},
 
 			commitAppeal(){