Bladeren bron

商城优惠劵

skyblued 2 jaren geleden
bovenliggende
commit
ddad01bf6b

+ 22 - 3
src/views/cart/cart-confirm-agin/index.tsx

@@ -1,4 +1,4 @@
-import { computed, ref, defineComponent, onMounted, reactive,watch } from 'vue'
+import { computed, ref, defineComponent, onMounted, reactive, watch } from 'vue'
 import { Card, Cell, CellGroup, Popup, SubmitBar, Toast } from 'vant'
 import { addressType, cartConfirm, formateAttr } from '../cart'
 import styles from '../index.module.less'
@@ -12,6 +12,7 @@ import ColPopup from '@/components/col-popup'
 import UserAuth from '@/views/order-detail/userAuth'
 import ColResult from '@/components/col-result'
 import { moneyFormat } from '@/helpers/utils'
+import UseCoupons, { couponEnum } from '@/views/order-detail/use-coupons'
 export default defineComponent({
   name: 'cartConfirmAgin',
   setup() {
@@ -20,7 +21,8 @@ export default defineComponent({
     const calcAmount = {
       totalAmount: cartConfirm.orderInfo?.totalAmount || 0,
       payAmount: cartConfirm.orderInfo?.payAmount || 0,
-      freightAmount: cartConfirm.orderInfo?.freightAmount || 0
+      freightAmount: cartConfirm.orderInfo?.freightAmount || 0,
+      couponAmount: cartConfirm.orderInfo?.couponAmount
     }
     const payType = ref(0) // 0->未支付;1->支付宝;2->微信
     const address: addressType = {
@@ -105,6 +107,23 @@ export default defineComponent({
               <CellGroup border={false}>
                 <Cell
                   border={false}
+                  title="优惠劵"
+                  v-slots={{
+                    value: () => (
+                      <span
+                        style={{
+                          fontSize: '0.42667rem',
+                          color: '#ff3535',
+                          fontWeight: 'bold'
+                        }}
+                      >
+                        {'-¥ ' + calcAmount.couponAmount}
+                      </span>
+                    )
+                  }}
+                ></Cell>
+                <Cell
+                  border={false}
                   title="总额"
                   value={'¥ ' + calcAmount.totalAmount}
                 ></Cell>
@@ -113,7 +132,7 @@ export default defineComponent({
                   title="运费"
                   value={calcAmount.freightAmount}
                 ></Cell>
-                <Cell border={false} title="优惠" value={'-¥ ' + cartConfirm.orderInfo?.promotionAmount}></Cell> */}
+                 */}
                 {/* <Cell border={false} title="优惠卷" value="暂无可用优惠卷"></Cell>
             <Cell border={false} title="乐乐币抵扣" value={"-¥" + calcAmount.promotionAmount}></Cell> */}
               </CellGroup>

+ 36 - 15
src/views/cart/cart-confirm/index.tsx

@@ -25,6 +25,7 @@ import {
   postMessage,
   removeListenerMessage
 } from '@/helpers/native-message'
+import UseCoupons, { couponEnum } from '@/views/order-detail/use-coupons'
 export default defineComponent({
   name: 'cartConfirm',
   setup() {
@@ -77,7 +78,8 @@ export default defineComponent({
     const authPopup = ref(false)
     const orderInfo = reactive({
       orderNo: '',
-      actualPrice: 0
+      actualPrice: 0,
+      couponId: ''
     })
     //修复实名认证头部问题
     watch(authPopup, (value, oldValue) => {
@@ -125,7 +127,9 @@ export default defineComponent({
       const body = {
         cartIds: ids,
         memberReceiveAddressId: address.value?.id,
-        platformType: state.platformType
+        platformType: state.platformType,
+        orderAmount: (cartConfirm.calcAmount.payAmount - cartConfirm.calcAmount.promotionAmount).toFixed(2),
+        couponId: orderInfo.couponId
       }
       try {
         let { code, data } = await request.post(
@@ -185,25 +189,42 @@ export default defineComponent({
                     ))}
                   </div>
                   <CellGroup border={false}>
-                    <Cell
-                      border={false}
-                      title="总额"
-                      value={
-                        '¥ ' + moneyFormat(cartConfirm.calcAmount.totalAmount)
-                      }
-                    ></Cell>
                     {/* <Cell
                     border={false}
                     title="运费"
                     value={moneyFormat(cartConfirm.calcAmount.freightAmount)}
                   ></Cell>
-                  <Cell
-                    border={false}
-                    title="优惠"
-                    value={'-¥ ' + moneyFormat(cartConfirm.calcAmount.promotionAmount)}
-                  ></Cell> */}
+                  
                     {/* <Cell border={false} title="优惠卷" value="暂无可用优惠卷"></Cell>
               <Cell border={false} title="乐乐币抵扣" value={"-¥" + cartConfirm.calcAmount.promotionAmount}></Cell> */}
+                    <UseCoupons
+                      orderType={couponEnum.GOODS}
+                      orderAmount={cartConfirm.calcAmount.totalAmount}
+                      onCouponSelect={(coupon) => {
+                        const discountPrice = coupon.map(n => n.discountPrice).reduce((total,n) => {
+                          return total + n
+                        },0)
+                        const couponId = coupon.map(n => n.couponIssueId).join(',')
+                        cartConfirm.calcAmount.promotionAmount = discountPrice
+                        orderInfo.couponId = couponId
+                      }}
+                    />
+                    {/* <Cell
+                      border={false}
+                      title="优惠"
+                      value={
+                        '-¥ ' +
+                        moneyFormat(cartConfirm.calcAmount.promotionAmount)
+                      }
+                    ></Cell> */}
+
+                    <Cell
+                      border={false}
+                      title="总额"
+                      value={
+                        '¥ ' + moneyFormat(cartConfirm.calcAmount.totalAmount)
+                      }
+                    ></Cell>
                   </CellGroup>
                 </div>
 
@@ -218,7 +239,7 @@ export default defineComponent({
                     <div class={styles.confirmBottom}>
                       合计{' '}
                       <span class={styles['price-des']}>
-                        ¥{moneyFormat(cartConfirm.calcAmount.payAmount)}
+                        ¥{moneyFormat(cartConfirm.calcAmount.payAmount - cartConfirm.calcAmount.promotionAmount)}
                       </span>
                     </div>
                   </SubmitBar>

+ 8 - 5
src/views/goods-order/components/after-sale-btns/index.tsx

@@ -34,11 +34,14 @@ export default defineComponent({
         v-slots={{
           title: () => (
             <div class={styles.orderPrice}>
-              订单金额
-              <span class={styles.price} style={{ paddingLeft: '5px' }}>
-                <i>¥</i>
-                {moneyFormat(item.payAmount)}
-              </span>
+              <div>
+                订单金额
+                <span class={styles.price} style={{ paddingLeft: '5px' }}>
+                  <i>¥ </i>
+                  {moneyFormat(item.payAmount)}
+                </span>
+              </div>
+              { !!item.couponAmount && <div class={styles.coupon}>优惠劵: -¥ {moneyFormat(item.couponAmount)}</div>}
             </div>
           ),
           default: () => (

+ 4 - 0
src/views/goods-order/index.module.less

@@ -83,6 +83,10 @@
     font-style: normal;
   }
 }
+.coupon{
+  font-size: 12px;
+  color: #ff4e19;
+}
 
 .sureGoods {
   padding-right: 12px;

+ 1 - 1
src/views/shop-mall/shop-order-detail/index.tsx

@@ -103,7 +103,7 @@ export default defineComponent({
               <Cell
                 border={false}
                 title="优惠价格:"
-                value={'-¥ ' + moneyFormat(order.value?.promotionAmount)}
+                value={'-¥ ' + moneyFormat(order.value?.couponAmount)}
               ></Cell>
               <Cell
                 border={false}