cr 4 роки тому
батько
коміт
378d86b8e1

+ 0 - 24
src/pages/goods/list.vue

@@ -391,30 +391,6 @@ export default {
391 391
             }
392 392
             return false;
393 393
         },
394
-
395
-        setCaetNum(val, num) {
396
-            let cartItem = this.ifCart(val);
397
-            console.log(cartItem, num);
398
-            const self = this;
399
-            if (num > 0) {
400
-                self.api
401
-                    .post("/Order/UpdateItemCount", {
402
-                        id: cartItem.id,
403
-                        count: num,
404
-                    })
405
-                    .then(() => {
406
-                        self.$refs.shopCart.refresh();
407
-                    });
408
-            } else {
409
-                self.api
410
-                    .delete("/Order/RemoveCart", {
411
-                        ids: [cartItem.id],
412
-                    })
413
-                    .then(() => {
414
-                        self.$refs.shopCart.refresh();
415
-                    });
416
-            }
417
-        },
418 394
         
419 395
         cartChange(){
420 396
         },

+ 443 - 8
src/pages/goods/list2.vue

@@ -13,6 +13,13 @@
13 13
         </div>
14 14
 
15 15
         <div class="page-tab">
16
+            <div
17
+                class="tab-item"
18
+                :class="{ on: curTab === '2' }"
19
+                @click="tabClick('2')"
20
+            >
21
+                店铺商品
22
+            </div>
16 23
             <div
17 24
                 class="tab-item"
18 25
                 :class="{ on: curTab === '0' }"
@@ -34,6 +41,177 @@
34 41
             :scroll-y="true"
35 42
             @scrolltolower="getMore"
36 43
         >
44
+            <div v-if="curTab === '2'">
45
+                <ul class="menu">
46
+                    <li
47
+                        class="menu__item"
48
+                        :class="{
49
+                            'menu__item--active': shopGoodSort === 'SaleDesc',
50
+                        }"
51
+                        @click="shopGoodSetSort('SaleDesc')"
52
+                    >
53
+                        <div class="menu__text">销量</div>
54
+                    </li>
55
+                    <li
56
+                        class="menu__item"
57
+                        :class="{
58
+                            'menu__item--active': shopGoodSort === 'NewDesc',
59
+                        }"
60
+                        @click="shopGoodSetSort('NewDesc')"
61
+                    >
62
+                        <div class="menu__text">新品</div>
63
+                    </li>
64
+                    <li
65
+                        class="menu__item"
66
+                        :class="{
67
+                            'menu__item--active':
68
+                                shopGoodSort === 'Price' ||
69
+                                shopGoodSort === 'PriceDesc',
70
+                        }"
71
+                        @click="shopGoodSetSort('Price')"
72
+                    >
73
+                        <div class="menu__text">价格</div>
74
+                        <div
75
+                            class="menu__sort"
76
+                            :class="{
77
+                                'menu__sort--up': shopGoodSort === 'Price',
78
+                                'menu__sort--down':
79
+                                    shopGoodSort === 'PriceDesc',
80
+                            }"
81
+                        ></div>
82
+                    </li>
83
+                </ul>
84
+                <ul class="goods">
85
+                    <li
86
+                        class="goods__item"
87
+                        v-for="(item, index) in shopGoodsList"
88
+                        :key="index"
89
+                    >
90
+                        <my-image
91
+                            class="goods__img"
92
+                            :src="item.image"
93
+                            @click="jumpShopGoodsDetail(item)"
94
+                        ></my-image>
95
+                        <div
96
+                            class="goods__title"
97
+                            @click="jumpShopGoodsDetail(item)"
98
+                        >
99
+                            {{ item.name }}
100
+                        </div>
101
+                        <div
102
+                            class="goods__coupon"
103
+                            v-if="item.coupon"
104
+                            @click="jumpShopGoodsDetail(item)"
105
+                        >
106
+                            {{ item.coupon }}
107
+                        </div>
108
+                        <div class="goods__price">
109
+                            <div
110
+                                class="goods__present"
111
+                                @click="jumpShopGoodsDetail(item)"
112
+                            >
113
+                                <span class="goods__rmb">¥</span>
114
+                                <span class="goods__big">{{
115
+                                    item.price / 100
116
+                                }}</span>
117
+                            </div>
118
+                            <div
119
+                                class="goods__original"
120
+                                @click="jumpShopGoodsDetail(item)"
121
+                                v-if="item.tagPrice !== 0"
122
+                            >
123
+                                {{ "¥" + item.tagPrice / 100 }}
124
+                            </div>
125
+                        </div>
126
+                        <!-- 登录 -->
127
+                        <div class="btns">
128
+                            <block
129
+                                v-if="
130
+                                    user.login && !item.skus.length && item.cart
131
+                                "
132
+                            >
133
+                                <button
134
+                                    class="button button2"
135
+                                    @click.stop="setCaetNum(item)"
136
+                                >
137
+                                    <div class="goods__remove"></div>
138
+                                </button>
139
+                                <span class="cart-num">{{
140
+                                    item.cart.count
141
+                                }}</span>
142
+                            </block>
143
+                            <button
144
+                                v-if="user.login && !item.skus.length"
145
+                                class="button"
146
+                                @click.stop="addSpec(item, 'cart', $event)"
147
+                            >
148
+                                <div class="goods__add"></div>
149
+                            </button>
150
+                            <button
151
+                                v-else-if="user.login && item.skus.length"
152
+                                class="button"
153
+                                @click.stop="openSpec(item, 'cart', $event)"
154
+                            >
155
+                                <div class="goods__add-text">选规格</div>
156
+                            </button>
157
+                            <!-- <f-input-number
158
+                            class="num-input"
159
+                            v-else-if="ifCart(item)"
160
+                            v-model="ifCart(item).count"
161
+                            :showMinText="false"
162
+                            :mini="true"
163
+                            :max="ifCart(item).stock"
164
+                            @change="setCaetNum(item, $event)"
165
+                        ></f-input-number> -->
166
+                            <!-- 未登录 -->
167
+                            <button
168
+                                v-if="!user.login && !item.skus.length"
169
+                                class="button"
170
+                                open-type="getUserInfo"
171
+                                lang="zh_CN"
172
+                                @getuserinfo.stop="
173
+                                    openSpec(item, 'cart', $event)
174
+                                "
175
+                            >
176
+                                <div class="goods__add"></div>
177
+                            </button>
178
+                            <button
179
+                                v-if="!user.login && item.skus.length"
180
+                                class="button"
181
+                                lang="zh_CN"
182
+                                open-type="getUserInfo"
183
+                                @getuserinfo.stop="
184
+                                    openSpec(item, 'cart', $event)
185
+                                "
186
+                            >
187
+                                <div class="goods__add-text">选规格</div>
188
+                            </button>
189
+                        </div>
190
+                    </li>
191
+                </ul>
192
+                <div
193
+                    class="more-text"
194
+                    v-if="shopGoodsList.length && !isHaveMore"
195
+                >
196
+                    - 没有更多了 -
197
+                </div>
198
+                <div class="null" v-if="loading && !shopGoodsList.length">
199
+                    <img
200
+                        class="null__img"
201
+                        src="/static/common/goods_null_2.jpg"
202
+                        alt
203
+                    />
204
+                    <div class="null__title">抱歉!没有找到相关商品~</div>
205
+                </div>
206
+                <g-spec-modal
207
+                    ref="spec"
208
+                    :goods="goods"
209
+                    :spec="'cart'"
210
+                    @change="modalCartChange()"
211
+                ></g-spec-modal>
212
+                <shop-cart ref="shopCart"></shop-cart>
213
+            </div>
214
+
37 215
             <div v-if="curTab === '0'">
38 216
                 <ul class="menu">
39 217
                     <li
@@ -212,10 +390,13 @@
212 390
 <script>
213 391
 import MyImage from "../../components/image/index";
214 392
 import FInputNumber from "../../components/form/inputNumber";
393
+import ShopCart from "../../components/shop-cart/index";
394
+import GSpec from "./spec";
395
+import GSpecModal from "./specModal";
215 396
 
216 397
 export default {
217 398
     name: "",
218
-    components: { MyImage, FInputNumber },
399
+    components: { MyImage, FInputNumber, ShopCart, GSpec, GSpecModal },
219 400
     // 数据
220 401
     data() {
221 402
         return {
@@ -229,12 +410,18 @@ export default {
229 410
             curTab: "0",
230 411
             sort: -1, // 排序
231 412
             asc: 1,
413
+
414
+            shopGoodAsc: -1,
415
+            shopGoodSort: -1,
416
+            shopGoodsList: [],
232 417
         };
233 418
     },
234 419
 
235
-    onLoad() {
420
+    onLoad(opts) {
236 421
         const self = this;
237 422
         self.fn.shareMenu();
423
+        console.log(opts)
424
+        self.curTab = opts.curTab || '0';
238 425
 
239 426
         if (!self.loading) {
240 427
             uni.showLoading({
@@ -250,7 +437,7 @@ export default {
250 437
         self.fn.shareMenu();
251 438
         self.keyword = self.$mp.query.title;
252 439
         self.fn.setTitle(self.keyword);
253
-        this.tabClick("0");
440
+        this.tabClick(self.curTab);
254 441
     },
255 442
 
256 443
     onShareAppMessage() {
@@ -274,8 +461,10 @@ export default {
274 461
         const self = this;
275 462
         if (self.curTab === "0") {
276 463
             this.getGoodsList();
277
-        } else {
464
+        } else if (self.curTab === "1") {
278 465
             self.getActivityList();
466
+        } else {
467
+            self.getShopGoodsList();
279 468
         }
280 469
     },
281 470
 
@@ -285,8 +474,10 @@ export default {
285 474
             this.fn.setTitle(this.keyword);
286 475
             if (this.curTab === "0") {
287 476
                 this.getGoodsList();
288
-            } else {
477
+            } else if (this.curTab === "1") {
289 478
                 this.getActivityList();
479
+            } else {
480
+                this.getShopGoodsList();
290 481
             }
291 482
         },
292 483
 
@@ -294,8 +485,10 @@ export default {
294 485
             this.curTab = val;
295 486
             if (val === "0") {
296 487
                 this.getGoodsList();
297
-            } else {
488
+            } else if (this.curTab === "1") {
298 489
                 this.getActivityList();
490
+            } else {
491
+                this.getShopGoodsList();
299 492
             }
300 493
         },
301 494
 
@@ -303,9 +496,26 @@ export default {
303 496
             const self = this;
304 497
             if (self.curTab === "0") {
305 498
                 this.getMoreGoods();
306
-            } else {
499
+            } else if (self.curTab === "1") {
307 500
                 self.getMoreActivity();
501
+            } else {
502
+                this.getShopMoreGoods();
503
+            }
504
+        },
505
+        // 设置排序
506
+        shopGoodSetSort(val) {
507
+            const self = this;
508
+
509
+            if (val === "Price") {
510
+                self.shopGoodSort = 1;
511
+                self.shopGoodAsc = self.asc === 1 ? 0 : 1;
512
+            } else {
513
+                self.shopGoodAsc = 0;
514
+                self.shopGoodSort = val;
308 515
             }
516
+            this.$forceUpdate();
517
+
518
+            self.getShopGoodsList();
309 519
         },
310 520
         // 设置排序
311 521
         setSort(val) {
@@ -375,7 +585,6 @@ export default {
375 585
                     }
376 586
 
377 587
                     self.activityList = self.activityList.concat(list);
378
-                    this.setGoodsList();
379 588
                 });
380 589
         },
381 590
 
@@ -464,6 +673,232 @@ export default {
464 673
                 },
465 674
             });
466 675
         },
676
+
677
+        jumpShopGoodsDetail(val) {
678
+            const self = this;
679
+
680
+            self.router.push({
681
+                path: "/pages/goods/detail",
682
+                query: {
683
+                    goodsId: val.id,
684
+                },
685
+            });
686
+        },
687
+
688
+        setCaetNum(item) {
689
+            item.cart.count--;
690
+            let num = item.cart.count;
691
+            const self = this;
692
+            if (num > 0) {
693
+                self.api
694
+                    .post("/Order/UpdateItemCount", {
695
+                        id: item.cart.id,
696
+                        count: num,
697
+                    })
698
+                    .then(() => {
699
+                        self.$refs.shopCart.refresh();
700
+                    });
701
+            } else {
702
+                let id = item.cart.id;
703
+                delete item.cart;
704
+                self.api
705
+                    .delete("/Order/RemoveCart", {
706
+                        ids: [id],
707
+                    })
708
+                    .then(() => {
709
+                        self.$refs.shopCart.refresh();
710
+                    });
711
+            }
712
+        },
713
+
714
+        // 打开规则选项
715
+        openSpec(item, type, user) {
716
+            const self = this;
717
+            let userInfo = user.detail.userInfo;
718
+
719
+            this.getDetail(item, () => {
720
+                if (self.user.login) {
721
+                    self.$refs.spec.num = 1;
722
+                    self.$refs.spec.open(type, (res) => {
723
+                        if (type === "cart") {
724
+                            // self.fn.showToast("已成功加入购物车");
725
+                            self.$refs.shopCart.refresh();
726
+                        } else if (type === "buy") {
727
+                            self.router.push({
728
+                                path: "/pages/order/affirm",
729
+                                query: {
730
+                                    ids: res.data,
731
+                                },
732
+                            });
733
+                        }
734
+                    });
735
+                } else {
736
+                    if (userInfo) {
737
+                        if (!self.user.login) {
738
+                            self.api
739
+                                .post("/User/UpdateUserWechatInfo", userInfo)
740
+                                .then(() => {
741
+                                    self.$store.commit("user/update", {
742
+                                        login: true,
743
+                                        userInfo: userInfo,
744
+                                    });
745
+                                });
746
+                        }
747
+
748
+                        self.$refs.spec.num = 1;
749
+                        self.$refs.spec.open(type, (res) => {
750
+                            if (type === "cart") {
751
+                                // self.fn.showToast("已成功加入购物车");
752
+                                self.$refs.shopCart.refresh();
753
+                            } else if (type === "buy") {
754
+                                self.router.push({
755
+                                    path: "/pages/order/affirm",
756
+                                    query: {
757
+                                        ids: res.data,
758
+                                    },
759
+                                });
760
+                            }
761
+                        });
762
+                    } else {
763
+                        self.fn.showToast("授权失败请重试");
764
+                    }
765
+                }
766
+            });
767
+        },
768
+
769
+        // 添加购物车
770
+        addSpec(item) {
771
+            const self = this;
772
+            if (item.cart) {
773
+                item.cart.count++;
774
+                self.api
775
+                    .post("/Order/UpdateItemCount", {
776
+                        id: item.cart.id,
777
+                        count: item.cart.count,
778
+                    })
779
+                    .then(() => {
780
+                        self.$refs.shopCart.refresh();
781
+                    })
782
+                    .catch((res) => {
783
+                        this.getCartLsit();
784
+                    });
785
+            } else {
786
+                self.api
787
+                    .post("/Order/AddCart", {
788
+                        productId: item.id,
789
+                        count: 1,
790
+                    })
791
+                    .then((res) => {
792
+                        // self.fn.showToast("已成功加入购物车");
793
+                        self.$refs.shopCart.refresh();
794
+                    })
795
+                    .catch((res) => {
796
+                        this.getCartLsit();
797
+                    });
798
+            }
799
+        },
800
+        // 获取购物车列表
801
+        getCartLsit() {
802
+            const self = this;
803
+
804
+            self.api
805
+                .get("/Order/GetCartList", {
806
+                    pageIndex: 1,
807
+                    pageSize: 100,
808
+                })
809
+                .then((res) => {
810
+                    res.data.forEach((item) => {
811
+                        item.price = item.priceFmt;
812
+                        item.active =
813
+                            item.stock >= item.count &&
814
+                            item.productStatus === 1;
815
+                    });
816
+                    self.cartList = res.data;
817
+                    this.setShopGoodsList();
818
+                });
819
+        },
820
+        setShopGoodsList() {
821
+            // 删除全部
822
+            for (let item of this.shopGoodsList) {
823
+                item.cart = null;
824
+            }
825
+            // 重新赋值
826
+            for (let item of this.shopGoodsList) {
827
+                for (let cart of this.cartList) {
828
+                    if (cart.productId === item.id) {
829
+                        if (item.skus.length === 0) {
830
+                            item.cart = cart;
831
+                        } else {
832
+                            if (item.cart) {
833
+                                item.cart.push(cart);
834
+                            } else {
835
+                                item.cart = [cart];
836
+                            }
837
+                        }
838
+                    }
839
+                }
840
+            }
841
+            this.shopGoodsList = [...this.shopGoodsList];
842
+        },
843
+        modalCartChange() {
844
+            this.$refs.shopCart.refresh();
845
+        },
846
+
847
+        // 获取商品列表
848
+        getShopGoodsList() {
849
+            const self = this;
850
+
851
+            let keyword = !self.categoryId && !self.brandId ? self.title : "";
852
+
853
+            self.page = 1;
854
+            uni.showLoading({
855
+                title: "加载中...",
856
+            });
857
+            self.api
858
+                .get("/Product/GetList", {
859
+                    keywords: this.keyword,
860
+                    sort: self.shopGoodSort,
861
+                    pageIndex: self.page,
862
+                    pageSize: 20,
863
+                })
864
+                .then((res) => {
865
+                    uni.hideLoading();
866
+                    uni.stopPullDownRefresh();
867
+                    if (res.data.data.length) {
868
+                        self.page++;
869
+                    } else {
870
+                        self.isHaveMore = false;
871
+                    }
872
+
873
+                    self.shopGoodsList = res.data.data;
874
+                    self.loading = true;
875
+                    this.setGoodsList();
876
+                    uni.hideLoading();
877
+                });
878
+        },
879
+
880
+        // 获取更多商品
881
+        getShopMoreGoods() {
882
+            const self = this;
883
+
884
+            self.api
885
+                .get("/Product/GetList", {
886
+                    keywords: this.keyword,
887
+                    sort: self.shopGoodSort,
888
+                    pageIndex: self.page,
889
+                    pageSize: 20,
890
+                })
891
+                .then((res) => {
892
+                    if (res.data.data.length) {
893
+                        self.page++;
894
+                    } else {
895
+                        self.isHaveMore = false;
896
+                    }
897
+
898
+                    self.shopGoodsList = self.shopGoodsList.concat(res.data.data);
899
+                    this.setShopGoodsList();
900
+                });
901
+        },
467 902
     },
468 903
 
469 904
     // 数据计算

+ 2 - 1
src/pages/goods/search.vue

@@ -104,9 +104,10 @@ export default {
104 104
             const self = this;
105 105
             if (this.curTab == "0") {
106 106
                 self.router.push({
107
-                    path: "/pages/goods/list",
107
+                    path: "/pages/goods/list2",
108 108
                     query: {
109 109
                         title: keyword,
110
+                        curTab:'2'
110 111
                     },
111 112
                 });
112 113
             } else {

+ 12 - 1
src/pages/order/affirm.vue

@@ -423,6 +423,7 @@
423 423
                 </div>
424 424
             </div>
425 425
         </div>
426
+        <address-select ref="addressSelect"></address-select>
426 427
     </div>
427 428
 </template>
428 429
 
@@ -430,10 +431,11 @@
430 431
 import MyImage from "../../components/image/index";
431 432
 import FInputNumber from "../../components/form/inputNumber";
432 433
 import OCoupon from "./coupon";
434
+import AddressSelect from "../../components/address-select/index";
433 435
 
434 436
 export default {
435 437
     name: "",
436
-    components: { FInputNumber, MyImage, OCoupon },
438
+    components: { FInputNumber, MyImage, OCoupon,AddressSelect },
437 439
     // 数据
438 440
     data() {
439 441
         return {
@@ -1341,6 +1343,15 @@ export default {
1341 1343
 
1342 1344
             return sum;
1343 1345
         },
1346
+
1347
+        // 打开地址
1348
+        oprenAddress() {
1349
+            const self = this;
1350
+
1351
+            self.$refs.openAddress.open((val) => {
1352
+                console.log(val);
1353
+            });
1354
+        },
1344 1355
     },
1345 1356
 
1346 1357
     // 数据监听

+ 311 - 22
src/pages/recommend/detail.vue

@@ -240,6 +240,64 @@
240 240
                     </li>
241 241
                 </ul>
242 242
             </div>
243
+
244
+            <div class="bg-white">
245
+                <div class="everybody">- 大家都在买 -</div>
246
+                <ul class="goods">
247
+                    <li
248
+                        class="goods__item"
249
+                        v-for="(item, index) in goodsList"
250
+                        :key="index"
251
+                    >
252
+                        <my-image
253
+                            class="goods__img"
254
+                            :src="item.pictureUrls[0]"
255
+                            @click="jumpGoodsDetail(item)"
256
+                        ></my-image>
257
+                        <div
258
+                            class="goods__title"
259
+                            @click="jumpGoodsDetail(item)"
260
+                        >
261
+                            {{ item.name }}
262
+                        </div>
263
+                        <div
264
+                            class="goods__coupon"
265
+                            v-if="item.coupon"
266
+                            @click="jumpGoodsDetail(item)"
267
+                        >
268
+                            {{ item.coupon }}
269
+                        </div>
270
+                        <div class="goods__price">
271
+                            <div
272
+                                class="goods__present"
273
+                                @click="jumpGoodsDetail(item)"
274
+                            >
275
+                                <span class="goods__big">¥{{
276
+                                    item.minPrice / 100
277
+                                }}</span>
278
+                            </div>
279
+                            <div
280
+                                class="goods__original"
281
+                                @click="jumpGoodsDetail(item)"
282
+                                v-if="item.tagPrice !== 0"
283
+                            >
284
+                                {{ "¥" + item.tagPrice / 100 }}
285
+                            </div>
286
+                        </div>
287
+                    </li>
288
+                </ul>
289
+                <div class="more-text" v-if="goodsList.length && !isHaveMore">
290
+                    - 没有更多了 -
291
+                </div>
292
+                <div class="null" v-if="loading && !goodsList.length">
293
+                    <img
294
+                        class="null__img"
295
+                        src="/static/common/goods_null_2.jpg"
296
+                        alt
297
+                    />
298
+                    <div class="null__title">抱歉!没有找到相关商品~</div>
299
+                </div>
300
+            </div>
243 301
         </scroll-view>
244 302
 
245 303
         <!--<div class="back" @click="jump({isTabBer: true, path: '/pages/index/index'})">返回首页</div>-->
@@ -389,6 +447,11 @@ export default {
389 447
             activityData: {},
390 448
 
391 449
             canvasforwardPath: "",
450
+
451
+            page: 1,
452
+            goodsList: [],
453
+            loading: false,
454
+            isHaveMore: false,
392 455
         };
393 456
     },
394 457
 
@@ -465,6 +528,7 @@ export default {
465 528
                         self.fn.setTitle(data.name);
466 529
                         console.log(self.goods);
467 530
                         self.creationShare2();
531
+                        self.getGoodsList();
468 532
                     } else {
469 533
                         self.fn
470 534
                             .showModal({
@@ -651,16 +715,6 @@ export default {
651 715
         },
652 716
 
653 717
         // 跳转到商品详情
654
-        jumpGoodsDetail(val) {
655
-            const self = this;
656
-
657
-            self.router.push({
658
-                path: "/pages/goods/detail",
659
-                query: {
660
-                    goodsId: val.id,
661
-                },
662
-            });
663
-        },
664 718
 
665 719
         // 打开分享
666 720
         oprenShare() {
@@ -683,7 +737,6 @@ export default {
683 737
         viewImg() {
684 738
             let self = this;
685 739
             //查看图片
686
-            console.log(111, self.canvasImgPath);
687 740
             uni.previewImage({
688 741
                 urls: self.canvasImgPath,
689 742
                 longPressActions: true,
@@ -1065,6 +1118,70 @@ export default {
1065 1118
                 });
1066 1119
             });
1067 1120
         },
1121
+
1122
+        // 获取商品列表
1123
+        getGoodsList() {
1124
+            const self = this;
1125
+
1126
+            self.page = 1;
1127
+            uni.showLoading({
1128
+                title: "加载中...",
1129
+            });
1130
+            self.api
1131
+                .get("/Product/GetRelevant", {
1132
+                    keyword: self.goods.name,
1133
+                    pageIndex: self.page,
1134
+                    pageSize: 20,
1135
+                })
1136
+                .then((res) => {
1137
+                    uni.hideLoading();
1138
+                    uni.stopPullDownRefresh();
1139
+                    let data = JSON.parse(res.data.list);
1140
+                    if (data.length) {
1141
+                        self.page++;
1142
+                    } else {
1143
+                        self.isHaveMore = false;
1144
+                    }
1145
+
1146
+                    self.goodsList = data;
1147
+                    self.loading = true;
1148
+                    uni.hideLoading();
1149
+                });
1150
+        },
1151
+
1152
+        // 获取更多商品
1153
+        getMoreGoods() {
1154
+            const self = this;
1155
+
1156
+            self.api
1157
+                .get("/Product/GetRelevant", {
1158
+                    keyword: self.goods.name,
1159
+                    pageIndex: self.page,
1160
+                    pageSize: 20,
1161
+                })
1162
+                .then((res) => {
1163
+                    let data = JSON.parse(res.data.list);
1164
+                    if (data.length) {
1165
+                        self.page++;
1166
+                    } else {
1167
+                        self.isHaveMore = false;
1168
+                    }
1169
+
1170
+                    self.goodsList = self.goodsList.concat(data);
1171
+                });
1172
+        },
1173
+
1174
+        // 跳转到商品详情
1175
+        jumpGoodsDetail(val) {
1176
+            const self = this;
1177
+
1178
+            self.router.replace({
1179
+                path: "/pages/recommend/detail",
1180
+                query: {
1181
+                    goodsId: val.pid,
1182
+                },
1183
+            });
1184
+        },
1068 1185
     },
1069 1186
 
1070 1187
     // 数据计算
@@ -1357,39 +1474,173 @@ page {
1357 1474
     display: flex;
1358 1475
     flex-wrap: wrap;
1359 1476
     justify-content: space-between;
1360
-    padding: 0 px(60);
1361
-    background-color: #fff;
1477
+    padding: 0 px(25) px(30);
1362 1478
 
1363 1479
     &__item {
1364
-        width: px(310);
1365
-        padding-bottom: px(100);
1480
+        width: px(500);
1481
+        padding-bottom: px(30);
1482
+        margin-top: px(25);
1366 1483
         overflow: hidden;
1367
-        border-radius: px(20);
1484
+        border-radius: px(15);
1485
+        background-color: #fff;
1486
+        position: relative;
1487
+
1488
+        &:nth-child(2n + 1) {
1489
+            margin-right: px(30);
1490
+        }
1491
+    }
1492
+    .button {
1493
+        // overflow: visible;
1494
+        // position: absolute;
1495
+        // bottom: 0;
1496
+        // right: 0;
1497
+        // z-index: 1;
1498
+        // padding: px(10) px(30) px(30) px(10);
1499
+    }
1500
+    .btns {
1501
+        overflow: visible;
1502
+        position: absolute;
1503
+        bottom: px(30);
1504
+        right: px(30);
1505
+        z-index: 1;
1506
+        display: flex;
1507
+        align-items: center;
1508
+    }
1509
+    .cart-num {
1510
+        // padding: px(30) px(10) px(10) px(30);
1511
+        padding: 0 px(30);
1512
+        box-sizing: border-box;
1513
+        min-width: px(60);
1514
+    }
1515
+    .num-input {
1516
+        overflow: visible;
1517
+        position: absolute;
1518
+        bottom: px(20);
1519
+        right: px(20);
1520
+        z-index: 1;
1521
+    }
1522
+    &__add-text {
1523
+        height: px(60);
1524
+        line-height: px(60);
1525
+        background-color: #27a34f;
1526
+        color: #fff;
1527
+        font-size: px(30);
1528
+        padding: 0 px(20);
1529
+        border-radius: px(30);
1530
+    }
1531
+    &__add {
1532
+        background-color: #27a34f;
1533
+        width: px(60);
1534
+        height: px(60);
1535
+        border-radius: 50%;
1536
+        // box-shadow: px(1) px(2) px(6) #27A34F;
1537
+        position: relative;
1538
+        &::after,
1539
+        &::before {
1540
+            content: "";
1541
+            position: absolute;
1542
+            top: 50%;
1543
+            left: 50%;
1544
+            z-index: 1;
1545
+            width: 60%;
1546
+            height: px(6);
1547
+            border-radius: px(6);
1548
+            background: #fff;
1549
+        }
1550
+        &::after {
1551
+            transform: translate(-50%, -50%);
1552
+        }
1553
+        &::before {
1554
+            transform-origin: center;
1555
+            transform: translate(-50%, -50%) rotate(90deg);
1556
+        }
1557
+    }
1558
+
1559
+    &__remove {
1560
+        background-color: #fff;
1561
+        width: px(60);
1562
+        height: px(60);
1563
+        border-radius: 50%;
1564
+        border: 1px solid #999;
1565
+        position: relative;
1566
+        &::after {
1567
+            content: "";
1568
+            position: absolute;
1569
+            top: 50%;
1570
+            left: 50%;
1571
+            z-index: 1;
1572
+            width: 60%;
1573
+            height: px(6);
1574
+            border-radius: px(6);
1575
+            background: #999;
1576
+            transform: translate(-50%, -50%);
1577
+        }
1368 1578
     }
1369 1579
 
1370 1580
     &__img /deep/ img {
1371
-        width: px(310);
1372
-        height: px(305);
1581
+        width: px(500);
1582
+        height: px(500);
1373 1583
     }
1374 1584
 
1375 1585
     &__title {
1376 1586
         @include omits(2);
1377 1587
         height: px(100);
1378
-        margin-top: px(30);
1379
-        font-size: px(36);
1588
+        margin: px(20);
1589
+        font-size: px(40);
1380 1590
         color: #333;
1381 1591
     }
1382 1592
 
1593
+    &__coupon {
1594
+        display: inline-flex;
1595
+        justify-content: center;
1596
+        align-items: center;
1597
+        height: px(40);
1598
+        padding: 0 px(15);
1599
+        margin: 0 px(20);
1600
+        font-size: px(30);
1601
+        color: #27a34f;
1602
+        border-radius: px(20);
1603
+        border: solid px(3) #27a34f;
1604
+    }
1605
+
1383 1606
     &__price {
1384 1607
         display: flex;
1385 1608
         align-items: flex-end;
1386
-        margin-top: px(30);
1609
+        padding: 0 px(20);
1610
+        margin-top: px(20);
1387 1611
     }
1388 1612
 
1389 1613
     &__present {
1390
-        font-size: px(38);
1391 1614
         color: #000;
1392 1615
     }
1616
+
1617
+    &__rmb {
1618
+        font-size: px(30);
1619
+    }
1620
+
1621
+    &__big {
1622
+        font-size: px(38);
1623
+        color: #27a34f;
1624
+    }
1625
+
1626
+    &__original {
1627
+        position: relative;
1628
+        margin-left: px(20);
1629
+        font-size: px(32);
1630
+        color: #999;
1631
+
1632
+        &:after {
1633
+            content: "";
1634
+            position: absolute;
1635
+            top: 50%;
1636
+            left: 0;
1637
+            z-index: 1;
1638
+            width: 100%;
1639
+            height: px(1);
1640
+            transform: translateY(-100%);
1641
+            background-color: #999;
1642
+        }
1643
+    }
1393 1644
 }
1394 1645
 
1395 1646
 .live {
@@ -1516,6 +1767,24 @@ page {
1516 1767
         background-color: #e5e5e5;
1517 1768
     }
1518 1769
 }
1770
+.null {
1771
+    display: flex;
1772
+    flex-direction: column;
1773
+    justify-content: center;
1774
+    align-items: center;
1775
+    padding-top: px(115);
1776
+
1777
+    &__img {
1778
+        width: px(741);
1779
+        height: px(340);
1780
+    }
1781
+
1782
+    &__title {
1783
+        margin-top: px(60);
1784
+        font-size: px(42);
1785
+        color: #666;
1786
+    }
1787
+}
1519 1788
 
1520 1789
 .canvas {
1521 1790
     position: fixed;
@@ -1579,6 +1848,10 @@ page {
1579 1848
     background-color: #fff;
1580 1849
     visibility: hidden;
1581 1850
     opacity: 0;
1851
+    position: fixed;
1852
+    left: -999px;
1853
+    top: -999px;
1854
+    z-index: -1;
1582 1855
 }
1583 1856
 
1584 1857
 .shop-recommend {
@@ -1893,4 +2166,20 @@ page {
1893 2166
 .bold {
1894 2167
     font-weight: bold;
1895 2168
 }
2169
+.more-text {
2170
+    display: flex;
2171
+    justify-content: center;
2172
+    padding-bottom: px(60);
2173
+    font-size: px(34);
2174
+    color: #999;
2175
+}
2176
+.bg-white{
2177
+    background-color: #fff;
2178
+    margin-top: px(30);
2179
+}
2180
+.everybody{
2181
+    text-align: center;
2182
+    padding: px(30);
2183
+    font-size: px(44);
2184
+}
1896 2185
 </style>

+ 147 - 56
src/pages/recommend/list.vue

@@ -121,10 +121,10 @@
121 121
                             class="goods__present"
122 122
                             @click="jumpGoodsDetail(item)"
123 123
                         >
124
-                            <span class="goods__rmb">¥</span>
125
-                            <span class="goods__big">{{
126
-                                item.minPrice / 100
127
-                            }}</span>
124
+                            <!-- <span class="goods__rmb"></span> -->
125
+                            <span class="goods__big"
126
+                                >¥{{ item.minPrice / 100 }}</span
127
+                            >
128 128
                         </div>
129 129
                         <div
130 130
                             class="goods__original"
@@ -135,56 +135,7 @@
135 135
                         </div>
136 136
                     </div>
137 137
                     <!-- 登录 -->
138
-                    <div class="btns">
139
-                        <!-- <block v-if="user.login && !item.skuList.length && item.cart">
140
-              <button class="button button2" @click.stop="setCaetNum(item)">
141
-                <div class="goods__remove"></div>
142
-              </button>
143
-              <span class="cart-num">{{ item.cart.count }}</span>
144
-            </block>
145
-            <button
146
-              v-if="user.login && !item.skuList.length"
147
-              class="button"
148
-              @click.stop="addSpec(item, 'cart', $event)"
149
-            >
150
-              <div class="goods__add"></div>
151
-            </button>
152
-            <button
153
-              v-else-if="user.login && item.skuList.length"
154
-              class="button"
155
-              @click.stop="openSpec(item, 'cart', $event)"
156
-            >
157
-              <div class="goods__add-text">选规格</div>
158
-            </button> -->
159
-                        <!-- <f-input-number
160
-                        class="num-input"
161
-                        v-else-if="ifCart(item)"
162
-                        v-model="ifCart(item).count"
163
-                        :showMinText="false"
164
-                        :mini="true"
165
-                        :max="ifCart(item).stock"
166
-                        @change="setCaetNum(item, $event)"
167
-                    ></f-input-number> -->
168
-                        <!-- 未登录 -->
169
-                        <!-- <button
170
-              v-if="!user.login && !item.skuList.length"
171
-              class="button"
172
-              open-type="getUserInfo"
173
-              lang="zh_CN"
174
-              @getuserinfo.stop="openSpec(item, 'cart', $event)"
175
-            >
176
-              <div class="goods__add"></div>
177
-            </button>
178
-            <button
179
-              v-if="!user.login && item.skuList.length"
180
-              class="button"
181
-              lang="zh_CN"
182
-              open-type="getUserInfo"
183
-              @getuserinfo.stop="openSpec(item, 'cart', $event)"
184
-            >
185
-              <div class="goods__add-text">选规格</div>
186
-            </button> -->
187
-                    </div>
138
+                    <div class="btns"></div>
188 139
                 </li>
189 140
             </ul>
190 141
             <div class="more-text" v-if="goodsList.length && !isHaveMore">
@@ -220,6 +171,11 @@
220 171
                 </div>
221 172
             </div>
222 173
         </div>
174
+        <canvas
175
+            class="canvas__forward"
176
+            canvas-id="canvas2"
177
+            :disable-scroll="true"
178
+        ></canvas>
223 179
     </div>
224 180
 </template>
225 181
 
@@ -252,6 +208,8 @@ export default {
252 208
             desModalVisible: false,
253 209
             desModalTitle: "",
254 210
             desModalDes: "",
211
+
212
+            canvasforwardPath: "",
255 213
         };
256 214
     },
257 215
 
@@ -285,9 +243,13 @@ export default {
285 243
         if (this.activeShop.store) {
286 244
             obj.storeId = this.activeShop.store.id;
287 245
         }
246
+        let title =
247
+            self.activityData.brandName +
248
+            ` (${self.activityData.onlineProductCount}款)`;
249
+            title += `【${self.activityData.minPrice / 100}元起】`;
288 250
         return {
289
-            title: self.activityData.brandName,
290
-            imageUrl: self.activityData.brandLogo,
251
+            title: title,
252
+            imageUrl: self.canvasforwardPath || self.activityData.brandLogo,
291 253
             path: self.router.getPath(self.$mp.page.route, self.$mp.query),
292 254
         };
293 255
     },
@@ -337,6 +299,7 @@ export default {
337 299
                     let data = JSON.parse(res.data);
338 300
                     this.activityData = data;
339 301
                     this.fn.setTitle(data.brandName);
302
+                    this.creationShare2();
340 303
                 });
341 304
         },
342 305
 
@@ -650,6 +613,122 @@ export default {
650 613
                     });
651 614
             }
652 615
         },
616
+
617
+        // 创建分享图
618
+        creationShare2() {
619
+            const self = this;
620
+            const ctx = uni.createCanvasContext("canvas2", self);
621
+
622
+            return new Promise((resolve) => {
623
+                self.router.getScene(self.$mp.query).then((res) => {
624
+                    res.uid = self.user.id;
625
+                    res.shopId = self.activeShop.id;
626
+
627
+                    Promise.all([
628
+                        uni.getImageInfo({
629
+                            src:
630
+                                "https://oss.ixiaokejia.com/images/common/share_bg.jpg",
631
+                        }),
632
+                        uni.getImageInfo({
633
+                            src:
634
+                                "https://oss.ixiaokejia.com/images/common/share_bg_box.png",
635
+                        }),
636
+                        uni.getImageInfo({
637
+                            src: self.activityData.brandLogo,
638
+                        }),
639
+                        uni.getImageInfo({
640
+                            src:
641
+                                "https://oss.ixiaokejia.com/images/common/share_tag1.jpg",
642
+                        }),
643
+                        uni.getImageInfo({
644
+                            src:
645
+                                "https://oss.ixiaokejia.com/images/common/share_tag2.png",
646
+                        }),
647
+                    ]).then((res) => {
648
+                        // 背景
649
+                        ctx.drawImage(res[0][1].path, 0, 0, 500, 400);
650
+
651
+                        // 标题
652
+                        ctx.setFontSize(28);
653
+                        ctx.setFillStyle("#fff");
654
+                        ctx.fillText("厂商直邮", 205, 40);
655
+                        ctx.stroke();
656
+
657
+                        ctx.setFontSize(24);
658
+                        ctx.setFillStyle("#fff");
659
+                        ctx.fillText("免费包邮,厂商快递直邮到家", 100, 75);
660
+                        ctx.stroke();
661
+
662
+                        // 背景box
663
+                        ctx.drawImage(res[1][1].path, 10, 92, 477, 292);
664
+
665
+                        // // 商品图片
666
+                        ctx.drawImage(res[2][1].path, 20, 100, 275, 275);
667
+
668
+                        // 特惠商品
669
+                        ctx.drawImage(res[3][1].path, 310, 110, 157, 46);
670
+
671
+                        ctx.setFontSize(28);
672
+                        ctx.setFillStyle("#fff");
673
+                        ctx.fillText("限时活动", 330, 144);
674
+
675
+                        if (self.activityData.minDiscount) {
676
+                            //折扣
677
+                            let tagPrice = "最低";
678
+                            ctx.setFontSize(28);
679
+                            ctx.setFillStyle("#999");
680
+                            ctx.fillText(tagPrice, 325, 215);
681
+                            ctx.stroke();
682
+
683
+
684
+                            let itemPrice =self.activityData.minDiscount * 10;
685
+                            itemPrice = itemPrice.toFixed(1)+'折';
686
+                            ctx.setFontSize(40);
687
+                            ctx.setFillStyle("#f00");
688
+                            ctx.fillText(itemPrice, 320, 265);
689
+                            ctx.stroke();
690
+
691
+                        } else {
692
+                            // 价格
693
+                            let itemPrice =
694
+                                self.activityData.minPrice / 100 + "元";
695
+                            ctx.setFontSize(38);
696
+                            ctx.setFillStyle("#f00");
697
+                            ctx.fillText("¥" + itemPrice, 320, 220);
698
+                            ctx.stroke();
699
+
700
+                            // 价格2
701
+                            let tagPrice = "起购";
702
+                            ctx.setFontSize(28);
703
+                            ctx.setFillStyle("#999");
704
+                            ctx.fillText(tagPrice, 325, 265);
705
+                            ctx.stroke();
706
+                        }
707
+
708
+                        // buy
709
+                        ctx.drawImage(res[4][1].path, 307, 300, 170, 70);
710
+
711
+                        ctx.setFontSize(28);
712
+                        ctx.setFillStyle("#fff");
713
+                        ctx.fillText("立即购买", 335, 345);
714
+
715
+                        ctx.draw();
716
+
717
+                        setTimeout(() => {
718
+                            // 生成临时路径
719
+                            uni.canvasToTempFilePath({
720
+                                canvasId: "canvas2",
721
+                                fileType: "jpg",
722
+                                success: function (res) {
723
+                                    // self.canvasShow = false
724
+                                    self.canvasforwardPath = res.tempFilePath;
725
+                                },
726
+                            });
727
+                        }, 100);
728
+                    });
729
+                });
730
+            });
731
+        },
653 732
     },
654 733
 
655 734
     // 数据计算
@@ -900,6 +979,7 @@ page {
900 979
 
901 980
     &__big {
902 981
         font-size: px(38);
982
+        color: #27a34f;
903 983
     }
904 984
 
905 985
     &__original {
@@ -1095,4 +1175,15 @@ page {
1095 1175
     background: #fff7e6;
1096 1176
     border-color: #ffd591;
1097 1177
 }
1178
+.canvas__forward {
1179
+    width: 500px;
1180
+    height: 400px;
1181
+    background-color: #fff;
1182
+    visibility: hidden;
1183
+    opacity: 0;
1184
+    position: fixed;
1185
+    left: -999px;
1186
+    top: -999px;
1187
+    z-index: -1;
1188
+}
1098 1189
 </style>