feat: 发送命令的组件与发送调整
This commit is contained in:
@@ -9,5 +9,5 @@ export const SCROLL_TO_BOTTOM = "SCROLL_TO_BOTTOM";
|
||||
// 推荐帖子
|
||||
export const RECOMMEND_POSTS_TITLE = "RECOMMEND_POSTS_TITLE";
|
||||
|
||||
// 发送命令
|
||||
export const SEND_COMMAND_TEXT = "SEND_COMMAND_TEXT";
|
||||
// 发送命令类型
|
||||
export const SEND_COMMAND_TYPE = "SEND_COMMAND_TYPE";
|
||||
|
||||
@@ -14,6 +14,7 @@ export const MessageType = {
|
||||
IMAGE: "IMAGE",
|
||||
};
|
||||
|
||||
/// 组件的名称
|
||||
export const CompName = {
|
||||
// 快速预定卡片
|
||||
quickBookingCard: "quickBookingCard",
|
||||
@@ -28,3 +29,21 @@ export const CompName = {
|
||||
// 输入车牌卡片
|
||||
enterLicensePlateCard: "enterLicensePlateCard",
|
||||
};
|
||||
|
||||
/// 发送的指令类型
|
||||
export const Command = {
|
||||
// 快速预定
|
||||
quickBooking: "Command.quickBooking",
|
||||
// 探索发现
|
||||
discovery: "Command.discovery",
|
||||
// 呼叫服务
|
||||
createWorkOrderCard: "Command.createWorkOrderCard",
|
||||
// 更多
|
||||
more: "Command.more",
|
||||
// 我的订单
|
||||
myOrder: "Command.myOrder",
|
||||
// 我的工单
|
||||
myWorkOrder: "Command.myWorkOrder",
|
||||
// 反馈意见
|
||||
feedbackCard: "Command.feedbackCard",
|
||||
};
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
<!-- 输入框区域 -->
|
||||
<view class="pb-safe-area">
|
||||
<ChatQuickAccess @replySent="handleReplyInstruct" />
|
||||
<ChatQuickAccess />
|
||||
<ChatInputArea
|
||||
ref="inputAreaRef"
|
||||
v-model="inputMessage"
|
||||
@@ -121,12 +121,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, nextTick, onUnmounted, ref, defineEmits, watch } from "vue";
|
||||
import { onMounted, nextTick, onUnmounted, ref, defineEmits } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import {
|
||||
SCROLL_TO_BOTTOM,
|
||||
RECOMMEND_POSTS_TITLE,
|
||||
SEND_COMMAND_TEXT,
|
||||
SEND_COMMAND_TYPE,
|
||||
NOTICE_EVENT_LOGOUT,
|
||||
NOTICE_EVENT_LOGIN_SUCCESS,
|
||||
} from "@/constant/constant";
|
||||
@@ -274,6 +274,11 @@ const handleReply = (text) => {
|
||||
// 是发送指令
|
||||
const handleReplyInstruct = async (item) => {
|
||||
await checkToken();
|
||||
// 更多服务
|
||||
if (item.type === "Command.more") {
|
||||
uni.$emit("SHOW_MORE_POPUP");
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.type === "Command.myOrder") {
|
||||
// 订单
|
||||
@@ -337,12 +342,10 @@ const addNoticeListener = () => {
|
||||
}
|
||||
});
|
||||
|
||||
uni.$on(SEND_COMMAND_TEXT, (value) => {
|
||||
console.log("SEND_COMMAND_TEXT:", value);
|
||||
if (value && value.length > 0) {
|
||||
commonType = "Command.quickBooking";
|
||||
sendMessage(value, true);
|
||||
setTimeoutScrollToBottom();
|
||||
uni.$on(SEND_COMMAND_TYPE, (item) => {
|
||||
console.log("SEND_COMMAND_TYPE:", item);
|
||||
if (item && item.type) {
|
||||
handleReplyInstruct(item);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -744,7 +747,7 @@ onUnmounted(() => {
|
||||
uni.$off(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||
uni.$off(SCROLL_TO_BOTTOM);
|
||||
uni.$off(RECOMMEND_POSTS_TITLE);
|
||||
uni.$off(SEND_COMMAND_TEXT);
|
||||
uni.$off(SEND_COMMAND_TYPE);
|
||||
uni.$off(NOTICE_EVENT_LOGOUT);
|
||||
|
||||
resetConfig();
|
||||
|
||||
@@ -19,109 +19,35 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { currentClientType, ClientType } from "@/constant/base";
|
||||
import { ref } from "vue";
|
||||
import { Command } from "@/model/ChatModel";
|
||||
import { SEND_COMMAND_TYPE } from "@/constant/constant";
|
||||
|
||||
const itemList = ref([
|
||||
{
|
||||
icon: "",
|
||||
title: "快速预定",
|
||||
type: "Command.quickBooking",
|
||||
type: Command.quickBooking,
|
||||
},
|
||||
{
|
||||
icon: "",
|
||||
title: "探索发现",
|
||||
type: "Command.discovery",
|
||||
type: Command.discovery,
|
||||
},
|
||||
{
|
||||
icon: "",
|
||||
title: "呼叫服务",
|
||||
type: "Command.createWorkOrderCard",
|
||||
type: Command.createWorkOrderCard,
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/version_101/home/more.png",
|
||||
title: "更多",
|
||||
type: "Command.more",
|
||||
type: Command.more,
|
||||
},
|
||||
]);
|
||||
|
||||
const emits = defineEmits(["replySent"]);
|
||||
|
||||
const sendReply = (item) => {
|
||||
if (item.type === "Command.more") {
|
||||
uni.$emit("SHOW_MORE_POPUP");
|
||||
return;
|
||||
}
|
||||
emits("replySent", item); // 向父组件传递数据
|
||||
};
|
||||
|
||||
// onMounted(() => {
|
||||
// initData();
|
||||
// });
|
||||
|
||||
const initData = () => {
|
||||
itemList.value =
|
||||
currentClientType() === ClientType.TIANMU
|
||||
? [
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_yuding.png",
|
||||
showIcon: false,
|
||||
title: "快速预定",
|
||||
content: "预定门票、房间、餐食",
|
||||
type: "Command.quickBooking",
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_find.png",
|
||||
showIcon: false,
|
||||
title: "探索发现",
|
||||
content: "探索玩法、出片佳地",
|
||||
type: "Command.discovery",
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_call.png",
|
||||
showIcon: false,
|
||||
title: "反馈意见",
|
||||
content: "有意见告诉沐沐",
|
||||
type: "Command.feedbackCard",
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_order.png",
|
||||
showIcon: false,
|
||||
title: "订单/工单",
|
||||
content: "我的订单/工单",
|
||||
type: "Command.myOrder",
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_yuding.png",
|
||||
showIcon: false,
|
||||
title: "快速预定",
|
||||
content: "预定门票、房间、餐食",
|
||||
type: "Command.quickBooking",
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_find.png",
|
||||
showIcon: false,
|
||||
title: "探索发现",
|
||||
content: "探索玩法、出片佳地",
|
||||
type: "Command.discovery",
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_order.png",
|
||||
showIcon: false,
|
||||
title: "订单/工单",
|
||||
content: "我的订单/工单",
|
||||
type: "Command.myOrder",
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/quick/quick_icon_call.png",
|
||||
showIcon: false,
|
||||
title: "反馈意见",
|
||||
content: "有意见告诉朵朵",
|
||||
type: "Command.feedbackCard",
|
||||
},
|
||||
];
|
||||
uni.$emit(SEND_COMMAND_TYPE, item);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
:duration="duration"
|
||||
>
|
||||
<swiper-item v-for="item in activityList" :key="item.id">
|
||||
<view class="swiper-item" @click="handleClick(item)">
|
||||
<view class="swiper-item" @click="handleClick()">
|
||||
<image
|
||||
class="swiper-img"
|
||||
:src="item.activityCover"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="corner-btn">快速预定</view>
|
||||
<view class="corner-btn">{{ commandModel.title }}</view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
@@ -26,7 +26,13 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { SEND_COMMAND_TEXT } from "@/constant/constant";
|
||||
import { SEND_COMMAND_TYPE } from "@/constant/constant";
|
||||
|
||||
const commandModel = ref({
|
||||
icon: "",
|
||||
title: "快速预定",
|
||||
type: Command.quickBooking,
|
||||
});
|
||||
|
||||
const autoplay = ref(true);
|
||||
const interval = ref(3000);
|
||||
@@ -39,8 +45,8 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const handleClick = (item) => {
|
||||
uni.$emit(SEND_COMMAND_TEXT, "快速预定");
|
||||
const handleClick = () => {
|
||||
uni.$emit(SEND_COMMAND_TYPE, commandModel.value);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class="item border-box border-bottom pt-20 pb-20"
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
@click="close"
|
||||
@click="handleClick(item)"
|
||||
>
|
||||
<view class="flex flex-items-center flex-justify-center">
|
||||
<image v-if="item.icon" class="left" :src="item.icon" />
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { Command } from "@/model/ChatModel";
|
||||
import { SEND_COMMAND_TYPE } from "@/constant/constant";
|
||||
|
||||
const popup = ref(null);
|
||||
|
||||
@@ -48,35 +50,35 @@ const list = ref([
|
||||
title: "快速预定",
|
||||
content: "预定门票、房间、餐食",
|
||||
btnText: "去预定",
|
||||
type: "Command.quickBooking",
|
||||
type: Command.quickBooking,
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/version_101/home/tsfx.png",
|
||||
title: "探索发现",
|
||||
content: "发现景点、活动、特色内容",
|
||||
btnText: "去探索",
|
||||
type: "Command.discovery",
|
||||
type: Command.discovery,
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/version_101/home/mddd.png",
|
||||
title: "我的订单",
|
||||
content: "查看门票、住宿、餐饮等订单",
|
||||
btnText: "去查看",
|
||||
type: "Command.myOrder",
|
||||
type: Command.myOrder,
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/version_101/home/wdgd.png",
|
||||
title: "我的工单",
|
||||
content: "查看服务工单、进度与处理情况",
|
||||
btnText: "去查看",
|
||||
type: "Command.myWorkOrder",
|
||||
type: Command.myWorkOrder,
|
||||
},
|
||||
{
|
||||
icon: "https://oss.nianxx.cn/mp/static/version_101/home/fkyj.png",
|
||||
title: "反馈意见",
|
||||
content: "提交使用问题、建议与需求",
|
||||
btnText: "去反馈",
|
||||
type: "Command.feedbackCard",
|
||||
type: Command.feedbackCard,
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -84,6 +86,11 @@ const open = () => {
|
||||
popup.value && popup.value.open();
|
||||
};
|
||||
|
||||
const handleClick = (item) => {
|
||||
uni.$emit(SEND_COMMAND_TYPE, item);
|
||||
close();
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
popup.value && popup.value.close();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user