@tencentcloud/ai-desk-customer-wechat
Version:
AI Desk customer UIKit for wechat mini program
59 lines (58 loc) • 1.9 kB
JavaScript
;
const aiDeskCustomerUniapp_server = require("../../ai-desk-customer-uniapp/server.js");
const common_vendor = require("../../common/vendor.js");
const CustomerServiceChat = () => "../../ai-desk-customer-uniapp/components/CustomerServiceChat/index-uniapp.js";
const _sfc_main = {
components: {
CustomerServiceChat
},
data() {
return {
toolbarButtonList: []
};
},
onLoad(options) {
const { SDKAppID, userID, userSig, toolbarButtonList } = options;
if (toolbarButtonList) {
let parsedToolbarButtonList = JSON.parse(toolbarButtonList);
if (Array.isArray(parsedToolbarButtonList)) {
parsedToolbarButtonList.forEach((item) => {
this.toolbarButtonList.push({
icon: item.icon || "",
title: item.title || "",
renderCondition: () => {
return true;
},
clickEvent: () => {
if (common_vendor.qt.isReady()) {
common_vendor.Qt.sendTextMessage({
to: "@customer_service_account",
conversationType: common_vendor.qt.TYPES.CONV_C2C,
payload: {
text: item.title || ""
}
});
}
}
});
});
}
}
this.$nextTick(() => {
aiDeskCustomerUniapp_server.TUICustomerServer.init(SDKAppID, userID, userSig);
});
}
};
if (!Array) {
const _component_CustomerServiceChat = common_vendor.resolveComponent("CustomerServiceChat");
_component_CustomerServiceChat();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.p({
toolbarButtonList: $data.toolbarButtonList
})
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);