Files
TIMSDK/MiniProgram/TUIKit/miniprogram/TUI-CustomerService/pages/TUI-Group/create-group/create.js
T
zhangChenXi b016c6183f feat: 小程序 TUIKit 支持分包
Co-authored-by: mileszzhang <mileszzhang@tencent.com>
2022-02-15 19:24:44 +08:00

84 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// miniprogram/pages/TUI-Group/create-group/create.js
import logger from '../../../utils/logger';
// eslint-disable-next-line no-undef
Page({
/**
* 页面的初始数据
*/
data: {
groupTypeList: [
{ groupType: '品牌客户群(Work)', Type: wx.$TUIKitTIM.TYPES.GRP_WORK },
{ groupType: 'VIP专属群(Public)', Type: wx.$TUIKitTIM.TYPES.GRP_PUBLIC },
{ groupType: '临时会议群 (Meeting)', Type: wx.$TUIKitTIM.TYPES.GRP_MEETING },
{ groupType: '直播群(AVChatRoom)', Type: wx.$TUIKitTIM.TYPES.GRP_AVCHATROOM },
],
groupType: '',
Type: '',
name: '',
groupID: '',
},
// 展示群列表
showGroupTypeList() {
this.setData({
popupToggle: true,
});
},
// 获取输入的群ID
bindGroupIDInput(e) {
const id = e.detail.value;
this.setData({
groupID: id,
});
},
// 获取输入的群名称
bindGroupNameInput(e) {
const groupname = e.detail.value;
this.setData({
name: groupname,
});
},
// 创建群聊时,传点击事件对应的值
click(e) {
this.setData({
groupType: e.currentTarget.dataset.value.groupType,
Type: e.currentTarget.dataset.value.Type,
name: e.currentTarget.dataset.value.name,
popupToggle: false,
});
},
// 确认创建群聊
bindConfirmCreate() {
logger.log(`| TUI-Group | create-group | bindConfirmCreate | groupID: ${this.data.groupID}`);
const promise = wx.$TUIKit.createGroup({
type: this.data.Type,
name: this.data.name,
groupID: this.data.groupID,
});
promise.then((imResponse) => { // 创建成功
// 创建的群的资料
const payloadData = {
conversationID: `GROUP${imResponse.data.group.groupID}`,
};
wx.navigateTo({
url: `../../TUI-Chat/chat?conversationInfomation=${JSON.stringify(payloadData)}`,
});
}).catch(() => {
wx.showToast({
title: '该群组ID被使用,请更换群ID',
icon: 'none',
});
});
},
// 点击空白区域关闭弹窗
handleChooseToggle() {
this.setData({
popupToggle: false,
});
},
});