Polyv Help Center

Help Center

Coupon

Updated: 2025-07-03 14:46:06

1. Introduction

The coupon component is used for the coupon functionality in live streaming rooms, supporting coupon claiming, viewing, and display. The component includes a list of claimable coupons, a list of claimed coupons, and a coupon widget.

The component provides three different entry components:

  • NormalCouponCommonList - Claimable coupon list component
  • NormalCouponUserList - Claimed coupon list component
  • NormalCouponPendant - Coupon widget component

2. Import

2.1 UMD Method

Among them, normal-coupon-common-list.umd.js is the claimable coupon list component, normal-coupon-user-list.umd.js is the claimed coupon list component, and normal-coupon-pendant.umd.js is the coupon widget component.

<script src="https://websdk.videocc.net/iar-coupon-ui/rc-20250612/normal-coupon-common-list.umd.js"></script>

<script>
const { NormalCouponCommonList, NormalCouponUserList, NormalCouponPendant } = window.PolyvIarCouponUi;
</script>

2.2 NPM Method

// 安装依赖
pnpm add @polyv/iar-coupon-ui

// 引入组件
import { NormalCouponCommonList, NormalCouponUserList, NormalCouponPendant } from '@polyv/iar-coupon-ui';

3. Code Example

<template>
  <div>
    <!-- 可领取优惠券列表 -->
    <NormalCouponCommonList
      ref="couponCommonListRef"
      :coupon-target="couponSDK"
      @to-show="onToShow"
      @to-hide="onToHide"
    />

    <!-- 已领取优惠券列表 -->
    <NormalCouponUserList
      ref="couponUserListRef"
      :coupon-target="couponSDK"
      @to-show="onToShow"
      @to-hide="onToHide"
    />

    <!-- 优惠券挂件 -->
    <NormalCouponPendant
      ref="couponPendantRef"
      :coupon-target="couponSDK"
      @to-show="onToShow"
      @to-hide="onToHide"
    />
  </div>
</template>

<script setup>
import { NormalCouponCommonList, NormalCouponUserList, NormalCouponPendant } from '@polyv/iar-coupon-ui';
import { Coupon } from '@polyv/iar-coupon-sdk';

// 初始化优惠券 SDK
const couponSDK = new Coupon(iarCore);

// 事件处理
const onToShow = () => {
  console.log('显示优惠券弹窗');
};

const onToHide = () => {
  console.log('隐藏优惠券弹窗');
};
</script>

4. API

4.1 Props

Parameter Description Type Default Required
couponTarget Coupon SDK instance Coupon - Yes

4.2 Events

Event Name Description Callback Parameters
to-show Triggered when the coupon popup is displayed () => void
to-hide Triggered when the coupon popup is hidden () => void

4.3 Methods

Component methods can be called via ref:

Method Name Description Parameters Return Value
show Display the component - void
hide Hide the component - void
联系客服,在线咨询