242 lines
10 KiB
JavaScript
242 lines
10 KiB
JavaScript
|
|
"use strict";
|
||
|
|
const common_vendor = require("../../../../common/vendor.js");
|
||
|
|
require("../../../adapter-vue.js");
|
||
|
|
const TUIKit_utils_documentLink = require("../../../utils/documentLink.js");
|
||
|
|
const TUIKit_utils_env = require("../../../utils/env.js");
|
||
|
|
const common_assets = require("../../../../common/assets.js");
|
||
|
|
const TUIKit_components_TUIGroup_createGroup_groupIntroduction_config = require("./group-introduction/config.js");
|
||
|
|
const TUIKit_components_common_Toast_index = require("../../common/Toast/index.js");
|
||
|
|
const TUIKit_components_TUIGroup_server = require("../server.js");
|
||
|
|
const TUIKit_components_common_Toast_type = require("../../common/Toast/type.js");
|
||
|
|
if (!Math) {
|
||
|
|
(Icon + Avatar + GroupIntroduction + Dialog)();
|
||
|
|
}
|
||
|
|
const Icon = () => "../../common/Icon.js";
|
||
|
|
const GroupIntroduction = () => "./group-introduction/index.js";
|
||
|
|
const Dialog = () => "../../common/Dialog/index.js";
|
||
|
|
const Avatar = () => "../../common/Avatar/index.js";
|
||
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||
|
|
__name: "index",
|
||
|
|
setup(__props) {
|
||
|
|
const TUIGroupServer = TUIKit_components_TUIGroup_server.TUIGroupServer.getInstance();
|
||
|
|
const TUIConstants = TUIGroupServer.constants;
|
||
|
|
const groupInfo = common_vendor.reactive({
|
||
|
|
profile: {
|
||
|
|
groupID: "",
|
||
|
|
name: "",
|
||
|
|
type: TUIKit_components_TUIGroup_createGroup_groupIntroduction_config.groupIntroConfig[0].type,
|
||
|
|
avatar: TUIKit_components_TUIGroup_createGroup_groupIntroduction_config.groupIntroConfig[0].icon,
|
||
|
|
introduction: "",
|
||
|
|
notification: "",
|
||
|
|
// joinOption: '',
|
||
|
|
memberList: [],
|
||
|
|
isSupportTopic: false
|
||
|
|
},
|
||
|
|
groupConfig: {
|
||
|
|
title: "",
|
||
|
|
value: "",
|
||
|
|
key: "",
|
||
|
|
type: "",
|
||
|
|
placeholder: ""
|
||
|
|
},
|
||
|
|
isEdit: false
|
||
|
|
});
|
||
|
|
common_vendor.watchEffect(() => {
|
||
|
|
const params = TUIGroupServer.getOnCallParams(TUIConstants.TUIGroup.SERVICE.METHOD.CREATE_GROUP);
|
||
|
|
groupInfo.profile.memberList = params.memberList;
|
||
|
|
groupInfo.groupConfig.title = params.title;
|
||
|
|
});
|
||
|
|
const groupTypeDetail = common_vendor.computed(() => {
|
||
|
|
return TUIKit_components_TUIGroup_createGroup_groupIntroduction_config.findGroupIntroConfig(groupInfo.profile.type);
|
||
|
|
});
|
||
|
|
const headerTitle = common_vendor.computed(() => {
|
||
|
|
let name = "添加群聊";
|
||
|
|
if (groupInfo.isEdit) {
|
||
|
|
name = groupInfo.groupConfig.title;
|
||
|
|
}
|
||
|
|
return common_vendor.Wt.t(`TUIGroup.${name}`);
|
||
|
|
});
|
||
|
|
const createInfo = common_vendor.computed(() => {
|
||
|
|
const groupNameInput = {
|
||
|
|
name: common_vendor.Wt.t("TUIGroup.群名称"),
|
||
|
|
key: "name",
|
||
|
|
placeholder: common_vendor.Wt.t("TUIGroup.请输入群名称")
|
||
|
|
};
|
||
|
|
const groupIDInput = {
|
||
|
|
name: `${common_vendor.Wt.t("TUIGroup.群ID")}(${common_vendor.Wt.t("TUIGroup.选填")})`,
|
||
|
|
key: "groupID",
|
||
|
|
placeholder: common_vendor.Wt.t("TUIGroup.请输入群ID")
|
||
|
|
};
|
||
|
|
return groupInfo.profile.type === common_vendor.qt.TYPES.GRP_COMMUNITY ? [groupNameInput] : [groupNameInput, groupIDInput];
|
||
|
|
});
|
||
|
|
const submitDisabledStatus = common_vendor.computed(() => {
|
||
|
|
return groupInfo.profile.name === "" && !groupInfo.isEdit;
|
||
|
|
});
|
||
|
|
const selected = (type) => {
|
||
|
|
if (groupInfo.profile.type !== type) {
|
||
|
|
groupInfo.profile.type = type;
|
||
|
|
groupInfo.profile.avatar = TUIKit_components_TUIGroup_createGroup_groupIntroduction_config.findGroupIntroConfig(type).icon;
|
||
|
|
if (groupInfo.isEdit) {
|
||
|
|
groupInfo.groupConfig.value = type;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const createGroup = async (options) => {
|
||
|
|
try {
|
||
|
|
options.memberList = options.memberList.map((item) => {
|
||
|
|
return { userID: item.userID };
|
||
|
|
});
|
||
|
|
if (options.type === common_vendor.qt.TYPES.GRP_COMMUNITY) {
|
||
|
|
delete options.groupID;
|
||
|
|
}
|
||
|
|
const res = await common_vendor.es.createGroup(options);
|
||
|
|
const { type } = res.data.group;
|
||
|
|
if (type === common_vendor.qt.TYPES.GRP_AVCHATROOM) {
|
||
|
|
await common_vendor.es.joinGroup({
|
||
|
|
groupID: res.data.group.groupID,
|
||
|
|
applyMessage: ""
|
||
|
|
});
|
||
|
|
}
|
||
|
|
handleCompleteCreate(res.data.group);
|
||
|
|
TUIKit_components_common_Toast_index.Toast({
|
||
|
|
message: common_vendor.Wt.t("TUIGroup.群组创建成功"),
|
||
|
|
type: TUIKit_components_common_Toast_type.TOAST_TYPE.SUCCESS
|
||
|
|
});
|
||
|
|
} catch (err) {
|
||
|
|
TUIKit_components_common_Toast_index.Toast({
|
||
|
|
message: err.message,
|
||
|
|
type: TUIKit_components_common_Toast_type.TOAST_TYPE.ERROR
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const submit = () => {
|
||
|
|
const { profile } = groupInfo;
|
||
|
|
if (groupInfo.isEdit) {
|
||
|
|
groupInfo.profile[groupInfo.groupConfig.key] = groupInfo.groupConfig.value;
|
||
|
|
return groupInfo.isEdit = !groupInfo.isEdit;
|
||
|
|
} else {
|
||
|
|
createGroup(profile);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const closeCreated = () => {
|
||
|
|
if (groupInfo.isEdit) {
|
||
|
|
return groupInfo.isEdit = !groupInfo.isEdit;
|
||
|
|
}
|
||
|
|
handleCompleteCreate(null);
|
||
|
|
};
|
||
|
|
const edit = (label) => {
|
||
|
|
groupInfo.isEdit = !groupInfo.isEdit;
|
||
|
|
groupInfo.groupConfig.key = label;
|
||
|
|
groupInfo.groupConfig.value = groupInfo.profile[label];
|
||
|
|
switch (label) {
|
||
|
|
case "name":
|
||
|
|
groupInfo.groupConfig.title = "设置群名称";
|
||
|
|
groupInfo.groupConfig.placeholder = "请输入群名称";
|
||
|
|
groupInfo.groupConfig.type = "input";
|
||
|
|
break;
|
||
|
|
case "groupID":
|
||
|
|
groupInfo.groupConfig.title = "设置群ID";
|
||
|
|
groupInfo.groupConfig.placeholder = "请输入群ID";
|
||
|
|
groupInfo.groupConfig.type = "input";
|
||
|
|
break;
|
||
|
|
case "type":
|
||
|
|
groupInfo.groupConfig.title = "选择群类型";
|
||
|
|
groupInfo.groupConfig.type = "select";
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const handleCompleteCreate = (group) => {
|
||
|
|
common_vendor.Jt.update(common_vendor.o.GRP, "isShowCreateComponent", false);
|
||
|
|
const callback = TUIGroupServer.getOnCallCallback(TUIConstants.TUIGroup.SERVICE.METHOD.CREATE_GROUP);
|
||
|
|
callback && callback(group);
|
||
|
|
};
|
||
|
|
return (_ctx, _cache) => {
|
||
|
|
return common_vendor.e({
|
||
|
|
a: common_vendor.o$1(closeCreated),
|
||
|
|
b: common_vendor.p({
|
||
|
|
file: common_vendor.unref(TUIKit_utils_env.isPC) ? common_vendor.unref(common_assets.closeIcon$2) : common_vendor.unref(common_assets.backIcon),
|
||
|
|
size: "16px"
|
||
|
|
}),
|
||
|
|
c: common_vendor.t(common_vendor.unref(headerTitle)),
|
||
|
|
d: !common_vendor.unref(groupInfo).isEdit
|
||
|
|
}, !common_vendor.unref(groupInfo).isEdit ? common_vendor.e({
|
||
|
|
e: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIGroup.群头像")),
|
||
|
|
f: common_vendor.p({
|
||
|
|
url: common_vendor.unref(groupInfo).profile.avatar
|
||
|
|
}),
|
||
|
|
g: common_vendor.f(common_vendor.unref(createInfo), (item, index, i0) => {
|
||
|
|
return common_vendor.e({
|
||
|
|
a: common_vendor.t(item.name)
|
||
|
|
}, common_vendor.unref(TUIKit_utils_env.isPC) ? {
|
||
|
|
b: item.placeholder,
|
||
|
|
c: common_vendor.unref(groupInfo).profile[item.key],
|
||
|
|
d: common_vendor.o$1(($event) => common_vendor.unref(groupInfo).profile[item.key] = $event.detail.value, index)
|
||
|
|
} : {
|
||
|
|
e: common_vendor.t(common_vendor.unref(groupInfo).profile[item.key]),
|
||
|
|
f: "3db83c6c-3-" + i0 + ",3db83c6c-0",
|
||
|
|
g: common_vendor.p({
|
||
|
|
file: common_vendor.unref(common_assets.rightIcon)
|
||
|
|
}),
|
||
|
|
h: common_vendor.o$1(($event) => edit(item.key), index)
|
||
|
|
}, {
|
||
|
|
i: index
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
h: common_vendor.unref(TUIKit_utils_env.isPC),
|
||
|
|
i: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIGroup.群类型")),
|
||
|
|
j: common_vendor.unref(TUIKit_utils_env.isPC)
|
||
|
|
}, common_vendor.unref(TUIKit_utils_env.isPC) ? {
|
||
|
|
k: common_vendor.o$1(selected),
|
||
|
|
l: common_vendor.p({
|
||
|
|
groupType: common_vendor.unref(groupInfo).profile.type
|
||
|
|
})
|
||
|
|
} : {
|
||
|
|
m: common_vendor.t(common_vendor.unref(groupTypeDetail).label),
|
||
|
|
n: common_vendor.p({
|
||
|
|
file: common_vendor.unref(common_assets.rightIcon)
|
||
|
|
}),
|
||
|
|
o: common_vendor.o$1(($event) => edit("type"))
|
||
|
|
}, {
|
||
|
|
p: !common_vendor.unref(TUIKit_utils_env.isPC)
|
||
|
|
}, !common_vendor.unref(TUIKit_utils_env.isPC) ? {
|
||
|
|
q: common_vendor.t(common_vendor.unref(groupTypeDetail).label),
|
||
|
|
r: common_vendor.t(common_vendor.unref(groupTypeDetail).detail),
|
||
|
|
s: common_vendor.t(common_vendor.unref(common_vendor.Wt).t(`TUIGroup.${common_vendor.unref(groupTypeDetail).src}`)),
|
||
|
|
t: common_vendor.unref(TUIKit_utils_documentLink.Link).product.url
|
||
|
|
} : {}) : common_vendor.e({
|
||
|
|
v: common_vendor.unref(groupInfo).groupConfig.type === "input"
|
||
|
|
}, common_vendor.unref(groupInfo).groupConfig.type === "input" ? {
|
||
|
|
w: common_vendor.unref(common_vendor.Wt).t(`TUIGroup.${common_vendor.unref(groupInfo).groupConfig.placeholder}`),
|
||
|
|
x: common_vendor.unref(groupInfo).groupConfig.value,
|
||
|
|
y: common_vendor.o$1(($event) => common_vendor.unref(groupInfo).groupConfig.value = $event.detail.value)
|
||
|
|
} : {
|
||
|
|
z: common_vendor.o$1(selected),
|
||
|
|
A: common_vendor.p({
|
||
|
|
groupType: common_vendor.unref(groupInfo).groupConfig.value
|
||
|
|
})
|
||
|
|
}), {
|
||
|
|
B: common_vendor.unref(TUIKit_utils_env.isPC) && !common_vendor.unref(groupInfo).isEdit
|
||
|
|
}, common_vendor.unref(TUIKit_utils_env.isPC) && !common_vendor.unref(groupInfo).isEdit ? {
|
||
|
|
C: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIGroup.取消")),
|
||
|
|
D: common_vendor.o$1(closeCreated)
|
||
|
|
} : {}, {
|
||
|
|
E: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIGroup.确认")),
|
||
|
|
F: common_vendor.unref(submitDisabledStatus),
|
||
|
|
G: common_vendor.o$1(submit),
|
||
|
|
H: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) ? "group-h5" : ""),
|
||
|
|
I: common_vendor.o$1(closeCreated),
|
||
|
|
J: common_vendor.p({
|
||
|
|
show: true,
|
||
|
|
isH5: !common_vendor.unref(TUIKit_utils_env.isPC),
|
||
|
|
isHeaderShow: false,
|
||
|
|
isFooterShow: false,
|
||
|
|
background: false
|
||
|
|
})
|
||
|
|
});
|
||
|
|
};
|
||
|
|
}
|
||
|
|
});
|
||
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3db83c6c"]]);
|
||
|
|
wx.createComponent(Component);
|
||
|
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIGroup/create-group/index.js.map
|