/*! For license information please see 8443.7fc6b315.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["8443"],{24433:function(n,t,s){"use strict";s.r(t);var d=s("80681");let a=["innerHTML"];t.default={setup:()=>({html:""}),render:()=>((0,d.wg)(),(0,d.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

Coupon

\n

Intro

\n

Used for redemption and selection of coupons.

\n

Install

\n

Register component globally via app.use, refer to Component Registration for more registration ways.

\n
import { createApp } from 'vue';\nimport { CouponCell, CouponList } from 'vant';\n\nconst app = createApp();\napp.use(CouponCell);\napp.use(CouponList);\n
\n

Usage

\n

Basic Usage

\n
<!-- Coupon Cell -->\n<van-coupon-cell\n  :coupons="coupons"\n  :chosen-coupon="chosenCoupon"\n  @click="showList = true"\n/>\n<!-- Coupon List -->\n<van-popup\n  v-model:show="showList"\n  round\n  position="bottom"\n  style="height: 90%; padding-top: 4px;"\n>\n  <van-coupon-list\n    :coupons="coupons"\n    :chosen-coupon="chosenCoupon"\n    :disabled-coupons="disabledCoupons"\n    @change="onChange"\n    @exchange="onExchange"\n  />\n</van-popup>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const coupon = {\n      available: 1,\n      originCondition: 0,\n      reason: '',\n      value: 150,\n      name: 'Coupon name',\n      startAt: 1489104000,\n      endAt: 1514592000,\n      valueDesc: '1.5',\n      unitDesc: '\u5143',\n    };\n\n    const coupons = ref([coupon]);\n    const showList = ref(false);\n    const chosenCoupon = ref(-1);\n\n    const onChange = (index) => {\n      showList.value = false;\n      chosenCoupon.value = index;\n    };\n    const onExchange = (code) => {\n      coupons.value.push(coupon);\n    };\n\n    return {\n      coupons,\n      showList,\n      onChange,\n      onExchange,\n      chosenCoupon,\n      disabledCoupons: [coupon],\n    };\n  },\n};\n
\n

API

\n

CouponCell Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionTypeDefault
titleCell titlestringCoupon
chosen-couponIndex of chosen couponnumber | number[]-1
couponsCoupon listCoupon[][]
editableCell editablebooleantrue
borderWhether to show inner borderbooleantrue
currencyCurrency symbolstring\xa5
\n

CouponList Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionTypeDefault
v-modelCurrent exchange codestring-
chosen-couponIndex of chosen coupons, support multiple selection (type is [])number | number[]-1
couponsCoupon listCouponInfo[][]
disabled-couponsDisabled coupon listCouponInfo[][]
enabled-titleTitle of coupon liststringAvailable
disabled-titleTitle of disabled coupon liststringUnavailable
exchange-button-textExchange button textstringExchange
exchange-button-loadingWhether to show loading in exchange buttonbooleanfalse
exchange-button-disabledWhether to disable exchange buttonbooleanfalse
exchange-min-lengthMin length to enable exchange buttonnumber1
displayed-coupon-indexIndex of displayed couponnumber-
close-button-textClose button textstringClose
input-placeholderInput placeholderstringCoupon code
currencyCurrency symbolstring\xa5
empty-imagePlaceholder image when list is emptystring-
show-countWhether to show coupon count in tab titlebooleantrue
\n

CouponList Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventDescriptionArguments
changeEmitted when chosen coupon changedindex: index of chosen coupon
exchangeEmitted when exchanging couponcode: exchange code
\n

CouponList Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescription
list-footerCoupon list bottom
disabled-list-footerUnavailable coupons list bottom
list-buttonCustomize the bottom button
\n

Data Structure of CouponInfo

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
KeyDescriptionType
idIdstring
nameNamestring
conditionConditionstring
startAtStart time (Timestamp, unit second)number
endAtEnd time (Timestamp, unit second)number
descriptionDescriptionstring
reasonUnavailable reasonstring
valueValuenumber
valueDescValue Textstring
unitDescUnit Textstring
\n

Types

\n

The component exports the following type definitions:

\n
import type { CouponCellProps, CouponListProps, CouponInfo } from 'vant';\n
\n

Theming

\n

CSS Variables

\n

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDefault ValueDescription
--van-coupon-margin0 var(--van-padding-sm) var(--van-padding-sm)-
--van-coupon-content-height84px-
--van-coupon-content-padding14px 0-
--van-coupon-content-text-colorvar(--van-text-color)-
--van-coupon-backgroundvar(--van-background-2)-
--van-coupon-active-backgroundvar(--van-active-color)-
--van-coupon-radiusvar(--van-radius-lg)-
--van-coupon-shadow0 0 4px rgba(0, 0, 0, 0.1)-
--van-coupon-head-width96px-
--van-coupon-amount-colorvar(--van-danger-color)-
--van-coupon-amount-font-size30px-
--van-coupon-currency-font-size40%-
--van-coupon-name-font-sizevar(--van-font-size-md)-
--van-coupon-disabled-text-colorvar(--van-text-color-2)-
--van-coupon-description-paddingvar(--van-padding-xs) var(--van-padding-md)-
--van-coupon-description-border-colorvar(--van-border-color)-
--van-coupon-checkbox-colorvar(--van-danger-color)-
--van-coupon-list-backgroundvar(--van-background)-
--van-coupon-list-field-padding5px 0 5px var(--van-padding-md)-
--van-coupon-list-exchange-button-height32px-
--van-coupon-list-close-button-height40px-
--van-coupon-list-empty-tip-colorvar(--van-text-color-2)-
--van-coupon-list-empty-tip-font-sizevar(--van-font-size-md)-
--van-coupon-list-empty-tip-line-heightvar(--van-line-height-md)-
--van-coupon-cell-selected-text-colorvar(--van-text-color)-
\n
'},null,8,a))}}}]);