|
@@ -37,129 +37,150 @@ const DeQuestions = ref([
|
|
|
isLong: false
|
|
isLong: false
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- label: 'List shipments with ETA changes in the last 30 days11111111111111111111111111111111111.',
|
|
|
|
|
- value: 'List shipments with ETA changes in the last 30 days11111111111111111111111111111111111.',
|
|
|
|
|
|
|
+ label:
|
|
|
|
|
+ 'List shipments with ETA changes in the last 30 days11111111111111111111111111111111111.',
|
|
|
|
|
+ value:
|
|
|
|
|
+ 'List shipments with ETA changes in the last 30 days11111111111111111111111111111111111.',
|
|
|
isLong: true
|
|
isLong: true
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- label: 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111122.',
|
|
|
|
|
- value: 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111122.',
|
|
|
|
|
|
|
+ label:
|
|
|
|
|
+ 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111122.',
|
|
|
|
|
+ value:
|
|
|
|
|
+ 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111122.',
|
|
|
isLong: true
|
|
isLong: true
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- label: 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111133.',
|
|
|
|
|
- value: 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111133.',
|
|
|
|
|
|
|
+ label:
|
|
|
|
|
+ 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111133.',
|
|
|
|
|
+ value:
|
|
|
|
|
+ 'List shipments with ETA changes in the last 30 days1111111111111111111111111111111111133.',
|
|
|
isLong: true
|
|
isLong: true
|
|
|
- },
|
|
|
|
|
|
|
+ }
|
|
|
])
|
|
])
|
|
|
-const itemGroups = ref([]);
|
|
|
|
|
-const pages = ref([]);
|
|
|
|
|
|
|
+const itemGroups = ref([])
|
|
|
|
|
+const pages = ref([])
|
|
|
// 随机显示方法
|
|
// 随机显示方法
|
|
|
const prepareGroups = () => {
|
|
const prepareGroups = () => {
|
|
|
- const groups = [];
|
|
|
|
|
- let currentGroup = [];
|
|
|
|
|
- let currentHeight = 0;
|
|
|
|
|
|
|
+ const groups = []
|
|
|
|
|
+ let currentGroup = []
|
|
|
|
|
+ let currentHeight = 0
|
|
|
|
|
+
|
|
|
|
|
+ DeQuestions.value.forEach((item) => {
|
|
|
|
|
+ const itemHeight = item.isLong ? 2 : 1
|
|
|
|
|
|
|
|
- DeQuestions.value.forEach(item => {
|
|
|
|
|
- const itemHeight = item.isLong ? 2 : 1;
|
|
|
|
|
-
|
|
|
|
|
if (currentHeight + itemHeight > 4) {
|
|
if (currentHeight + itemHeight > 4) {
|
|
|
- groups.push(currentGroup);
|
|
|
|
|
- currentGroup = [];
|
|
|
|
|
- currentHeight = 0;
|
|
|
|
|
|
|
+ groups.push(currentGroup)
|
|
|
|
|
+ currentGroup = []
|
|
|
|
|
+ currentHeight = 0
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- currentGroup.push(item);
|
|
|
|
|
- currentHeight += itemHeight;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ currentGroup.push(item)
|
|
|
|
|
+ currentHeight += itemHeight
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
// 添加最后一组
|
|
// 添加最后一组
|
|
|
if (currentGroup.length > 0) {
|
|
if (currentGroup.length > 0) {
|
|
|
- groups.push(currentGroup);
|
|
|
|
|
|
|
+ groups.push(currentGroup)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- itemGroups.value = groups;
|
|
|
|
|
|
|
+ itemGroups.value = groups
|
|
|
}
|
|
}
|
|
|
// 智能分页算法
|
|
// 智能分页算法
|
|
|
const generatePages = () => {
|
|
const generatePages = () => {
|
|
|
- const result = [];
|
|
|
|
|
- let currentPage = { row1: [], row2: [] };
|
|
|
|
|
- let cursor = 0;
|
|
|
|
|
-
|
|
|
|
|
- while(cursor < DeQuestions.value.length) {
|
|
|
|
|
|
|
+ const result = []
|
|
|
|
|
+ let currentPage = { row1: [], row2: [] }
|
|
|
|
|
+ let cursor = 0
|
|
|
|
|
+
|
|
|
|
|
+ while (cursor < DeQuestions.value.length) {
|
|
|
// 处理第一排
|
|
// 处理第一排
|
|
|
- const currentItem = DeQuestions.value[cursor];
|
|
|
|
|
|
|
+ const currentItem = DeQuestions.value[cursor]
|
|
|
// 第一排逻辑
|
|
// 第一排逻辑
|
|
|
- if(currentItem.isLong) {
|
|
|
|
|
|
|
+ if (currentItem.isLong) {
|
|
|
// 长文本独占第一排
|
|
// 长文本独占第一排
|
|
|
- currentPage.row1.push(currentItem);
|
|
|
|
|
- cursor++;
|
|
|
|
|
|
|
+ currentPage.row1.push(currentItem)
|
|
|
|
|
+ cursor++
|
|
|
} else {
|
|
} else {
|
|
|
// 尝试取两个短文本
|
|
// 尝试取两个短文本
|
|
|
- const nextItem = DeQuestions.value[cursor + 1];
|
|
|
|
|
- if(nextItem && !nextItem.isLong) {
|
|
|
|
|
- currentPage.row1.push(currentItem, nextItem);
|
|
|
|
|
- cursor += 2;
|
|
|
|
|
|
|
+ const nextItem = DeQuestions.value[cursor + 1]
|
|
|
|
|
+ if (nextItem && !nextItem.isLong) {
|
|
|
|
|
+ currentPage.row1.push(currentItem, nextItem)
|
|
|
|
|
+ cursor += 2
|
|
|
} else {
|
|
} else {
|
|
|
- currentPage.row1.push(currentItem);
|
|
|
|
|
- cursor++;
|
|
|
|
|
|
|
+ currentPage.row1.push(currentItem)
|
|
|
|
|
+ cursor++
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 处理第二排
|
|
// 处理第二排
|
|
|
- const remaining = DeQuestions.value.slice(cursor);
|
|
|
|
|
- if(remaining.length > 0) {
|
|
|
|
|
- const secondItem = remaining[0];
|
|
|
|
|
-
|
|
|
|
|
- if(secondItem.isLong) {
|
|
|
|
|
- currentPage.row2.push(secondItem);
|
|
|
|
|
- cursor++;
|
|
|
|
|
|
|
+ const remaining = DeQuestions.value.slice(cursor)
|
|
|
|
|
+ if (remaining.length > 0) {
|
|
|
|
|
+ const secondItem = remaining[0]
|
|
|
|
|
+
|
|
|
|
|
+ if (secondItem.isLong) {
|
|
|
|
|
+ currentPage.row2.push(secondItem)
|
|
|
|
|
+ cursor++
|
|
|
} else {
|
|
} else {
|
|
|
- const nextSecondItem = remaining[1];
|
|
|
|
|
- if(nextSecondItem && !nextSecondItem.isLong) {
|
|
|
|
|
- currentPage.row2.push(secondItem, nextSecondItem);
|
|
|
|
|
- cursor += 2;
|
|
|
|
|
|
|
+ const nextSecondItem = remaining[1]
|
|
|
|
|
+ if (nextSecondItem && !nextSecondItem.isLong) {
|
|
|
|
|
+ currentPage.row2.push(secondItem, nextSecondItem)
|
|
|
|
|
+ cursor += 2
|
|
|
} else {
|
|
} else {
|
|
|
- currentPage.row2.push(secondItem);
|
|
|
|
|
- cursor++;
|
|
|
|
|
|
|
+ currentPage.row2.push(secondItem)
|
|
|
|
|
+ cursor++
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 保存当前页
|
|
// 保存当前页
|
|
|
- result.push(currentPage);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ result.push(currentPage)
|
|
|
|
|
+
|
|
|
// 重置页面
|
|
// 重置页面
|
|
|
- currentPage = { row1: [], row2: [] };
|
|
|
|
|
|
|
+ currentPage = { row1: [], row2: [] }
|
|
|
}
|
|
}
|
|
|
- pages.value = result.filter(p => p.row1.length > 0);
|
|
|
|
|
|
|
+ pages.value = result.filter((p) => p.row1.length > 0)
|
|
|
console.log(pages.value)
|
|
console.log(pages.value)
|
|
|
}
|
|
}
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
prepareGroups()
|
|
prepareGroups()
|
|
|
generatePages()
|
|
generatePages()
|
|
|
-});
|
|
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const emit = defineEmits<{ question: [string] }>()
|
|
|
|
|
+const clickQuestion = (question) => {
|
|
|
|
|
+ emit('question', question)
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
<template>
|
|
<template>
|
|
|
<div class="flex_center">
|
|
<div class="flex_center">
|
|
|
- <div class="dialogue_content ">
|
|
|
|
|
|
|
+ <div class="dialogue_content">
|
|
|
<div class="dialogue_content_title">
|
|
<div class="dialogue_content_title">
|
|
|
<div class="dialogue_title_left">
|
|
<div class="dialogue_title_left">
|
|
|
- <img class="dialogue_title_left_img" src="../image/icon_ai_robot48_b@2x.png" width="48px" />
|
|
|
|
|
|
|
+ <img
|
|
|
|
|
+ class="dialogue_title_left_img"
|
|
|
|
|
+ src="../image/icon_ai_robot48_b@2x.png"
|
|
|
|
|
+ width="48px"
|
|
|
|
|
+ />
|
|
|
<div class="dialogue_title_left_text">Frequently Asked Questions</div>
|
|
<div class="dialogue_title_left_text">Frequently Asked Questions</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <el-carousel v-if="props.modalSize === 'large'" class="carousel large_carousel" :autoplay="false" height="115px" >
|
|
|
|
|
- <el-carousel-item
|
|
|
|
|
- v-for="(page, index) in pages "
|
|
|
|
|
- :key="index"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <el-carousel
|
|
|
|
|
+ v-if="props.modalSize === 'large'"
|
|
|
|
|
+ class="carousel large_carousel"
|
|
|
|
|
+ :autoplay="false"
|
|
|
|
|
+ height="115px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-carousel-item v-for="(page, index) in pages" :key="index">
|
|
|
<div class="dialogue_container dialogue_container_large">
|
|
<div class="dialogue_container dialogue_container_large">
|
|
|
<div class="double-row-layout">
|
|
<div class="double-row-layout">
|
|
|
<!-- 第一排 -->
|
|
<!-- 第一排 -->
|
|
|
<div class="row first-row">
|
|
<div class="row first-row">
|
|
|
<template v-for="item in page.row1" :key="item.id">
|
|
<template v-for="item in page.row1" :key="item.id">
|
|
|
- <div class="dialogue_content_item" :class="{ 'long-item': item.isLong }">
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ @click="clickQuestion(item.label)"
|
|
|
|
|
+ class="dialogue_content_item"
|
|
|
|
|
+ :class="{ 'long-item': item.isLong }"
|
|
|
|
|
+ >
|
|
|
{{ item.label }}
|
|
{{ item.label }}
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -167,7 +188,11 @@ onMounted(() => {
|
|
|
<!-- 第二排 -->
|
|
<!-- 第二排 -->
|
|
|
<div class="row second-row">
|
|
<div class="row second-row">
|
|
|
<template v-for="item in page.row2" :key="item.id">
|
|
<template v-for="item in page.row2" :key="item.id">
|
|
|
- <div class="dialogue_content_item" :class="{ 'long-item': item.isLong }">
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ @click="clickQuestion(item.label)"
|
|
|
|
|
+ class="dialogue_content_item"
|
|
|
|
|
+ :class="{ 'long-item': item.isLong }"
|
|
|
|
|
+ >
|
|
|
{{ item.label }}
|
|
{{ item.label }}
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -176,17 +201,14 @@ onMounted(() => {
|
|
|
</div>
|
|
</div>
|
|
|
</el-carousel-item>
|
|
</el-carousel-item>
|
|
|
</el-carousel>
|
|
</el-carousel>
|
|
|
- <el-carousel v-else class="carousel small_carousel" :autoplay="false" height="190px" >
|
|
|
|
|
- <el-carousel-item
|
|
|
|
|
- v-for="(group, index) in itemGroups "
|
|
|
|
|
- :key="index"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <el-carousel v-else class="carousel small_carousel" :autoplay="false" height="190px">
|
|
|
|
|
+ <el-carousel-item v-for="(group, index) in itemGroups" :key="index">
|
|
|
<div class="dialogue_container">
|
|
<div class="dialogue_container">
|
|
|
- <div
|
|
|
|
|
|
|
+ <div
|
|
|
class="dialogue_content_item"
|
|
class="dialogue_content_item"
|
|
|
v-for="item in group"
|
|
v-for="item in group"
|
|
|
:key="item.label"
|
|
:key="item.label"
|
|
|
- :class="{ 'long_item': item.isLong }"
|
|
|
|
|
|
|
+ :class="{ long_item: item.isLong }"
|
|
|
>
|
|
>
|
|
|
{{ item.label }}
|
|
{{ item.label }}
|
|
|
</div>
|
|
</div>
|
|
@@ -260,4 +282,3 @@ onMounted(() => {
|
|
|
padding-bottom: 0 !important;
|
|
padding-bottom: 0 !important;
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|
|
|
-
|
|
|