Ver código fonte

商品操作

cr 3 anos atrás
pai
commit
c74ca0aabb
3 arquivos alterados com 126 adições e 681 exclusões
  1. 1 0
      src/common/store/common.js
  2. 3 9
      src/pages/yx/brand.vue
  3. 122 672
      src/pages/yx/good.vue

+ 1 - 0
src/common/store/common.js

@@ -6,6 +6,7 @@ const module = {
6 6
     // 仓库
7 7
     state: {
8 8
         iphoneX:false,
9
+        activityData:{} // yx/good 使用
9 10
     },
10 11
 
11 12
     // 同步方法

+ 3 - 9
src/pages/yx/brand.vue

@@ -133,7 +133,7 @@
133 133
                                             @click="setActivityDisplay(item)"
134 134
                                         >
135 135
                                             {{
136
-                                                item.display === 0
136
+                                                item.offline
137 137
                                                     ? "上线"
138 138
                                                     : "下线"
139 139
                                             }}
@@ -363,11 +363,7 @@ export default {
363 363
 
364 364
         // 设置活动显示或隐藏
365 365
         setActivityDisplay(val) {
366
-            let offline = true;
367
-            if (val.display === 1) {
368
-            } else {
369
-                offline = false;
370
-            }
366
+            let offline = !val.offline;
371 367
             this.api
372 368
                 .get(
373 369
                     "/Supplier/SetActivityOffline",
@@ -379,9 +375,7 @@ export default {
379 375
                 )
380 376
                 .then((res) => {
381 377
                     if (res.success) {
382
-                        val.display === 0
383
-                            ? (val.display = 0)
384
-                            : (val.display = 1);
378
+                        val.offline=!val.offline;
385 379
                         this.$forceUpdate();
386 380
                         this.fn.showToast("设置成功");
387 381
                     } else {

+ 122 - 672
src/pages/yx/good.vue

@@ -125,16 +125,14 @@
125 125
                                     >
126 126
                                     <span @click="setActivityDisplay(activity)">
127 127
                                         {{
128
-                                            activity.display === 1
129
-                                                ? "隐藏"
130
-                                                : "取消隐藏"
128
+                                            activity.offline ? "上线" : "下线"
131 129
                                         }}</span
132 130
                                     >
133
-                                    <span @click="pushGive(activity)">
134
-                                        推送到群</span
131
+                                    <span @click="editActivity(activity)">
132
+                                        编辑</span
135 133
                                     >
136
-                                    <span @click="shareApp(activity)">
137
-                                        分享</span
134
+                                    <span @click="removeActivity(activity)">
135
+                                        删除</span
138 136
                                     >
139 137
                                 </div>
140 138
                             </div>
@@ -267,31 +265,31 @@
267 265
                                     <div class="btns">
268 266
                                         <div
269 267
                                             class="btn"
270
-                                            @click="sharePoster(item)"
268
+                                            @click="setProductOffline(item)"
271 269
                                         >
272 270
                                             {{
273 271
                                                 item.shareLoading
274
-                                                    ? "生成中"
275
-                                                    : "海报"
272
+                                                    ? "上线"
273
+                                                    : "下线"
276 274
                                             }}
277 275
                                         </div>
278 276
                                         <div
279 277
                                             class="btn"
280
-                                            @click="pushProduct(item)"
278
+                                            @click="setSortOrder(item)"
281 279
                                         >
282
-                                            推荐
280
+                                            修改权重
283 281
                                         </div>
284 282
                                         <div
285 283
                                             class="btn"
286
-                                            @click="shareGoodFun(item)"
284
+                                            @click="editGood(item)"
287 285
                                         >
288
-                                            分享
286
+                                            编辑
289 287
                                         </div>
290 288
                                         <div
291 289
                                             class="btn"
292
-                                            @click="openMore(item)"
290
+                                            @click="removeGood(item)"
293 291
                                         >
294
-                                            更多
292
+                                            删除
295 293
                                         </div>
296 294
                                     </div>
297 295
                                 </li>
@@ -321,29 +319,6 @@
321 319
             </div>
322 320
         </div>
323 321
 
324
-        <!-- 海报 -->
325
-        <div
326
-            class="canvas"
327
-            v-show="canvasShow"
328
-            @touchmove.stop=""
329
-            @click="closeCanvas"
330
-        >
331
-            <div class="canvas__content">
332
-                <div class="canvas__close">
333
-                    <img
334
-                        class="canvas__img"
335
-                        src="/static/live/close.png"
336
-                        alt=""
337
-                    />
338
-                </div>
339
-                <canvas
340
-                    class="canvas__box"
341
-                    canvas-id="canvas"
342
-                    :disable-scroll="true"
343
-                    @click.stop="viewImg()"
344
-                ></canvas>
345
-            </div>
346
-        </div>
347 322
         <!-- 描述 -->
348 323
         <div class="des-modal" v-if="desModalVisible">
349 324
             <div class="bg" @click="hideContent"></div>
@@ -379,12 +354,6 @@ export default {
379 354
             searchVal: "",
380 355
             otherUrl: "https://bot.ixiaokejia.com/",
381 356
 
382
-            // 分享
383
-            canvasShow: false,
384
-            shareGood: {},
385
-            shareRootLoading: false,
386
-            shareLoadList: [],
387
-
388 357
             // 文字弹框
389 358
             desModalVisible: false,
390 359
             desModalTitle: "",
@@ -569,71 +538,52 @@ export default {
569 538
 
570 539
         //  设置活动置顶
571 540
         setActivityTop(val) {
572
-            if (val.top > 0) {
573
-                // 取消置顶
574
-                this.api
575
-                    .get("/Yx/CancelActivityTop", {
576
-                        aid: val.aid,
577
-                    })
578
-                    .then((res) => {
579
-                        if (res.success) {
541
+            if (this.user.roleId !== "0") {
542
+                return this.fn.showToast("需管理员账号才能执行此操作");
543
+            }
544
+            this.api
545
+                .get(
546
+                    "/Supplier/SetActivityTop",
547
+                    {
548
+                        aid: val.activityNo,
549
+                        untop: val.top > 0 ? true : false,
550
+                    },
551
+                    { pass: true }
552
+                )
553
+                .then((res) => {
554
+                    if (res.success) {
555
+                        if (val.top > 0) {
580 556
                             val.top = 0;
581
-                            this.goodList.sort((x, y) => {
582
-                                return y.top - x.top;
583
-                            });
584
-                            this.$forceUpdate();
585
-                            this.fn.showToast("取消成功");
586
-                        } else {
587
-                            this.fn.showModal({
588
-                                title: "设置失败",
589
-                                content: res.message,
590
-                                showCancel: false,
591
-                            });
592
-                        }
593
-                    });
594
-            } else {
595
-                // 置顶
596
-                this.api
597
-                    .get("/Yx/SetActivityTop", {
598
-                        aid: val.aid,
599
-                    })
600
-                    .then((res) => {
601
-                        if (res.success) {
602
-                            val.top = 1;
603
-                            this.goodList.sort((x, y) => {
604
-                                return y.top - x.top;
605
-                            });
606
-                            this.$forceUpdate();
607
-                            this.fn.showToast("置顶成功");
608 557
                         } else {
609
-                            this.fn.showModal({
610
-                                title: "设置失败",
611
-                                content: res.message,
612
-                                showCancel: false,
613
-                            });
558
+                            val.top = 999;
614 559
                         }
615
-                    });
616
-            }
560
+                        this.$forceUpdate();
561
+                        this.fn.showToast("设置成功");
562
+                    } else {
563
+                        this.fn.showModal({
564
+                            title: "设置失败",
565
+                            content: res.message,
566
+                            showCancel: false,
567
+                        });
568
+                    }
569
+                });
617 570
         },
618 571
 
619 572
         // 设置活动显示或隐藏
620 573
         setActivityDisplay(val) {
621
-            let display = 0;
622
-            if (val.display === 1) {
623
-                // 隐藏
624
-                display = 0;
625
-            } else {
626
-                // 置顶
627
-                display = 1;
628
-            }
574
+            let offline = !val.offline;
629 575
             this.api
630
-                .get("/Yx/SetActivityDisplay", {
631
-                    aid: val.aid,
632
-                    display,
633
-                })
576
+                .get(
577
+                    "/Supplier/SetActivityOffline",
578
+                    {
579
+                        id: val._id,
580
+                        offline,
581
+                    },
582
+                    { pass: true }
583
+                )
634 584
                 .then((res) => {
635 585
                     if (res.success) {
636
-                        val.display = display;
586
+                        val.offline = !val.offline;
637 587
                         this.$forceUpdate();
638 588
                         this.fn.showToast("设置成功");
639 589
                     } else {
@@ -646,82 +596,98 @@ export default {
646 596
                 });
647 597
         },
648 598
 
649
-        // 推送
650
-        pushGive(item) {
599
+        editActivity(val) {},
600
+
601
+        // 删除
602
+        removeActivity(val) {
651 603
             let sendData = {
652
-                aid: item.activityNo,
604
+                id: val._id,
605
+                query: true,
653 606
             };
654
-
655 607
             this.api
656
-                .get("/Yx/SendActivity", sendData, {
608
+                .delete("/Supplier/RemoveActivity", sendData, {
657 609
                     pass: true,
658 610
                 })
659 611
                 .then((res) => {
660
-                    let data = JSON.parse(res.data);
661
-                    this.fn.showToast(data.message);
612
+                    if (res.success) {
613
+                        this.fn.showToast("删除成功");
614
+                        this.router.back();
615
+                    } else {
616
+                        this.fn.showModal({
617
+                            title: "删除失败",
618
+                            content: res.message,
619
+                            showCancel: false,
620
+                        });
621
+                    }
622
+                });
623
+        },
624
+
625
+        // 商品上下线
626
+        setProductOffline(val) {
627
+            let offline = !val.offline;
628
+            this.api
629
+                .get(
630
+                    "/Supplier/SetProductOffline",
631
+                    {
632
+                        id: val.id,
633
+                        offline,
634
+                    },
635
+                    { pass: true }
636
+                )
637
+                .then((res) => {
638
+                    if (res.success) {
639
+                        val.offline = !val.offline;
640
+                        this.$forceUpdate();
641
+                        this.fn.showToast("设置成功");
642
+                    } else {
643
+                        this.fn.showModal({
644
+                            title: "设置失败",
645
+                            content: res.message,
646
+                            showCancel: false,
647
+                        });
648
+                    }
662 649
                 });
663 650
         },
664 651
 
665
-        // 分享
666
-        shareApp(val) {
667
-            uni.navigateToMiniProgram({
668
-                appId: "wx7d16ba51271496b8",
669
-                path: `/pages/recommend/list?shopId=${this.shopId}&aid=${val.activityNo}`,
670
-                extraData: {
671
-                    shopId: this.shopId,
672
-                    aid: val.activityNo,
673
-                },
674
-            });
652
+        // 商品权重
653
+        setSortOrder(val) {
654
+            
675 655
         },
676 656
 
677
-        // 推荐商品
678
-        pushProduct(item, type) {
657
+        // 编辑商品
658
+        editGood(val) {},
659
+
660
+        // 删除商品
661
+        removeGood(val) {
679 662
             let sendData = {
680
-                pid: item.id,
663
+                id: val.id,
664
+                query: true,
681 665
             };
682
-
683 666
             this.api
684
-                .get("/Yx/Sendproduct", sendData, {
667
+                .delete("/Supplier/RemoveProduct", sendData, {
685 668
                     pass: true,
686 669
                 })
687 670
                 .then((res) => {
688
-                    let data = JSON.parse(res.data);
689
-                    this.fn.showToast(data.message);
671
+                    if (res.success) {
672
+                        let arr = [];
673
+                        for (let item of this.goodList) {
674
+                            if (item.id !== val.id) {
675
+                                arr.push(item);
676
+                            }
677
+                        }
678
+                        this.goodList = [...arr];
679
+                        this.fn.showToast("删除成功");
680
+                        this.router.back();
681
+                    } else {
682
+                        this.fn.showModal({
683
+                            title: "删除失败",
684
+                            content: res.message,
685
+                            showCancel: false,
686
+                        });
687
+                    }
690 688
                 });
691 689
         },
692 690
 
693
-        // 分享商品
694
-        shareGoodFun(val) {
695
-            uni.navigateToMiniProgram({
696
-                appId: "wx7d16ba51271496b8",
697
-                path: `/pages/recommend/detail?shopId=${this.shopId}&goodsId=${val.id}`,
698
-                extraData: {
699
-                    shopId: this.shopId,
700
-                    id: val.id,
701
-                },
702
-            });
703
-        },
704
-
705
-        // 更多
706
-        openMore(val) {
707
-            let arr = [];
708
-            if (val.top === 0) {
709
-                arr.push("置顶");
710
-            } else {
711
-                arr.push("取消置顶");
712
-            }
713
-            this.fn.showActionSheet(arr).then((res) => {
714
-                switch (arr[res]) {
715
-                    case "置顶":
716
-                        this.setProductTop(val, true);
717
-                        break;
718
-                    case "取消置顶":
719
-                        this.setProductTop(val, false);
720
-                        break;
721
-                }
722
-            });
723
-        },
724
-
725 691
         // 商品置顶
726 692
         setProductTop(val, isUp) {
727 693
             if (isUp) {
@@ -765,522 +731,6 @@ export default {
765 731
             }
766 732
         },
767 733
 
768
-        // 去详情
769
-        goDetail(val) {
770
-            this.router.push({
771
-                path: "/pages/youxuan/good-detail",
772
-                query: {
773
-                    id: val.id,
774
-                },
775
-            });
776
-        },
777
-
778
-        shareLoading(id, status) {
779
-            for (let item of this.goodList) {
780
-                if (item.id === id) {
781
-                    item.shareLoading = status;
782
-                }
783
-            }
784
-            this.goodList = [...this.goodList];
785
-        },
786
-
787
-        // 分享
788
-        sharePoster(val) {
789
-            if (val.shareLoading) {
790
-                return;
791
-            }
792
-            if (this.shareRootLoading) {
793
-                this.shareLoadList.push(val);
794
-            }
795
-            this.shareRootLoading = true;
796
-            const self = this;
797
-            this.shareLoading(val.id, true);
798
-            // uni.showLoading({
799
-            //     title: "加载中...",
800
-            //     mask:true
801
-            // });
802
-            this.api.get("/Supplier/GetProduct", { id: val.id }).then((res) => {
803
-                this.shareGood = JSON.parse(res.data);
804
-                // uni.hideLoading();
805
-                // self.$refs.share.open("", "", "", () => {
806
-                //     self.canvasShow = false;
807
-                // });
808
-                this.saveImage("single");
809
-            });
810
-        },
811
-        // 获取换算成画布使用的像素
812
-        getPx(size) {
813
-            let windowWidth = uni.getSystemInfoSync().windowWidth || 414;
814
-            let multiple = (windowWidth / 1080) * (920 / 670);
815
-            size = size * multiple;
816
-
817
-            return Number(size.toFixed(2));
818
-        },
819
-        // 创建分享图
820
-        creationShare() {
821
-            const self = this;
822
-            const ctx = uni.createCanvasContext("canvas", self);
823
-
824
-            // uni.showLoading({
825
-            //     title: "正在生成海报",
826
-            //     mask:true
827
-            // });
828
-            return new Promise((resolve) => {
829
-                self.router.getScene(self.$mp.query).then((res) => {
830
-                    Promise.all([
831
-                        uni.getImageInfo({
832
-                            src:
833
-                                this.user.appLogo ||
834
-                                self.config.imageResourceUrl +
835
-                                    "images/common/avatar.png",
836
-                        }),
837
-                        uni.getImageInfo({
838
-                            src: self.shareGood.pictureUrls[0],
839
-                        }),
840
-                        // 获取小程序吗
841
-                        self.api
842
-                            .get("/Share/GetQRCode", {
843
-                                path: "pages/recommend/detail",
844
-                                paremeters: JSON.stringify({
845
-                                    goodsId: self.shareGood.pid,
846
-                                    shopId: this.shopId,
847
-                                }),
848
-                            })
849
-                            .then((res) => {
850
-                                return uni.getImageInfo({
851
-                                    src: res.data,
852
-                                });
853
-                            }),
854
-                    ]).then((res) => {
855
-                        // 背景
856
-                        ctx.setFillStyle("#fff");
857
-                        ctx.fillRect(0, 0, self.getPx(670), self.getPx(1080));
858
-
859
-                        // 头像
860
-                        if (res[0][1].path) {
861
-                            let avatarurl_width = self.getPx(70);
862
-                            let avatarurl_heigth = self.getPx(70);
863
-                            let avatarurl_x = self.getPx(30);
864
-                            let avatarurl_y = self.getPx(40);
865
-                            ctx.save();
866
-                            ctx.beginPath();
867
-                            ctx.arc(
868
-                                avatarurl_width / 2 + avatarurl_x,
869
-                                avatarurl_heigth / 2 + avatarurl_y,
870
-                                avatarurl_width / 2,
871
-                                0,
872
-                                Math.PI * 2,
873
-                                true
874
-                            );
875
-                            ctx.clip();
876
-                            ctx.drawImage(
877
-                                res[0][1].path,
878
-                                avatarurl_x,
879
-                                avatarurl_y,
880
-                                avatarurl_width,
881
-                                avatarurl_heigth
882
-                            );
883
-                            ctx.restore();
884
-                        }
885
-
886
-                        // 昵称
887
-                        ctx.setFontSize(self.getPx(28));
888
-                        ctx.setFillStyle("#333");
889
-                        ctx.fillText(
890
-                            self.user.appName,
891
-                            self.getPx(115),
892
-                            self.getPx(90)
893
-                        );
894
-                        ctx.stroke();
895
-
896
-                        // 商品图片
897
-                        ctx.drawImage(
898
-                            res[1][1].path,
899
-                            self.getPx(0),
900
-                            self.getPx(145),
901
-                            self.getPx(670),
902
-                            self.getPx(670)
903
-                        );
904
-
905
-                        // 商品标题,第一行
906
-                        let goodsName = self.shareGood.name;
907
-
908
-                        if (goodsName.length > 12) {
909
-                            goodsName = goodsName.substr(0, 12);
910
-                        }
911
-                        ctx.setFontSize(self.getPx(28));
912
-                        ctx.setFillStyle("#333");
913
-                        ctx.fillText(
914
-                            goodsName,
915
-                            self.getPx(50),
916
-                            self.getPx(880)
917
-                        );
918
-                        ctx.stroke();
919
-
920
-                        // 商品标题,第二行
921
-                        let goodsName2 = self.shareGood.name;
922
-                        if (goodsName2.length > 12) {
923
-                            goodsName2 = goodsName2.substr(12, 10) + "...";
924
-
925
-                            ctx.setFontSize(self.getPx(28));
926
-                            ctx.setFillStyle("#333");
927
-                            ctx.fillText(
928
-                                goodsName2,
929
-                                self.getPx(50),
930
-                                self.getPx(920)
931
-                            );
932
-                            ctx.stroke();
933
-                        }
934
-
935
-                        // 商品描述,第一行
936
-                        let descName = self.shareGood.description || "";
937
-
938
-                        if (descName.length > 14) {
939
-                            descName = descName.substr(0, 14);
940
-                        }
941
-                        ctx.setFontSize(self.getPx(24));
942
-                        ctx.setFillStyle("#666");
943
-                        ctx.fillText(descName, self.getPx(50), self.getPx(965));
944
-                        ctx.stroke();
945
-
946
-                        // 商品描述,第二行
947
-                        let descName2 = self.shareGood.description || "";
948
-                        if (descName2.length > 14) {
949
-                            descName2 = descName2.substr(14, 14) + "...";
950
-
951
-                            ctx.setFontSize(self.getPx(24));
952
-                            ctx.setFillStyle("#666");
953
-                            ctx.fillText(
954
-                                descName2,
955
-                                self.getPx(50),
956
-                                self.getPx(995)
957
-                            );
958
-                            ctx.stroke();
959
-                        }
960
-
961
-                        // 商品价格符号
962
-                        ctx.setFontSize(self.getPx(20));
963
-                        ctx.setFillStyle("#f8662a");
964
-                        ctx.fillText("¥", self.getPx(50), self.getPx(1050));
965
-                        ctx.stroke();
966
-
967
-                        // 商品价格
968
-                        ctx.setFontSize(self.getPx(40));
969
-                        ctx.setFillStyle("#f8662a");
970
-                        ctx.fillText(
971
-                            self.shareGood.agentFee / 100,
972
-                            self.getPx(65),
973
-                            self.getPx(1050)
974
-                        );
975
-                        ctx.stroke();
976
-
977
-                        // 小程序吗
978
-                        ctx.drawImage(
979
-                            res[2][1].path,
980
-                            self.getPx(460),
981
-                            self.getPx(850),
982
-                            self.getPx(170),
983
-                            self.getPx(170)
984
-                        );
985
-
986
-                        // 长按扫码购买
987
-                        ctx.setFontSize(self.getPx(24));
988
-                        ctx.setFillStyle("#999");
989
-                        ctx.fillText(
990
-                            "长按扫码购买",
991
-                            self.getPx(470),
992
-                            self.getPx(1050)
993
-                        );
994
-                        ctx.stroke();
995
-
996
-                        ctx.draw();
997
-
998
-                        self.canvasShow = true;
999
-                        // uni.hideLoading();
1000
-                        setTimeout(() => {
1001
-                            // 生成临时路径
1002
-                            uni.canvasToTempFilePath({
1003
-                                canvasId: "canvas",
1004
-                                fileType: "jpg",
1005
-                                success: function (res) {
1006
-                                    self.canvasShow = false;
1007
-                                    self.canvasImgPath = [res.tempFilePath];
1008
-                                    resolve(res.tempFilePath);
1009
-                                },
1010
-                            });
1011
-                        }, 100);
1012
-                    });
1013
-                });
1014
-            });
1015
-        },
1016
-        viewImg() {
1017
-            let self = this;
1018
-            //查看图片
1019
-            uni.previewImage({
1020
-                urls: self.canvasImgPath,
1021
-                longPressActions: true,
1022
-            });
1023
-        },
1024
-
1025
-        // 关闭海报
1026
-        closeCanvas() {
1027
-            const self = this;
1028
-
1029
-            self.canvasShow = false;
1030
-        },
1031
-        // 创建多张分享图
1032
-        creationShares(url) {
1033
-            const self = this;
1034
-            const ctx = uni.createCanvasContext("canvas", self);
1035
-
1036
-            return new Promise((resolve) => {
1037
-                self.router.getScene(self.$mp.query).then((res) => {
1038
-                    Promise.all([
1039
-                        uni.getImageInfo({
1040
-                            src:
1041
-                                this.user.avatar ||
1042
-                                self.config.imageResourceUrl +
1043
-                                    "images/common/avatar.png",
1044
-                        }),
1045
-                        uni.getImageInfo({
1046
-                            src: url,
1047
-                        }),
1048
-                        uni.getImageInfo({
1049
-                            src:
1050
-                                self.config.imageResourceUrl +
1051
-                                "resource/share/recognition.jpg",
1052
-                        }),
1053
-                        // 获取小程序吗
1054
-                        self.api
1055
-                            .get("/Share/GetQRCode", {
1056
-                                path: "pages/goods/detail",
1057
-                                paremeters: JSON.stringify({
1058
-                                    goodsId: self.shareGood.pid,
1059
-                                    shopId: this.shopId,
1060
-                                }),
1061
-                            })
1062
-                            .then((res) => {
1063
-                                return uni.getImageInfo({
1064
-                                    src: res.data,
1065
-                                });
1066
-                            }),
1067
-                    ]).then((res) => {
1068
-                        // 背景
1069
-                        ctx.setFillStyle("#fff");
1070
-                        ctx.fillRect(0, 0, self.getPx(670), self.getPx(1080));
1071
-
1072
-                        // 头像
1073
-                        if (res[0][1].path) {
1074
-                            let avatarurl_width = self.getPx(70);
1075
-                            let avatarurl_heigth = self.getPx(70);
1076
-                            let avatarurl_x = self.getPx(30);
1077
-                            let avatarurl_y = self.getPx(40);
1078
-                            ctx.save();
1079
-                            ctx.beginPath();
1080
-                            ctx.arc(
1081
-                                avatarurl_width / 2 + avatarurl_x,
1082
-                                avatarurl_heigth / 2 + avatarurl_y,
1083
-                                avatarurl_width / 2,
1084
-                                0,
1085
-                                Math.PI * 2,
1086
-                                true
1087
-                            );
1088
-                            ctx.clip();
1089
-                            ctx.drawImage(
1090
-                                res[0][1].path,
1091
-                                avatarurl_x,
1092
-                                avatarurl_y,
1093
-                                avatarurl_width,
1094
-                                avatarurl_heigth
1095
-                            );
1096
-                            ctx.restore();
1097
-                        }
1098
-
1099
-                        // 昵称
1100
-                        ctx.setFontSize(self.getPx(28));
1101
-                        ctx.setFillStyle("#333");
1102
-                        ctx.fillText(
1103
-                            self.user.nickName + "分享一件好物给你~",
1104
-                            self.getPx(115),
1105
-                            self.getPx(90)
1106
-                        );
1107
-                        ctx.stroke();
1108
-
1109
-                        // 商品图片
1110
-                        ctx.drawImage(
1111
-                            res[1][1].path,
1112
-                            self.getPx(0),
1113
-                            self.getPx(145),
1114
-                            self.getPx(670),
1115
-                            self.getPx(670)
1116
-                        );
1117
-
1118
-                        // 底部图片
1119
-                        ctx.drawImage(
1120
-                            res[2][1].path,
1121
-                            self.getPx(30),
1122
-                            self.getPx(880),
1123
-                            self.getPx(400),
1124
-                            self.getPx(120)
1125
-                        );
1126
-
1127
-                        // 小程序吗
1128
-                        ctx.drawImage(
1129
-                            res[3][1].path,
1130
-                            self.getPx(460),
1131
-                            self.getPx(850),
1132
-                            self.getPx(170),
1133
-                            self.getPx(170)
1134
-                        );
1135
-
1136
-                        // 长按扫码购买
1137
-                        ctx.setFontSize(self.getPx(24));
1138
-                        ctx.setFillStyle("#999");
1139
-                        ctx.fillText(
1140
-                            "长按扫码购买",
1141
-                            self.getPx(470),
1142
-                            self.getPx(1050)
1143
-                        );
1144
-                        ctx.stroke();
1145
-
1146
-                        ctx.draw();
1147
-
1148
-                        self.canvasShow = true;
1149
-                        uni.hideLoading();
1150
-                        setTimeout(() => {
1151
-                            // 生成临时路径
1152
-                            uni.canvasToTempFilePath({
1153
-                                canvasId: "canvas",
1154
-                                fileType: "jpg",
1155
-                                success: function (res) {
1156
-                                    resolve(res.tempFilePath);
1157
-                                },
1158
-                            });
1159
-                        }, 100);
1160
-                    });
1161
-                });
1162
-            });
1163
-        },
1164
-        // 保存图片到相册
1165
-        async saveImage(type) {
1166
-            const self = this;
1167
-            const good = this.shareGood;
1168
-            if (type === "single" && !self.canvasHandleStatus) {
1169
-                // 分享图
1170
-                self.canvasHandleStatus = true;
1171
-                // 获取用户设置
1172
-                uni.getSetting({
1173
-                    success(res) {
1174
-                        if (
1175
-                            res.authSetting["scope.writePhotosAlbum"] === false
1176
-                        ) {
1177
-                            //用户拒绝权限打开设置界面
1178
-                            self.fn
1179
-                                .showModal({
1180
-                                    title: "图片保存失败",
1181
-                                    content:
1182
-                                        "需要你打开允许使用“相册”权限,才能成功保存图片",
1183
-                                    confirmText: "去设置",
1184
-                                })
1185
-                                .then((res) => {
1186
-                                    if (res.confirm) {
1187
-                                        self.canvasHandleStatus = false;
1188
-                                        self.shareEnd();
1189
-                                        self.fn.openSetting();
1190
-                                    } else {
1191
-                                        self.shareLoading(good.pid, false);
1192
-                                    }
1193
-                                });
1194
-                        } else {
1195
-                            // 生成分享图
1196
-                            self.creationShare().then((res) => {
1197
-                                // 保存分享图到相册
1198
-                                uni.saveImageToPhotosAlbum({
1199
-                                    filePath: res,
1200
-                                    success: function () {
1201
-                                        self.shareLoading(good.pid, false);
1202
-                                        self.shareEnd();
1203
-                                        self.fn.showToast("海报保存成功");
1204
-                                    },
1205
-                                    complete: function () {
1206
-                                        // self.shareLoading(
1207
-                                        //     good.baseInfo.id,
1208
-                                        //     false
1209
-                                        // );
1210
-                                        self.canvasHandleStatus = false;
1211
-                                        // self.shareEnd();
1212
-                                    },
1213
-                                });
1214
-                            });
1215
-                        }
1216
-                    },
1217
-                });
1218
-            } else {
1219
-                // 素材图
1220
-                let setting = await uni.getSetting();
1221
-
1222
-                if (
1223
-                    setting[1].authSetting["scope.writePhotosAlbum"] === false
1224
-                ) {
1225
-                    //用户拒绝权限打开设置界面
1226
-                    self.fn
1227
-                        .showModal({
1228
-                            title: "图片保存失败",
1229
-                            content:
1230
-                                "需要你打开允许使用“相册”权限,才能成功保存图片",
1231
-                            confirmText: "去设置",
1232
-                        })
1233
-                        .then((res) => {
1234
-                            if (res.confirm) {
1235
-                                self.fn.openSetting();
1236
-                            }
1237
-                        });
1238
-                } else if (!self.canvasHandleStatus) {
1239
-                    let imageList = self.shareGood.images;
1240
-                    let num = imageList.length;
1241
-
1242
-                    self.canvasHandleStatus = true;
1243
-                    uni.showLoading({
1244
-                        title: "正在生成海报",
1245
-                    });
1246
-
1247
-                    for (let i = 0; i < num; i++) {
1248
-                        let url = await self.creationShares(imageList[i]);
1249
-
1250
-                        // 保存分享图到相册
1251
-                        uni.saveImageToPhotosAlbum({
1252
-                            filePath: url,
1253
-                            complete: function () {
1254
-                                if (i + 1 === num) {
1255
-                                    self.canvasHandleStatus = false;
1256
-                                    self.canvasShow = false;
1257
-                                    self.fn.showModal({
1258
-                                        title:
1259
-                                            "已经保存" +
1260
-                                            num +
1261
-                                            "张商品素材图到手机相册可在相册直接查看",
1262
-                                        showCancel: false,
1263
-                                        confirmText: "我知道了",
1264
-                                    });
1265
-                                }
1266
-                            },
1267
-                        });
1268
-                    }
1269
-                }
1270
-            }
1271
-        },
1272
-
1273
-        shareEnd() {
1274
-            this.shareRootLoading = false;
1275
-            if (this.shareLoadList.length > 0) {
1276
-                let val = this.shareLoadList[0];
1277
-                this.shareLoadList.splice(0, 1);
1278
-                this.shareLoadList = [...this.shareLoadList];
1279
-                val.shareLoading = false;
1280
-                this.sharePoster(val);
1281
-            }
1282
-        },
1283
-
1284 734
         showContent(tit, con) {
1285 735
             this.desModalVisible = true;
1286 736
             this.desModalTitle = tit;