cr 3 роки тому
батько
коміт
64abdec1f7
1 змінених файлів з 175 додано та 162 видалено
  1. 175 162
      src/pages/recommend/detail.vue

+ 175 - 162
src/pages/recommend/detail.vue

@@ -866,197 +866,210 @@ export default {
866 866
                 let logoUrl =
867 867
                     "https://youxuan.ixiaokejia.com/home/forwardimg?url=" +
868 868
                     encodeURI(self.goods.pictureUrls[0]);
869
+                let brandLogo =
870
+                    "https://youxuan.ixiaokejia.com/home/forwardimg?url=" +
871
+                    encodeURI(self.goods.brandLogo);
869 872
                 self.api.get(logoUrl).then((logoRes) => {
870
-                    self.router.getScene(self.$mp.query).then((res) => {
871
-                        res.uid = self.user.id;
872
-                        res.shopId = self.activeShop.id;
873
-
874
-                        Promise.all([
875
-                            uni.getImageInfo({
876
-                                src: self.goods.brandLogo,
877
-                            }),
878
-                            uni.getImageInfo({
879
-                                src: logoRes.data,
880
-                            }),
881
-                            // 获取小程序吗
882
-                            self.api
883
-                                .get("/Share/GetQRCode", {
884
-                                    path: self.$mp.page.route,
885
-                                    paremeters: JSON.stringify(res),
886
-                                })
887
-                                .then((res) => {
888
-                                    return uni.getImageInfo({
889
-                                        src: res.data,
890
-                                    });
873
+                    self.api.get(brandLogo).then((brandLogoRes) => {
874
+                        self.router.getScene(self.$mp.query).then((res) => {
875
+                            res.uid = self.user.id;
876
+                            res.shopId = self.activeShop.id;
877
+
878
+                            Promise.all([
879
+                                uni.getImageInfo({
880
+                                    src: brandLogoRes.data,
891 881
                                 }),
892
-                        ]).then((res) => {
893
-                            // 背景
894
-                            ctx.setFillStyle("#fff");
895
-                            ctx.fillRect(
896
-                                0,
897
-                                0,
898
-                                self.getPx(670),
899
-                                self.getPx(1080)
900
-                            );
901
-
902
-                            // 头像
903
-                            if (res[0][1].path) {
904
-                                let avatarurl_width = self.getPx(70);
905
-                                let avatarurl_heigth = self.getPx(70);
906
-                                let avatarurl_x = self.getPx(30);
907
-                                let avatarurl_y = self.getPx(40);
908
-                                ctx.save();
909
-                                ctx.beginPath();
910
-                                ctx.arc(
911
-                                    avatarurl_width / 2 + avatarurl_x,
912
-                                    avatarurl_heigth / 2 + avatarurl_y,
913
-                                    avatarurl_width / 2,
882
+                                uni.getImageInfo({
883
+                                    src: logoRes.data,
884
+                                }),
885
+                                // 获取小程序吗
886
+                                self.api
887
+                                    .get("/Share/GetQRCode", {
888
+                                        path: self.$mp.page.route,
889
+                                        paremeters: JSON.stringify(res),
890
+                                    })
891
+                                    .then((res) => {
892
+                                        return uni.getImageInfo({
893
+                                            src: res.data,
894
+                                        });
895
+                                    }),
896
+                            ]).then((res) => {
897
+                                // 背景
898
+                                ctx.setFillStyle("#fff");
899
+                                ctx.fillRect(
914 900
                                     0,
915
-                                    Math.PI * 2,
916
-                                    true
917
-                                );
918
-                                ctx.clip();
919
-                                ctx.drawImage(
920
-                                    res[0][1].path,
921
-                                    avatarurl_x,
922
-                                    avatarurl_y,
923
-                                    avatarurl_width,
924
-                                    avatarurl_heigth
901
+                                    0,
902
+                                    self.getPx(670),
903
+                                    self.getPx(1080)
925 904
                                 );
926
-                                ctx.restore();
927
-                            }
928
-
929
-                            // 昵称
930
-                            ctx.setFontSize(self.getPx(28));
931
-                            ctx.setFillStyle("#333");
932
-                            ctx.fillText(
933
-                                self.goods.brandName,
934
-                                self.getPx(115),
935
-                                self.getPx(90)
936
-                            );
937
-                            ctx.stroke();
938 905
 
939
-                            // // 商品图片
940
-                            ctx.drawImage(
941
-                                res[1][1].path,
942
-                                self.getPx(0),
943
-                                self.getPx(145),
944
-                                self.getPx(670),
945
-                                self.getPx(670)
946
-                            );
906
+                                // 头像
907
+                                if (res[0][1].path) {
908
+                                    let avatarurl_width = self.getPx(70);
909
+                                    let avatarurl_heigth = self.getPx(70);
910
+                                    let avatarurl_x = self.getPx(30);
911
+                                    let avatarurl_y = self.getPx(40);
912
+                                    ctx.save();
913
+                                    ctx.beginPath();
914
+                                    ctx.arc(
915
+                                        avatarurl_width / 2 + avatarurl_x,
916
+                                        avatarurl_heigth / 2 + avatarurl_y,
917
+                                        avatarurl_width / 2,
918
+                                        0,
919
+                                        Math.PI * 2,
920
+                                        true
921
+                                    );
922
+                                    ctx.clip();
923
+                                    ctx.drawImage(
924
+                                        res[0][1].path,
925
+                                        avatarurl_x,
926
+                                        avatarurl_y,
927
+                                        avatarurl_width,
928
+                                        avatarurl_heigth
929
+                                    );
930
+                                    ctx.restore();
931
+                                }
947 932
 
948
-                            // 商品标题,第一行
949
-                            let goodsName = self.goods.name;
933
+                                // 昵称
934
+                                ctx.setFontSize(self.getPx(28));
935
+                                ctx.setFillStyle("#333");
936
+                                ctx.fillText(
937
+                                    self.goods.brandName,
938
+                                    self.getPx(115),
939
+                                    self.getPx(90)
940
+                                );
941
+                                ctx.stroke();
950 942
 
951
-                            if (goodsName.length > 12) {
952
-                                goodsName = goodsName.substr(0, 12);
953
-                            }
954
-                            ctx.setFontSize(self.getPx(28));
955
-                            ctx.setFillStyle("#333");
956
-                            ctx.fillText(
957
-                                goodsName,
958
-                                self.getPx(50),
959
-                                self.getPx(880)
960
-                            );
961
-                            ctx.stroke();
943
+                                // // 商品图片
944
+                                ctx.drawImage(
945
+                                    res[1][1].path,
946
+                                    self.getPx(0),
947
+                                    self.getPx(145),
948
+                                    self.getPx(670),
949
+                                    self.getPx(670)
950
+                                );
962 951
 
963
-                            // 商品标题,第二行
964
-                            let goodsName2 = self.goods.name;
965
-                            if (goodsName2.length > 12) {
966
-                                goodsName2 = goodsName2.substr(12, 10) + "...";
952
+                                // 商品标题,第一行
953
+                                let goodsName = self.goods.name;
967 954
 
955
+                                if (goodsName.length > 12) {
956
+                                    goodsName = goodsName.substr(0, 12);
957
+                                }
968 958
                                 ctx.setFontSize(self.getPx(28));
969 959
                                 ctx.setFillStyle("#333");
970 960
                                 ctx.fillText(
971
-                                    goodsName2,
961
+                                    goodsName,
972 962
                                     self.getPx(50),
973
-                                    self.getPx(920)
963
+                                    self.getPx(880)
974 964
                                 );
975 965
                                 ctx.stroke();
976
-                            }
977 966
 
978
-                            // 商品描述,第一行
979
-                            let descName = self.goods.description;
980
-
981
-                            if (descName.length > 14) {
982
-                                descName = descName.substr(0, 14);
983
-                            }
984
-                            ctx.setFontSize(self.getPx(24));
985
-                            ctx.setFillStyle("#666");
986
-                            ctx.fillText(
987
-                                descName,
988
-                                self.getPx(50),
989
-                                self.getPx(965)
990
-                            );
991
-                            ctx.stroke();
967
+                                // 商品标题,第二行
968
+                                let goodsName2 = self.goods.name;
969
+                                if (goodsName2.length > 12) {
970
+                                    goodsName2 =
971
+                                        goodsName2.substr(12, 10) + "...";
972
+
973
+                                    ctx.setFontSize(self.getPx(28));
974
+                                    ctx.setFillStyle("#333");
975
+                                    ctx.fillText(
976
+                                        goodsName2,
977
+                                        self.getPx(50),
978
+                                        self.getPx(920)
979
+                                    );
980
+                                    ctx.stroke();
981
+                                }
992 982
 
993
-                            // 商品描述,第二行
994
-                            let descName2 = self.goods.description;
995
-                            if (descName2.length > 14) {
996
-                                descName2 = descName2.substr(14, 14) + "...";
983
+                                // 商品描述,第一行
984
+                                let descName = self.goods.description;
997 985
 
986
+                                if (descName.length > 14) {
987
+                                    descName = descName.substr(0, 14);
988
+                                }
998 989
                                 ctx.setFontSize(self.getPx(24));
999 990
                                 ctx.setFillStyle("#666");
1000 991
                                 ctx.fillText(
1001
-                                    descName2,
992
+                                    descName,
1002 993
                                     self.getPx(50),
1003
-                                    self.getPx(995)
994
+                                    self.getPx(965)
1004 995
                                 );
1005 996
                                 ctx.stroke();
1006
-                            }
1007 997
 
1008
-                            // 商品价格符号
1009
-                            ctx.setFontSize(self.getPx(20));
1010
-                            ctx.setFillStyle("#f8662a");
1011
-                            ctx.fillText("¥", self.getPx(50), self.getPx(1050));
1012
-                            ctx.stroke();
998
+                                // 商品描述,第二行
999
+                                let descName2 = self.goods.description;
1000
+                                if (descName2.length > 14) {
1001
+                                    descName2 =
1002
+                                        descName2.substr(14, 14) + "...";
1003
+
1004
+                                    ctx.setFontSize(self.getPx(24));
1005
+                                    ctx.setFillStyle("#666");
1006
+                                    ctx.fillText(
1007
+                                        descName2,
1008
+                                        self.getPx(50),
1009
+                                        self.getPx(995)
1010
+                                    );
1011
+                                    ctx.stroke();
1012
+                                }
1013 1013
 
1014
-                            // 商品价格
1015
-                            ctx.setFontSize(self.getPx(40));
1016
-                            ctx.setFillStyle("#f8662a");
1017
-                            ctx.fillText(
1018
-                                self.goods.minPrice / 100,
1019
-                                self.getPx(65),
1020
-                                self.getPx(1050)
1021
-                            );
1022
-                            ctx.stroke();
1014
+                                // 商品价格符号
1015
+                                ctx.setFontSize(self.getPx(20));
1016
+                                ctx.setFillStyle("#f8662a");
1017
+                                ctx.fillText(
1018
+                                    "¥",
1019
+                                    self.getPx(50),
1020
+                                    self.getPx(1050)
1021
+                                );
1022
+                                ctx.stroke();
1023 1023
 
1024
-                            // 小程序吗
1025
-                            ctx.drawImage(
1026
-                                res[2][1].path,
1027
-                                self.getPx(460),
1028
-                                self.getPx(850),
1029
-                                self.getPx(170),
1030
-                                self.getPx(170)
1031
-                            );
1024
+                                // 商品价格
1025
+                                ctx.setFontSize(self.getPx(40));
1026
+                                ctx.setFillStyle("#f8662a");
1027
+                                ctx.fillText(
1028
+                                    self.goods.minPrice / 100,
1029
+                                    self.getPx(65),
1030
+                                    self.getPx(1050)
1031
+                                );
1032
+                                ctx.stroke();
1032 1033
 
1033
-                            // 长按扫码购买
1034
-                            ctx.setFontSize(self.getPx(24));
1035
-                            ctx.setFillStyle("#999");
1036
-                            ctx.fillText(
1037
-                                "长按扫码购买",
1038
-                                self.getPx(470),
1039
-                                self.getPx(1050)
1040
-                            );
1041
-                            ctx.stroke();
1034
+                                // 小程序吗
1035
+                                ctx.drawImage(
1036
+                                    res[2][1].path,
1037
+                                    self.getPx(460),
1038
+                                    self.getPx(850),
1039
+                                    self.getPx(170),
1040
+                                    self.getPx(170)
1041
+                                );
1042 1042
 
1043
-                            ctx.draw();
1044
-
1045
-                            self.canvasShow = true;
1046
-                            uni.hideLoading();
1047
-                            setTimeout(() => {
1048
-                                // 生成临时路径
1049
-                                uni.canvasToTempFilePath({
1050
-                                    canvasId: "canvas",
1051
-                                    fileType: "jpg",
1052
-                                    success: function (res) {
1053
-                                        // self.canvasShow = false
1054
-                                        console.log(res.tempFilePath,2222);
1055
-                                        self.canvasImgPath = [res.tempFilePath];
1056
-                                        resolve(res.tempFilePath);
1057
-                                    },
1058
-                                });
1059
-                            }, 100);
1043
+                                // 长按扫码购买
1044
+                                ctx.setFontSize(self.getPx(24));
1045
+                                ctx.setFillStyle("#999");
1046
+                                ctx.fillText(
1047
+                                    "长按扫码购买",
1048
+                                    self.getPx(470),
1049
+                                    self.getPx(1050)
1050
+                                );
1051
+                                ctx.stroke();
1052
+
1053
+                                ctx.draw();
1054
+
1055
+                                self.canvasShow = true;
1056
+                                uni.hideLoading();
1057
+                                setTimeout(() => {
1058
+                                    // 生成临时路径
1059
+                                    uni.canvasToTempFilePath({
1060
+                                        canvasId: "canvas",
1061
+                                        fileType: "jpg",
1062
+                                        success: function (res) {
1063
+                                            // self.canvasShow = false
1064
+                                            console.log(res.tempFilePath, 2222);
1065
+                                            self.canvasImgPath = [
1066
+                                                res.tempFilePath,
1067
+                                            ];
1068
+                                            resolve(res.tempFilePath);
1069
+                                        },
1070
+                                    });
1071
+                                }, 100);
1072
+                            });
1060 1073
                         });
1061 1074
                     });
1062 1075
                 });