Blame view

member-miniapp/packageProfile/order-list/order-list.vue 7.77 KB
5c34676a   “wangming”   对会员端进行了设计
1
2
3
4
5
6
7
8
9
10
11
  <template>
    <view class="page-shell order-list-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>
d8035736   “wangming”   Refactor project ...
12
            <text class="subpage-subtitle">从下单到核销自提,把每一次购买都安静记录</text>
5c34676a   “wangming”   对会员端进行了设计
13
14
15
16
17
          </view>
        </view>
  
        <scroll-view class="status-scroll" scroll-x>
          <view class="status-row">
e1dcb3a0   “wangming”   1
18
            <view v-for="item in statuses" :key="item.key" class="status-chip" :class="{ active: activeStatus === item.key }" @tap="selectStatus(item.key)">
5c34676a   “wangming”   对会员端进行了设计
19
20
21
22
23
              {{ item.label }}
            </view>
          </view>
        </scroll-view>
  
e1dcb3a0   “wangming”   1
24
        <view v-for="item in orders" :key="item.id" class="order-card glass-card" @tap="goDetail(item)">
5c34676a   “wangming”   对会员端进行了设计
25
          <view class="order-top">
e1dcb3a0   “wangming”   1
26
27
            <text class="order-status">{{ statusText(item.orderStatus) }}</text>
            <text class="order-time">{{ formatTime(item.createTime) }}</text>
5c34676a   “wangming”   对会员端进行了设计
28
29
          </view>
          <view class="order-main">
e1dcb3a0   “wangming”   1
30
31
            <image v-if="firstImg(item)" class="order-thumb" :src="firstImg(item)" mode="aspectFill" />
            <view v-else class="order-art">
5c34676a   “wangming”   对会员端进行了设计
32
              <view class="order-art-ring"></view>
e1dcb3a0   “wangming”   1
33
              <text class="order-art-label">{{ shortLabel(firstName(item)) }}</text>
5c34676a   “wangming”   对会员端进行了设计
34
35
            </view>
            <view class="order-copy">
e1dcb3a0   “wangming”   1
36
37
38
39
              <text class="order-name">{{ firstName(item) }}</text>
              <text class="order-sku">{{ itemsSummary(item) }}</text>
              <text class="order-store">{{ item.storeName }} · 门店自提</text>
              <text class="order-amount">¥{{ item.payAmount }}</text>
5c34676a   “wangming”   对会员端进行了设计
40
41
42
            </view>
          </view>
        </view>
e1dcb3a0   “wangming”   1
43
44
45
  
        <view v-if="!loading && !orders.length" class="empty-tip">暂无相关订单</view>
        <view v-if="loading" class="empty-tip">正在加载…</view>
5c34676a   “wangming”   对会员端进行了设计
46
47
48
49
50
      </view>
    </view>
  </template>
  
  <script>
e1dcb3a0   “wangming”   1
51
52
  import { getMyOrders } from '@/api/mall'
  import { orderStatusText } from '@/utils/orderStatus'
5c34676a   “wangming”   对会员端进行了设计
53
54
55
56
  
  export default {
    data() {
      return {
e1dcb3a0   “wangming”   1
57
58
        orders: [],
        activeStatus: 0,
5c34676a   “wangming”   对会员端进行了设计
59
        statuses: [
e1dcb3a0   “wangming”   1
60
61
62
63
64
65
66
67
68
69
70
          { key: 0, label: '全部' },
          { key: 1, label: '待付款' },
          { key: 2, label: '待自提' },
          { key: 3, label: '已完成' },
          { key: 4, label: '已取消' }
        ],
        currentPage: 1,
        pageSize: 10,
        total: 0,
        loading: false,
        finished: false
5c34676a   “wangming”   对会员端进行了设计
71
72
73
      }
    },
    onLoad(options) {
e1dcb3a0   “wangming”   1
74
75
      if (options.status !== undefined && options.status !== '') {
        this.activeStatus = Number(options.status) || 0
5c34676a   “wangming”   对会员端进行了设计
76
      }
e1dcb3a0   “wangming”   1
77
      this.resetAndLoad()
5c34676a   “wangming”   对会员端进行了设计
78
    },
e1dcb3a0   “wangming”   1
79
80
    onReachBottom() {
      this.loadList()
d8035736   “wangming”   Refactor project ...
81
    },
5c34676a   “wangming”   对会员端进行了设计
82
    methods: {
e1dcb3a0   “wangming”   1
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
      resetAndLoad() {
        this.currentPage = 1
        this.orders = []
        this.total = 0
        this.finished = false
        this.loadList()
      },
      loadList() {
        if (this.loading || this.finished) return
        this.loading = true
        const params = { currentPage: this.currentPage, pageSize: this.pageSize }
        if (this.activeStatus) params.OrderStatus = this.activeStatus
        getMyOrders(params)
          .then((res) => {
            const list = (res && res.list) || []
            this.orders = this.orders.concat(list)
            const pagination = (res && res.pagination) || {}
            this.total = pagination.total || this.orders.length
            if (list.length < this.pageSize || this.orders.length >= this.total) {
              this.finished = true
            } else {
              this.currentPage += 1
            }
            this.loading = false
          })
          .catch(() => {
            this.loading = false
          })
      },
      selectStatus(key) {
        if (this.activeStatus === key) return
        this.activeStatus = key
        this.resetAndLoad()
      },
      statusText(status) {
        return orderStatusText(status)
      },
      formatTime(time) {
        return time ? String(time).replace('T', ' ').slice(0, 16) : ''
      },
      firstItem(item) {
        const items = item.items || []
        return items[0] || {}
      },
      firstName(item) {
        return this.firstItem(item).productName || '绿纤商品'
      },
      firstImg(item) {
        return this.firstItem(item).productImg || ''
      },
      itemsSummary(item) {
        const items = item.items || []
        if (!items.length) return ''
        const first = items[0]
        const qty = items.reduce((sum, it) => sum + (it.quantity || 0), 0)
        const skuText = first.skuName ? `${first.skuName} · ` : ''
        return items.length > 1 ? `${skuText}共 ${qty} 件` : `${skuText}× ${first.quantity}`
      },
5c34676a   “wangming”   对会员端进行了设计
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
      shortLabel(title) {
        return String(title || '绿纤').replace(/\s+/g, '').slice(0, 2)
      },
      goBack() {
        uni.navigateBack({ fail: () => uni.redirectTo({ url: '/pages/profile/profile' }) })
      },
      goDetail(item) {
        uni.navigateTo({ url: `/packageProfile/order-detail/order-detail?id=${item.id}` })
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  @import '@/styles/mixins.scss';
  @import '@/styles/subpage.scss';
  
  .status-scroll {
    white-space: nowrap;
    margin-bottom: 24rpx;
  }
  
  .status-row {
    display: inline-flex;
    padding-bottom: 6rpx;
  }
  
  .status-chip {
    @include selection-chip;
    min-width: 138rpx;
    padding: 22rpx 28rpx;
    margin-right: 16rpx;
    text-align: center;
    font-size: 24rpx;
    color: $text-secondary;
d8035736   “wangming”   Refactor project ...
176
177
178
179
180
    transition: transform 240ms ease, box-shadow 240ms ease, background 240ms ease, color 240ms ease;
  }
  
  .status-chip:active {
    transform: translateY(-2rpx) scale(0.98);
5c34676a   “wangming”   对会员端进行了设计
181
182
183
184
185
186
187
188
189
  }
  
  .status-chip.active {
    @include selection-chip-active;
  }
  
  .order-card {
    padding: 30rpx;
    margin-bottom: 22rpx;
d8035736   “wangming”   Refactor project ...
190
191
192
193
194
195
196
197
198
199
200
    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;
  }
  
  .order-card:nth-of-type(1) { animation-delay: 0.08s; }
  .order-card:nth-of-type(2) { animation-delay: 0.16s; }
  .order-card:nth-of-type(3) { animation-delay: 0.24s; }
  .order-card:nth-of-type(4) { animation-delay: 0.32s; }
  
  .order-card:active {
    transform: translateY(-4rpx);
5c34676a   “wangming”   对会员端进行了设计
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
  }
  
  .order-top,
  .order-main {
    display: flex;
  }
  
  .order-top {
    justify-content: space-between;
    align-items: center;
  }
  
  .order-status {
    @include chip-soft;
  }
  
  .order-time {
    font-size: 22rpx;
    color: $text-tertiary;
  }
  
  .order-main {
    margin-top: 22rpx;
  }
  
e1dcb3a0   “wangming”   1
226
227
228
229
230
231
232
  .order-thumb {
    width: 180rpx;
    height: 180rpx;
    border-radius: 28rpx;
    flex-shrink: 0;
  }
  
5c34676a   “wangming”   对会员端进行了设计
233
234
235
236
237
238
239
240
241
242
243
244
  .order-art {
    width: 180rpx;
    height: 180rpx;
    border-radius: 28rpx;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(241, 246, 241, 0.96);
    border: 1rpx solid rgba(120, 146, 121, 0.14);
    box-shadow: inset 0 1rpx 0 rgba(255, 255, 255, 0.65);
d8035736   “wangming”   Refactor project ...
245
    overflow: hidden;
5c34676a   “wangming”   对会员端进行了设计
246
247
248
249
250
251
252
253
  }
  
  .order-art-ring {
    width: 96rpx;
    height: 96rpx;
    border-radius: 50%;
    border: 1rpx solid rgba(120, 146, 121, 0.18);
    background: rgba(255, 255, 255, 0.45);
d8035736   “wangming”   Refactor project ...
254
    animation: lfPulseSoft 5.2s ease-in-out infinite;
5c34676a   “wangming”   对会员端进行了设计
255
256
257
258
259
260
261
262
263
264
  }
  
  .order-art-label {
    position: absolute;
    font-size: 24rpx;
    letter-spacing: 4rpx;
    color: $brand-primary-deep;
    font-weight: 600;
  }
  
d8035736   “wangming”   Refactor project ...
265
266
267
268
269
270
271
272
273
274
275
276
  .order-art::before {
    content: '';
    position: absolute;
    right: -30rpx;
    top: -30rpx;
    width: 120rpx;
    height: 120rpx;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(210, 191, 156, 0.22), rgba(210, 191, 156, 0));
    animation: lfFloatSoft 9.8s ease-in-out infinite;
  }
  
5c34676a   “wangming”   对会员端进行了设计
277
278
279
280
281
  .order-copy {
    flex: 1;
    margin-left: 22rpx;
  }
  
d8035736   “wangming”   Refactor project ...
282
283
284
285
  .order-name,
  .order-sku,
  .order-store,
  .order-amount {
5c34676a   “wangming”   对会员端进行了设计
286
    display: block;
d8035736   “wangming”   Refactor project ...
287
288
289
290
291
    margin-top: 14rpx;
  }
  
  .order-name {
    margin-top: 0;
5c34676a   “wangming”   对会员端进行了设计
292
293
294
295
296
297
    font-size: 30rpx;
    line-height: 1.5;
    font-weight: 700;
  }
  
  .order-sku,
d8035736   “wangming”   Refactor project ...
298
  .order-store {
5c34676a   “wangming”   对会员端进行了设计
299
300
301
302
303
304
305
306
307
308
    font-size: 24rpx;
    color: $text-secondary;
  }
  
  .order-amount {
    font-size: 34rpx;
    color: $brand-primary-deep;
    font-weight: 700;
  }
  </style>