修改商品显示

v1.0.0
于肖磊 2024-09-02 14:33:01 +08:00
parent 10e875eca7
commit 918ae7e9a1
2 changed files with 24 additions and 47 deletions

View File

@ -66,9 +66,8 @@
</template>
<script setup lang="ts">
import { get_math } from '@/utils';
import ShopAPI from '@/api/shop';
import { shopStore } from '@/store';
const shop_store = shopStore();
import { commonStore } from '@/store';
const common_store = commonStore();
const props = defineProps({
value: {
@ -124,27 +123,17 @@ const base_list = reactive({
],
});
const init = () => {
if (!shop_store.is_shop_api) {
shop_store.set_is_shop_api(true);
ShopAPI.getShop()
.then((res) => {
const { goods_category, brand_list } = res.data;
base_list.product_category_list = goods_category;
base_list.product_brand_list = brand_list;
shop_store.set_category_brand(goods_category, brand_list);
})
.catch((err) => {
shop_store.set_is_shop_api(false);
});
} else {
base_list.product_category_list = shop_store.category_list;
base_list.product_brand_list = shop_store.brand_list;
}
};
onBeforeMount(() => {
init();
nextTick(() => {
// common_store.common.article_category
const interval = setInterval(() => {
if (common_store.common.goods_category.length > 0 || common_store.common.brand_list.length > 0) {
base_list.product_category_list = common_store.common.goods_category;
base_list.product_brand_list = common_store.common.brand_list;
clearInterval(interval);
}
}, 1000);
});
});
const goods_list_remove = (index: number) => {

View File

@ -94,9 +94,8 @@
</template>
<script setup lang="ts">
import { get_math, tabs_style } from '@/utils';
import ShopAPI from '@/api/shop';
import { shopStore } from '@/store';
const shop_store = shopStore();
import { commonStore } from '@/store';
const common_store = commonStore();
const props = defineProps({
value: {
@ -162,29 +161,18 @@ const base_list = reactive({
{ name: '浏览量', value: '1' },
],
});
//
const init = () => {
//
if (!shop_store.is_shop_api) {
shop_store.set_is_shop_api(true);
ShopAPI.getShop()
.then((res) => {
const { goods_category, brand_list } = res.data;
base_list.product_category_list = goods_category;
base_list.product_brand_list = brand_list;
shop_store.set_category_brand(goods_category, brand_list);
})
.catch((err) => {
shop_store.set_is_shop_api(false);
});
} else {
base_list.product_category_list = shop_store.category_list;
base_list.product_brand_list = shop_store.brand_list;
}
};
onBeforeMount(() => {
init();
nextTick(() => {
// common_store.common.article_category
const interval = setInterval(() => {
if (common_store.common.goods_category.length > 0 || common_store.common.brand_list.length > 0) {
base_list.product_category_list = common_store.common.goods_category;
base_list.product_brand_list = common_store.common.brand_list;
clearInterval(interval);
}
}, 1000);
});
});
const active_index = ref(0);