/*! 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
\nIntro
\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
\nBasic Usage
\n
\n<van-coupon-cell\n :coupons="coupons"\n :chosen-coupon="chosenCoupon"\n @click="showList = true"\n/>\n\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
\nCouponCell Props
\n
\n\n\nAttribute | \nDescription | \nType | \nDefault | \n
\n\n\n\ntitle | \nCell title | \nstring | \nCoupon | \n
\n\nchosen-coupon | \nIndex of chosen coupon | \nnumber | number[] | \n-1 | \n
\n\ncoupons | \nCoupon list | \nCoupon[] | \n[] | \n
\n\neditable | \nCell editable | \nboolean | \ntrue | \n
\n\nborder | \nWhether to show inner border | \nboolean | \ntrue | \n
\n\ncurrency | \nCurrency symbol | \nstring | \n\xa5 | \n
\n\n
\n
CouponList Props
\n
\n\n\nAttribute | \nDescription | \nType | \nDefault | \n
\n\n\n\nv-model | \nCurrent exchange code | \nstring | \n- | \n
\n\nchosen-coupon | \nIndex of chosen coupons, support multiple selection (type is [] ) | \nnumber | number[] | \n-1 | \n
\n\ncoupons | \nCoupon list | \nCouponInfo[] | \n[] | \n
\n\ndisabled-coupons | \nDisabled coupon list | \nCouponInfo[] | \n[] | \n
\n\nenabled-title | \nTitle of coupon list | \nstring | \nAvailable | \n
\n\ndisabled-title | \nTitle of disabled coupon list | \nstring | \nUnavailable | \n
\n\nexchange-button-text | \nExchange button text | \nstring | \nExchange | \n
\n\nexchange-button-loading | \nWhether to show loading in exchange button | \nboolean | \nfalse | \n
\n\nexchange-button-disabled | \nWhether to disable exchange button | \nboolean | \nfalse | \n
\n\nexchange-min-length | \nMin length to enable exchange button | \nnumber | \n1 | \n
\n\ndisplayed-coupon-index | \nIndex of displayed coupon | \nnumber | \n- | \n
\n\nclose-button-text | \nClose button text | \nstring | \nClose | \n
\n\ninput-placeholder | \nInput placeholder | \nstring | \nCoupon code | \n
\n\ncurrency | \nCurrency symbol | \nstring | \n\xa5 | \n
\n\nempty-image | \nPlaceholder image when list is empty | \nstring | \n- | \n
\n\nshow-count | \nWhether to show coupon count in tab title | \nboolean | \ntrue | \n
\n\n
\n
CouponList Events
\n
\n\n\nEvent | \nDescription | \nArguments | \n
\n\n\n\nchange | \nEmitted when chosen coupon changed | \nindex: index of chosen coupon | \n
\n\nexchange | \nEmitted when exchanging coupon | \ncode: exchange code | \n
\n\n
\n
CouponList Slots
\n
\n\n\nName | \nDescription | \n
\n\n\n\nlist-footer | \nCoupon list bottom | \n
\n\ndisabled-list-footer | \nUnavailable coupons list bottom | \n
\n\nlist-button | \nCustomize the bottom button | \n
\n\n
\n
Data Structure of CouponInfo
\n
\n\n\nKey | \nDescription | \nType | \n
\n\n\n\nid | \nId | \nstring | \n
\n\nname | \nName | \nstring | \n
\n\ncondition | \nCondition | \nstring | \n
\n\nstartAt | \nStart time (Timestamp, unit second) | \nnumber | \n
\n\nendAt | \nEnd time (Timestamp, unit second) | \nnumber | \n
\n\ndescription | \nDescription | \nstring | \n
\n\nreason | \nUnavailable reason | \nstring | \n
\n\nvalue | \nValue | \nnumber | \n
\n\nvalueDesc | \nValue Text | \nstring | \n
\n\nunitDesc | \nUnit Text | \nstring | \n
\n\n
\n
Types
\n
The component exports the following type definitions:
\n
import type { CouponCellProps, CouponListProps, CouponInfo } from 'vant';\n
\n
Theming
\nCSS Variables
\n
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\n
\n\n\nName | \nDefault Value | \nDescription | \n
\n\n\n\n--van-coupon-margin | \n0 var(--van-padding-sm) var(--van-padding-sm) | \n- | \n
\n\n--van-coupon-content-height | \n84px | \n- | \n
\n\n--van-coupon-content-padding | \n14px 0 | \n- | \n
\n\n--van-coupon-content-text-color | \nvar(--van-text-color) | \n- | \n
\n\n--van-coupon-background | \nvar(--van-background-2) | \n- | \n
\n\n--van-coupon-active-background | \nvar(--van-active-color) | \n- | \n
\n\n--van-coupon-radius | \nvar(--van-radius-lg) | \n- | \n
\n\n--van-coupon-shadow | \n0 0 4px rgba(0, 0, 0, 0.1) | \n- | \n
\n\n--van-coupon-head-width | \n96px | \n- | \n
\n\n--van-coupon-amount-color | \nvar(--van-danger-color) | \n- | \n
\n\n--van-coupon-amount-font-size | \n30px | \n- | \n
\n\n--van-coupon-currency-font-size | \n40% | \n- | \n
\n\n--van-coupon-name-font-size | \nvar(--van-font-size-md) | \n- | \n
\n\n--van-coupon-disabled-text-color | \nvar(--van-text-color-2) | \n- | \n
\n\n--van-coupon-description-padding | \nvar(--van-padding-xs) var(--van-padding-md) | \n- | \n
\n\n--van-coupon-description-border-color | \nvar(--van-border-color) | \n- | \n
\n\n--van-coupon-checkbox-color | \nvar(--van-danger-color) | \n- | \n
\n\n--van-coupon-list-background | \nvar(--van-background) | \n- | \n
\n\n--van-coupon-list-field-padding | \n5px 0 5px var(--van-padding-md) | \n- | \n
\n\n--van-coupon-list-exchange-button-height | \n32px | \n- | \n
\n\n--van-coupon-list-close-button-height | \n40px | \n- | \n
\n\n--van-coupon-list-empty-tip-color | \nvar(--van-text-color-2) | \n- | \n
\n\n--van-coupon-list-empty-tip-font-size | \nvar(--van-font-size-md) | \n- | \n
\n\n--van-coupon-list-empty-tip-line-height | \nvar(--van-line-height-md) | \n- | \n
\n\n--van-coupon-cell-selected-text-color | \nvar(--van-text-color) | \n- | \n
\n\n
\n
'},null,8,a))}}}]);