Polyv Help Center

Help Center

Product Library

Updated: 2024-06-04 09:32:36

This document primarily describes how to integrate the product library component on the interactive feature receiving end. After integration, the audience can view the product library content.

Before introducing and using this functional component, you need to perform common configuration for the interactive feature receiving end SDK. For details, please see: Interactive Feature Receiving End UI Components - Configuring the SDK.

Import

Online File Import Method

// script 标签引入,根据版本号引入JS版本。
<script src="https://websdk.videocc.net/interactions-receive-sdk-ui-default/0.24.0/lib/MobileProduct/MobileProduct.umd.min.js"></script>
<script>
    const MobileProduct = window.PolyvIRScene.MobileProduct.default;
</script>
import MobileProduct from '@polyv/interactions-receive-sdk-ui-default/lib/MobileProduct';

Code Example

First, instantiate the SDK, then pass it into the product library component for internal logic processing.

Taking Mobile end integration as an example:

<template>
  <div class="plv-demo-product">
    <product-list
        v-if="productSdk"
        :product-sdk="productSdk"
        :lang="lang"
        @browse-product="handleBrowseProduct"
        @click-buy="handleClickBuy"
        @job-detail="handleShowJobDetail"
    ></product-list>

    <div
        class="c-product-bubble"
    >
      <product-bubble
          v-if="productSdk"
          :product-sdk="productSdk"
          :lang="lang"
          :getLinkParams="getLinkParams"
          @click-buy="handleClickBuy"
      />
    </div>
    <!-- modal是一个弹窗组件,可根据界面风格自行设计 -->
    <modal
        draggable
        body-locked
        title="岗位详情"
        :visible="visible"
        :close-on-click-modal="false"
        no-bg
        @close="hideJobDetail"
    >
      <product-job
          v-if="productSdk"
          :product-sdk="productSdk"
          :job-detail="jobDetail"
          :use-mobile-class="true"
      />
    </modal>
  </div>
</template>

<script>
import { Product } from '@polyv/interactions-receive-sdk';
import ProductList from '@polyv/interactions-receive-sdk-ui-default/lib/MobileProduct';
import ProductBubble from '@polyv/interactions-receive-sdk-ui-default/lib/ProductBubble'
import ProductJob from '@polyv/interactions-receive-sdk-ui-default/lib/ProductJob';


export default {
  components: {
    ProductList,
    ProductBubble,
    ProductJob
  },

  props: {
    lang: {
      type: String,
      default: 'zh_CN',
    }
  },

  data() {
    return {
      // 商品库 SDK 实例
      productSdk: null,
      visible: false,
      jobDetail: {
        cover: '',
        name: '',
        tags: [],
        params: ''
      },
    };
  },

  created() {
    this.productSdk = new Product();
  },

  beforeDestroy() {
    this.productSdk?.destroy();
  },

  methods: {
    getLinkParams() {
      // 跳转路径上携带参数如: ***.com?customParams1=自定义参数
      // return {
      //   customParams1: '自定义参数'
      // }
      return {};
    },
    handleBrowseProduct() {
      // TODO 用于统计用户数据
    },
    handleClickBuy() {
      // TODO 用户统计点击商品
    },
    handleShowJobDetail(data) {
      this.$set(this, 'jobDetail', data);
      this.visible = true;
    },
    hideJobDetail() {
      this.visible = false;
    },
  }
};
</script>

<style lang="scss">
.plv-demo-product {
  position: relative;
}
.c-product-bubble {
  position: absolute;
  top: 16px;
  padding-left: 8px;
  z-index: 35;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.c-product-bubble--mobile {
  top: 60px;
}
</style>

ProductList

Attributes

Attribute Name Type Default Value Description
productSdk Object null Product library SDK instance
lang string: 'zh_CN', 'en' 'zh_CN' Language
getWeixinSdk Function null Callback parameter: none. Obtains the WeChat SDK object for opening product library links in mini-programs. Not required in non-mini-program environments.
getLinkParams Function null Callback parameter: product information. Passes additional parameters for the product link redirection.
customClickButtonHandler Function null Callback parameter: product information. Customizes the handling of the purchase button click. Note: passing this parameter disables automatic redirection; the logic must be implemented within this function.

Events

Event Name Parameter Type Parameter Meaning Description
browse-product Array Product list Records products browsed by the user
click-buy Object Product data Click on the purchase button
job-detail Object Job product data Click on the job product button

ProductBubble

Attributes

Attribute Name Type Default Value Description
productSdk Object null Product library SDK instance
lang string: 'zh_CN', 'en' 'zh_CN' Language
getWeixinSdk Function null Callback parameter: none. Obtains the WeChat SDK object for opening product library links in mini-programs. Not required in non-mini-program environments.
getLinkParams Function null Callback parameter: product information. Passes additional parameters for the product link redirection.
customClickButtonHandler Function null Callback parameter: product information. Customizes the handling of the purchase button click. Note: passing this parameter disables automatic redirection; the logic must be implemented within this function.

Events

Event Name Parameter Type Parameter Meaning Description
click-buy Object Product data Click on the purchase button
product-push Object Product data Push product data

ProductJob

Attributes

Attribute Name Type Default Value Description
productSdk Object null Product library SDK instance
lang string: 'zh_CN', 'en' 'zh_CN' Language
jobDetail Object null Job product data
use-mobile-class Boolean false Whether to use mobile styles

Events

Event Name Parameter Type Parameter Meaning Description
click-buy Object Job product data Click on the purchase button
联系客服,在线咨询