"use strict"; const common_vendor = require("../../common/vendor.js"); const sheep_index = require("../../sheep/index.js"); const pages_chat_emoji = require("./emoji.js"); const pages_chat_socket = require("./socket.js"); require("../../sheep/api/index.js"); require("../../sheep/api/distri/score.js"); require("../../sheep/request/index.js"); require("../../sheep/config/index.js"); require("../../sheep/store/index.js"); require("../../sheep/store/app.js"); require("../../sheep/api/promotion/diy.js"); require("../../sheep/platform/index.js"); require("../../sheep/platform/provider/wechat/index.js"); require("../../sheep/platform/provider/wechat/miniProgram.js"); require("../../sheep/api/member/auth.js"); require("../../sheep/api/member/social.js"); require("../../sheep/api/member/user.js"); require("../../sheep/platform/provider/apple/index.js"); require("../../sheep/platform/share.js"); require("../../sheep/router/index.js"); require("../../sheep/hooks/useModal.js"); require("../../sheep/helper/index.js"); require("../../sheep/helper/test.js"); require("../../sheep/helper/digit.js"); require("../../sheep/api/member/signin.js"); require("../../sheep/helper/throttle.js"); require("../../sheep/url/index.js"); require("../../sheep/platform/pay.js"); require("../../sheep/api/pay/order.js"); require("../../sheep/store/user.js"); require("../../sheep/store/cart.js"); require("../../sheep/api/trade/cart.js"); require("../../sheep/api/pay/wallet.js"); require("../../sheep/api/trade/order.js"); require("../../sheep/api/promotion/coupon.js"); require("../../sheep/store/sys.js"); require("../../sheep/store/modal.js"); require("../../sheep/api/distri/share.js"); require("../../sheep/api/distri/team.js"); require("../../sheep/api/infra/file.js"); require("../../sheep/api/member/address.js"); require("../../sheep/api/member/point.js"); require("../../sheep/api/migration/app.js"); require("../../sheep/api/migration/chat.js"); require("../../sheep/api/migration/index.js"); require("../../sheep/api/migration/third.js"); require("../../sheep/api/pay/channel.js"); require("../../sheep/api/product/category.js"); require("../../sheep/api/product/comment.js"); require("../../sheep/api/product/favorite.js"); require("../../sheep/api/product/history.js"); require("../../sheep/api/product/spu.js"); require("../../sheep/api/promotion/activity.js"); require("../../sheep/api/promotion/article.js"); require("../../sheep/api/promotion/bargain.js"); require("../../sheep/api/promotion/combination.js"); require("../../sheep/api/promotion/rewardActivity.js"); require("../../sheep/api/promotion/seckill.js"); require("../../sheep/api/system/area.js"); require("../../sheep/api/system/voice.js"); require("../../sheep/api/trade/afterSale.js"); require("../../sheep/api/trade/brokerage.js"); require("../../sheep/api/trade/config.js"); require("../../sheep/api/trade/delivery.js"); require("../../sheep/config/zIndex.js"); if (!Array) { const _easycom_su_image2 = common_vendor.resolveComponent("su-image"); const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput"); const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed"); const _easycom_s_uploader2 = common_vendor.resolveComponent("s-uploader"); const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup"); const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout"); (_easycom_su_image2 + _easycom_uni_easyinput2 + _easycom_su_fixed2 + _easycom_s_uploader2 + _easycom_su_popup2 + _easycom_s_layout2)(); } const _easycom_su_image = () => "../../sheep/ui/su-image/su-image.js"; const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js"; const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js"; const _easycom_s_uploader = () => "../../sheep/components/s-uploader/s-uploader.js"; const _easycom_su_popup = () => "../../sheep/ui/su-popup/su-popup.js"; const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js"; if (!Math) { (_easycom_su_image + GoodsItem + OrderItem + _easycom_uni_easyinput + _easycom_su_fixed + _easycom_s_uploader + _easycom_su_popup + SelectPopup + _easycom_s_layout)(); } const SelectPopup = () => "./components/select-popup.js"; const GoodsItem = () => "./components/goods.js"; const OrderItem = () => "./components/order.js"; const _sfc_main = { __name: "index", setup(__props) { const { socketInit, state: chatData, socketSendMsg, formatChatInput, socketHistoryList, onDrop, onPaste, getFocus, // upload, getUserToken, // socketTest, showTime, formatTime } = pages_chat_socket.useChatWebSocket(); const chatList = common_vendor.toRefs(chatData).chatList; const customerServiceInfo = common_vendor.toRefs(chatData).customerServerInfo; const chatHistoryPagination = common_vendor.toRefs(chatData).chatHistoryPagination; const customerUserInfo = common_vendor.toRefs(chatData).customerUserInfo; const socketState = common_vendor.toRefs(chatData).socketState; const sys_navBar = sheep_index.sheep.$platform.navbar; const chatConfig = common_vendor.computed(() => sheep_index.sheep.$store("app").chat); const { screenHeight, safeAreaInsets, safeArea, screenWidth } = sheep_index.sheep.$platform.device; const pageHeight = safeArea.height - 44 - 35 - 50; const loadingMap = { loadmore: { title: "查看更多", icon: "el-icon-d-arrow-left" }, nomore: { title: "没有更多了", icon: "" }, loading: { title: "加载中... ", icon: "el-icon-loading" } }; const onLoadMore = () => { chatHistoryPagination.value.page < chatHistoryPagination.value.lastPage && socketHistoryList(); }; const chat = common_vendor.reactive({ msg: "", scrollInto: "", showTools: false, toolsMode: "", showSelect: false, selectMode: "", chatStyle: { mode: "inner", color: "#F8270F", type: "color", alwaysShow: 1, src: "", list: {} } }); function onTools(mode) { if (!socketState.value.isConnect) { sheep_index.sheep.$helper.toast(socketState.value.tip || "您已掉线!请返回重试"); return; } if (!chat.toolsMode || chat.toolsMode === mode) { chat.showTools = !chat.showTools; } chat.toolsMode = mode; if (!chat.showTools) { chat.toolsMode = ""; } } function onShowSelect(mode) { chat.showTools = false; chat.showSelect = true; chat.selectMode = mode; } async function onSelect({ type, data }) { let msg = ""; switch (type) { case "image": const { path, fullurl } = await sheep_index.sheep.$api.app.upload(data.tempFiles[0].path, "default"); msg = { from: "customer", mode: "image", date: (/* @__PURE__ */ new Date()).getTime(), content: { url: fullurl, path } }; break; case "goods": msg = { from: "customer", mode: "goods", date: (/* @__PURE__ */ new Date()).getTime(), content: { item: { id: data.goods.id, title: data.goods.title, image: data.goods.image, price: data.goods.price, stock: data.goods.stock } } }; break; case "order": msg = { from: "customer", mode: "order", date: (/* @__PURE__ */ new Date()).getTime(), content: { item: { id: data.id, order_sn: data.order_sn, create_time: data.create_time, pay_fee: data.pay_fee, items: data.items.filter((item) => ({ goods_id: item.goods_id, goods_title: item.goods_title, goods_image: item.goods_image, goods_price: item.goods_price })), status_text: data.status_text } } }; break; } if (msg) { socketSendMsg(msg, () => { scrollBottom(); }); chat.showTools = false; chat.showSelect = false; chat.selectMode = ""; } } function onSendMessage() { if (!socketState.value.isConnect) { sheep_index.sheep.$helper.toast(socketState.value.tip || "您已掉线!请返回重试"); return; } if (!chat.msg) return; const data = { from: "customer", mode: "text", date: (/* @__PURE__ */ new Date()).getTime(), content: { text: chat.msg } }; socketSendMsg(data, () => { scrollBottom(); }); chat.showTools = false; setTimeout(() => { chat.msg = ""; }, 100); } function onTemplateList(e) { if (!socketState.value.isConnect) { sheep_index.sheep.$helper.toast(socketState.value.tip || "您已掉线!请返回重试"); return; } const data = { from: "customer", mode: "text", date: (/* @__PURE__ */ new Date()).getTime(), content: { text: e.title }, customData: { question_id: e.id } }; socketSendMsg(data, () => { scrollBottom(); }); } function onEmoji(item) { chat.msg += item.name; } function selEmojiFile(name) { for (let index in pages_chat_emoji.emojiList) { if (pages_chat_emoji.emojiList[index].name === name) { return pages_chat_emoji.emojiList[index].file; } } return false; } function replaceEmoji(data) { let newData = data; if (typeof newData !== "object") { let reg = /\[(.+?)\]/g; let zhEmojiName = newData.match(reg); if (zhEmojiName) { zhEmojiName.forEach((item) => { let emojiFile = selEmojiFile(item); newData = newData.replace( item, `` ); }); } } return newData; } function scrollBottom() { let timeout = null; chat.scrollInto = ""; clearTimeout(timeout); timeout = setTimeout(() => { chat.scrollInto = "scrollBottom"; }, 100); } common_vendor.onLoad(async () => { const { error } = await getUserToken(); if (error === 0) { socketInit(chatConfig.value, () => { scrollBottom(); }); } else { socketState.value.isConnect = false; } }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.t(common_vendor.unref(socketState).isConnect ? common_vendor.unref(customerServiceInfo).title : "网络已断开,请检查网络后刷新重试"), b: common_vendor.unref(sys_navBar) + "px", c: common_vendor.unref(chatList).length && common_vendor.unref(chatHistoryPagination).lastPage > 1 && loadingMap[common_vendor.unref(chatHistoryPagination).loadStatus].title }, common_vendor.unref(chatList).length && common_vendor.unref(chatHistoryPagination).lastPage > 1 && loadingMap[common_vendor.unref(chatHistoryPagination).loadStatus].title ? { d: common_vendor.t(loadingMap[common_vendor.unref(chatHistoryPagination).loadStatus].title), e: common_vendor.n(loadingMap[common_vendor.unref(chatHistoryPagination).loadStatus].icon), f: common_vendor.o(onLoadMore) } : {}, { g: common_vendor.f(common_vendor.unref(chatList), (item, index, i0) => { var _a; return common_vendor.e({ a: item.from !== "system" && common_vendor.unref(showTime)(item, index) }, item.from !== "system" && common_vendor.unref(showTime)(item, index) ? { b: common_vendor.t(common_vendor.unref(formatTime)(item.date)) } : {}, { c: item.from === "system" }, item.from === "system" ? { d: common_vendor.t(item.content.text) } : {}, { e: item.mode === "template" && item.content.list.length }, item.mode === "template" && item.content.list.length ? { f: common_vendor.f(item.content.list, (item2, index2, i1) => { return { a: common_vendor.t(item2.title), b: index2, c: common_vendor.o(($event) => onTemplateList(item2), index2) }; }) } : {}, { g: item.from === "customer_service" && item.mode !== "template" || item.from === "customer" }, item.from === "customer_service" && item.mode !== "template" || item.from === "customer" ? common_vendor.e({ h: item.from === "customer_service", i: common_vendor.unref(sheep_index.sheep).$url.cdn((_a = item == null ? void 0 : item.sender) == null ? void 0 : _a.avatar) || common_vendor.unref(sheep_index.sheep).$url.static("/static/images/default.png"), j: item.from === "customer" && index == common_vendor.unref(chatData).chatList.length - 1 && common_vendor.unref(chatData).isSendSucces !== 0 }, item.from === "customer" && index == common_vendor.unref(chatData).chatList.length - 1 && common_vendor.unref(chatData).isSendSucces !== 0 ? common_vendor.e({ k: common_vendor.unref(chatData).isSendSucces == -1 }, common_vendor.unref(chatData).isSendSucces == -1 ? { l: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/loading.png") } : {}) : {}, { m: item.mode === "text" }, item.mode === "text" ? { n: replaceEmoji(item.content.text), o: common_vendor.o((...args) => _ctx.onRichtext && _ctx.onRichtext(...args), index), p: common_vendor.n(item.from) } : {}, { q: item.mode === "image" }, item.mode === "image" ? { r: "5a559478-1-" + i0 + ",5a559478-0", s: common_vendor.p({ isPreview: true, previewList: [common_vendor.unref(sheep_index.sheep).$url.cdn(item.content.url)], current: 0, src: common_vendor.unref(sheep_index.sheep).$url.cdn(item.content.url), height: 200, width: 200, mode: "aspectFill" }), t: common_vendor.n(item.from) } : {}, { v: item.mode === "goods" }, item.mode === "goods" ? { w: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", { id: item.content.item.id }), index), x: "5a559478-2-" + i0 + ",5a559478-0", y: common_vendor.p({ goodsData: item.content.item }) } : {}, { z: item.mode === "order" }, item.mode === "order" ? { A: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/order/detail", { id: item.content.item.id }), index), B: "5a559478-3-" + i0 + ",5a559478-0", C: common_vendor.p({ from: "msg", orderData: item.content.item }) } : {}, { D: item.from === "customer", E: common_vendor.unref(sheep_index.sheep).$url.cdn(common_vendor.unref(customerUserInfo).avatar), F: common_vendor.n(item.from === "customer_service" ? `ss-row-left` : item.from === "customer" ? `ss-row-right` : "") }) : {}, { G: index }); }), h: pageHeight + "px", i: chat.scrollInto, j: pageHeight + "px", k: common_vendor.o(($event) => chat.msg = $event), l: common_vendor.p({ inputBorder: false, clearable: false, placeholder: "请输入你要咨询的问题", modelValue: chat.msg }), m: common_vendor.o(($event) => onTools("emoji")), n: !chat.msg }, !chat.msg ? { o: chat.toolsMode == "tools" ? 1 : "", p: common_vendor.o(($event) => onTools("tools")) } : {}, { q: chat.msg }, chat.msg ? { r: common_vendor.o(onSendMessage) } : {}, { s: common_vendor.p({ bottom: true }), t: common_vendor.o(($event) => chat.msg = $event), v: common_vendor.p({ inputBorder: false, clearable: false, placeholder: "请输入你要咨询的问题", modelValue: chat.msg }), w: common_vendor.o(($event) => onTools("emoji")), x: !chat.msg }, !chat.msg ? { y: chat.toolsMode == "tools" ? 1 : "", z: common_vendor.o(($event) => onTools("tools")) } : {}, { A: chat.msg }, chat.msg ? { B: common_vendor.o(onSendMessage) } : {}, { C: chat.toolsMode == "emoji" }, chat.toolsMode == "emoji" ? { D: common_vendor.f(common_vendor.unref(pages_chat_emoji.emojiPage), (emoji, k0, i0) => { return { a: common_vendor.f(emoji, (item, k1, i1) => { return { a: common_vendor.unref(sheep_index.sheep).$url.cdn(`/static/img/chat/emoji/${item.file}`), b: common_vendor.o(($event) => onEmoji(item), item), c: item }; }), b: emoji }; }) } : { E: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/image.png"), F: common_vendor.o(($event) => onSelect({ type: "image", data: $event })), G: common_vendor.p({ ["file-mediatype"]: "image", imageStyles: { width: 50, height: 50, border: false } }), H: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/goods.png"), I: common_vendor.o(($event) => onShowSelect("goods")), J: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/order.png"), K: common_vendor.o(($event) => onShowSelect("order")) }, { L: common_vendor.o(($event) => { chat.showTools = false; chat.toolsMode = ""; }), M: common_vendor.p({ show: chat.showTools }), N: common_vendor.o(onSelect), O: common_vendor.o(($event) => chat.showSelect = false), P: common_vendor.p({ mode: chat.selectMode, show: chat.showSelect }), Q: common_vendor.p({ title: "客服", navbar: "inner" }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5a559478"], ["__file", "D:/zx/mall-front-app/pages/chat/index.vue"]]); wx.createPage(MiniProgramPage);