Socket
Socket
Sign inDemoInstall

chat-uikit-wechat

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chat-uikit-wechat

含聊天的UI组件库


Version published
Maintainers
1
Created
Source

TUICalling 组件接入说明

本文档主要介绍如何快速集成TUICalling,实现实时视频/语音通话。

目录结构

TUICalling
├─ component        // UI 组件
    ├─ calling      // 呼叫中 UI 组件
    └─ connected    // 通话中 UI 组件
├─ static         // UI icon 图片
├─ TUICallEngine    // TUICallEngine 逻辑文件
  1. 复制 TUICalling 到 components 文件
  2. 添加组件到对应page
{
  "usingComponents": {
    "TUICalling": "../../components/TUICalling/TUICalling",
}
  1. 使用组件

js文件

Page({
  /**
   * 页面的初始数据
   */
  data: {
    config: {
      sdkAppID: 0,
      userID: 0,
      userSig: '',
      type: 1,
      tim: null, // 参数适用于业务中已存在 TIM 实例,为保证 TIM 实例唯一性
    },
    userId: 1,//被呼叫的用户ID
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    	// 将初始化后到TUICalling实例注册到this.TUICalling中,this.TUICalling 可使用TUICalling所以方法功能。
   		this.TUICalling = this.selectComponent('#TUICalling-component');
   		//初始化TUICalling
   		this.TUICalling.init()
  },
   /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    this.TUICalling.destroyed()
  },
  
  call: function() {
   // 注:初始化完成后调用call方法
    this.TUICalling.call({ userID: this.data.userId, type:2})
  },
})

wxml文件

		<TUICalling 
      id="TUICalling-component"
      config="{{config}}"
    ></TUICalling>

TUICalling 属性

属性类型默认值必填说明
idString绑定TRTCCalling的dom ID,可通过this.selectComponent(ID)获取实例
configObjectTRTCCalling初始化配置

config 参数

参数类型必填说明
sdkAppIDNumber开通实时音视频服务创建应用后分配的 SDKAppID
userIDString用户 ID,可以由您的帐号体系指定。
userSigString身份签名(即相当于登录密码),由 userID 计算得出,具体计算方法请参见 如何计算 UserSig
typeNumber指定通话类型。1:语音通话,2:视频通话。
timobjecttim 参数适用于业务中已存在 TIM 实例,为保证 TIM 实例唯一性

组件方法

selectComponent()

您可以通过小程序提供的 this.selectComponent() 方法获取组件实例。

const TUICallingContext = this.selectComponent(ID)
call({userID, type})

进行某个 user 进行呼叫。

参数含义
userID希望呼叫用户的 userID。
type通话类型,type = 1:语音通话,type =2:视频通话。
let userID = 'test'
let type = 2
TUICallingContext.call({userID, type})

FAQs

Package last updated on 23 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc