修改接口为空报错问题

v1.3.0
于肖磊 2025-03-24 18:34:57 +08:00
parent f73f063d2f
commit de2677f8e1
4 changed files with 24 additions and 15 deletions

View File

@ -194,9 +194,9 @@ const theme_bg_img = ref<themeBgImg>({
});
//
onMounted(() => {
if (!isEmpty(form.value.data_list) && form.value.data_type == '1') {
if (!isEmpty(form.value.data_list) && form.value.data_type == '0') {
data_list.value = form.value.data_list;
} else if (form.value.data_type == '0') {
} else if (form.value.data_type == '1') {
if (!isEmpty(form.value.data_auto_list)) {
data_list.value = form.value.data_auto_list;
} else {
@ -243,7 +243,7 @@ const data_list_computer = computed(() => {
watch(
() => data_list_computer.value,
(new_value) => {
if (new_value.data_type == '0') {
if (new_value.data_type == '1') {
get_coupon();
} else {
if (!isEmpty(form.value.data_list)) {

View File

@ -17,7 +17,7 @@
<el-radio v-for="item in base_list.data_type_list" :key="item.value" :value="item.value">{{ item.name }}</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="form.data_type === '1'">
<template v-if="form.data_type === '0'">
<el-form-item label="手动选择">
<div class="flex-col gap-20 w">
<drag v-if="form.data_list.length > 0" :data="form.data_list" :space-col="20" @remove="remove" @on-sort="on_sort">
@ -107,8 +107,8 @@ const url_value_dialog_visible = ref(false);
const new_url = ref('');
const base_list = reactive({
data_type_list: [
{ name: '动', value: '0' },
{ name: '动', value: '1' },
{ name: '动', value: '0' },
{ name: '动', value: '1' },
],
themeList: Array.from({ length: 7 }, (_, index) => ({
id: String(index + 1),

View File

@ -71,6 +71,8 @@ import ShopAPI from '@/api/shop';
import { Swiper, SwiperSlide } from 'swiper/vue';
import { Autoplay } from 'swiper/modules';
const modules = [Autoplay];
import { commonStore } from '@/store';
const common_store = commonStore();
/**
* @description: 文章列表渲染
* @param value{Object} 样式数据
@ -118,28 +120,35 @@ type data_list = {
const default_list = {
name: '测试商户标题',
describe: '测试商户描述',
icon_list: [{ icon: 'http://shopxo.com/static/diy/images/layout/siderbar/data-magic.png'}, { icon: ''}],
icon_list: [{ icon: common_store.common.config.attachment_host + `/static/diy/images/components/model-shop/auth.png`}, { icon: ''}],
logo: '',
new_cover: [],
};
const list = ref<data_list[]>([]);
const new_url_list = computed(() => {
return (icon_list: url[]) => {
if (isEmpty(icon_list)) {
return [];
}
return icon_list.filter(item1 => !isEmpty(item1.icon));
}
});
//
const title_img_style = computed(() => {
return (icon_list: url[], index: number) => {
const { shop_title_img_width = 0, shop_title_img_height = 0, shop_title_img_radius, shop_title_img_inner_spacing, shop_title_img_outer_spacing} = new_style.value;
let style = `width: ${shop_title_img_width || 0 }px;height: ${ shop_title_img_height || 0 }px;${ radius_computer(shop_title_img_radius) }`;
const list = icon_list.filter(item1 => !isEmpty(item1.icon));
if (index < list.length - 1) {
style += `margin-right: ${ shop_title_img_inner_spacing || 0}px;`;
if (isEmpty(icon_list)) {
return '';
} else {
style += `margin-right: ${ shop_title_img_outer_spacing || 0}px;`;
const { shop_title_img_width = 0, shop_title_img_height = 0, shop_title_img_radius, shop_title_img_inner_spacing, shop_title_img_outer_spacing} = new_style.value;
let style = `width: ${shop_title_img_width || 0 }px;height: ${ shop_title_img_height || 0 }px;${ radius_computer(shop_title_img_radius) }`;
const list = icon_list.filter(item1 => !isEmpty(item1.icon));
if (index < list.length - 1) {
style += `margin-right: ${ shop_title_img_inner_spacing || 0}px;`;
} else {
style += `margin-right: ${ shop_title_img_outer_spacing || 0}px;`;
}
return style;
}
return style;
}
});
//

View File

@ -276,7 +276,7 @@ const save_formmat_form_data = (data: diy_data_item, close: boolean = false, is_
item.com_data.content.data_ids = item.com_data.content.data_list.map((item: any) => item.id).join(',') || '';
item.com_data.content.data_list = [];
item.com_data.content.data_auto_list = [];
if (item.com_data.content.data_type == '1') {
if (item.com_data.content.data_type == '0') {
item.com_data.content = {
keywords: '',
type: defaultConfigSetting.coupon_ids,