123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- "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,
- `<image class="chat-img" style="width: 24px;height: 24px;margin: 0 3px;" src="${sheep_index.sheep.$url.cdn(
- "/static/img/chat/emoji/" + emojiFile
- )}"/></image>`
- );
- });
- }
- }
- 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);
|