Branch_csl #31

Merged
root merged 3 commits from Branch_csl into master 2024-10-08 17:44:33 +08:00
16 changed files with 894 additions and 424 deletions

View File

@ -109,3 +109,13 @@ export const exportSpu = async (params) => {
export const getSpuSimpleList = async () => { export const getSpuSimpleList = async () => {
return request.get({ url: '/product/spu/list-all-simple' }) return request.get({ url: '/product/spu/list-all-simple' })
} }
// 获得拼团商品 SPU 列表
export const getSpuAdminSpuList = async () => {
return request.get({ url: '/promotion/combination-activity/adminSpuList' })
}
// 获得秒杀商品 SPU 列表
export const getSpuMiaoShaAdminSpuList = async () => {
return request.get({ url: '/promotion/seckill-activity/adminSpuList' })
}

View File

@ -21,6 +21,7 @@
<!-- 右侧链接列表 --> <!-- 右侧链接列表 -->
<el-scrollbar class="h-full flex-1" @scroll="handleScroll" ref="linkScrollbar"> <el-scrollbar class="h-full flex-1" @scroll="handleScroll" ref="linkScrollbar">
<div v-for="(group, groupIndex) in APP_LINK_GROUP_LIST" :key="groupIndex"> <div v-for="(group, groupIndex) in APP_LINK_GROUP_LIST" :key="groupIndex">
<template v-if="activeGroup == group.name">
<!-- 分组标题 --> <!-- 分组标题 -->
<div class="font-bold" ref="groupTitleRefs">{{ group.name }}</div> <div class="font-bold" ref="groupTitleRefs">{{ group.name }}</div>
<!-- 链接列表 --> <!-- 链接列表 -->
@ -39,6 +40,8 @@
{{ appLink.name }} {{ appLink.name }}
</el-button> </el-button>
</el-tooltip> </el-tooltip>
</template>
</div> </div>
</el-scrollbar> </el-scrollbar>
</div> </div>
@ -155,11 +158,11 @@ const linkScrollbar = ref<ScrollbarInstance>()
// //
const handleGroupSelected = (group: string) => { const handleGroupSelected = (group: string) => {
activeGroup.value = group activeGroup.value = group
const titleRef = groupTitleRefs.value.find((item: HTMLInputElement) => item.textContent === group) // const titleRef = groupTitleRefs.value.find((item: HTMLInputElement) => item.textContent === group)
if (titleRef) { // if (titleRef) {
// // //
linkScrollbar.value?.setScrollTop(titleRef.offsetTop) // linkScrollbar.value?.setScrollTop(titleRef.offsetTop)
} // }
} }
// //

View File

@ -250,5 +250,30 @@ export const APP_LINK_GROUP_LIST = [
path: '/pages/user/user_vip/index' path: '/pages/user/user_vip/index'
} }
] ]
},
{
name: '自定义页面',
links: [
{
name: '促销页面',
path: 'ss'
},
{
name: '关于我们',
path: '/pages/pay/recharge-lo'
},
{
name: '产品与服务',
path: '/pages/pay/recharge-l'
},
{
name: '自定义页面',
path: '/pages/pay/recharge-'
},
{
name: '个人中心',
path: '/pages/pay/recharge'
}
]
} }
] as AppLinkGroup[] ] as AppLinkGroup[]

View File

@ -128,8 +128,8 @@ const handleCloneComponent = (component: DiyComponent<any>) => {
width: 86px; width: 86px;
height: 86px; height: 86px;
cursor: move; cursor: move;
border-right: 1px solid var(--el-border-color-lighter); // border-right: 1px solid var(--el-border-color-lighter);
border-bottom: 1px solid var(--el-border-color-lighter); // border-bottom: 1px solid var(--el-border-color-lighter);
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;

View File

@ -1,7 +1,7 @@
<template> <template>
<el-scrollbar class="z-1 min-h-30px" wrap-class="w-full" ref="containerRef"> <el-scrollbar class="z-1 min-h-30px" wrap-class="w-full" ref="containerRef">
<div <div
class="flex flex-row text-12px" class="new-class flex flex-row text-12px"
:style="{ :style="{
gap: `${property.space}px`, gap: `${property.space}px`,
width: scrollbarWidth width: scrollbarWidth
@ -20,13 +20,10 @@
:key="index" :key="index"
> >
<!-- 布局11--> <!-- 布局11-->
<div v-if="property.columns === 1" class="m-l-16px flex flex-row justify-between p-8px"> <!-- <div v-if="property.columns === 1" class="m-l-16px flex flex-row justify-between p-8px">
<div class="flex flex-col justify-evenly gap-4px"> <div class="flex flex-col justify-evenly gap-4px">
<!-- 优惠值 -->
<CouponDiscount :coupon="coupon" /> <CouponDiscount :coupon="coupon" />
<!-- 优惠描述 -->
<CouponDiscountDesc :coupon="coupon" /> <CouponDiscountDesc :coupon="coupon" />
<!-- 有效期 -->
<CouponValidTerm :coupon="coupon" /> <CouponValidTerm :coupon="coupon" />
</div> </div>
<div class="flex flex-col justify-evenly"> <div class="flex flex-col justify-evenly">
@ -40,11 +37,11 @@
立即领取 立即领取
</div> </div>
</div> </div>
</div> </div> -->
<!-- 布局22--> <!-- 布局22-->
<!-- v-else-if="property.columns === 2"s -->
<div <div
v-else-if="property.columns === 2" class="m-l-16px flex flex-row justify-between"
class="m-l-16px flex flex-row justify-between p-8px"
> >
<div class="flex flex-col justify-evenly gap-4px"> <div class="flex flex-col justify-evenly gap-4px">
<!-- 优惠值 --> <!-- 优惠值 -->
@ -64,8 +61,7 @@
</div> </div>
</div> </div>
<!-- 布局33--> <!-- 布局33-->
<div v-else class="flex flex-col items-center justify-around gap-4px p-4px"> <!-- <div v-else class="flex flex-col items-center justify-around gap-4px p-4px">
<!-- 优惠值 -->
<CouponDiscount :coupon="coupon" /> <CouponDiscount :coupon="coupon" />
<div>{{ coupon.name }}</div> <div>{{ coupon.name }}</div>
<div <div
@ -77,7 +73,7 @@
> >
立即领取 立即领取
</div> </div>
</div> </div> -->
</div> </div>
</div> </div>
</el-scrollbar> </el-scrollbar>
@ -139,4 +135,11 @@ onMounted(() => {
phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 375 phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 375
}) })
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss">
.new-class{
margin-left: 10px;
.box-content{
margin-right:10px;
}
}
</style>

View File

@ -26,6 +26,7 @@
'w-140px': property.layoutType === 'oneColSmallImg' 'w-140px': property.layoutType === 'oneColSmallImg'
} }
]" ]"
style="padding:10px;"
> >
<el-image fit="cover" class="h-full w-full" :src="spu.picUrl" /> <el-image fit="cover" class="h-full w-full" :src="spu.picUrl" />
</div> </div>

View File

@ -1,5 +1,25 @@
<template> <template>
<el-scrollbar class="z-1 min-h-30px" wrap-class="w-full" ref="containerRef"> <el-scrollbar class="z-1 min-h-30px" wrap-class="w-full" ref="containerRef">
<div class="component">
<div style="padding: 0px; border-radius: 0px; overflow: hidden;">
<div class="min-h-42px flex flex-col">
<div class="item h-42px flex flex-row items-center justify-between gap-4px p-x-12px">
<div class="flex flex-1 flex-row items-center gap-8px">
<div class="wh">
<img
src="https://zysc.fjptzykj.com:3000/shangcheng/02d372da2be37f10ecb4b79509a68f4d1c3fe6429add76d4c80f3cb9ee401e33.png" />
</div>
<span class="text-16px" style="color: rgb(187, 187, 187);">92人拼团成功</span>
</div>
<div class="item-center flex flex-row justify-center gap-4px">
<span class="text-12px" style="color: rgb(187, 187, 187);">查看更多</span>
<Icon icon="ep-arrow-right" color="#000" :size="16" />
</div>
</div>
</div>
</div>
</div>
<!-- 商品网格 --> <!-- 商品网格 -->
<div <div
class="grid overflow-x-auto" class="grid overflow-x-auto"
@ -11,7 +31,7 @@
> >
<!-- 商品 --> <!-- 商品 -->
<div <div
class="relative box-content flex flex-row flex-wrap overflow-hidden bg-white" class="new-class relative box-content flex flex-row flex-wrap overflow-hidden "
:style="{ :style="{
borderTopLeftRadius: `${property.borderRadiusTop}px`, borderTopLeftRadius: `${property.borderRadiusTop}px`,
borderTopRightRadius: `${property.borderRadiusTop}px`, borderTopRightRadius: `${property.borderRadiusTop}px`,
@ -79,7 +99,8 @@ watch(
if (!props.property.activityId) return if (!props.property.activityId) return
const activity = await CombinationActivityApi.getCombinationActivity(props.property.activityId) const activity = await CombinationActivityApi.getCombinationActivity(props.property.activityId)
if (!activity?.spuId) return if (!activity?.spuId) return
spuList.value = [await ProductSpuApi.getSpu(activity.spuId)] spuList.value = await ProductSpuApi.getSpuAdminSpuList()
console.log(spuList.value,'请求成功')
}, },
{ {
immediate: true, immediate: true,
@ -122,4 +143,31 @@ onMounted(() => {
}) })
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss">
.new-class{
padding: 10px;
// width:42%;
}
:deep(.el-scrollbar__view) {
background-color: white;
border-radius: 12px;
}
.wh {
position: relative;
padding-right: 10px;
}
.wh::after {
position: absolute;
content: "";
top: 50%;
right: 0;
width: 1px;
height: 57%;
border-right: 1px solid #ababab;
transform: translateY(-50%);
}
</style>

View File

@ -14,7 +14,7 @@
</el-form-item> </el-form-item>
</el-card> </el-card>
<el-card header="商品样式" class="property-group" shadow="never"> <el-card header="商品样式" class="property-group" shadow="never">
<el-form-item label="布局" prop="type"> <!-- <el-form-item label="布局" prop="type">
<el-radio-group v-model="formData.layoutType"> <el-radio-group v-model="formData.layoutType">
<el-tooltip class="item" content="单列" placement="bottom"> <el-tooltip class="item" content="单列" placement="bottom">
<el-radio-button label="oneCol"> <el-radio-button label="oneCol">
@ -27,7 +27,7 @@
</el-radio-button> </el-radio-button>
</el-tooltip> </el-tooltip>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item> -->
<el-form-item label="商品名称" prop="fields.name.show"> <el-form-item label="商品名称" prop="fields.name.show">
<div class="flex gap-8px"> <div class="flex gap-8px">
<ColorInput v-model="formData.fields.name.color" /> <ColorInput v-model="formData.fields.name.color" />

View File

@ -1,59 +1,64 @@
<template> <template>
<el-scrollbar class="z-1 min-h-30px" wrap-class="w-full" ref="containerRef"> <el-scrollbar class="z-1 min-h-30px" wrap-class="w-full" ref="containerRef">
<div class="component">
<div style="padding: 0px; border-radius: 0px; overflow: hidden;">
<div class="min-h-42px flex flex-col">
<div class="item h-42px flex flex-row items-center justify-between gap-4px p-x-12px">
<div class="flex flex-1 flex-row items-center gap-8px">
<div class="wh">
<img
src="https://zysc.fjptzykj.com:3000/shangcheng/1bd7faadbb3c319c6ad303edc23ecbf12162b8ac22e2c8058b3914397d9dd226.png" />
</div>
<span class="text-16px" style="color: rgb(187, 187, 187);">已有99人购买</span>
</div>
<div class="item-center flex flex-row justify-center gap-4px">
<span class="text-12px" style="color: rgb(187, 187, 187);">查看更多</span>
<Icon icon="ep-arrow-right" color="#000" :size="16" />
</div>
</div>
</div>
</div>
</div>
<!-- 商品网格 --> <!-- 商品网格 -->
<div <!-- gridGap: `${property.space}px`, -->
class="grid overflow-x-auto" <div class="new-main" :style="{
:style="{
gridGap: `${property.space}px`,
gridTemplateColumns, gridTemplateColumns,
width: scrollbarWidth width: scrollbarWidth
}" }">
>
<!-- 商品 --> <!-- 商品 -->
<div <!--
class="relative box-content flex flex-row flex-wrap overflow-hidden bg-white"
:style="{ :style="{
borderTopLeftRadius: `${property.borderRadiusTop}px`, borderTopLeftRadius: `${property.borderRadiusTop}px`,
borderTopRightRadius: `${property.borderRadiusTop}px`, borderTopRightRadius: `${property.borderRadiusTop}px`,
borderBottomLeftRadius: `${property.borderRadiusBottom}px`, borderBottomLeftRadius: `${property.borderRadiusBottom}px`,
borderBottomRightRadius: `${property.borderRadiusBottom}px` borderBottomRightRadius: `${property.borderRadiusBottom}px`
}" }"
v-for="(spu, index) in spuList" -->
:key="index" <div class="new-class relative box-content flex-row flex-wrap overflow-hidden"
> v-for="(spu, index) in spuList" :key="index">
<!-- 角标 --> <!-- 角标 -->
<div <div v-if="property.badge.show" class="absolute left-0 top-0 z-1 items-center justify-center">
v-if="property.badge.show" <el-image fit="cover" :src="property.badge.imgUrl" class="new-img" />
class="absolute left-0 top-0 z-1 items-center justify-center"
>
<el-image fit="cover" :src="property.badge.imgUrl" class="h-26px w-38px" />
</div> </div>
<!-- 商品封面图 --> <!-- 商品封面图 -->
<el-image fit="cover" :src="spu.picUrl" :style="{ width: imageSize, height: imageSize }" /> <el-image fit="cover" :src="spu.picUrl" :style="{ width: imageSize, height: imageSize }" />
<div <div :class="[
:class="[
'flex flex-col gap-8px p-8px box-border', 'flex flex-col gap-8px p-8px box-border',
{ {
'w-[calc(100%-64px)]': columns === 2, 'w-[calc(100%-64px)]': columns === 2,
'w-full': columns === 3 'w-full': columns === 3
} }
]" ]">
>
<!-- 商品名称 --> <!-- 商品名称 -->
<div <div v-if="property.fields.name.show" class="truncate text-12px"
v-if="property.fields.name.show" :style="{ color: property.fields.name.color }">
class="truncate text-12px"
:style="{ color: property.fields.name.color }"
>
{{ spu.name }} {{ spu.name }}
</div> </div>
<div> <div>
<!-- 商品价格 --> <!-- 商品价格 -->
<span <span v-if="property.fields.price.show" class="text-12px"
v-if="property.fields.price.show" :style="{ color: property.fields.price.color }">
class="text-12px"
:style="{ color: property.fields.price.color }"
>
{{ spu.price }} {{ spu.price }}
</span> </span>
</div> </div>
@ -63,43 +68,43 @@
</el-scrollbar> </el-scrollbar>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PromotionSeckillProperty } from './config' import { PromotionSeckillProperty } from './config'
import * as ProductSpuApi from '@/api/mall/product/spu' import * as ProductSpuApi from '@/api/mall/product/spu'
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity' import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
/** 秒杀 */ /** 秒杀 */
defineOptions({ name: 'PromotionSeckill' }) defineOptions({ name: 'PromotionSeckill' })
// //
const props = defineProps<{ property: PromotionSeckillProperty }>() const props = defineProps<{ property : PromotionSeckillProperty }>()
// //
const spuList = ref<ProductSpuApi.Spu[]>([]) const spuList = ref<ProductSpuApi.Spu[]>([])
watch( watch(
() => props.property.activityId, () => props.property.activityId,
async () => { async () => {
if (!props.property.activityId) return if (!props.property.activityId) return
const activity = await SeckillActivityApi.getSeckillActivity(props.property.activityId) const activity = await SeckillActivityApi.getSeckillActivity(props.property.activityId)
if (!activity?.spuId) return if (!activity?.spuId) return
spuList.value = [await ProductSpuApi.getSpu(activity.spuId)] spuList.value = await ProductSpuApi.getSpuMiaoShaAdminSpuList()
}, },
{ {
immediate: true, immediate: true,
deep: true deep: true
} }
) )
// //
const phoneWidth = ref(375) const phoneWidth = ref(375)
// //
const containerRef = ref() const containerRef = ref()
// //
const columns = ref(2) const columns = ref(2)
// //
const scrollbarWidth = ref('100%') const scrollbarWidth = ref('100%')
// //
const imageSize = ref('0') const imageSize = ref('0')
// //
const gridTemplateColumns = ref('') const gridTemplateColumns = ref('')
// //
watch( watch(
() => [props.property, phoneWidth, spuList.value.length], () => [props.property, phoneWidth, spuList.value.length],
() => { () => {
// //
@ -115,11 +120,46 @@ watch(
scrollbarWidth.value = '100%' scrollbarWidth.value = '100%'
}, },
{ immediate: true, deep: true } { immediate: true, deep: true }
) )
onMounted(() => { onMounted(() => {
// //
phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 375 phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 375
}) })
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss">
:deep(.el-scrollbar__view) {
background-color: white;
border-radius: 12px;
}
.new-class {
width: 33%;
padding: 10px;
// width:42%;
}
.new-main {
display: flex;
}
:deep(.el-image) {
width: 100% !important;
}
.wh {
position: relative;
padding-right: 10px;
}
.wh::after {
position: absolute;
content: "";
top: 50%;
right: 0;
width: 1px;
height: 57%;
border-right: 1px solid #ababab;
transform: translateY(-50%);
}
</style>

View File

@ -249,6 +249,7 @@ watch(
const component = componentConfigs[item.id] const component = componentConfigs[item.id]
return { ...component, property: item.property } return { ...component, property: item.property }
}) })
console.log(modelValue,"pageComponents.value")
}, },
{ {
immediate: true immediate: true

View File

@ -146,7 +146,7 @@ export const PAGE_LIBS = [
components: [ components: [
'PromotionCombination', 'PromotionCombination',
'PromotionSeckill', 'PromotionSeckill',
'PromotionPoint', // 'PromotionPoint',
'CouponCard', 'CouponCard',
'PromotionArticle' 'PromotionArticle'
] ]

View File

@ -469,7 +469,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
] ]
}, },
{ {
path: '/diy', path: '/diy-template/diy',
name: 'DiyCenter', name: 'DiyCenter',
meta: { hidden: true }, meta: { hidden: true },
component: Layout, component: Layout,

View File

@ -1,18 +1,10 @@
<template> <template>
<DiyEditor <DiyEditor v-if="formData && !formLoading" v-model="currentFormData!.property"
v-if="formData && !formLoading" :title="templateItems[selectedTemplateItem].name" :libs="libs" :show-page-config="selectedTemplateItem !== 0"
v-model="currentFormData!.property" :show-tab-bar="selectedTemplateItem === 0" :show-navigation-bar="selectedTemplateItem !== 0"
:title="templateItems[selectedTemplateItem].name" :preview-url="previewUrl" @save="submitForm" @reset="handleEditorReset">
:libs="libs"
:show-page-config="selectedTemplateItem !== 0"
:show-tab-bar="selectedTemplateItem === 0"
:show-navigation-bar="selectedTemplateItem !== 0"
:preview-url="previewUrl"
@save="submitForm"
@reset="handleEditorReset"
>
<template #toolBarLeft> <template #toolBarLeft>
<el-radio-group <!-- <el-radio-group
v-model="selectedTemplateItem" v-model="selectedTemplateItem"
class="h-full!" class="h-full!"
@change="handleTemplateItemChange" @change="handleTemplateItemChange"
@ -22,82 +14,90 @@
<Icon :icon="item.icon" :size="24" /> <Icon :icon="item.icon" :size="24" />
</el-radio-button> </el-radio-button>
</el-tooltip> </el-tooltip>
</el-radio-group> </el-radio-group> -->
</template> </template>
</DiyEditor> </DiyEditor>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// TODO @ decorate index.vue // TODO @ decorate index.vue
import * as DiyTemplateApi from '@/api/mall/promotion/diy/template' import * as DiyTemplateApi from '@/api/mall/promotion/diy/template'
import * as DiyPageApi from '@/api/mall/promotion/diy/page' import * as DiyPageApi from '@/api/mall/promotion/diy/page'
import { useTagsViewStore } from '@/store/modules/tagsView' import { useTagsViewStore } from '@/store/modules/tagsView'
import { DiyComponentLibrary, PAGE_LIBS } from '@/components/DiyEditor/util' // DIY DiyEditor import { DiyComponentLibrary, PAGE_LIBS } from '@/components/DiyEditor/util' // DIY DiyEditor
import { toNumber } from 'lodash-es' import { toNumber } from 'lodash-es'
// import { watch } from 'vue';
/** 装修模板表单 */ /** 装修模板表单 */
defineOptions({ name: 'DiyTemplateDecorate' }) defineOptions({ name: 'DiyTemplateDecorate' })
/** 初始化 **/
// const { currentRoute } = useRouter() //
const selectedTemplateItem = ref(0) const { delView } = useTagsViewStore() //
const templateItems = reactive([ const route = useRoute();
//
const selectedTemplateItem = ref('0')
// console.log(selectedTemplateItem.value,'selectedTemplateItemselectedTemplateItem')
const templateItems = reactive([
{ name: '基础设置', icon: 'ep:iphone' }, { name: '基础设置', icon: 'ep:iphone' },
{ name: '首页', icon: 'ep:home-filled' }, { name: '首页', icon: 'ep:home-filled' },
{ name: '我的', icon: 'ep:user-filled' } { name: '我的', icon: 'ep:user-filled' }
]) ])
const message = useMessage() // const message = useMessage() //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formData = ref<DiyTemplateApi.DiyTemplatePropertyVO>() const formData = ref<DiyTemplateApi.DiyTemplatePropertyVO>()
const formRef = ref() // Ref const formRef = ref() // Ref
// //
const currentFormData = ref<DiyTemplateApi.DiyTemplatePropertyVO | DiyPageApi.DiyPageVO>() const currentFormData = ref<DiyTemplateApi.DiyTemplatePropertyVO | DiyPageApi.DiyPageVO>()
// H5 // H5
const previewUrl = ref('') const previewUrl = ref('')
// //
const getPageDetail = async (id: any) => { const getPageDetail = async (id : any) => {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await DiyTemplateApi.getDiyTemplateProperty(id) formData.value = await DiyTemplateApi.getDiyTemplateProperty(id)
currentFormData.value = formData.value currentFormData.value = formData.value
// //
const domain = import.meta.env.VITE_MALL_H5_DOMAIN const domain = import.meta.env.VITE_MALL_H5_DOMAIN
previewUrl.value = `${domain}/#/pages/index/index?templateId=${formData.value.id}` previewUrl.value = `${domain}/#/pages/index/index?templateId=${formData.value.id}`
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
}
//
const templateLibs = [] as DiyComponentLibrary[]
//
const libs = ref<DiyComponentLibrary[]>(templateLibs)
//
const handleTemplateItemChange = () => {
//
if (selectedTemplateItem.value === 0) {
libs.value = templateLibs
currentFormData.value = formData.value
return
} }
//
const templateLibs = [] as DiyComponentLibrary[]
//
const libs = ref<DiyComponentLibrary[]>(templateLibs)
//
const handleTemplateItemChange = () => {
//
// if (selectedTemplateItem.value === 0) {
// libs.value = templateLibs
// currentFormData.value = formData.value
// return
// }
// //
libs.value = PAGE_LIBS libs.value = PAGE_LIBS
currentFormData.value = formData.value!.pages.find( console.log(formData.value!.pages, 'PAGE_LIBS')
(page: DiyPageApi.DiyPageVO) => page.name === templateItems[selectedTemplateItem.value].name // currentFormData.value = formData.value!.pages.find(
) // // (page: DiyPageApi.DiyPageVO) => page.name === templateItems[selectedTemplateItem.value].name
} // (page: DiyPageApi.DiyPageVO) => page.name === templateItems[1].name
// )
currentFormData.value = formData.value!.pages[selectedTemplateItem.value]
console.log(selectedTemplateItem.value, 'selectedTemplateItem.value11111111111111')
}
// //
const submitForm = async () => { const submitForm = async () => {
// //
if (!formRef) return if (!formRef) return
// //
formLoading.value = true formLoading.value = true
try { try {
if (selectedTemplateItem.value === 0) { if (selectedTemplateItem.value === '0') {
// //
await DiyTemplateApi.updateDiyTemplateProperty(unref(formData)!) await DiyTemplateApi.updateDiyTemplateProperty(unref(formData)!)
} else { } else {
@ -108,10 +108,10 @@ const submitForm = async () => {
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} }
// //
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
id: undefined, id: undefined,
name: '', name: '',
@ -123,19 +123,19 @@ const resetForm = () => {
pages: [] pages: []
} as DiyTemplateApi.DiyTemplatePropertyVO } as DiyTemplateApi.DiyTemplatePropertyVO
formRef.value?.resetFields() formRef.value?.resetFields()
} }
// //
const handleEditorReset = () => storePageIndex() const handleEditorReset = () => storePageIndex()
//#region //#region
// //
const DIY_PAGE_INDEX_KEY = 'diy_page_index' const DIY_PAGE_INDEX_KEY = 'diy_page_index'
// 1. // 1.
const storePageIndex = () => const storePageIndex = () =>
sessionStorage.setItem(DIY_PAGE_INDEX_KEY, `${selectedTemplateItem.value}`) sessionStorage.setItem(DIY_PAGE_INDEX_KEY, `${selectedTemplateItem.value}`)
// 2. // 2.
const recoverPageIndex = () => { const recoverPageIndex = () => {
// //
const pageIndex = toNumber(sessionStorage.getItem(DIY_PAGE_INDEX_KEY)) || 0 const pageIndex = toNumber(sessionStorage.getItem(DIY_PAGE_INDEX_KEY)) || 0
// //
@ -145,23 +145,28 @@ const recoverPageIndex = () => {
selectedTemplateItem.value = pageIndex selectedTemplateItem.value = pageIndex
handleTemplateItemChange() handleTemplateItemChange()
} }
}
//#endregion
/** 初始化 **/
const { currentRoute } = useRouter() //
const { delView } = useTagsViewStore() //
onMounted(async () => {
resetForm()
if (!currentRoute.value.params.id) {
message.warning('参数错误,页面编号不能为空!')
delView(unref(currentRoute))
return
} }
//#endregion
onMounted(async () => {
resetForm()
// if (!currentRoute.value.params.id) {
// message.warning('')
// delView(unref(currentRoute))
// return
// }
// //
await getPageDetail(currentRoute.value.params.id) // await getPageDetail(currentRoute.value.params.id)
await getPageDetail(4)
// //
recoverPageIndex() recoverPageIndex()
}) currentFormData.value = formData.value!.pages[0]
})
// watch(() => route.path, (newPath, oldPath) => {
// console.log(newPath,'newPathnewPath');
// // handleTemplateItemChange()
// }, { immediate: true });
</script> </script>

View File

@ -0,0 +1,175 @@
<template>
<DiyEditor v-if="formData && !formLoading" v-model="currentFormData!.property"
:title="templateItems[selectedTemplateItem].name" :libs="libs" :show-page-config="selectedTemplateItem !== 0"
:show-tab-bar="selectedTemplateItem === 0" :show-navigation-bar="selectedTemplateItem !== 0"
:preview-url="previewUrl" @save="submitForm" @reset="handleEditorReset">
<template #toolBarLeft>
<!-- <el-radio-group
v-model="selectedTemplateItem"
class="h-full!"
@change="handleTemplateItemChange"
>
<el-tooltip v-for="(item, index) in templateItems" :key="index" :content="item.name">
<el-radio-button :label="index">
<Icon :icon="item.icon" :size="24" />
</el-radio-button>
</el-tooltip>
</el-radio-group> -->
</template>
</DiyEditor>
</template>
<script setup lang="ts">
// TODO @ decorate index.vue
import * as DiyTemplateApi from '@/api/mall/promotion/diy/template'
import * as DiyPageApi from '@/api/mall/promotion/diy/page'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { DiyComponentLibrary, PAGE_LIBS } from '@/components/DiyEditor/util' // DIY DiyEditor
import { toNumber } from 'lodash-es'
// import { watch } from 'vue';
/** 装修模板表单 */
defineOptions({ name: 'DiyTemplateDecorate' })
/** 初始化 **/
const { currentRoute } = useRouter() //
const { delView } = useTagsViewStore() //
const route = useRoute();
//
const selectedTemplateItem = ref('1')
// console.log(selectedTemplateItem.value,'selectedTemplateItemselectedTemplateItem')
const templateItems = reactive([
{ name: '基础设置', icon: 'ep:iphone' },
{ name: '首页', icon: 'ep:home-filled' },
{ name: '我的', icon: 'ep:user-filled' }
])
const message = useMessage() //
const formLoading = ref(false) // 12
const formData = ref<DiyTemplateApi.DiyTemplatePropertyVO>()
const formRef = ref() // Ref
//
const currentFormData = ref<DiyTemplateApi.DiyTemplatePropertyVO | DiyPageApi.DiyPageVO>()
// H5
const previewUrl = ref('')
//
const getPageDetail = async (id : any) => {
formLoading.value = true
try {
formData.value = await DiyTemplateApi.getDiyTemplateProperty(id)
currentFormData.value = formData.value
//
const domain = import.meta.env.VITE_MALL_H5_DOMAIN
previewUrl.value = `${domain}/#/pages/index/index?templateId=${formData.value.id}`
} finally {
formLoading.value = false
}
}
//
const templateLibs = [] as DiyComponentLibrary[]
//
const libs = ref<DiyComponentLibrary[]>(templateLibs)
//
const handleTemplateItemChange = () => {
//
// if (selectedTemplateItem.value === 0) {
// libs.value = templateLibs
// currentFormData.value = formData.value
// return
// }
//
libs.value = PAGE_LIBS
console.log(formData.value!.pages, 'PAGE_LIBS')
// currentFormData.value = formData.value!.pages.find(
// // (page: DiyPageApi.DiyPageVO) => page.name === templateItems[selectedTemplateItem.value].name
// (page: DiyPageApi.DiyPageVO) => page.name === templateItems[1].name
// )
currentFormData.value = formData.value!.pages[selectedTemplateItem.value]
console.log(selectedTemplateItem.value, 'selectedTemplateItem.value11111111111111')
}
//
const submitForm = async () => {
//
if (!formRef) return
//
formLoading.value = true
try {
if (selectedTemplateItem.value === '0') {
//
await DiyTemplateApi.updateDiyTemplateProperty(unref(formData)!)
} else {
//
await DiyPageApi.updateDiyPageProperty(unref(currentFormData)!)
}
message.success('保存成功')
} finally {
formLoading.value = false
}
}
//
const resetForm = () => {
formData.value = {
id: undefined,
name: '',
used: false,
usedTime: undefined,
remark: '',
previewPicUrls: [],
property: '',
pages: []
} as DiyTemplateApi.DiyTemplatePropertyVO
formRef.value?.resetFields()
}
//
const handleEditorReset = () => storePageIndex()
//#region
//
const DIY_PAGE_INDEX_KEY = 'diy_page_index'
// 1.
const storePageIndex = () =>
sessionStorage.setItem(DIY_PAGE_INDEX_KEY, `${selectedTemplateItem.value}`)
// 2.
const recoverPageIndex = () => {
//
const pageIndex = toNumber(sessionStorage.getItem(DIY_PAGE_INDEX_KEY)) || 0
//
sessionStorage.removeItem(DIY_PAGE_INDEX_KEY)
//
if (pageIndex !== selectedTemplateItem.value) {
selectedTemplateItem.value = pageIndex
handleTemplateItemChange()
}
}
//#endregion
onMounted(async () => {
resetForm()
// if (!currentRoute.value.params.id) {
// message.warning('')
// delView(unref(currentRoute))
// return
// }
//
// await getPageDetail(currentRoute.value.params.id)
await getPageDetail(4)
//
recoverPageIndex()
selectedTemplateItem.value = 1
currentFormData.value = formData.value!.pages[selectedTemplateItem.value]
// handleTemplateItemChange()
console.log(currentRoute.value.params.id, "currentRoute.value.params.id");
})
// watch(() => route.path, (newPath, oldPath) => {
// console.log(newPath,'newPathnewPath');
// // handleTemplateItemChange()
// }, { immediate: true });
</script>

View File

@ -0,0 +1,175 @@
<template>
<DiyEditor v-if="formData && !formLoading" v-model="currentFormData!.property"
:title="templateItems[selectedTemplateItem].name" :libs="libs" :show-page-config="selectedTemplateItem !== 0"
:show-tab-bar="selectedTemplateItem === 0" :show-navigation-bar="selectedTemplateItem !== 0"
:preview-url="previewUrl" @save="submitForm" @reset="handleEditorReset">
<template #toolBarLeft>
<!-- <el-radio-group
v-model="selectedTemplateItem"
class="h-full!"
@change="handleTemplateItemChange"
>
<el-tooltip v-for="(item, index) in templateItems" :key="index" :content="item.name">
<el-radio-button :label="index">
<Icon :icon="item.icon" :size="24" />
</el-radio-button>
</el-tooltip>
</el-radio-group> -->
</template>
</DiyEditor>
</template>
<script setup lang="ts">
// TODO @ decorate index.vue
import * as DiyTemplateApi from '@/api/mall/promotion/diy/template'
import * as DiyPageApi from '@/api/mall/promotion/diy/page'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { DiyComponentLibrary, PAGE_LIBS } from '@/components/DiyEditor/util' // DIY DiyEditor
import { toNumber } from 'lodash-es'
// import { watch } from 'vue';
/** 装修模板表单 */
defineOptions({ name: 'DiyTemplateDecorate' })
/** 初始化 **/
const { currentRoute } = useRouter() //
const { delView } = useTagsViewStore() //
const route = useRoute();
//
const selectedTemplateItem = ref('1')
// console.log(selectedTemplateItem.value,'selectedTemplateItemselectedTemplateItem')
const templateItems = reactive([
{ name: '基础设置', icon: 'ep:iphone' },
{ name: '首页', icon: 'ep:home-filled' },
{ name: '我的', icon: 'ep:user-filled' }
])
const message = useMessage() //
const formLoading = ref(false) // 12
const formData = ref<DiyTemplateApi.DiyTemplatePropertyVO>()
const formRef = ref() // Ref
//
const currentFormData = ref<DiyTemplateApi.DiyTemplatePropertyVO | DiyPageApi.DiyPageVO>()
// H5
const previewUrl = ref('')
//
const getPageDetail = async (id : any) => {
formLoading.value = true
try {
formData.value = await DiyTemplateApi.getDiyTemplateProperty(id)
currentFormData.value = formData.value
//
const domain = import.meta.env.VITE_MALL_H5_DOMAIN
previewUrl.value = `${domain}/#/pages/index/index?templateId=${formData.value.id}`
} finally {
formLoading.value = false
}
}
//
const templateLibs = [] as DiyComponentLibrary[]
//
const libs = ref<DiyComponentLibrary[]>(templateLibs)
//
const handleTemplateItemChange = () => {
//
// if (selectedTemplateItem.value === 0) {
// libs.value = templateLibs
// currentFormData.value = formData.value
// return
// }
//
libs.value = PAGE_LIBS
console.log(formData.value!.pages, 'PAGE_LIBS')
// currentFormData.value = formData.value!.pages.find(
// // (page: DiyPageApi.DiyPageVO) => page.name === templateItems[selectedTemplateItem.value].name
// (page: DiyPageApi.DiyPageVO) => page.name === templateItems[1].name
// )
currentFormData.value = formData.value!.pages[selectedTemplateItem.value]
console.log(selectedTemplateItem.value, 'selectedTemplateItem.value11111111111111')
}
//
const submitForm = async () => {
//
if (!formRef) return
//
formLoading.value = true
try {
if (selectedTemplateItem.value === '0') {
//
await DiyTemplateApi.updateDiyTemplateProperty(unref(formData)!)
} else {
//
await DiyPageApi.updateDiyPageProperty(unref(currentFormData)!)
}
message.success('保存成功')
} finally {
formLoading.value = false
}
}
//
const resetForm = () => {
formData.value = {
id: undefined,
name: '',
used: false,
usedTime: undefined,
remark: '',
previewPicUrls: [],
property: '',
pages: []
} as DiyTemplateApi.DiyTemplatePropertyVO
formRef.value?.resetFields()
}
//
const handleEditorReset = () => storePageIndex()
//#region
//
const DIY_PAGE_INDEX_KEY = 'diy_page_index'
// 1.
const storePageIndex = () =>
sessionStorage.setItem(DIY_PAGE_INDEX_KEY, `${selectedTemplateItem.value}`)
// 2.
const recoverPageIndex = () => {
//
const pageIndex = toNumber(sessionStorage.getItem(DIY_PAGE_INDEX_KEY)) || 0
//
sessionStorage.removeItem(DIY_PAGE_INDEX_KEY)
//
if (pageIndex !== selectedTemplateItem.value) {
selectedTemplateItem.value = pageIndex
handleTemplateItemChange()
}
}
//#endregion
onMounted(async () => {
resetForm()
// if (!currentRoute.value.params.id) {
// message.warning('')
// delView(unref(currentRoute))
// return
// }
//
// await getPageDetail(currentRoute.value.params.id)
await getPageDetail(4)
//
recoverPageIndex()
libs.value = templateLibs
currentFormData.value = formData.value
// handleTemplateItemChange()
console.log(currentRoute.value.params.id, "currentRoute.value.params.id");
})
// watch(() => route.path, (newPath, oldPath) => {
// console.log(newPath,'newPathnewPath');
// // handleTemplateItemChange()
// }, { immediate: true });
</script>

View File

@ -1,39 +1,23 @@
<template> <template>
<Dialog :title="dialogTitle" v-model="dialogVisible"> <Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form <el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px" v-loading="formLoading">
ref="formRef"
:model="formData"
:rules="formRules"
label-width="120px"
v-loading="formLoading"
>
<el-form-item label="秒杀时段名称" prop="name"> <el-form-item label="秒杀时段名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入秒杀时段名称" /> <el-input v-model="formData.name" placeholder="请输入秒杀时段名称" />
</el-form-item> </el-form-item>
<el-form-item label="开始时间点" prop="startTime"> <el-form-item label="开始时间点" prop="startTime">
<el-time-picker <el-time-picker v-model="formData.startTime" value-format="HH:mm" format="HH:mm"
v-model="formData.startTime" placeholder="选择开始时间点" />
value-format="HH:mm:ss"
placeholder="选择开始时间点"
/>
</el-form-item> </el-form-item>
<el-form-item label="结束时间点" prop="endTime"> <el-form-item label="结束时间点" prop="endTime">
<el-time-picker <el-time-picker v-model="formData.endTime" value-format="HH:mm" format="HH:mm" placeholder="选择结束时间点" />
v-model="formData.endTime"
value-format="HH:mm:ss"
placeholder="选择结束时间点"
/>
</el-form-item> </el-form-item>
<el-form-item label="秒杀轮播图" prop="sliderPicUrls"> <el-form-item label="秒杀轮播图" prop="sliderPicUrls">
<UploadImgs v-model="formData.sliderPicUrls" placeholder="请输入秒杀轮播图" /> <UploadImgs v-model="formData.sliderPicUrls" placeholder="请输入秒杀轮播图" />
</el-form-item> </el-form-item>
<el-form-item label="活动状态" prop="status"> <el-form-item label="活动状态" prop="status">
<el-radio-group v-model="formData.status"> <el-radio-group v-model="formData.status">
<el-radio <el-radio v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" :key="dict.value"
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" :label="dict.value">
:key="dict.value"
:label="dict.value"
>
{{ dict.label }} {{ dict.label }}
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
@ -46,38 +30,38 @@
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { SeckillConfigApi, SeckillConfigVO } from '@/api/mall/promotion/seckill/seckillConfig.ts' import { SeckillConfigApi, SeckillConfigVO } from '@/api/mall/promotion/seckill/seckillConfig.ts'
import { CommonStatusEnum } from '@/utils/constants' import { CommonStatusEnum } from '@/utils/constants'
/** 秒杀时段 表单 */ /** 秒杀时段 表单 */
defineOptions({ name: 'SeckillConfigForm' }) defineOptions({ name: 'SeckillConfigForm' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formData = ref({ const formData = ref({
id: undefined, id: undefined,
name: undefined, name: undefined,
startTime: undefined, startTime: undefined,
endTime: undefined, endTime: undefined,
sliderPicUrls: undefined, sliderPicUrls: undefined,
status: undefined status: undefined
}) })
const formRules = reactive({ const formRules = reactive({
name: [{ required: true, message: '秒杀时段名称不能为空', trigger: 'blur' }], name: [{ required: true, message: '秒杀时段名称不能为空', trigger: 'blur' }],
startTime: [{ required: true, message: '开始时间点不能为空', trigger: 'blur' }], startTime: [{ required: true, message: '开始时间点不能为空', trigger: 'blur' }],
endTime: [{ required: true, message: '结束时间点不能为空', trigger: 'blur' }], endTime: [{ required: true, message: '结束时间点不能为空', trigger: 'blur' }],
status: [{ required: true, message: '活动状态不能为空', trigger: 'blur' }] status: [{ required: true, message: '活动状态不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type : string, id ?: number) => {
dialogVisible.value = true dialogVisible.value = true
dialogTitle.value = t('action.' + type) dialogTitle.value = t('action.' + type)
formType.value = type formType.value = type
@ -91,12 +75,12 @@ const open = async (type: string, id?: number) => {
formLoading.value = false formLoading.value = false
} }
} }
} }
defineExpose({ open }) // open defineExpose({ open }) // open
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success const emit = defineEmits(['success']) // success
const submitForm = async () => { const submitForm = async () => {
// //
await formRef.value.validate() await formRef.value.validate()
// //
@ -116,10 +100,10 @@ const submitForm = async () => {
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} }
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
id: undefined, id: undefined,
name: undefined, name: undefined,
@ -129,5 +113,5 @@ const resetForm = () => {
status: CommonStatusEnum.ENABLE status: CommonStatusEnum.ENABLE
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }
</script> </script>