|
|
@@ -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) {
|