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