Merge branch 'main' of https://git.brother7.cn/zoujing/YGChatCS into order-729

This commit is contained in:
duanshuwen
2025-08-07 09:42:57 +08:00
7 changed files with 181 additions and 12 deletions

View File

@@ -21,22 +21,42 @@
</view>
<view class="detail-item">
<text class="detail-label">联系房客</text>
<!-- 呼叫成功后显示为文本否则显示输入框 -->
<input
v-if="!isCallSuccess"
class="detail-input"
placeholder="请填写联系人"
v-model="contactName"
/>
<text v-else class="detail-value">{{ contactName }}</text>
</view>
<view class="detail-item">
<text class="detail-label">联系电话</text>
<!-- 呼叫成功后显示为文本否则显示输入框 -->
<input
v-if="!isCallSuccess"
class="detail-input"
placeholder="请填写联系电话"
v-model="contactPhone"
/>
<text v-else class="detail-value">{{ contactPhone }}</text>
</view>
</view>
<button class="order-button" @click="handleCall">立即呼叫</button>
<!-- 呼叫前显示立即呼叫按钮 -->
<button v-if="!isCallSuccess" class="order-button" @click="handleCall">
立即呼叫
</button>
<!-- 呼叫成功后显示两个按钮 -->
<view v-else class="order-buttons">
<button class="order-button-secondary" @click="viewWorkOrder">
查看工单
</button>
<button class="order-button-primary" @click="markCompleted">
已完成
</button>
</view>
</view>
</view>
@@ -49,14 +69,100 @@
</template>
<script setup>
import { ref } from "vue";
import { ref, onMounted, nextTick } from "vue";
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
import { createWorkOrder } from "@/request/api/OrderApi";
const contactName = ref("");
const contactPhone = ref("");
const isCallSuccess = ref(false); // 呼叫成功状态
const workOrderId = ref(""); // 工单ID
const handleCall = () => {
// Logic to handle the call action
console.log("Calling with:", contactName.value, contactPhone.value);
const handleCall = async () => {
// 验证输入
if (!contactName.value.trim()) {
uni.showToast({
title: '请填写联系人',
icon: 'none',
duration: 2000
});
return;
}
if (!contactPhone.value.trim()) {
uni.showToast({
title: '请填写联系电话',
icon: 'none',
duration: 2000
});
return;
}
try {
const res = await createWorkOrder({
contactName: contactName.value,
contactPhone: contactPhone.value,
workOrderTypeId: '1942741501754765314',
roomId: '302',
});
if (res.code === 0) {
// 保存工单ID
workOrderId.value = res.data?.id || "";
// 设置呼叫成功状态
isCallSuccess.value = true;
uni.showToast({
title: '工单创建成功',
icon: 'success',
duration: 2000
});
} else {
uni.showToast({
title: res.message || '创建工单失败',
icon: 'none',
duration: 2000
});
}
} catch (error) {
console.error('创建工单失败:', error);
uni.showToast({
title: '网络错误,请重试',
icon: 'none',
duration: 2000
});
}
};
// 查看工单
const viewWorkOrder = () => {
console.log("查看工单:", workOrderId.value);
// 这里可以跳转到工单详情页面
uni.navigateTo({
url: `/pages/order/list?id=${workOrderId.value}`
});
};
// 标记已完成
const markCompleted = () => {
console.log("标记工单已完成:", workOrderId.value);
uni.showModal({
title: '确认完成',
content: '确认标记此工单为已完成吗?',
success: (res) => {
if (res.confirm) {
// 这里可以调用API标记工单完成
uni.showToast({
title: '工单已完成',
icon: 'success',
duration: 2000
});
}
}
});
};
const makePhoneCall = () => {
@@ -65,6 +171,14 @@ const makePhoneCall = () => {
phoneNumber: "15185111210",
});
};
onMounted(() => {
nextTick(() => {
setTimeout(() => {
uni.$emit(SCROLL_TO_BOTTOM, true)
}, 200)
});
})
</script>
<style scoped lang="scss">

View File

@@ -8,6 +8,10 @@
联系电话:
立即呼叫按钮
呼叫成功之后
1、呼叫按钮变为两个按钮 查看工单和已完成,见图中的布局
2、联系人和联系电话仅展示不能编辑
## 提示词:
使用 uniapp + vue3 组合式 api 开发微信小程序,要求如下:

View File

@@ -121,6 +121,43 @@
justify-content: center;
}
// 呼叫成功后的按钮容器
.order-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
gap: 12px;
}
// 查看工单按钮(次要按钮)
.order-button-secondary {
flex: 1;
height: 42px;
background: linear-gradient(90deg, #0256FF, #00A6FF);
color: #fff;
font-size: 14px;
font-weight: 600;
border: none;
border-radius: 20px;
display: flex;
align-items: center;
justify-content: center;
}
// 已完成按钮(主要按钮)
.order-button-primary {
flex: 1;
height: 42px;
background: linear-gradient(90deg, #ff7e00, #ffba00);
color: #fff;
font-size: 14px;
font-weight: 600;
border-radius: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.footer-help {
margin-bottom: 12px;
display: flex;

View File

@@ -85,16 +85,16 @@
import { ref, watch, nextTick, onMounted, onUnmounted } from 'vue'
const props = defineProps({
inputMessage: String,
modelValue: String,
holdKeyboard: Boolean,
isSessionActive: Boolean,
stopRequest: Function
})
const emit = defineEmits(['update:inputMessage', 'send', 'noHideKeyboard', 'keyboardShow', 'keyboardHide', 'sendVoice'])
const emit = defineEmits(['update:modelValue', 'send', 'noHideKeyboard', 'keyboardShow', 'keyboardHide', 'sendVoice'])
const textareaRef = ref(null)
const placeholder = ref('快告诉朵朵您在想什么~')
const inputMessage = ref(props.inputMessage || '')
const inputMessage = ref(props.modelValue || '')
const isFocused = ref(false)
const keyboardHeight = ref(0)
const isVoiceMode = ref(false)
@@ -107,10 +107,18 @@ const isSlideToText = ref(false)
// 保持和父组件同步
watch(() => props.inputMessage, (val) => {
watch(() => props.modelValue, (val) => {
inputMessage.value = val
})
// 当子组件的 inputMessage 变化时,通知父组件(但要避免循环更新)
watch(inputMessage, (val) => {
// 只有当值真正不同时才emit避免循环更新
if (val !== props.modelValue) {
emit('update:modelValue', val)
}
})
// 切换语音/文本模式
const toggleVoiceMode = () => {
isVoiceMode.value = !isVoiceMode.value

View File

@@ -133,8 +133,8 @@ onMounted(() => {
box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1); /* 阴影 */
}
.calendar-img {
width: 48rpx;
height: 48rpx;
width: 16px;
height: 16px;
}
.calendar-text {
font-size: 22rpx;

View File

@@ -2,7 +2,7 @@
<view class="container">
<ModuleTitle :title="commodityDTO.title" />
<view class="container-scroll">
<view class="mk-card-item" v-for="(item) in commodityDTO.commodityList" :key="item.commodityName">
<view class="mk-card-item" v-for="(item, index) in commodityDTO.commodityList" :key="`${item.commodityId}-${index}`">
<!-- <view class="card-badge">超值推荐</view> -->
<image class="card-img" :src="item.commodityIcon" mode="aspectFill" />
<view class="card-content">

View File

@@ -9,6 +9,11 @@ const userWorkOrderList = (args) => {
return request.post("/hotelBiz/workOrder/userWorkOrderList", args);
};
/// 创建工单
function createWorkOrder(args) {
return request.post('/hotelBiz/workOrder/createWorkOrder', args);
}
// 获取订单详情
const userOrderDetail = (args) => {
return request.post("/hotelBiz/order/userOrderDetail", args);
@@ -37,6 +42,7 @@ const orderPayNow = (args) => {
export {
userOrderList,
userWorkOrderList,
createWorkOrder,
userOrderDetail,
preOrder,
orderCancel,