Просмотр исходного кода

商品sku只展示一个问题

mabo 4 лет назад
Родитель
Сommit
f7167912e7

+ 11 - 14
buyer/src/components/goodsDetail/ShowGoods.vue

@@ -84,14 +84,14 @@
           </div>
         </div>
         <!-- 选择颜色 -->
-        <div class="item-select" v-for="(sku, index) in formatList" :key="sku.id">
+        <div class="item-select" v-for="(sku, index) in formatList" :key="sku.name">
           <div class="item-select-title">
             <p>{{ sku.name }}</p>
           </div>
           <div class="item-select-column">
-            <div class="item-select-row" v-for="(item) in sku.values" :key="item.id">
-              <div class="item-select-box" @click="select(index, sku.id, item.id)"
-                :class="{ 'item-select-box-active': item.id === currentSelceted[index] }"
+            <div class="item-select-row" v-for="(item) in sku.values" :key="item.value">
+              <div class="item-select-box" @click="select(index, item.value)"
+                :class="{ 'item-select-box-active': item.value === currentSelceted[index] }"
               >
                 <div class="item-select-intro">
                   <p>{{ item.value }}</p>
@@ -170,14 +170,14 @@ export default {
     Promotion
   },
   methods: {
-    select (index, id, valueId) { // 选择规格
-      this.$set(this.currentSelceted, index, valueId);
+    select (index, value) { // 选择规格
+      this.$set(this.currentSelceted, index, value);
 
       let selectedSkuId = this.goodsSpecList.find((i) => {
         let matched = true;
         let specValues = i.specValues.filter((j) => j.specName !== 'images');
         for (let n = 0; n < specValues.length; n++) {
-          if (specValues[n].specValueId !== this.currentSelceted[n]) {
+          if (specValues[n].specValue !== this.currentSelceted[n]) {
             matched = false;
             return;
           }
@@ -267,15 +267,13 @@ export default {
     },
     formatSku (list) {
       // 格式化数据
-
+      console.log(list);
       let arr = [{}];
 
       list.forEach((item, index) => {
         item.specValues.forEach((spec, specIndex) => {
-          let id = spec.specNameId;
           let name = spec.specName;
           let values = {
-            id: spec.specValueId,
             value: spec.specValue,
             quantity: item.quantity
           };
@@ -287,7 +285,7 @@ export default {
             if (
               arrItem.name === name &&
               arrItem.values &&
-              !arrItem.values.find((i) => i.id === values.id)
+              !arrItem.values.find((i) => i.value === values.value)
             ) {
               arrItem.values.push(values);
             }
@@ -297,7 +295,6 @@ export default {
             });
             if (!keys.includes(name)) {
               arr.push({
-                id: id,
                 name: name,
                 values: [values]
               });
@@ -307,12 +304,12 @@ export default {
       });
       arr.shift();
       this.formatList = arr;
-
+      console.log(this.formatList);
       let cur = list.filter((i) => i.skuId === this.$route.query.skuId)[0];
       if (cur) {
         cur.specValues.filter((i) => i.specName !== 'images')
           .forEach((value, _index) => {
-            this.currentSelceted[_index] = value.specValueId;
+            this.currentSelceted[_index] = value.specValue;
           });
       }
       this.skuList = list;

+ 0 - 1
buyer/src/pages/GoodsDetail.vue

@@ -77,7 +77,6 @@ export default {
               name: cateName[index]
             });
           });
-          console.log(cateArr);
           this.categoryBar = cateArr;
           this.goodsMsg = res.result;
           // 判断是否收藏

+ 8 - 8
manager/src/config/index.js

@@ -17,14 +17,14 @@ export default {
    * @description api请求基础路径
    */
   api_dev: {
-    // common: "https://common-api.pickmall.cn",
-    // buyer: "https://buyer-api.pickmall.cn",
-    // seller: "https://store-api.pickmall.cn",
-    // manager: "https://admin-api.pickmall.cn"
-    common: 'http://192.168.0.109:8890',
-    buyer: 'http://192.168.0.109:8888',
-    seller: 'http://192.168.0.109:8889',
-    manager: 'http://192.168.0.109:8887'
+    common: "https://common-api.pickmall.cn",
+    buyer: "https://buyer-api.pickmall.cn",
+    seller: "https://store-api.pickmall.cn",
+    manager: "https://admin-api.pickmall.cn"
+    // common: 'http://192.168.0.109:8890',
+    // buyer: 'http://192.168.0.109:8888',
+    // seller: 'http://192.168.0.109:8889',
+    // manager: 'http://192.168.0.109:8887'
   },
   api_prod: {
     common: "https://common-api.pickmall.cn",