图标选择器优化,底部导航
This commit is contained in:
parent
18eb788ac9
commit
5dbc93a1bc
|
|
@ -2,7 +2,7 @@ import request from '@/utils/request'
|
||||||
|
|
||||||
// 页面装修详情
|
// 页面装修详情
|
||||||
export function getDecoratePages(params: any) {
|
export function getDecoratePages(params: any) {
|
||||||
return request.get({ url: '/decorate/pages/detail', params })
|
return request.get({ url: '/decorate/pages/detail', params }, { ignoreCancelToken: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面装修保存
|
// 页面装修保存
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="custom-link mt-[60px]">
|
<div class="custom-link mt-[30px]">
|
||||||
<div class="flex flex-wrap items-center">
|
<div class="flex flex-wrap items-center">
|
||||||
自定义链接
|
自定义链接
|
||||||
<div class="ml-4 flex-1 min-w-[100px]">
|
<div class="ml-4 flex-1 min-w-[100px]">
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="link flex">
|
<div class="link flex">
|
||||||
<el-menu
|
<el-menu
|
||||||
:default-active="activeMenu"
|
:default-active="activeMenu"
|
||||||
class="w-[160px] min-h-[400px] link-menu"
|
class="w-[160px] min-h-[350px] link-menu"
|
||||||
@select="handleSelect"
|
@select="handleSelect"
|
||||||
>
|
>
|
||||||
<el-menu-item v-for="(item, index) in menus" :index="item.type" :key="index">
|
<el-menu-item v-for="(item, index) in menus" :index="item.type" :key="index">
|
||||||
|
|
@ -10,8 +10,16 @@
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
<div class="flex-1 pl-4">
|
<div class="flex-1 pl-4">
|
||||||
<shop-pages v-model="activeLink" v-if="LinkTypeEnum.SHOP_PAGES == activeMenu" />
|
<shop-pages
|
||||||
<custom-link v-model="activeLink" v-if="LinkTypeEnum.CUSTOM_LINK == activeMenu" />
|
v-model="activeLink"
|
||||||
|
v-if="LinkTypeEnum.SHOP_PAGES == activeMenu"
|
||||||
|
@update:model-value="updateLink"
|
||||||
|
/>
|
||||||
|
<custom-link
|
||||||
|
v-model="activeLink"
|
||||||
|
v-if="LinkTypeEnum.CUSTOM_LINK == activeMenu"
|
||||||
|
@update:model-value="updateLink"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -24,36 +32,60 @@ import CustomLink from './custom-link.vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Object as PropType<Link>
|
type: Object as PropType<Link>,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'update:modelValue', value: any): void
|
(event: 'update:modelValue', value: any): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const activeLink = computed({
|
|
||||||
get() {
|
|
||||||
return props.modelValue
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
emit('update:modelValue', value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const menus = ref([
|
const menus = ref([
|
||||||
{
|
{
|
||||||
name: '商城页面',
|
name: '商城页面',
|
||||||
type: LinkTypeEnum.SHOP_PAGES
|
type: LinkTypeEnum.SHOP_PAGES,
|
||||||
|
link: {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '自定义链接',
|
name: '自定义链接',
|
||||||
type: LinkTypeEnum.CUSTOM_LINK
|
type: LinkTypeEnum.CUSTOM_LINK,
|
||||||
|
link: {}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const activeLink = computed({
|
||||||
|
get() {
|
||||||
|
return menus.value.find((item) => item.type == activeMenu.value)?.link as Link
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
menus.value.forEach((item) => {
|
||||||
|
if (item.type == activeMenu.value) {
|
||||||
|
item.link = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const activeMenu = ref<string>(LinkTypeEnum.SHOP_PAGES)
|
const activeMenu = ref<string>(LinkTypeEnum.SHOP_PAGES)
|
||||||
|
|
||||||
const handleSelect = (index: string) => {
|
const handleSelect = (index: string) => {
|
||||||
activeMenu.value = index
|
activeMenu.value = index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateLink = (value: any) => {
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(value) => {
|
||||||
|
activeMenu.value = value.type
|
||||||
|
activeLink.value = value
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Link } from '.'
|
import { LinkTypeEnum, type Link } from '.'
|
||||||
import LinkContent from './index.vue'
|
import LinkContent from './index.vue'
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
@ -31,14 +31,16 @@ const emit = defineEmits<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||||
const activeLink = ref<Link>()
|
const activeLink = ref<Link>({ path: '', type: LinkTypeEnum.SHOP_PAGES })
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
emit('update:modelValue', activeLink.value)
|
emit('update:modelValue', activeLink.value)
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(value) => {
|
(value) => {
|
||||||
activeLink.value = value as Link
|
if (value?.type) {
|
||||||
|
activeLink.value = value as Link
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true
|
immediate: true
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="shop-pages">
|
<div class="shop-pages">
|
||||||
<div class="link-list flex flex-wrap">
|
<div class="link-list flex flex-wrap">
|
||||||
<div
|
<div
|
||||||
class="link-item border border-br px-5 py-[5px] rounded-[3px] cursor-pointer"
|
class="link-item border border-br px-5 py-[5px] rounded-[3px] cursor-pointer mr-[10px] mb-[10px]"
|
||||||
v-for="(item, index) in linkList"
|
v-for="(item, index) in linkList"
|
||||||
:class="{ 'border-primary text-primary': modelValue.path == item.path }"
|
:class="{ 'border-primary text-primary': modelValue.path == item.path }"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
|
@ -33,6 +33,16 @@ const linkList = ref([
|
||||||
path: '/pages/index/index',
|
path: '/pages/index/index',
|
||||||
name: '商城首页',
|
name: '商城首页',
|
||||||
type: LinkTypeEnum.SHOP_PAGES
|
type: LinkTypeEnum.SHOP_PAGES
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/pages/news/news',
|
||||||
|
name: '文章资讯',
|
||||||
|
type: LinkTypeEnum.SHOP_PAGES
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/pages/user/user',
|
||||||
|
name: '个人中心',
|
||||||
|
type: LinkTypeEnum.SHOP_PAGES
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
<div class="tabbar flex">
|
<div class="tabbar flex">
|
||||||
<div
|
<div
|
||||||
class="tabbar-item flex flex-col justify-center items-center flex-1"
|
class="tabbar-item flex flex-col justify-center items-center flex-1"
|
||||||
v-for="(item, index) in tabbar.data"
|
v-for="(item, index) in tabbar.list"
|
||||||
:key="index"
|
:key="index"
|
||||||
:style="{ color: tabbar.color }"
|
:style="{ color: tabbar.style.defaultColor }"
|
||||||
>
|
>
|
||||||
<img class="w-[22px] h-[22px]" :src="item.unselected" alt="" />
|
<img class="w-[22px] h-[22px]" :src="item.unselected" alt="" />
|
||||||
<div class="leading-3 text-[12px] mt-[4px]">{{ item.name }}</div>
|
<div class="leading-3 text-[12px] mt-[4px]">{{ item.name }}</div>
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
<el-tab-pane label="导航图片" name="content">
|
<el-tab-pane label="导航图片" name="content">
|
||||||
<div class="mb-[18px]">
|
<div class="mb-[18px]">
|
||||||
<del-wrap
|
<del-wrap
|
||||||
v-for="(item, index) in tabbar.data"
|
v-for="(item, index) in tabbar.list"
|
||||||
:key="index"
|
:key="index"
|
||||||
@close="handleDelete(index)"
|
@close="handleDelete(index)"
|
||||||
class="max-w-[400px]"
|
class="max-w-[400px]"
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
</del-wrap>
|
</del-wrap>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-form-item v-if="tabbar.data?.length < max" label-width="0">
|
<el-form-item v-if="tabbar.list?.length < max" label-width="0">
|
||||||
<el-button type="primary" @click="handleAdd">
|
<el-button type="primary" @click="handleAdd">
|
||||||
添加导航
|
添加导航
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -86,10 +86,16 @@
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="样式设置" name="styles">
|
<el-tab-pane label="样式设置" name="styles">
|
||||||
<el-form-item label="默认颜色">
|
<el-form-item label="默认颜色">
|
||||||
<color-picker class="max-w-[400px]" v-model="tabbar.color" />
|
<color-picker
|
||||||
|
class="max-w-[400px]"
|
||||||
|
v-model="tabbar.style.defaultColor"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="选中颜色">
|
<el-form-item label="选中颜色">
|
||||||
<color-picker class="max-w-[400px]" v-model="tabbar.color" />
|
<color-picker
|
||||||
|
class="max-w-[400px]"
|
||||||
|
v-model="tabbar.style.selectedColor"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
@ -108,8 +114,11 @@ import feedback from '@/utils/feedback'
|
||||||
const max = 5
|
const max = 5
|
||||||
const min = 2
|
const min = 2
|
||||||
const tabbar = reactive({
|
const tabbar = reactive({
|
||||||
color: '',
|
style: {
|
||||||
data: [
|
defaultColor: '',
|
||||||
|
selectedColor: ''
|
||||||
|
},
|
||||||
|
list: [
|
||||||
{
|
{
|
||||||
name: '',
|
name: '',
|
||||||
selected: '',
|
selected: '',
|
||||||
|
|
@ -120,8 +129,8 @@ const tabbar = reactive({
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
if (tabbar.data?.length < max) {
|
if (tabbar.list?.length < max) {
|
||||||
tabbar.data.push({
|
tabbar.list.push({
|
||||||
name: '',
|
name: '',
|
||||||
selected: '',
|
selected: '',
|
||||||
unselected: '',
|
unselected: '',
|
||||||
|
|
@ -132,18 +141,19 @@ const handleAdd = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const handleDelete = (index: number) => {
|
const handleDelete = (index: number) => {
|
||||||
if (tabbar.data?.length <= min) {
|
if (tabbar.list?.length <= min) {
|
||||||
return feedback.msgError(`最少保留${min}个`)
|
return feedback.msgError(`最少保留${min}个`)
|
||||||
}
|
}
|
||||||
tabbar.data.splice(index, 1)
|
tabbar.list.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const data = await getDecorateTabbar()
|
const data = await getDecorateTabbar()
|
||||||
// tabbar.value = data
|
tabbar.list = data.list
|
||||||
|
tabbar.style = data.style
|
||||||
}
|
}
|
||||||
const setData = async () => {
|
const setData = async () => {
|
||||||
// await setDecorateTabbar(tabbar.value)
|
await setDecorateTabbar(toRaw(tabbar))
|
||||||
getData()
|
getData()
|
||||||
feedback.msgSuccess('保存成功')
|
feedback.msgSuccess('保存成功')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue