|
|
|
## 投票组件
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 版本历史
|
|
|
|
|
|
|
|
| 版本号 | 更新时间 | 更新描述 |
|
|
|
|
| ------ | --------- | ---------------------- |
|
|
|
|
| 1.0.0 | 2022.8.1 | 直播带货组件上线 |
|
|
|
|
| 1.1.0 | 2022.2.15 | 直播带货支持多平台链接 |
|
|
|
|
| | | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 组件引入
|
|
|
|
|
|
|
|
注意:所有使用互动组件必须要引入basemodule库,最新版本见 [互动组件对接文档](互动组件/互动组件对接文档)
|
|
|
|
|
|
|
|
项目根目录build.gradle引入:
|
|
|
|
|
|
|
|
```groovy
|
|
|
|
repositories {
|
|
|
|
maven { url 'http://nexus-app.bokecc.com/repository/sdk-group/' }
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
module的build.gradle引入:
|
|
|
|
|
|
|
|
```java
|
|
|
|
dependencies {
|
|
|
|
api ('com.bokecc:basemodule:x.x.x')
|
|
|
|
api ('com.bokecc.module:commercemodule:x.x.x')
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Application的onCreate方法中,调用`DWLiveEngine.init`初始化dwlivesdk后,添加代码:
|
|
|
|
|
|
|
|
```java
|
|
|
|
CommerceInteractSDK.getInstance().init(app);
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 1. 组件描述
|
|
|
|
|
|
|
|
直播带货组件是基于基础组件库扩展的直播带货组件服务,通过IM组件实现带货活动事件的实时推送,包括获取推送商品,获取商品列表等功能,为业务方提供直播带货能力。带货组件包含管理器和基于管理器实现的UI界面,接入方可基于管理器对外API实现完全自定义UI的带货,也可直接集成组件SDK提供的UI。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 2. 组件架构
|
|
|
|
|
|
|
|
#### 2.1 组件架构图
|
|
|
|
|
|
|
|
![image-20220506100931572](组件架构图.png)
|
|
|
|
|
|
|
|
#### 2.2 核心对外API
|
|
|
|
|
|
|
|
IVoteManager内部唯一实现类为VoteManagerImpl
|
|
|
|
|
|
|
|
| 作用 | API |
|
|
|
|
| ------------ | ------------------------------------------------------------ |
|
|
|
|
| 初始化 | init(CommerceListener listener) |
|
|
|
|
| 设置token | sendToken(String interactToken,String userId,String roomId,String viewId,String username,boolean isRegisterIm) |
|
|
|
|
| 获取商品列表 | getGoodsList(boolean isClear) |
|
|
|
|
| 获取商品详情 | getGoodsDetail(String productId) |
|
|
|
|
| 获取商品链接 | getGoodsDetail(int type,String productId) |
|
|
|
|
| 重连 | reConnect()
|
|
|
|
| 释放 | release() |
|
|
|
|
|
|
|
|
API接口代码
|
|
|
|
|
|
|
|
```java
|
|
|
|
public interface CommerceManager {
|
|
|
|
/**
|
|
|
|
* 初始化电商模块
|
|
|
|
* @param giftListener 模块回调监听
|
|
|
|
*/
|
|
|
|
void init(CommerceListener giftListener);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设置token及相关参数
|
|
|
|
* @param interactToken
|
|
|
|
* @param userId
|
|
|
|
* @param roomId
|
|
|
|
* @param viewId
|
|
|
|
* @param username
|
|
|
|
* @param isRegisterIm
|
|
|
|
*/
|
|
|
|
void setToken(String interactToken,String userId,String roomId,String viewId,String username,boolean isRegisterIm);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取商品列表
|
|
|
|
*/
|
|
|
|
void getGoodsList(final boolean isClear);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取商品详情
|
|
|
|
* @param productId
|
|
|
|
*/
|
|
|
|
void getGoods(String productId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取商品链接
|
|
|
|
* @param type
|
|
|
|
* @param productId
|
|
|
|
*/
|
|
|
|
void getGoodsLink(int type,String productId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 重连
|
|
|
|
*/
|
|
|
|
void reConnect();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 释放
|
|
|
|
*/
|
|
|
|
void release();
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### 2.3 数据参数定义
|
|
|
|
|
|
|
|
数据类参数说明
|
|
|
|
|
|
|
|
```java
|
|
|
|
public class CCGoodsModel {
|
|
|
|
|
|
|
|
/**商品id*/
|
|
|
|
private long id;
|
|
|
|
/**封面*/
|
|
|
|
private String cover;
|
|
|
|
/**标题*/
|
|
|
|
private String title;
|
|
|
|
/**描述*/
|
|
|
|
private String desc;
|
|
|
|
/***/
|
|
|
|
private String[] tag;
|
|
|
|
/**当前价格*/
|
|
|
|
private int currentPrice;
|
|
|
|
/**原价*/
|
|
|
|
private int originPrice;
|
|
|
|
/**按钮文案*/
|
|
|
|
private String button;
|
|
|
|
/**0-未置顶;1-置顶*/
|
|
|
|
private int top;
|
|
|
|
/**0-未推送;1-推送*/
|
|
|
|
private int push;
|
|
|
|
/**序号*/
|
|
|
|
private int score;
|
|
|
|
|
|
|
|
/**获取更多视图,0不显示/1获取更多/2到底了*/
|
|
|
|
private int loadMoreStatus = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 1 多平台链接,0 通用链接,判断,如果是0,走接口获取商品地址,判断如果是1,遍历platformLink,取terminal是2得链接,没有置灰按钮
|
|
|
|
*/
|
|
|
|
private int linkType;
|
|
|
|
/**
|
|
|
|
* 平台链接数组
|
|
|
|
*/
|
|
|
|
private ArrayList<PlatformLinkDTO> platformLink;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class PlatformLinkDTO{
|
|
|
|
/**
|
|
|
|
* 1:PC 2:H5
|
|
|
|
*/
|
|
|
|
private int terminal;
|
|
|
|
/**
|
|
|
|
* 链接
|
|
|
|
*/
|
|
|
|
private String link;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 3. 组件接入
|
|
|
|
|
|
|
|
#### 3.1 使用组件提供UI
|
|
|
|
|
|
|
|
推送商品视图CCRecommendGoodsView
|
|
|
|
|
|
|
|
1. 登录业务SDK(云直播等)
|
|
|
|
|
|
|
|
2. xml中添加VoteMainLayout
|
|
|
|
|
|
|
|
```xml
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<LinearLayout
|
|
|
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
|
|
android:layout_width="match_parent"
|
|
|
|
android:layout_height="match_parent"
|
|
|
|
android:background="#eeeeee"
|
|
|
|
android:orientation="vertical">
|
|
|
|
|
|
|
|
|
|
|
|
<com.bokecc.commerce.view.CCRecommendGoodsView
|
|
|
|
android:id="@+id/recommerce_goods_view"
|
|
|
|
android:layout_width="match_parent"
|
|
|
|
android:layout_height="match_parent"/>
|
|
|
|
|
|
|
|
</LinearLayout>
|
|
|
|
```
|
|
|
|
|
|
|
|
1. 推送商品的使用
|
|
|
|
|
|
|
|
(1)获取token-初始化投票需要传递参数token,userId,roomId,viewId,username,可以通过业务SDK(云直播等)提供的对外API获取token
|
|
|
|
|
|
|
|
(2)获取正在进行活动-如果需要进入时就展示互动组件,需要调用业务SDK提供的正在进行中组件活动API获取正在进行的活动
|
|
|
|
|
|
|
|
(3)初始化组件-使用前两步获取的信息初始化组件SDK
|
|
|
|
|
|
|
|
```java
|
|
|
|
.initialize(String interactToken,String userId,String roomId,String viewId,String username,new CommerceUiListener() {
|
|
|
|
@Override
|
|
|
|
public void onClose() {
|
|
|
|
//关闭
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCommercePush(String id) {
|
|
|
|
//推送
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onProductLink(String link) {
|
|
|
|
//商品链接,跳转浏览器等操作
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
2. 商品列表的使用
|
|
|
|
|
|
|
|
(1)获取token-初始化投票需要传递参数token,userId,roomId,viewId,username,可以通过业务SDK(云直播等)提供的对外API获取token
|
|
|
|
|
|
|
|
(2)获取正在进行活动-如果需要进入时就展示互动组件,需要调用业务SDK提供的正在进行中组件活动API获取正在进行的活动
|
|
|
|
|
|
|
|
(3)初始化组件-使用前两步获取的信息初始化组件SDK
|
|
|
|
|
|
|
|
```java
|
|
|
|
.initialize(token,userId,roomId,"","", new CommerceUiListener() {
|
|
|
|
@Override
|
|
|
|
public void onClose() {
|
|
|
|
recommerce_goodslist_view.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCommercePush(String id) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onProductLink(String link) {
|
|
|
|
//获取商品链接,跳转浏览器
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
|
|
|
3. 商品列表刷新
|
|
|
|
|
|
|
|
```java
|
|
|
|
@Override
|
|
|
|
protected void flushList() {
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
4. 销毁组件
|
|
|
|
|
|
|
|
```java
|
|
|
|
@Override
|
|
|
|
protected void release() {
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 4. 混淆配置
|
|
|
|
|
|
|
|
混淆配置
|
|
|
|
|
|
|
|
```
|
|
|
|
-keep class com.bokecc.**{*;}
|
|
|
|
-keep interface com.bokecc.**{*;}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 5. 组件库依赖
|
|
|
|
|
|
|
|
```groovy
|
|
|
|
implementation 'com.android.support:appcompat-v7:28.0.0'
|
|
|
|
implementation 'com.android.support:recyclerview-v7:28.0.0'
|
|
|
|
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
|
|
|
``` |
|
|
|
\ No newline at end of file |