修改商品显示
parent
10e875eca7
commit
918ae7e9a1
|
|
@ -66,9 +66,8 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { get_math } from '@/utils';
|
import { get_math } from '@/utils';
|
||||||
import ShopAPI from '@/api/shop';
|
import { commonStore } from '@/store';
|
||||||
import { shopStore } from '@/store';
|
const common_store = commonStore();
|
||||||
const shop_store = shopStore();
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: {
|
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(() => {
|
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) => {
|
const goods_list_remove = (index: number) => {
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,8 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { get_math, tabs_style } from '@/utils';
|
import { get_math, tabs_style } from '@/utils';
|
||||||
import ShopAPI from '@/api/shop';
|
import { commonStore } from '@/store';
|
||||||
import { shopStore } from '@/store';
|
const common_store = commonStore();
|
||||||
const shop_store = shopStore();
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: {
|
value: {
|
||||||
|
|
@ -162,29 +161,18 @@ const base_list = reactive({
|
||||||
{ name: '浏览量', value: '1' },
|
{ 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(() => {
|
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);
|
const active_index = ref(0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue