Blame view

member-miniapp/packageMall/product-detail/product-detail.vue 11.7 KB
5c34676a   “wangming”   对会员端进行了设计
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  <template>
    <view class="page-shell product-detail-page">
      <view class="page-blur"></view>
      <view class="page-blur-secondary"></view>
      <view class="page-blur-tertiary"></view>
  
      <view class="page-content subpage-content">
        <view class="subpage-nav">
          <view class="subpage-back" @tap="goBack">‹</view>
          <view class="subpage-title-wrap">
            <text class="subpage-title">商品详情</text>
            <text class="subpage-subtitle">把门店里的护理感,慢慢带回日常</text>
          </view>
        </view>
  
        <view class="product-hero glass-card">
e1dcb3a0   “wangming”   1
17
          <image v-if="product.coverImg" class="product-image" :src="product.coverImg" mode="aspectFill" />
d8035736   “wangming”   Refactor project ...
18
19
          <view class="product-image-mask"></view>
          <view class="product-image-glow"></view>
e1dcb3a0   “wangming”   1
20
          <text v-if="product.categoryName" class="product-hero-badge">{{ product.categoryName }}</text>
5c34676a   “wangming”   对会员端进行了设计
21
22
23
        </view>
  
        <view class="subpage-card">
e1dcb3a0   “wangming”   1
24
25
26
27
28
29
          <text v-if="product.categoryName" class="product-badge">{{ product.categoryName }}</text>
          <text class="product-title">{{ product.productName }}</text>
          <view class="price-line">
            <text class="product-price">¥{{ currentPrice }}</text>
            <text v-if="currentOriginalPrice && currentOriginalPrice > currentPrice" class="product-origin-price">¥{{ currentOriginalPrice }}</text>
          </view>
5c34676a   “wangming”   对会员端进行了设计
30
          <view class="meta-grid">
e1dcb3a0   “wangming”   1
31
32
            <text class="meta-pill">库存 {{ currentStock }}</text>
            <text class="meta-pill">已售 {{ product.sales || 0 }}</text>
5c34676a   “wangming”   对会员端进行了设计
33
          </view>
e1dcb3a0   “wangming”   1
34
          <text v-if="product.description" class="product-desc">{{ product.description }}</text>
5c34676a   “wangming”   对会员端进行了设计
35
36
        </view>
  
e1dcb3a0   “wangming”   1
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
        <view v-if="skus.length" class="subpage-card">
          <view class="section-head">
            <text class="section-title">选择规格</text>
            <text class="section-link">{{ selectedSku ? selectedSku.skuName : '请选择' }}</text>
          </view>
          <view class="sku-row">
            <view
              v-for="sku in skus"
              :key="sku.id"
              class="sku-chip"
              :class="{ active: selectedSku && selectedSku.id === sku.id, disabled: sku.stock <= 0 }"
              @tap="selectSku(sku)"
            >
              {{ sku.skuName }}
            </view>
          </view>
        </view>
  
        <view class="subpage-card qty-card">
          <text class="qty-label">购买数量</text>
          <view class="qty-stepper">
            <view class="qty-btn" :class="{ disabled: quantity <= 1 }" @tap="changeQty(-1)">−</view>
            <text class="qty-value">{{ quantity }}</text>
            <view class="qty-btn" :class="{ disabled: quantity >= currentStock }" @tap="changeQty(1)">+</view>
          </view>
        </view>
  
        <view v-if="product.detail" class="subpage-card">
5c34676a   “wangming”   对会员端进行了设计
65
66
67
68
69
          <view class="section-head">
            <text class="section-title">产品说明</text>
            <text class="section-link">居家护理</text>
          </view>
          <text class="detail-copy">{{ product.detail }}</text>
5c34676a   “wangming”   对会员端进行了设计
70
71
        </view>
  
d8035736   “wangming”   Refactor project ...
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        <view class="subpage-card">
          <view class="section-head">
            <text class="section-title">购买流程</text>
            <text class="section-link">门店自提</text>
          </view>
          <view class="flow-list">
            <view v-for="(item, index) in purchaseSteps" :key="item.title" class="flow-item">
              <view class="flow-index">{{ index + 1 }}</view>
              <view class="flow-copy">
                <text class="flow-title">{{ item.title }}</text>
                <text class="flow-desc">{{ item.desc }}</text>
              </view>
            </view>
          </view>
          <view class="soft-panel flow-note">
e1dcb3a0   “wangming”   1
87
            <text class="flow-note-text">支付完成后会自动生成取件码,到店出示后门店核销即可完成自提。</text>
d8035736   “wangming”   Refactor project ...
88
89
90
          </view>
        </view>
  
5c34676a   “wangming”   对会员端进行了设计
91
92
93
94
95
96
97
98
99
        <view class="cta-row">
          <view class="secondary-button" @tap="addWishlist">{{ isWishlisted ? '查看心愿单' : '加入心愿单' }}</view>
          <view class="primary-button" @tap="goOrder">立即购买</view>
        </view>
      </view>
    </view>
  </template>
  
  <script>
e1dcb3a0   “wangming”   1
100
101
102
  import { getMallDetail } from '@/api/mall'
  
  const WISHLIST_KEY = 'lf_wishlist'
5c34676a   “wangming”   对会员端进行了设计
103
104
105
106
  
  export default {
    data() {
      return {
e1dcb3a0   “wangming”   1
107
108
109
110
111
        productId: '',
        product: {},
        skus: [],
        selectedSku: null,
        quantity: 1,
d8035736   “wangming”   Refactor project ...
112
113
114
        isWishlisted: false,
        purchaseSteps: [
          { title: '下单支付', desc: '确认商品后完成支付,订单会立即进入自提流程。' },
e1dcb3a0   “wangming”   1
115
116
117
          { title: '生成取件码', desc: '支付成功后,小程序会自动生成专属取件码。' },
          { title: '到店出示', desc: '前往自提门店,出示取件码即可。' },
          { title: '门店核销', desc: '门店完成核销,订单状态会同步更新。' },
d8035736   “wangming”   Refactor project ...
118
119
          { title: '完成自提', desc: '核销完成后即可当场自提商品,流程更轻更快。' }
        ]
5c34676a   “wangming”   对会员端进行了设计
120
121
      }
    },
e1dcb3a0   “wangming”   1
122
123
124
125
126
127
128
129
130
131
132
133
    computed: {
      currentPrice() {
        return this.selectedSku ? this.selectedSku.price : (this.product.price || 0)
      },
      currentOriginalPrice() {
        return this.selectedSku ? this.selectedSku.originalPrice : this.product.originalPrice
      },
      currentStock() {
        const stock = this.selectedSku ? this.selectedSku.stock : this.product.stock
        return stock || 0
      }
    },
5c34676a   “wangming”   对会员端进行了设计
134
    onLoad(options) {
e1dcb3a0   “wangming”   1
135
136
      this.productId = options.id
      this.loadDetail()
5c34676a   “wangming”   对会员端进行了设计
137
138
139
140
141
    },
    onShow() {
      this.loadWishlistState()
    },
    methods: {
e1dcb3a0   “wangming”   1
142
143
144
145
146
147
148
149
150
151
152
153
154
      loadDetail() {
        getMallDetail(this.productId)
          .then((data) => {
            this.product = data || {}
            this.skus = (data && data.skus) || []
            if (this.skus.length) {
              const firstInStock = this.skus.find(s => s.stock > 0)
              this.selectedSku = firstInStock || this.skus[0]
            }
            this.loadWishlistState()
          })
          .catch(() => {})
      },
5c34676a   “wangming”   对会员端进行了设计
155
      loadWishlistState() {
e1dcb3a0   “wangming”   1
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
        const list = uni.getStorageSync(WISHLIST_KEY) || []
        this.isWishlisted = list.some(item => String(item.id) === String(this.productId))
      },
      selectSku(sku) {
        if (sku.stock <= 0) {
          uni.showToast({ title: '该规格暂时缺货', icon: 'none' })
          return
        }
        this.selectedSku = sku
        if (this.quantity > sku.stock) this.quantity = 1
      },
      changeQty(delta) {
        const next = this.quantity + delta
        if (next < 1) return
        if (next > this.currentStock) {
          uni.showToast({ title: '已达库存上限', icon: 'none' })
          return
        }
        this.quantity = next
5c34676a   “wangming”   对会员端进行了设计
175
176
177
178
179
180
181
182
183
      },
      goBack() {
        uni.navigateBack({
          fail: () => {
            uni.redirectTo({ url: '/packageMall/main/main' })
          }
        })
      },
      addWishlist() {
e1dcb3a0   “wangming”   1
184
        const list = uni.getStorageSync(WISHLIST_KEY) || []
5c34676a   “wangming”   对会员端进行了设计
185
186
187
188
        if (this.isWishlisted) {
          uni.navigateTo({ url: '/packageMall/wishlist/wishlist' })
          return
        }
e1dcb3a0   “wangming”   1
189
190
191
192
193
194
195
196
        list.push({
          id: this.product.id,
          name: this.product.productName,
          image: this.product.coverImg || '',
          price: this.product.price,
          desc: this.product.description || ''
        })
        uni.setStorageSync(WISHLIST_KEY, list)
5c34676a   “wangming”   对会员端进行了设计
197
198
199
200
201
202
203
        this.isWishlisted = true
        uni.showToast({ title: '已加入心愿单', icon: 'none' })
        setTimeout(() => {
          uni.navigateTo({ url: '/packageMall/wishlist/wishlist' })
        }, 280)
      },
      goOrder() {
e1dcb3a0   “wangming”   1
204
205
206
207
208
209
210
211
212
213
214
        if (this.skus.length && !this.selectedSku) {
          uni.showToast({ title: '请先选择规格', icon: 'none' })
          return
        }
        if (this.currentStock <= 0) {
          uni.showToast({ title: '商品暂时缺货', icon: 'none' })
          return
        }
        const query = [`productId=${this.product.id}`, `quantity=${this.quantity}`]
        if (this.selectedSku) query.push(`skuId=${this.selectedSku.id}`)
        uni.navigateTo({ url: `/packageMall/order-confirm/order-confirm?${query.join('&')}` })
5c34676a   “wangming”   对会员端进行了设计
215
216
217
218
219
220
221
222
223
224
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  @import '@/styles/mixins.scss';
  @import '@/styles/subpage.scss';
  
  .product-hero {
d8035736   “wangming”   Refactor project ...
225
    position: relative;
5c34676a   “wangming”   对会员端进行了设计
226
227
228
    padding: 0;
    overflow: hidden;
    margin-bottom: 28rpx;
d8035736   “wangming”   Refactor project ...
229
230
231
232
233
    min-height: 620rpx;
  }
  
  .product-hero:active .product-image {
    transform: scale(1.05);
5c34676a   “wangming”   对会员端进行了设计
234
235
236
237
238
239
  }
  
  .product-image {
    width: 100%;
    height: 620rpx;
    display: block;
d8035736   “wangming”   Refactor project ...
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
    transition: transform 1.2s ease;
  }
  
  .product-image-mask,
  .product-image-glow,
  .product-hero-badge {
    position: absolute;
  }
  
  .product-image-mask {
    inset: 0;
    background: linear-gradient(180deg, rgba(32, 53, 45, 0.04), rgba(32, 53, 45, 0.12) 54%, rgba(32, 53, 45, 0.3) 100%);
  }
  
  .product-image-glow {
    right: -80rpx;
    top: -20rpx;
    width: 260rpx;
    height: 260rpx;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
    animation: lfFloatSoft 11.8s ease-in-out infinite;
  }
  
  .product-hero-badge {
    left: 28rpx;
    top: 28rpx;
    z-index: 2;
    @include chip-inverse;
  }
  
  .product-badge,
  .product-price {
    position: relative;
    z-index: 2;
5c34676a   “wangming”   对会员端进行了设计
275
276
277
278
  }
  
  .product-badge {
    @include chip-soft;
d8035736   “wangming”   Refactor project ...
279
280
281
282
283
    transition: transform 240ms ease;
  }
  
  .product-badge:active {
    transform: scale(0.97);
5c34676a   “wangming”   对会员端进行了设计
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
  }
  
  .product-title {
    display: block;
    margin-top: 18rpx;
    font-size: 40rpx;
    line-height: 1.4;
    font-weight: 700;
  }
  
  .product-price {
    display: block;
    margin-top: 18rpx;
    font-size: 46rpx;
    font-weight: 700;
    color: $brand-primary-deep;
  }
  
  .product-desc,
  .detail-copy {
    display: block;
    margin-top: 18rpx;
    font-size: 24rpx;
    line-height: 1.8;
    color: $text-secondary;
  }
  
e1dcb3a0   “wangming”   1
311
312
313
314
315
316
317
318
319
320
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
379
380
381
382
383
384
385
386
387
388
389
390
391
  .price-line {
    display: flex;
    align-items: baseline;
    margin-top: 18rpx;
  }
  
  .product-origin-price {
    margin-left: 16rpx;
    font-size: 26rpx;
    color: $text-tertiary;
    text-decoration: line-through;
  }
  
  .sku-row {
    display: flex;
    flex-wrap: wrap;
  }
  
  .sku-chip {
    padding: 16rpx 28rpx;
    margin: 0 16rpx 16rpx 0;
    border-radius: 999rpx;
    font-size: 24rpx;
    color: $text-secondary;
    background: rgba(255, 255, 255, 0.82);
    border: 1rpx solid rgba(210, 191, 156, 0.16);
    transition: transform 240ms ease, background 240ms ease, color 240ms ease;
  }
  
  .sku-chip.active {
    color: #fff;
    background: $brand-primary-deep;
    border-color: rgba(210, 191, 156, 0.24);
    box-shadow: $shadow-chip;
  }
  
  .sku-chip.disabled {
    opacity: 0.4;
  }
  
  .qty-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .qty-label {
    font-size: 28rpx;
    font-weight: 600;
    color: $text-primary;
  }
  
  .qty-stepper {
    display: flex;
    align-items: center;
  }
  
  .qty-btn {
    width: 60rpx;
    height: 60rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18rpx;
    font-size: 36rpx;
    color: $brand-primary-deep;
    background: rgba(210, 191, 156, 0.14);
  }
  
  .qty-btn.disabled {
    opacity: 0.4;
  }
  
  .qty-value {
    min-width: 80rpx;
    text-align: center;
    font-size: 30rpx;
    font-weight: 700;
    color: $text-primary;
  }
  
5c34676a   “wangming”   对会员端进行了设计
392
393
394
395
396
397
398
399
400
  .spec-panel {
    margin-top: 24rpx;
  }
  
  .spec-item {
    display: block;
    font-size: 24rpx;
    line-height: 1.9;
    color: $text-primary;
d8035736   “wangming”   Refactor project ...
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
436
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
462
463
464
465
466
467
468
469
    transition: transform 220ms ease;
  }
  
  .spec-item:active {
    transform: translateX(6rpx);
  }
  
  .flow-list {
    margin-top: 4rpx;
  }
  
  .flow-item {
    display: flex;
    align-items: flex-start;
    padding: 18rpx 0;
    border-bottom: 1rpx solid rgba(100, 140, 118, 0.08);
  }
  
  .flow-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }
  
  .flow-index {
    width: 52rpx;
    height: 52rpx;
    margin-right: 18rpx;
    flex-shrink: 0;
    border-radius: 18rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24rpx;
    font-weight: 700;
    color: $brand-primary-deep;
    background: rgba(210, 191, 156, 0.14);
  }
  
  .flow-copy {
    flex: 1;
  }
  
  .flow-title,
  .flow-desc,
  .flow-note-text {
    display: block;
  }
  
  .flow-title {
    font-size: 28rpx;
    font-weight: 600;
    color: $text-primary;
  }
  
  .flow-desc {
    margin-top: 10rpx;
    font-size: 23rpx;
    line-height: 1.8;
    color: $text-secondary;
  }
  
  .flow-note {
    margin-top: 24rpx;
  }
  
  .flow-note-text {
    font-size: 23rpx;
    line-height: 1.8;
    color: $brand-primary-deep;
5c34676a   “wangming”   对会员端进行了设计
470
471
  }
  </style>