jiuyiUniapp/jiuyi2/unpackage/dist/dev/mp-weixin/pages/news/group-chat/index.js

93 lines
3.1 KiB
JavaScript
Raw Normal View History

2024-12-18 15:46:27 +08:00
"use strict";
const common_vendor = require("../../../common/vendor.js");
if (!Array) {
const _easycom_uni_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
_easycom_uni_search_bar2();
}
const _easycom_uni_search_bar = () => "../../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.js";
if (!Math) {
(common_vendor.unref(JyCommonHead) + _easycom_uni_search_bar + common_vendor.unref(book))();
}
const book = () => "./book.js";
const JyCommonHead = () => "../../../components/public/jy-common-head/index.js";
const _sfc_main = {
__name: "index",
setup(__props) {
const { userinfo } = common_vendor.useStore().state;
const searchValue = common_vendor.ref("");
const clear = () => {
console.log("清除");
searchValue.value = "";
};
const membersList = common_vendor.ref([]);
const checkboxChange = (e) => {
membersList.value = e.detail.value;
};
const { showToastAndRedirect } = common_vendor.inject("util");
const right = () => {
if (membersList.value.length < 2) {
showToastAndRedirect("至少选择2人", "error");
}
let members = [];
membersList.value.forEach((element) => {
members.push(element.userId);
});
let groupname = `${userinfo.userNickname},${membersList.value[0].userNickname},${membersList.value[1].userNickname}`;
groupname = groupname.slice(0, 10) + "...";
let option = {
data: {
// 名称
groupname,
// 描述
desc: "写点什么吧",
// 用户id
members,
// 是否为公开群:
public: false,
// 入群申请是否需群主或管理员审批
approval: false,
// 是否允许普通群成员邀请人入群:
allowinvites: true,
// 邀请加群时是否需要受邀用户确认:
inviteNeedConfirm: false,
// 群组最大成员数,默认为 200
maxusers: 200,
// 群组扩展信息
ext: ""
}
};
common_vendor.index.WebIM.conn.createGroup(option).then((res) => {
var _a;
if ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.groupid) {
console.log(res);
showToastAndRedirect("创建成功", "success");
common_vendor.index.navigateBack();
}
}).catch((e) => {
console.log(e);
});
};
return (_ctx, _cache) => {
return {
a: common_vendor.o$1(right),
b: common_vendor.p({
title: "群聊",
isRight: true
}),
c: common_vendor.o$1(clear),
d: common_vendor.o$1(($event) => searchValue.value = $event),
e: common_vendor.p({
placeholder: "请输入的用户名称",
modelValue: searchValue.value
}),
f: common_vendor.o$1(checkboxChange),
g: common_vendor.p({
search: searchValue.value
})
};
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-56b98620"]]);
wx.createPage(MiniProgramPage);