|
@@ -55,13 +55,13 @@
|
|
<van-dropdown-item
|
|
<van-dropdown-item
|
|
v-model="type1ValueRef"
|
|
v-model="type1ValueRef"
|
|
:options="dropdownTypeOptions1"
|
|
:options="dropdownTypeOptions1"
|
|
- title="一级分类"
|
|
|
|
|
|
+ :title="type1DropMenuTextRef === '全部' ? '一级分类' : type1DropMenuTextRef"
|
|
@change="handleChangeDropdownOfType1"
|
|
@change="handleChangeDropdownOfType1"
|
|
/>
|
|
/>
|
|
<van-dropdown-item
|
|
<van-dropdown-item
|
|
v-model="type2ValueRef"
|
|
v-model="type2ValueRef"
|
|
:options="dropdownTypeOptions2"
|
|
:options="dropdownTypeOptions2"
|
|
- title="二级分类"
|
|
|
|
|
|
+ :title="type2DropMenuTextRef === '全部' ? '二级分类' : type2DropMenuTextRef"
|
|
@change="handleChangeDropdownOfType2"
|
|
@change="handleChangeDropdownOfType2"
|
|
/>
|
|
/>
|
|
</van-dropdown-menu>
|
|
</van-dropdown-menu>
|
|
@@ -108,31 +108,38 @@
|
|
finished-text="没有更多了"
|
|
finished-text="没有更多了"
|
|
@load="onLoad"
|
|
@load="onLoad"
|
|
>
|
|
>
|
|
- <div class="tool-card-content w-full px-4 flex flex-wrap md:max-w-[1440px] mx-auto">
|
|
|
|
- <div class="tool-card" v-for="item in toolsListRef" :key="item" @click="handleDetail(item)">
|
|
|
|
- <el-image class="tool-img" :src="`${devPath + item.picturePath}`" fit="contain">
|
|
|
|
- <template #error>
|
|
|
|
- <div class="w-full h-full flex items-center justify-center">
|
|
|
|
- <van-icon name="photo-fail" color="#dcdee0" size="32" />
|
|
|
|
|
|
+ <div class="w-full px-4 ">
|
|
|
|
+ <div class="tool-card-content w-full flex flex-wrap mx-auto md:max-w-[1440px]">
|
|
|
|
+ <div
|
|
|
|
+ class="tool-card"
|
|
|
|
+ v-for="item in toolsListRef"
|
|
|
|
+ :key="item"
|
|
|
|
+ @click="handleDetail(item)"
|
|
|
|
+ >
|
|
|
|
+ <el-image class="tool-img" :src="`${devPath + item.picturePath}`" fit="contain">
|
|
|
|
+ <template #error>
|
|
|
|
+ <div class="w-full h-full flex items-center justify-center">
|
|
|
|
+ <van-icon name="photo-fail" color="#dcdee0" size="32" />
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-image>
|
|
|
|
+ <div class="px-3 pt-2 flex-1 flex flex-col">
|
|
|
|
+ <div class="font-[PingFang-Heavy] truncate">{{ item.toolName }}</div>
|
|
|
|
+ <div class="text-[#585F66] text-xs mt-1 line-clamp-2 break-all">
|
|
|
|
+ {{ item.describe }}
|
|
|
|
+ </div>
|
|
|
|
+ <div class="flex-1 flex items-center justify-end" v-if="+item.toolNum">
|
|
|
|
+ <span class="text-2xl font-['DIN'] font-semibold text-[#004EA2]">{{
|
|
|
|
+ item.toolNum
|
|
|
|
+ }}</span>
|
|
|
|
+ <span class="text-sm font-['PingFang-Heavy'] font-semibold ml-1 text-[#004EA2]"
|
|
|
|
+ >件</span
|
|
|
|
+ >
|
|
</div>
|
|
</div>
|
|
- </template>
|
|
|
|
- </el-image>
|
|
|
|
- <div class="px-3 pt-2 flex-1 flex flex-col">
|
|
|
|
- <div class="font-[PingFang-Heavy] truncate">{{ item.toolName }}</div>
|
|
|
|
- <div class="text-[#585F66] text-xs mt-1 line-clamp-2 break-all">
|
|
|
|
- {{ item.describe }}
|
|
|
|
- </div>
|
|
|
|
- <div class="flex-1 flex items-center justify-end" v-if="+item.toolNum">
|
|
|
|
- <span class="text-2xl font-['DIN'] font-semibold text-[#004EA2]">{{
|
|
|
|
- item.toolNum
|
|
|
|
- }}</span>
|
|
|
|
- <span class="text-sm font-['PingFang-Heavy'] font-semibold ml-1 text-[#004EA2]"
|
|
|
|
- >件</span
|
|
|
|
- >
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="tool-card-none" v-for="item in noneCardNum" :key="item"></div>
|
|
</div>
|
|
</div>
|
|
- <div class="tool-card-none" v-for="item in noneCardNum" :key="item"></div>
|
|
|
|
</div>
|
|
</div>
|
|
</van-list>
|
|
</van-list>
|
|
<van-back-top />
|
|
<van-back-top />
|
|
@@ -164,6 +171,9 @@ const hotToolsRef = ref([])
|
|
|
|
|
|
const type1ValueRef = ref('')
|
|
const type1ValueRef = ref('')
|
|
const type2ValueRef = ref('')
|
|
const type2ValueRef = ref('')
|
|
|
|
+// 下拉选择的文本
|
|
|
|
+const type1DropMenuTextRef = ref('全部')
|
|
|
|
+const type2DropMenuTextRef = ref('全部')
|
|
// 分类列表1级
|
|
// 分类列表1级
|
|
const typeOptions1Ref = ref([])
|
|
const typeOptions1Ref = ref([])
|
|
// 分类列表2级
|
|
// 分类列表2级
|
|
@@ -199,27 +209,42 @@ const noneCardNum = ref(0)
|
|
const onLoad = (value) => {
|
|
const onLoad = (value) => {
|
|
listTools({
|
|
listTools({
|
|
level: '3',
|
|
level: '3',
|
|
- parentId: value,
|
|
|
|
|
|
+ // 优先级,指定的 parentId > 二级分类 id > 一级分类 id > null
|
|
|
|
+ parentId: value || type2ValueRef.value || type1ValueRef.value || null,
|
|
toolName: searchValueRef.value,
|
|
toolName: searchValueRef.value,
|
|
pageNum: pageNum.value,
|
|
pageNum: pageNum.value,
|
|
pageSize: pageSize.value,
|
|
pageSize: pageSize.value,
|
|
delFlag: 0
|
|
delFlag: 0
|
|
}).then((res) => {
|
|
}).then((res) => {
|
|
- toolsListRef.value = toolsListRef.value.concat(res.rows)
|
|
|
|
|
|
+ if (pageNum.value === 1) {
|
|
|
|
+ toolsListRef.value = res.rows
|
|
|
|
+ pageNum.value = 2
|
|
|
|
+ } else {
|
|
|
|
+ toolsListRef.value = toolsListRef.value.concat(res.rows)
|
|
|
|
+ pageNum.value += 1
|
|
|
|
+ }
|
|
// 加载状态结束
|
|
// 加载状态结束
|
|
loadingRef.value = false
|
|
loadingRef.value = false
|
|
-
|
|
|
|
- pageNum.value += 1
|
|
|
|
if (res.rows.length < pageSize.value) finished.value = true
|
|
if (res.rows.length < pageSize.value) finished.value = true
|
|
else finished.value = false
|
|
else finished.value = false
|
|
getFillNums('.tool-card-content', toolsListRef.value, device.value === 'pc' ? 220 : 165).then(
|
|
getFillNums('.tool-card-content', toolsListRef.value, device.value === 'pc' ? 220 : 165).then(
|
|
(nums) => {
|
|
(nums) => {
|
|
- console.log('getFillNums', nums)
|
|
|
|
|
|
+ // console.log('getFillNums', nums)
|
|
noneCardNum.value = nums
|
|
noneCardNum.value = nums
|
|
}
|
|
}
|
|
)
|
|
)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+const getType2Tools = (value) => {
|
|
|
|
+ listTools({
|
|
|
|
+ level: '2',
|
|
|
|
+ parentId: value,
|
|
|
|
+ pageSize: 999
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ typeOptions2Ref.value = res.rows
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
const init = () => {
|
|
const init = () => {
|
|
loadingRef.value = true
|
|
loadingRef.value = true
|
|
// 一级分类
|
|
// 一级分类
|
|
@@ -230,27 +255,21 @@ const init = () => {
|
|
})
|
|
})
|
|
type1ValueRef.value = route.query.id ? Number(route.query.id) : ''
|
|
type1ValueRef.value = route.query.id ? Number(route.query.id) : ''
|
|
type2ValueRef.value = ''
|
|
type2ValueRef.value = ''
|
|
- // 二级分类
|
|
|
|
- // listTools({
|
|
|
|
- // level: '2',
|
|
|
|
- // parentId: route.query.id ? route.query.id : '',
|
|
|
|
- // pageSize: 999
|
|
|
|
- // }).then((res) => {
|
|
|
|
- // typeOptions2Ref.value = res.rows
|
|
|
|
- // })
|
|
|
|
|
|
+ if (type1ValueRef.value) {
|
|
|
|
+ getType2Tools(type1ValueRef.value)
|
|
|
|
+ }
|
|
onLoad(route.query.id)
|
|
onLoad(route.query.id)
|
|
// 常用工具列表
|
|
// 常用工具列表
|
|
getCommonTool().then((res) => {
|
|
getCommonTool().then((res) => {
|
|
hotToolsRef.value = res.data.data.length > 10 ? res.data.data.slice(0, 10) : res.data.data
|
|
hotToolsRef.value = res.data.data.length > 10 ? res.data.data.slice(0, 10) : res.data.data
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-init()
|
|
|
|
|
|
|
|
// 搜索
|
|
// 搜索
|
|
const handleSearch = (pId = '') => {
|
|
const handleSearch = (pId = '') => {
|
|
if (loadingRef.value) return
|
|
if (loadingRef.value) return
|
|
- toolsListRef.value = []
|
|
|
|
pageNum.value = 1
|
|
pageNum.value = 1
|
|
|
|
+ // toolsListRef.value = []
|
|
onLoad(pId)
|
|
onLoad(pId)
|
|
// 每次搜索时存一下搜索内容的次数,方便后台统计常用工具
|
|
// 每次搜索时存一下搜索内容的次数,方便后台统计常用工具
|
|
searchValueRef.value && setCommonTool({ toolName: searchValueRef.value })
|
|
searchValueRef.value && setCommonTool({ toolName: searchValueRef.value })
|
|
@@ -258,20 +277,25 @@ const handleSearch = (pId = '') => {
|
|
// 点击热门关键字搜索
|
|
// 点击热门关键字搜索
|
|
const handleKeySearch = (toolName) => {
|
|
const handleKeySearch = (toolName) => {
|
|
searchValueRef.value = toolName
|
|
searchValueRef.value = toolName
|
|
- toolsListRef.value = []
|
|
|
|
handleSearch()
|
|
handleSearch()
|
|
}
|
|
}
|
|
|
|
|
|
// 点击一级菜单
|
|
// 点击一级菜单
|
|
const handleChangeDropdownOfType1 = (value) => {
|
|
const handleChangeDropdownOfType1 = (value) => {
|
|
- // resetList()
|
|
|
|
|
|
+ if (loadingRef.value) return
|
|
// 取消勾选
|
|
// 取消勾选
|
|
- if (type1ValueRef.value === value && device.value === "pc") {
|
|
|
|
|
|
+ if (type1ValueRef.value === value && device.value === 'pc') {
|
|
type1ValueRef.value = ''
|
|
type1ValueRef.value = ''
|
|
|
|
+ type2ValueRef.value = ''
|
|
typeOptions2Ref.value = []
|
|
typeOptions2Ref.value = []
|
|
handleSearch()
|
|
handleSearch()
|
|
} else {
|
|
} else {
|
|
type1ValueRef.value = value
|
|
type1ValueRef.value = value
|
|
|
|
+ if (device.value === 'phone') {
|
|
|
|
+ type2DropMenuTextRef.value = '全部'
|
|
|
|
+ const targetOfDropDownItem = dropdownTypeOptions1.value.find((item) => item.value == value)
|
|
|
|
+ type1DropMenuTextRef.value = targetOfDropDownItem.text
|
|
|
|
+ }
|
|
listTools({
|
|
listTools({
|
|
level: '2',
|
|
level: '2',
|
|
parentId: value,
|
|
parentId: value,
|
|
@@ -279,18 +303,23 @@ const handleChangeDropdownOfType1 = (value) => {
|
|
}).then((res) => {
|
|
}).then((res) => {
|
|
typeOptions2Ref.value = res.rows
|
|
typeOptions2Ref.value = res.rows
|
|
})
|
|
})
|
|
|
|
+
|
|
handleSearch(value)
|
|
handleSearch(value)
|
|
}
|
|
}
|
|
type2ValueRef.value = value
|
|
type2ValueRef.value = value
|
|
}
|
|
}
|
|
// 点击二级菜单
|
|
// 点击二级菜单
|
|
const handleChangeDropdownOfType2 = (value) => {
|
|
const handleChangeDropdownOfType2 = (value) => {
|
|
- // resetList()
|
|
|
|
|
|
+ if (loadingRef.value) return
|
|
// 取消勾选
|
|
// 取消勾选
|
|
- if (type2ValueRef.value === value && device.value === "pc") {
|
|
|
|
|
|
+ if (type2ValueRef.value === value && device.value === 'pc') {
|
|
type2ValueRef.value = ''
|
|
type2ValueRef.value = ''
|
|
handleSearch(type1ValueRef.value)
|
|
handleSearch(type1ValueRef.value)
|
|
} else {
|
|
} else {
|
|
|
|
+ if (device.value === 'phone') {
|
|
|
|
+ const targetOfDropDownItem = dropdownTypeOptions2.value.find((item) => item.value == value)
|
|
|
|
+ type2DropMenuTextRef.value = targetOfDropDownItem.text
|
|
|
|
+ }
|
|
type2ValueRef.value = value
|
|
type2ValueRef.value = value
|
|
handleSearch(value)
|
|
handleSearch(value)
|
|
}
|
|
}
|
|
@@ -301,8 +330,10 @@ const handleClear = () => {
|
|
handleSearch()
|
|
handleSearch()
|
|
}
|
|
}
|
|
const handleDetail = (row) => {
|
|
const handleDetail = (row) => {
|
|
- router.push({ path: '/detail', query: { id: row.id, toolName: row.toolName } })
|
|
|
|
|
|
+ router.push({ path: '/detail', query: { id: row.id } })
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+init()
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -313,9 +344,12 @@ const handleDetail = (row) => {
|
|
@apply flex-1 flex flex-wrap;
|
|
@apply flex-1 flex flex-wrap;
|
|
}
|
|
}
|
|
.menu-item {
|
|
.menu-item {
|
|
- @apply pl-6 py-1 cursor-pointer;
|
|
|
|
|
|
+ @apply pl-3 pr-3 py-1 cursor-pointer text-center font-semibold;
|
|
&.active {
|
|
&.active {
|
|
color: #004ea2;
|
|
color: #004ea2;
|
|
|
|
+ background-color: #dee6ef;
|
|
|
|
+ border: 1px solid #004ea2;
|
|
|
|
+ border-radius: 4px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|