Blame view

member-miniapp/packageMall/main/main.vue 16.9 KB
5c34676a   “wangming”   对会员端进行了设计
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  <template>
    <view class="page-shell mall-page">
      <view class="page-blur"></view>
      <view class="page-blur-secondary"></view>
      <view class="page-blur-tertiary"></view>
  
      <view class="page-content">
        <view class="mall-header capsule-safe">
          <view>
            <text class="mall-title">美容商城</text>
            <text class="mall-subtitle">把门店里的护理感,慢慢带回日常。</text>
          </view>
        </view>
  
        <view class="feature-card glass-card">
          <view class="feature-copy">
            <text class="feature-tag">CURATED COLLECTION</text>
            <text class="feature-title">把门店里的护理感带回家</text>
            <text class="feature-desc">按当下所需慢慢挑选,在轻盈的双列陈列里,找到适合自己的护理好物。</text>
          </view>
          <view class="feature-art-wrap">
            <image class="feature-art" src="/static/images/art-home.png" mode="aspectFill" />
          </view>
        </view>
  
        <view class="search-card glass-card">
          <view class="search-icon"></view>
          <input
            v-model="searchKeyword"
            class="search-input"
            placeholder="搜索精华、面膜、身体护理、香氛好物"
            placeholder-class="search-placeholder"
            confirm-type="search"
e1dcb3a0   “wangming”   1
34
            @confirm="onSearch"
5c34676a   “wangming”   对会员端进行了设计
35
36
37
38
39
40
41
42
43
          />
        </view>
  
        <view class="category-row">
          <view
            v-for="item in categories"
            :key="item"
            class="category-chip"
            :class="{ active: activeCategory === item }"
e1dcb3a0   “wangming”   1
44
            @tap="selectCategory(item)"
5c34676a   “wangming”   对会员端进行了设计
45
46
47
48
49
          >
            {{ item }}
          </view>
        </view>
  
e1dcb3a0   “wangming”   1
50
51
52
53
54
55
56
57
58
59
60
61
        <view class="category-row sort-row">
          <view
            v-for="item in sorts"
            :key="item.key"
            class="category-chip"
            :class="{ active: activeSort === item.key }"
            @tap="selectSort(item.key)"
          >
            {{ item.label }}
          </view>
        </view>
  
5c34676a   “wangming”   对会员端进行了设计
62
63
        <view class="section-head product-head">
          <text class="section-title">甄选好物</text>
e1dcb3a0   “wangming”   1
64
          <text class="section-link">{{ total }} 件在售</text>
5c34676a   “wangming”   对会员端进行了设计
65
66
        </view>
  
e1dcb3a0   “wangming”   1
67
        <view v-if="products.length" class="waterfall">
5c34676a   “wangming”   对会员端进行了设计
68
69
70
          <view class="waterfall-col">
            <view
              v-for="product in leftProducts"
e1dcb3a0   “wangming”   1
71
              :key="product.id"
5c34676a   “wangming”   对会员端进行了设计
72
73
74
75
              class="product-card glass-card"
              @tap="previewProduct(product)"
            >
              <view class="product-cover" :style="product.coverStyle">
e1dcb3a0   “wangming”   1
76
                <image v-if="product.image" class="product-photo" :src="product.image" mode="aspectFill" />
5c34676a   “wangming”   对会员端进行了设计
77
                <view class="product-cover-mask"></view>
e1dcb3a0   “wangming”   1
78
                <text v-if="product.categoryName" class="product-badge">{{ product.categoryName }}</text>
5c34676a   “wangming”   对会员端进行了设计
79
80
81
              </view>
              <view class="product-body">
                <text class="product-name">{{ product.name }}</text>
5c34676a   “wangming”   对会员端进行了设计
82
83
84
85
86
87
88
89
90
91
92
93
94
95
                <view class="product-footer">
                  <view>
                    <text class="price-symbol">¥</text>
                    <text class="product-price">{{ product.price }}</text>
                  </view>
                  <text class="product-sales">已售 {{ product.sales }}</text>
                </view>
              </view>
            </view>
          </view>
  
          <view class="waterfall-col">
            <view
              v-for="product in rightProducts"
e1dcb3a0   “wangming”   1
96
              :key="product.id"
5c34676a   “wangming”   对会员端进行了设计
97
98
99
100
              class="product-card glass-card"
              @tap="previewProduct(product)"
            >
              <view class="product-cover" :style="product.coverStyle">
e1dcb3a0   “wangming”   1
101
                <image v-if="product.image" class="product-photo" :src="product.image" mode="aspectFill" />
5c34676a   “wangming”   对会员端进行了设计
102
                <view class="product-cover-mask"></view>
e1dcb3a0   “wangming”   1
103
                <text v-if="product.categoryName" class="product-badge">{{ product.categoryName }}</text>
5c34676a   “wangming”   对会员端进行了设计
104
105
106
              </view>
              <view class="product-body">
                <text class="product-name">{{ product.name }}</text>
5c34676a   “wangming”   对会员端进行了设计
107
108
109
110
111
112
113
114
115
116
117
118
                <view class="product-footer">
                  <view>
                    <text class="price-symbol">¥</text>
                    <text class="product-price">{{ product.price }}</text>
                  </view>
                  <text class="product-sales">已售 {{ product.sales }}</text>
                </view>
              </view>
            </view>
          </view>
        </view>
  
e1dcb3a0   “wangming”   1
119
        <view v-else-if="!loading" class="empty-card glass-card">
5c34676a   “wangming”   对会员端进行了设计
120
121
122
123
          <text class="empty-title">暂未找到相关商品</text>
          <text class="empty-desc">可以换个关键词,或切换分类继续看看。</text>
        </view>
  
e1dcb3a0   “wangming”   1
124
125
126
        <view v-if="loading" class="list-tip">正在加载…</view>
        <view v-else-if="finished && products.length" class="list-tip">已经到底啦</view>
  
5c34676a   “wangming”   对会员端进行了设计
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
        <view class="safe-bottom-space"></view>
      </view>
  
      <view class="lf-tabbar-wrap">
        <view class="lf-tabbar-panel">
          <view
            v-for="item in tabs"
            :key="item.key"
            class="lf-tabbar-item"
            :class="{ active: item.key === 'mall' }"
            @tap="goTab(item)"
          >
            <view class="lf-tabbar-icon-shell">
              <image
                class="lf-tabbar-icon"
                :src="item.key === 'mall' ? item.activeIcon : item.icon"
                mode="aspectFit"
              />
            </view>
            <text class="lf-tabbar-label">{{ item.label }}</text>
          </view>
        </view>
      </view>
    </view>
  </template>
  
  <script>
e1dcb3a0   “wangming”   1
154
  import { getMallList, getMallCategories } from '@/api/mall'
5c34676a   “wangming”   对会员端进行了设计
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  
  export default {
    data() {
      return {
        tabs: [
          {
            key: 'home',
            label: '首页',
            path: '/pages/home/home',
            icon: '/static/images/tab-home.png',
            activeIcon: '/static/images/tab-home-active.png'
          },
          {
            key: 'booking',
            label: '预约',
            path: '/pages/booking/booking',
            icon: '/static/images/tab-booking.png',
            activeIcon: '/static/images/tab-booking-active.png'
          },
          {
            key: 'mall',
            label: '商城',
            path: '/packageMall/main/main',
            icon: '/static/images/tab-mall.png',
            activeIcon: '/static/images/tab-mall-active.png'
          },
          {
            key: 'profile',
            label: '我的',
            path: '/pages/profile/profile',
            icon: '/static/images/tab-profile.png',
            activeIcon: '/static/images/tab-profile-active.png'
          }
        ],
e1dcb3a0   “wangming”   1
189
        activeCategory: '全部',
5c34676a   “wangming”   对会员端进行了设计
190
        searchKeyword: '',
e1dcb3a0   “wangming”   1
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
        // 分类标签:默认仅「全部」,onLoad 时从后端「分类管理」拉取启用分类
        categories: ['全部'],
        activeSort: 'default',
        sorts: [
          { key: 'default', label: '综合' },
          { key: 'sales', label: '销量' },
          { key: 'priceAsc', label: '价格升' },
          { key: 'priceDesc', label: '价格降' }
        ],
        products: [],
        currentPage: 1,
        pageSize: 10,
        total: 0,
        loading: false,
        finished: false
5c34676a   “wangming”   对会员端进行了设计
206
207
208
      }
    },
    computed: {
5c34676a   “wangming”   对会员端进行了设计
209
210
211
212
213
      distributedColumns() {
        const columns = [
          { height: 0, items: [] },
          { height: 0, items: [] }
        ]
e1dcb3a0   “wangming”   1
214
        this.products.forEach((product) => {
5c34676a   “wangming”   对会员端进行了设计
215
216
217
218
219
220
221
222
223
224
225
226
227
          const target = columns[0].height <= columns[1].height ? columns[0] : columns[1]
          target.items.push(product)
          target.height += product.height
        })
        return columns
      },
      leftProducts() {
        return this.distributedColumns[0].items
      },
      rightProducts() {
        return this.distributedColumns[1].items
      }
    },
e1dcb3a0   “wangming”   1
228
229
230
231
232
233
234
235
236
237
    onLoad() {
      this.loadCategories()
      this.resetAndLoad()
    },
    onReachBottom() {
      this.loadList()
    },
    onPullDownRefresh() {
      this.resetAndLoad(() => uni.stopPullDownRefresh())
    },
5c34676a   “wangming”   对会员端进行了设计
238
    methods: {
e1dcb3a0   “wangming”   1
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
      normalize(item, index) {
        const height = 320 + ((index * 37) % 130)
        return {
          id: item.id,
          name: item.productName,
          image: item.coverImg || '',
          categoryName: item.categoryName || '',
          price: item.price,
          originalPrice: item.originalPrice,
          sales: item.sales || 0,
          stock: item.stock,
          height,
          coverStyle: `height:${height}rpx;background:rgba(245,248,245,0.96);`
        }
      },
      loadCategories() {
        getMallCategories()
          .then((res) => {
            const list = Array.isArray(res) ? res : (res && res.data) || []
            const names = list.map((c) => c.name).filter((n) => !!n)
            this.categories = ['全部'].concat(names)
          })
          .catch(() => {
            this.categories = ['全部']
          })
      },
      resetAndLoad(done) {
        this.currentPage = 1
        this.products = []
        this.total = 0
        this.finished = false
        this.loadList(done)
      },
      loadList(done) {
        if (this.loading || this.finished) {
          if (done) done()
          return
        }
        this.loading = true
        const params = {
          currentPage: this.currentPage,
          pageSize: this.pageSize,
          SortBy: this.activeSort
        }
        const keyword = String(this.searchKeyword || '').trim()
        if (keyword) params.Keyword = keyword
        if (this.activeCategory && this.activeCategory !== '全部') params.CategoryName = this.activeCategory
  
        getMallList(params)
          .then((res) => {
            const list = (res && res.list) || []
            const startIndex = this.products.length
            const mapped = list.map((item, i) => this.normalize(item, startIndex + i))
            this.products = this.products.concat(mapped)
            const pagination = (res && res.pagination) || {}
            this.total = pagination.total || this.products.length
            if (list.length < this.pageSize || this.products.length >= this.total) {
              this.finished = true
            } else {
              this.currentPage += 1
            }
            this.loading = false
            if (done) done()
          })
          .catch(() => {
            this.loading = false
            if (done) done()
          })
      },
      onSearch() {
        this.resetAndLoad()
      },
      selectCategory(item) {
        if (this.activeCategory === item) return
        this.activeCategory = item
        this.resetAndLoad()
      },
      selectSort(key) {
        if (this.activeSort === key) return
        this.activeSort = key
        this.resetAndLoad()
      },
5c34676a   “wangming”   对会员端进行了设计
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
      previewProduct(product) {
        uni.navigateTo({
          url: `/packageMall/product-detail/product-detail?id=${product.id}`
        })
      },
      goTab(item) {
        if (item.key === 'mall') {
          return
        }
        uni.redirectTo({
          url: item.path
        })
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  @import '@/styles/mixins.scss';
  
  .mall-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28rpx;
  }
  
  .mall-title {
    display: block;
    font-size: 44rpx;
    font-weight: 700;
  }
  
  .mall-subtitle {
    display: block;
    margin-top: 10rpx;
    font-size: 24rpx;
    color: $text-secondary;
    line-height: 1.7;
  }
  
  .feature-card {
    position: relative;
    overflow: hidden;
    min-height: 260rpx;
    margin-bottom: 28rpx;
    padding: 34rpx;
  
    &::after {
      content: '';
      position: absolute;
      right: -82rpx;
      top: -10rpx;
      width: 380rpx;
      height: 380rpx;
      border-radius: 50%;
      background: radial-gradient(circle, rgba(100, 140, 118, 0.04), rgba(100, 140, 118, 0));
      z-index: 0;
d8035736   “wangming”   Refactor project ...
379
      animation: lfFloatSoft 11.8s ease-in-out infinite;
5c34676a   “wangming”   对会员端进行了设计
380
381
382
383
384
385
386
387
388
389
390
391
    }
  
    &::before {
      content: '';
      position: absolute;
      right: 6rpx;
      top: 60rpx;
      width: 220rpx;
      height: 220rpx;
      border-radius: 50%;
      border: 2rpx solid rgba(100, 140, 118, 0.035);
      z-index: 1;
d8035736   “wangming”   Refactor project ...
392
      animation: lfPulseSoft 8.6s ease-in-out infinite;
5c34676a   “wangming”   对会员端进行了设计
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
    }
  }
  
  .feature-copy {
    position: relative;
    z-index: 3;
    max-width: 100%;
    padding-right: 36rpx;
  }
  
  .feature-tag {
    display: inline-block;
    font-size: 20rpx;
    letter-spacing: 3rpx;
    color: $brand-primary;
  }
  
  .feature-title {
    display: block;
    margin: 16rpx 0 12rpx;
    font-size: 40rpx;
    font-weight: 700;
    line-height: 1.35;
  }
  
  .feature-desc {
    display: block;
    font-size: 24rpx;
    color: $text-secondary;
    line-height: 1.8;
  }
  
  .feature-art-wrap {
    position: absolute;
    right: -118rpx;
    top: -34rpx;
    z-index: 1;
    width: 420rpx;
    height: 420rpx;
    border-radius: 50%;
    overflow: hidden;
    opacity: 0.08;
    pointer-events: none;
d8035736   “wangming”   Refactor project ...
436
    animation: lfFloatSoft 13.2s ease-in-out infinite 0.6s;
5c34676a   “wangming”   对会员端进行了设计
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
  
    &::after {
      content: '';
      position: absolute;
      inset: 0;
      background: radial-gradient(circle at 34% 40%, rgba(255, 255, 255, 0.40), rgba(255, 255, 255, 0.12) 44%, rgba(255, 255, 255, 0));
    }
  }
  
  .feature-art {
    width: 480rpx;
    height: 480rpx;
    margin-left: -38rpx;
    margin-top: -28rpx;
    transform: rotate(-10deg) scale(1.04);
    filter: saturate(0.72) brightness(1.04);
  }
  
  .search-card {
    @include outlined-card(0.92);
    display: flex;
    align-items: center;
    min-height: 92rpx;
    margin-bottom: 24rpx;
    padding: 0 26rpx;
d8035736   “wangming”   Refactor project ...
462
463
464
465
466
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 320ms ease;
  }
  
  .search-card:active {
    transform: translateY(-3rpx);
5c34676a   “wangming”   对会员端进行了设计
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
  }
  
  .search-icon {
    position: relative;
    width: 36rpx;
    height: 36rpx;
    margin-right: 18rpx;
    border: 3rpx solid rgba(182, 142, 154, 0.42);
    border-radius: 50%;
  
    &::after {
      content: '';
      position: absolute;
      width: 16rpx;
      height: 3rpx;
      right: -8rpx;
      bottom: 0;
      background: rgba(182, 142, 154, 0.42);
      transform: rotate(45deg);
      border-radius: 999rpx;
    }
  }
  
  .search-input {
    flex: 1;
    height: 92rpx;
    font-size: 26rpx;
    color: $text-primary;
  }
  
  .search-placeholder {
    color: $text-tertiary;
  }
  
  .category-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 28rpx;
  }
  
  .category-chip {
    padding: 16rpx 28rpx;
    margin: 0 16rpx 16rpx 0;
    border-radius: 999rpx;
    font-size: 24rpx;
    color: $text-secondary;
    background: rgba(255, 255, 255, 0.80);
    border: 1rpx solid rgba(210, 191, 156, 0.14);
d8035736   “wangming”   Refactor project ...
515
516
517
518
519
    transition: transform 240ms ease, box-shadow 240ms ease, background 240ms ease, color 240ms ease;
  }
  
  .category-chip:active {
    transform: translateY(-2rpx) scale(0.98);
5c34676a   “wangming”   对会员端进行了设计
520
521
522
523
524
525
526
527
528
  }
  
  .category-chip.active {
    color: #fff;
    background: $brand-primary-deep;
    border-color: rgba(210, 191, 156, 0.22);
    box-shadow: $shadow-chip;
  }
  
e1dcb3a0   “wangming”   1
529
530
531
532
  .sort-row {
    margin-top: -8rpx;
  }
  
5c34676a   “wangming”   对会员端进行了设计
533
534
535
536
  .product-head {
    margin-bottom: 18rpx;
  }
  
e1dcb3a0   “wangming”   1
537
538
539
540
541
542
543
  .list-tip {
    margin: 16rpx 0 8rpx;
    text-align: center;
    font-size: 22rpx;
    color: $text-tertiary;
  }
  
5c34676a   “wangming”   对会员端进行了设计
544
545
546
547
548
549
550
551
552
553
554
555
556
557
  .waterfall {
    display: flex;
    justify-content: space-between;
  }
  
  .waterfall-col {
    width: calc((100% - 18rpx) / 2);
  }
  
  .product-card {
    @include outlined-card(0.92);
    overflow: hidden;
    margin-bottom: 20rpx;
    padding: 0;
d8035736   “wangming”   Refactor project ...
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
    transition: transform 340ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 340ms ease;
    animation: lfRevealUp 760ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  
  .waterfall-col:nth-child(1) .product-card:nth-child(1),
  .waterfall-col:nth-child(2) .product-card:nth-child(1) {
    animation-delay: 0.12s;
  }
  
  .waterfall-col:nth-child(1) .product-card:nth-child(2),
  .waterfall-col:nth-child(2) .product-card:nth-child(2) {
    animation-delay: 0.2s;
  }
  
  .waterfall-col:nth-child(1) .product-card:nth-child(3),
  .waterfall-col:nth-child(2) .product-card:nth-child(3) {
    animation-delay: 0.28s;
  }
  
  .waterfall-col:nth-child(1) .product-card:nth-child(4),
  .waterfall-col:nth-child(2) .product-card:nth-child(4) {
    animation-delay: 0.36s;
  }
  
  .product-card:active {
    transform: translateY(-6rpx);
    box-shadow: 0 22rpx 44rpx rgba(54, 77, 64, 0.1);
5c34676a   “wangming”   对会员端进行了设计
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
  }
  
  .product-cover {
    position: relative;
    padding: 24rpx;
    color: #fff;
  }
  
  .product-photo,
  .product-cover-mask {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }
  
  .product-cover-mask {
    background: linear-gradient(180deg, rgba(32, 53, 45, 0.02), rgba(32, 53, 45, 0.08) 56%, rgba(32, 53, 45, 0.36) 100%);
  }
  
d8035736   “wangming”   Refactor project ...
606
607
608
609
610
611
612
613
  .product-photo {
    transition: transform 1.2s ease;
  }
  
  .product-card:active .product-photo {
    transform: scale(1.06);
  }
  
5c34676a   “wangming”   对会员端进行了设计
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
  .product-badge {
    position: relative;
    z-index: 2;
    @include chip-inverse;
  }
  
  .product-cover-title {
    position: absolute;
    left: 24rpx;
    right: 24rpx;
    bottom: 24rpx;
    z-index: 2;
    font-size: 34rpx;
    line-height: 1.35;
    font-weight: 700;
  }
  
  .product-body {
    padding: 24rpx;
  }
  
  .product-name {
    display: block;
    font-size: 30rpx;
    line-height: 1.45;
    font-weight: 700;
  }
  
  .product-tags {
    display: flex;
    flex-wrap: wrap;
    margin-top: 16rpx;
  }
  
  .product-tag {
    @include chip-soft;
    margin: 0 12rpx 12rpx 0;
    font-size: 20rpx;
    padding: 8rpx 16rpx;
d8035736   “wangming”   Refactor project ...
653
    transition: transform 240ms ease;
5c34676a   “wangming”   对会员端进行了设计
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
  }
  
  .product-tag:nth-child(2) {
    @include chip-rose;
  }
  
  .product-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 12rpx;
  }
  
  .price-symbol,
  .product-price {
    color: $brand-primary-deep;
    font-weight: 700;
  }
  
  .price-symbol {
    font-size: 22rpx;
    color: $brand-accent;
  }
  
  .product-sales {
    color: $brand-rose;
  }
  
  .product-price {
    font-size: 38rpx;
  }
  
  .product-sales {
    font-size: 22rpx;
    color: $text-tertiary;
  }
  
  .empty-card {
    @include outlined-card(0.94);
    padding: 40rpx 32rpx;
    text-align: center;
  }
  
  .empty-title {
    display: block;
    font-size: 30rpx;
    font-weight: 700;
    color: $text-primary;
  }
  
  .empty-desc {
    display: block;
    margin-top: 12rpx;
    font-size: 24rpx;
    color: $text-secondary;
  }
  </style>