营销:适配商城装修组件【营销文章】

(cherry picked from commit d4dc105b4f)
This commit is contained in:
owen 2023-11-25 15:53:07 +08:00 committed by shizhong
parent 73f4521bc7
commit 687ec00343
8 changed files with 113 additions and 5 deletions

View File

@ -17,7 +17,7 @@ export interface ArticleVO {
}
// 查询文章管理列表
export const getArticlePage = async (params) => {
export const getArticlePage = async (params: any) => {
return await request.get({ url: `/promotion/article/page`, params })
}

View File

@ -1,6 +1,6 @@
import { ComponentStyle, DiyComponent } from '@/components/DiyEditor/util'
/** 商品卡片属性 */
/** 商品属性 */
export interface ProductListProperty {
// 布局类型:双列 | 三列 | 水平滑动
layoutType: 'twoCol' | 'threeCol' | 'horizSwiper'

View File

@ -66,7 +66,7 @@
import { ProductListProperty } from './config'
import * as ProductSpuApi from '@/api/mall/product/spu'
/** 商品卡片 */
/** 商品 */
defineOptions({ name: 'ProductList' })
//
const props = defineProps<{ property: ProductListProperty }>()

View File

@ -88,7 +88,7 @@ import { ProductListProperty } from './config'
import { usePropertyForm } from '@/components/DiyEditor/util'
import SpuShowcase from '@/views/mall/product/spu/components/SpuShowcase.vue'
//
//
defineOptions({ name: 'ProductListProperty' })
const props = defineProps<{ modelValue: ProductListProperty }>()

View File

@ -0,0 +1,25 @@
import { ComponentStyle, DiyComponent } from '@/components/DiyEditor/util'
/** 营销文章属性 */
export interface PromotionArticleProperty {
// 文章编号
id: number
// 组件样式
style: ComponentStyle
}
// 定义组件
export const component = {
id: 'PromotionArticle',
name: '营销文章',
icon: 'ph:article-medium',
property: {
style: {
bgType: 'color',
bgColor: '',
marginLeft: 8,
marginRight: 8,
marginBottom: 8
} as ComponentStyle
}
} as DiyComponent<PromotionArticleProperty>

View File

@ -0,0 +1,27 @@
<template>
<div class="min-h-30px" v-html="article.content"></div>
</template>
<script setup lang="ts">
import { PromotionArticleProperty } from './config'
import * as ArticleApi from '@/api/mall/promotion/article/index'
/** 营销文章 */
defineOptions({ name: 'PromotionArticle' })
//
const props = defineProps<{ property: PromotionArticleProperty }>()
//
const article = ref<ArticleApi.ArticleVO[]>({})
watch(
() => props.property.id,
async () => {
if (props.property.id) {
article.value = await ArticleApi.getArticle(props.property.id)
}
},
{
immediate: true
}
)
</script>
<style scoped lang="scss"></style>

View File

@ -0,0 +1,56 @@
<template>
<ComponentContainerProperty v-model="formData.style">
<el-form label-width="40px" :model="formData">
<el-form-item label="文章" prop="id">
<el-select
v-model="formData.id"
placeholder="请选择文章"
class="w-full"
filterable
remote
:remote-method="queryArticleList"
:loading="loading"
>
<el-option
v-for="article in articles"
:key="article.id"
:label="article.title"
:value="article.id"
/>
</el-select>
</el-form-item>
</el-form>
</ComponentContainerProperty>
</template>
<script setup lang="ts">
import { PromotionArticleProperty } from './config'
import { usePropertyForm } from '@/components/DiyEditor/util'
import * as ArticleApi from '@/api/mall/promotion/article/index'
//
defineOptions({ name: 'PromotionArticleProperty' })
const props = defineProps<{ modelValue: PromotionArticleProperty }>()
const emit = defineEmits(['update:modelValue'])
const { formData } = usePropertyForm(props.modelValue, emit)
//
const articles = ref<ArticleApi.ArticleVO>([])
//
const loading = ref(false)
//
const queryArticleList = async (title?: string) => {
loading.value = true
const { list } = await ArticleApi.getArticlePage({ title, pageSize: 10 })
articles.value = list
loading.value = false
}
//
onMounted(() => {
queryArticleList()
})
</script>
<style scoped lang="scss"></style>

View File

@ -116,6 +116,6 @@ export const PAGE_LIBS = [
{
name: '营销组件',
extended: true,
components: ['CombinationCard', 'SeckillCard', 'PointCard', 'CouponCard']
components: ['CombinationCard', 'SeckillCard', 'PointCard', 'CouponCard', 'PromotionArticle']
}
] as DiyComponentLibrary[]