Selaa lähdekoodia

添加购买优惠券的功能

lighter 1 vuosi sitten
vanhempi
commit
5a6c5bdb5d

+ 9 - 2
src/api/coupon.js

@@ -16,11 +16,18 @@ export function receiveSalesmanCoupon(key) {
     })
 }
 
-
 export function getMyCoupons(data) {
     return request({
         url: '/coupon/getMyCoupons',
         method: 'post',
         data
     })
-}
+}
+
+export function getCouponInfo(key) {
+    return request({
+        url: '/coupon/getCouponInfo',
+        method: 'get',
+        params: { key },
+    })
+}

+ 7 - 0
src/router/index.js

@@ -370,6 +370,13 @@ export const constantRoutes = [
       title: '领取优惠券',
     },
   },
+  {
+    path: '/buyCoupon/:key',
+    component: () => import('../views/isolations/BuyCoupon.vue'),
+    meta: {
+      title: '购买优惠券',
+    },
+  },
   {
     path: '/selectPriceQueryBranch',
     component: () => import('../views/hospital-service/query-price/SelectPriceQueryBranch.vue'),

+ 1 - 3
src/utils/request.js

@@ -45,9 +45,7 @@ service.interceptors.response.use(
                 title: '提示',
                 message: response.data.message,
             }).then(() => {
-                if (response.data.code === 3001) {
-                    WeixinJSBridge.call('closeWindow')
-                }
+                WeixinJSBridge.call('closeWindow')
             })
         }
         return Promise.reject(new Error(response.data.message || '服务器内部错误'));

+ 141 - 0
src/views/isolations/BuyCoupon.vue

@@ -0,0 +1,141 @@
+<template>
+  <window-size class="buy-coupon">
+    <div class="coupon-box">
+      <div class="flex">
+        <div class="value-box">
+          <div class="amount-box">
+            <span class="amount">{{coupon.value}}</span>
+            <span>&nbsp;元</span>
+          </div>
+          <div class="description">
+            {{coupon.description}}
+          </div>
+          <div class="description" style="color: #1c1c1e">
+            购买价格:¥{{coupon.price}}
+          </div>
+        </div>
+        <div class="name-box">
+          <div class="name">
+            {{coupon.name}}
+          </div>
+          <div class="time">
+            {{makeStartDate()}} - 2099.12.31
+          </div>
+        </div>
+      </div>
+      <div v-if="coupon.availableCharge" class="charge-name">
+        <span class="alert">
+          可用项目:
+        </span>
+        {{coupon.availableChargeName}}
+      </div>
+      <van-button
+          block
+          type="success"
+          :style="{marginTop: coupon.availableCharge ? '10px' : '20px'}"
+          @click="toCashier"
+      >
+        前往购买(¥{{coupon.price}})
+      </van-button>
+    </div>
+  </window-size>
+</template>
+
+<script setup>
+import router from "@/router";
+import {onMounted, ref} from "vue";
+import {getCouponInfo} from "@/api/coupon";
+import store from "@/store";
+
+const key = router.currentRoute.value.params.key
+
+const coupon = ref({})
+
+function makeStartDate() {
+  return coupon.value.createTime?.split(" ")[0].replaceAll("-", ".")
+}
+
+function toCashier() {
+  const createOrderRequest = {
+    body: '购买优惠券',
+    orderType: 6,
+    totalFee: coupon.value.price,
+    patientId: store.getters.getDefaultCard?.patientId || 'unknown',
+    fundpayAmt: 0,
+    acctpayAmt:0,
+    cashpayAmt: coupon.value.price,
+    couponAmt: 0,
+    couponId: key
+  }
+  store.dispatch({
+    type: 'storeCreateOrderRequest',
+    createOrderRequest,
+  }).then(() => {
+    router.push('/cashier')
+  })
+}
+
+onMounted(() => {
+  getCouponInfo(key).then(res => {
+    console.log(res)
+    coupon.value = res
+  }).catch(e => {
+    console.log(e)
+  })
+})
+</script>
+
+<style lang="scss">
+.buy-coupon{
+  .coupon-box {
+    margin: 20px 10px 10px 20px;
+    width: calc(100% - 40px);
+    height: max-content;
+    background-color: white;
+    border-radius: 8px;
+    .flex {
+      display: flex;
+      align-items: center;
+    }
+    .value-box {
+      margin: 20px 20px 6px 20px;
+      color: rgb(25, 137, 250);
+      .amount-box{
+        font-weight: bold;
+        .amount{
+          font-size: 32px;
+        }
+      }
+      .description {
+        margin-top: 4px;
+        font-size: 12px;
+        margin-left: 2px;
+      }
+    }
+    .name-box {
+      margin-left: 30px;
+      .name {
+        font-size: 16px;
+        font-weight: bold;
+      }
+      .time {
+        margin-top: 12px;
+        font-size: 12px;
+      }
+    }
+
+    .charge-name {
+      border-top: 1px dashed #dfdfdf;
+      color: rgb(25, 137, 250);
+      font-size: 12px;
+      padding: 6px 10px;
+      min-height: 30px;
+      display: flex;
+      align-items: center;
+      .alert {
+        color: darkred;
+      }
+    }
+  }
+}
+</style>

+ 9 - 6
src/views/public-pages/Cashier.vue

@@ -11,7 +11,7 @@
       <div class="label money-box">
         待缴金额:
         <span class="money">{{ psnCashpayAmt }}</span>
-        <div class="detail-box">
+        <div v-if="createOrderRequest.orderType !== 6" class="detail-box">
           <div>
             <div>
               总计金额:{{makeMoneyStyle(createOrderRequest.totalFee)}}
@@ -32,6 +32,7 @@
 
     <div style="margin: 0 12px">
       <van-coupon-cell
+          v-if="createOrderRequest.orderType !== 6"
           :coupons="usableCoupons"
           :chosen-coupon="chosenCouponIndex"
           @click="showCouponList = true"
@@ -182,11 +183,13 @@ onMounted(() => {
       chargeCodeList.push(item.itemCode)
     })
   }
-  const hisOrdNum = getHisOrdNum()
-  getMyCoupons({hisOrdNum, chargeCodeList}).then(res => {
-    usableCoupons.value = res.usableCoupons
-    unusableCoupons.value = res.unusableCoupons
-  });
+  if (createOrderRequest.orderType !== 6) {
+    const hisOrdNum = getHisOrdNum()
+    getMyCoupons({hisOrdNum, chargeCodeList}).then(res => {
+      usableCoupons.value = res.usableCoupons
+      unusableCoupons.value = res.unusableCoupons
+    });
+  }
 })
 </script>
 

+ 1 - 1
src/views/public-pages/PaymentSuccess.vue

@@ -172,7 +172,7 @@ import WxOrderDetail from '@/components/wx-order-detail/index.vue'
 
 const router = useRouter()
 const createOrderRequest = store.getters.getCreateOrderRequest
-if (!createOrderRequest.patientId) {
+if (createOrderRequest.orderType !== 6 && !createOrderRequest.patientId) {
   router.push('/404')
 }