tremble 3 jaren geleden
bovenliggende
commit
b630cade01
1 gewijzigde bestanden met toevoegingen van 19 en 9 verwijderingen
  1. 19 9
      src/components/Tags/goods-list.vue

+ 19 - 9
src/components/Tags/goods-list.vue

@@ -89,9 +89,11 @@ const emit = defineEmits(["close"]);
 
 const current = ref(0);
 
+const mysw = ref(null);
+
 const viewDetail = (item) => {
   if (isshoppingguide.value) {
-      return;
+    return;
   }
   apis.burying_point({ type: 3, productId: item.id });
   browser.openLink(
@@ -102,7 +104,6 @@ const viewDetail = (item) => {
 };
 
 const onClickSku = (item) => {
- 
   let tempData = toRaw(tagclick.value.data);
 
   tempData.products[current.value] = {
@@ -118,7 +119,7 @@ const onClickSku = (item) => {
 
 const addCart = async (item) => {
   if (isshoppingguide.value) {
-      return;
+    return;
   }
   Loading.show();
 
@@ -193,9 +194,15 @@ const updateProductsById = async (idx) => {
 watch(
   () => tagclick.value.type,
   (val, old) => {
-    if (val === "goodlist") {
-      current.value = 0
-      updateProductsById(current.value);
+    if (mysw.value) {
+      if (val === "goodlist") {
+        console.log(4848449);
+        current.value = 0;
+        updateProductsById(current.value);
+      }
+      if (!val) {
+        mysw.value.slideTo(0);
+      }
     }
   }
 );
@@ -204,7 +211,7 @@ const brandScroll = () => {
   nextTick(() => {
     let t = setTimeout(() => {
       clearTimeout(t);
-      new Swiper("#goodlist", {
+      mysw.value = new Swiper("#goodlist", {
         effect: "coverflow",
         grabCursor: true,
         centeredSlides: true,
@@ -222,8 +229,11 @@ const brandScroll = () => {
             e.preventDefault();
           },
           slideChange() {
-            current.value = this.activeIndex;
-            updateProductsById(current.value);
+            if (tagclick.value.type) {
+              console.log(1111111111111);
+              current.value = this.activeIndex;
+              updateProductsById(current.value);
+            }
           },
         },
       });