storeBelieveInLight hace 1 año
padre
commit
07e23363c8

+ 27 - 2
commit/product.js

@@ -286,7 +286,7 @@ export function shippingListApi(data) {
286 286
 /**
287 287
  * 添加商品
288 288
  */
289
-export function addProduct(data) {
289
+export function addProduct(id,data) {
290 290
     return myRequestPhp({
291 291
         url: `${pre}mer/store/product/create`,
292 292
         method: 'POST',
@@ -390,4 +390,29 @@ export function getMerchantProfitApi(data) {
390 390
         data,
391 391
         apiType
392 392
     })
393
-}
393
+}
394
+
395
+
396
+//产品详情
397
+export function getProductDetail(id,data){
398
+	
399
+	return myRequestPhp({
400
+	    url: `${pre}mer/store/product/detail/${id}`,
401
+	    method: 'GET',
402
+	    data,
403
+	    apiType
404
+	})
405
+}
406
+
407
+//产品gengx
408
+export function updateProduct(id,data){
409
+	
410
+	return myRequestPhp({
411
+	    url: `${pre}mer/store/product/update/${id}`,
412
+	    method: 'POST',
413
+	    data,
414
+	    apiType
415
+	})
416
+}
417
+
418
+

+ 18 - 1
components/editor.vue

@@ -201,7 +201,24 @@ export default {
201 201
       formats: {},
202 202
     };
203 203
   },
204
-
204
+  watch: {
205
+    value:{
206
+      handler(val){
207
+         this.richText = val
208
+         console.log(val)
209
+         if(val){
210
+          this.$nextTick(()=>{
211
+            this.onEditorReady()
212
+          })
213
+         }
214
+      },
215
+      deep:true,
216
+    },
217
+  },
218
+  mounted(){
219
+     this.richText = this.value;
220
+     this.onEditorReady()
221
+  },
205 222
   methods: {
206 223
     readOnlyChange() {
207 224
       this.readOnly = !this.readOnly;

+ 124 - 26
shop/productManagementModule/addProduct.vue

@@ -13,11 +13,13 @@
13 13
       <uploadVue
14 14
         formItemTitle="商品封面"
15 15
         :maxLimit="1"
16
+        :fileList="fengMianImage"
16 17
         @changeFiles="changeFilesfengmian"
17 18
       ></uploadVue>
18 19
       <!-- 商品轮播图 -->
19 20
       <uploadVue
20 21
         formItemTitle="商品轮播图"
22
+        :fileList="lunBoTuImage"
21 23
         @changeFiles="changeFileslunbotu"
22 24
       ></uploadVue>
23 25
 
@@ -366,6 +368,8 @@ import {
366 368
   addProduct,
367 369
   productConfigApi,
368 370
   getMerchantProfitApi,
371
+  getProductDetail,
372
+  updateProduct,
369 373
 } from "@/commit/product.js";
370 374
 import { getBaseInfo } from "@/commit/user.js";
371 375
 import { accMul, accDiv, accAdd, accSub } from "@/utils/acc.js";
@@ -460,21 +464,112 @@ export default {
460 464
         volume: "", //商品体积(m³)
461 465
       },
462 466
       costInputValue: "",
467
+      clickType: "create",
468
+      product_id: "",
469
+      fengMianImage: [], //封面
470
+      lunBoTuImage: [], //轮播图
463 471
     };
464 472
   },
465
-  async onLoad() {
466
-    await this.initData();
473
+  async onLoad(e) {
474
+    this.product_id = e.product_id || "";
475
+    this.clickType = e.clickType;
476
+     await this.getGoodsClassCategoryData();
477
+      await this.getMerchantProfit();
478
+    if (this.clickType == "updated" && this.product_id) {
479
+      uni.showLoading({
480
+        title: "加载中",
481
+        mask: true,
482
+      });
483
+      await this.getProductDetailData(this.product_id);
484
+    }
485
+     await this.initData();
467 486
   },
468 487
   onShow() {},
469 488
   methods: {
489
+    async getProductDetailData(id) {
490
+      try {
491
+        const res = await getProductDetail(id);
492
+        if (res.data.status == 200) {
493
+          let data = res.data.data || {};
494
+          let attrValue = (data.attrValue && data.attrValue[0]) || {};
495
+          this.formData.store_name = data.store_name;
496
+          this.formData.unit_name = data.unit_name;
497
+          this.formData.brand_id = data.brand_id;
498
+          this.formData.temp_id = data.temp_id;
499
+          this.formData.type = String(data.type);
500
+          this.formData.spec_type = String(data.spec_type);
501
+          this.formData.extension_type = String(data.extension_type);
502
+          this.formData.cate_id = data.cate_id;
503
+          this.formData.store_info = data.store_info;
504
+          this.formData.content = data.content;
505
+          this.attrValueForm.extension_one = attrValue.extension_one;
506
+          this.attrValueForm.cost = attrValue.cost;
507
+          this.priceDefault = attrValue.price;
508
+          this.attrValueForm.ot_price = attrValue.ot_price;
509
+          this.attrValueForm.stock = attrValue.stock;
510
+          this.attrValueForm.bar_code = attrValue.bar_code;
511
+          this.attrValueForm.weight = attrValue.weight;
512
+          this.attrValueForm.volume = attrValue.volume;
513
+          console.log(this.fengMianImage, "this.fengMianImage999");
514
+          console.log(this.pingtaiData, "this.fengMianImage999his.pingtaiData");
515
+          let dataArr = this.convertToFlatArray(this.pingtaiData);
516
+          console.log(this.fengMianImage, "this.fengMianImage99945454545");
517
+          const findObj =
518
+            dataArr.find((item) => item.value == data.cate_id) || {};
519
+          this.pingtaifeilei.name = findObj.label || "";
520
+          this.pingtaifeilei.id = findObj.value || data.cate_id || "";
521
+          console.log(this.base_commission,"this.base_commission")
522
+          this.getCalcAfterPrice({
523
+            extension_one:attrValue.extension_one,
524
+            cost:this.attrValueForm.cost
525
+          })
526
+          if (data.image) {
527
+            this.fengMianImage = [];
528
+            let fenMian = {
529
+              //封面
530
+              path: data.image,
531
+              Files: [],
532
+            };
533
+            this.fengMianImage.push(fenMian);
534
+          }
535
+          console.log(this.fengMianImage, "this.fengMianImage");
536
+          if (data.slider_image && data.slider_image.length > 0) {
537
+            this.lunBoTuImage = [];
538
+            data.slider_image.forEach((item) => {
539
+              let lunBoTu = {
540
+                //轮播图
541
+                path: item,
542
+                Files: [],
543
+              };
544
+              this.lunBoTuImage.push(lunBoTu);
545
+            });
546
+          }
547
+        }
548
+        uni.hideLoading();
549
+      } catch (error) {
550
+        uni.hideLoading();
551
+      }
552
+    },
470 553
     async initData() {
471 554
       await this.getBrandSelectData();
472 555
       await this.getShippingListData();
473 556
       await this.getGoodsClassData();
474
-      await this.getGoodsClassCategoryData();
557
+    
475 558
       await this.productCon();
476 559
       await this.getMerInfo();
477
-      await this.getMerchantProfit();
560
+     
561
+    },
562
+    convertToFlatArray(data) {
563
+     return Array.isArray(data)
564
+        ? data.flatMap((node) => {
565
+            const { value, label, children = [] } = node;
566
+            if (typeof value !== "number" || typeof label !== "string")
567
+              return [];
568
+            return Array.isArray(children)
569
+              ? [{ value, label }, ...convertToFlatArray(children)]
570
+              : [{ value, label }];
571
+          })
572
+        : [];
478 573
     },
479 574
     productCon() {
480 575
       productConfigApi()
@@ -566,7 +661,7 @@ export default {
566 661
       const { data } = e;
567 662
       const lastItem = data[data.length - 1];
568 663
       this.selectData = data || [];
569
-      console.log(lastItem, "pickerCallback回調");
664
+      console.log(lastItem, "pickerCallcate_idcate_idcate_idback回調");
570 665
       this.formData.mer_cate_id.push(lastItem.id);
571 666
       this.classification = lastItem || {};
572 667
     },
@@ -589,7 +684,7 @@ export default {
589 684
       const { data } = e;
590 685
       const lastItem = data[data.length - 1];
591 686
       this.selectData = data || [];
592
-      console.log(lastItem, "pickerCallbackpintai");
687
+      console.log(lastItem, "pickerCallback99999pintai");
593 688
       this.pingtaifeilei = lastItem || {};
594 689
     },
595 690
     bindTextAreaBlur(e) {
@@ -673,14 +768,18 @@ export default {
673 768
         });
674 769
         return;
675 770
       }
676
-      if(this.attrValueForm.extension_one <5 || this.attrValueForm.extension_one > 100 || this.attrValueForm.extension_one == ""){
771
+      if (
772
+        this.attrValueForm.extension_one < 5 ||
773
+        this.attrValueForm.extension_one > 100 ||
774
+        this.attrValueForm.extension_one == ""
775
+      ) {
677 776
         uni.showToast({
678 777
           title: "请填写正确的分润比例",
679
-          icon: "none", 
680
-        })
778
+          icon: "none",
779
+        });
681 780
         return;
682 781
       }
683
-       
782
+
684 783
       if (this.formData.store_info == "") {
685 784
         uni.showToast({
686 785
           title: "请填写商品简介",
@@ -688,19 +787,20 @@ export default {
688 787
         });
689 788
         return;
690 789
       }
691
-      this.attrValueForm.image =  this.formData.image 
692
-
693
-
694
-
790
+      this.attrValueForm.image = this.formData.image;
791
+      this.formData.cate_id = this.pingtaifeilei.id; //平台商品分类
695 792
       // 转换为包含合并后对象的数组
696
-      const result = [{  ...this.attrValueForm }];
793
+      const result = [{ ...this.attrValueForm }];
697 794
       const newParams = { ...this.formData, attrValue: result };
698 795
       console.log(newParams, "newParams");
699 796
       uni.showLoading({
700 797
         title: "数据提交中...",
701 798
       });
799
+      let req = this.clickType === "updated" ? updateProduct : addProduct
800
+      let product_id = this.clickType === "updated"? this.product_id : ""
801
+
702 802
       try {
703
-        const res = await addProduct(newParams);
803
+        const res = await req(product_id,newParams);
704 804
         if (res.data.status == 200) {
705 805
           uni.showToast({
706 806
             title: "数据提交成功",
@@ -772,19 +872,18 @@ export default {
772 872
           title: "分润比例不能小于5%",
773 873
           icon: "none",
774 874
         });
775
-        this.$nextTick(()=>{
776
-        this.attrValueForm.extension_one = '5';
777
-        })
875
+        this.$nextTick(() => {
876
+          this.attrValueForm.extension_one = "5";
877
+        });
778 878
       }
779 879
       if (value > 100) {
780 880
         uni.showToast({
781 881
           title: "分润比例不能大于100%",
782 882
           icon: "none",
783 883
         });
784
-        this.$nextTick(()=>{
785
-        this.attrValueForm.extension_one = this.base_commission;
786
-        })
787
-
884
+        this.$nextTick(() => {
885
+          this.attrValueForm.extension_one = this.base_commission;
886
+        });
788 887
       }
789 888
 
790 889
       let data = {
@@ -844,10 +943,9 @@ export default {
844 943
       }
845 944
 
846 945
       const formatted = this.limitPriceFormat(value);
847
-        this.$nextTick(()=>{
946
+      this.$nextTick(() => {
848 947
         _this.attrValueForm.ot_price = formatted;
849
-        })
850
-     
948
+      });
851 949
     },
852 950
 
853 951
     limitPriceFormat(value) {

+ 22 - 5
shop/productManagementModule/components/upload.vue

@@ -69,6 +69,20 @@ export default {
69 69
       type: Number,
70 70
       default: 0,
71 71
     },
72
+    fileList: {
73
+      type: Array,
74
+      default: () => [],
75
+    },
76
+  },
77
+  watch: {
78
+    fileList: {
79
+      handler(newVal) {
80
+        console.log(newVal, "newVal");
81
+        this.fileListData = newVal;
82
+        this.emitChangeFiles(newVal);
83
+      },
84
+      deep: true,
85
+    },
72 86
   },
73 87
   data() {
74 88
     return {
@@ -76,6 +90,10 @@ export default {
76 90
       paths: "",
77 91
     };
78 92
   },
93
+  mounted() {
94
+    this.fileListData = this.fileList;
95
+    this.emitChangeFiles(this.fileListData);
96
+  },
79 97
   methods: {
80 98
     emitChangeFiles(data) {
81 99
       this.$emit("changeFiles", {
@@ -94,10 +112,9 @@ export default {
94 112
         // sizeType: ["compressed"], // original 原图,compressed 压缩图,默认二者都有
95 113
         sourceType: ["album", "camera"], // album 从相册选图,camera 使用相机,默认二者都有
96 114
         success: async function (res) {
97
-            const tempFiles = res.tempFiles;
98
-            const tempFilePaths = res.tempFilePaths;
115
+          const tempFiles = res.tempFiles;
116
+          const tempFilePaths = res.tempFilePaths;
99 117
           if (that.fileListData.length === 0) {
100
-          
101 118
             const data = await that.uploadFileData(tempFiles[0]);
102 119
             if (!data) {
103 120
               that.fileListData = [];
@@ -167,14 +184,14 @@ export default {
167 184
             }
168 185
             resolve(this.paths);
169 186
             console.log("上传成功", JSON.parse(res.data));
170
-             uni.hideLoading();
187
+            uni.hideLoading();
171 188
             uni.hideToast();
172 189
           },
173 190
           fail: (err) => {
174 191
             console.error("上传失败", err);
175 192
             this.paths = "";
176 193
             resolve(this.paths);
177
-             uni.hideLoading();
194
+            uni.hideLoading();
178 195
             uni.hideToast();
179 196
           },
180 197
           complete: () => {

+ 7 - 0
shop/productManagementModule/index.vue

@@ -30,6 +30,8 @@
30 30
        class="mb-t1" 
31 31
       :fullSreen="true"
32 32
         fullSreenTitle="在线选品列表"  @custom-handle-click="onHandleXuanPin"></listCardInfo> -->
33
+		
34
+		 <listCardInfo headerTitle="添加商品" class="mb-t1" :fullSreen="true" fullSreenTitle="添加单规格商品" @custom-handle-click="addProductRuKou"></listCardInfo>
33 35
     </view>
34 36
   </view>
35 37
 </template>
@@ -201,6 +203,11 @@ export default {
201 203
     }
202 204
   },
203 205
   methods: {
206
+	  addProductRuKou(){
207
+		  uni.redirectTo({
208
+		  	url:`./addProduct?clickType=create`
209
+		  })
210
+	  },
204 211
     async getGoodsTabNum() {
205 212
       try {
206 213
         const res = await getGoodsTab();

+ 63 - 14
shop/productManagementModule/productManagement.vue

@@ -74,9 +74,17 @@
74 74
               <button
75 75
                 class="list-card-bottom-btn-list--item set-activity active"
76 76
                 @click="huodong(item, index)"
77
+                v-if="type != 1 && type != 2"
77 78
               >
78 79
                 活动
79 80
               </button>
81
+              <button
82
+                class="list-card-bottom-btn-list--item edit-activity active"
83
+                @click="editProduct(item, index)"
84
+                v-if="type == 1 || type == 2"
85
+              >
86
+                编辑
87
+              </button>
80 88
               <!-- v-if="tableFrom.type === '5'" -->
81 89
               <button
82 90
                 v-if="type == 5"
@@ -203,6 +211,7 @@ import {
203 211
   productDeleteApi,
204 212
   productRestoreApi,
205 213
   Addseckill, //活动
214
+  getProductDetail,
206 215
 } from "@/commit/product.js";
207 216
 //商品列表
208 217
 export default {
@@ -289,15 +298,15 @@ export default {
289 298
     await this.getGoodsTabData();
290 299
     await this.getProductListData();
291 300
   },
292
-  async onPullDownRefresh() {
301
+  onPullDownRefresh() {
293 302
     uni.showLoading({
294 303
       title: "加载中",
295 304
     });
296 305
     this.page = 1;
297 306
     this.is_panudn = true;
298 307
     this.list = [];
299
-    await this.getProductListData();
300
-     uni.hideLoading();
308
+    this.getProductListData();
309
+    uni.hideLoading();
301 310
   },
302 311
   onReachBottom() {
303 312
     console.log("onReachBottom");
@@ -348,13 +357,13 @@ export default {
348 357
         is_gift_bag: this.is_gift_bag,
349 358
         p_type: this.p_type,
350 359
       };
351
-
360
+      uni.showLoading({
361
+        title: "加载中",
362
+      });
352 363
       try {
353
-        uni.showLoading({
354
-          title: "加载中",
355
-        });
356 364
         const res = await getProductList(params);
357
-         uni.hideLoading();
365
+        uni.hideLoading();
366
+        uni.stopPullDownRefresh();
358 367
         if (res.data.status == 200) {
359 368
           this.tihsi = res.data.data.list.length;
360 369
           if (res.data.data.count > 0) {
@@ -392,7 +401,7 @@ export default {
392 401
     async onHandleShow(item, type) {
393 402
       const id = item.product_id;
394 403
       const data = {
395
-        status: item.is_show==1?0:1,
404
+        status: item.is_show == 1 ? 0 : 1,
396 405
       };
397 406
       const titleTips = item.is_show == 1 ? "商品下架中" : "商品上架中";
398 407
       const titleMsg = item.is_show == 1 ? "商品下架成功" : "商品上架成功";
@@ -406,12 +415,12 @@ export default {
406 415
             title: titleMsg,
407 416
             icon: "none",
408 417
           });
409
-          await this.getGoodsTabData()
418
+          await this.getGoodsTabData();
410 419
           await this.getProductListData();
411
-           uni.hideLoading();
420
+          uni.hideLoading();
412 421
         }
413 422
       } catch (error) {
414
-         uni.hideLoading();
423
+        uni.hideLoading();
415 424
       } finally {
416 425
         uni.hideLoading();
417 426
         uni.hideToast();
@@ -494,7 +503,7 @@ export default {
494 503
     huodong(item) {
495 504
       this.dataObj = item;
496 505
       const _this = this;
497
-      if (item.seckill == 1 && this.type !=2) {
506
+      if (item.seckill == 1 && this.type != 2) {
498 507
         uni.showModal({
499 508
           title: "温馨提示",
500 509
           content: "此商品正在处于秒杀状态,请勿操作",
@@ -503,7 +512,7 @@ export default {
503 512
         });
504 513
         return;
505 514
       }
506
-       _this.showPopup()
515
+      _this.showPopup();
507 516
       // Addseckill({}).then(data=>{
508 517
       //   console.log(data)
509 518
       // }).catch((res) => {
@@ -597,6 +606,42 @@ export default {
597 606
         this.isEmpty = false;
598 607
       }
599 608
     },
609
+    async editProduct(item, index) {
610
+      const isU = await this.getProductType(item.product_id);
611
+      if (isU == "single") {
612
+        uni.redirectTo({
613
+          url: `./addProduct?clickType=updated&product_id=${item.product_id}`,
614
+        });
615
+      } else if (isU == "multi") {
616
+        uni.showModal({
617
+          content: "非单规格产品,不支持移动端编辑,请前往PC端编辑",
618
+          showCancel: false,
619
+        });
620
+      } else {
621
+        uni.showModal({
622
+          content: "网络错误",
623
+          showCancel: false,
624
+        });
625
+      }
626
+      console.log(item, index, isU);
627
+    },
628
+    async getProductType(id) {
629
+      uni.showLoading({
630
+        title: "正在跳转",
631
+      });
632
+      try {
633
+        const res = await getProductDetail(id);
634
+        if (res.data.status == 200) {
635
+          return res.data.data.spec_type == 0 ? "single" : "multi";
636
+        } else {
637
+          return false;
638
+        }
639
+      } catch (err) {
640
+        return false;
641
+      } finally {
642
+        uni.hideLoading();
643
+      }
644
+    },
600 645
   },
601 646
 };
602 647
 </script>
@@ -766,6 +811,10 @@ page {
766 811
               background: #e9ca1d;
767 812
               color: white;
768 813
             }
814
+            &.edit-activity {
815
+              background: #e9ca1d;
816
+              color: white;
817
+            }
769 818
 
770 819
             &:active {
771 820
               opacity: 0.8;