@uxda/appkit 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <scroll-view class="account-view"
2
+ <scroll-view
3
+ class="account-view"
3
4
  :class="{ popupOpen: isAnyPopupOpen }"
4
5
  :scroll-y="!isAnyPopupOpen"
5
6
  :refresher-enabled="!isAnyPopupOpen"
@@ -7,14 +8,18 @@
7
8
  @scroll="onScroll"
8
9
  @refresherrefresh="onPullDownRefresh"
9
10
  :lower-threshold="50"
10
- @scrolltolower="onReachBottom">
11
+ @scrolltolower="onReachBottom"
12
+ >
11
13
  <div class="scroll-content">
12
- <page-header color-mode="dark" title="我的账户"
13
- :class="{'with-background': scrolled > 0}"
14
- @close="onPageHeaderClose" />
14
+ <page-header
15
+ color-mode="dark"
16
+ title="我的账户"
17
+ :class="{ 'with-background': scrolled > 0 }"
18
+ @close="onPageHeaderClose"
19
+ />
15
20
  <div class="row jusify-right">
16
21
  <div class="small-bean-button" @click="onSecondBalanceButtonClick">
17
- <label>小云豆余额</label>
22
+ <label>权益余额</label>
18
23
  </div>
19
24
  </div>
20
25
  <div class="balance">
@@ -22,7 +27,8 @@
22
27
  <div class="bean-img">
23
28
  <img
24
29
  class="bean-icon"
25
- src="https://cdn.ddjf.com/static/images/bpms-workBench/gold-bean.png" />
30
+ src="https://cdn.ddjf.com/static/images/bpms-workBench/gold-bean.png"
31
+ />
26
32
  <div class="bean-tag tag">云豆</div>
27
33
  </div>
28
34
  <div class="rule" @click="rulesPopupOpen = true">规则说明</div>
@@ -32,9 +38,11 @@
32
38
  <div class="pay" @click="gotoRecharge">云豆充值</div>
33
39
  </div>
34
40
  </div>
35
- <div class="operation-title spa-between"
36
- :class="{'with-shadow': scrolled > 0}"
37
- :style="{top: `${safeArea.status + safeArea.nav}px`}">
41
+ <div
42
+ class="operation-title spa-between"
43
+ :class="{ 'with-shadow': scrolled > 0 }"
44
+ :style="{ top: `${safeArea.status + safeArea.nav}px` }"
45
+ >
38
46
  <div class="search-time">
39
47
  <div class="title">收支明细</div>
40
48
  <div class="time" @click="openDateFilter" v-show="filtering.dateFrom">
@@ -42,24 +50,27 @@
42
50
  <img
43
51
  style="margin-top: -2px"
44
52
  class="time-icon"
45
- src="https://cdn.ddjf.com/static/images/bpms-workBench/clound-bean-down.png" />
53
+ src="https://cdn.ddjf.com/static/images/bpms-workBench/clound-bean-down.png"
54
+ />
46
55
  </div>
47
56
  </div>
48
57
  <div class="search" @click="filterOpen = true">
49
58
  <span class="text">筛选</span>
50
59
  <img
51
60
  class="time-icon"
52
- src="https://cdn.ddjf.com/static/images/bpms-workBench/clound-bean-select-icon.png" />
61
+ src="https://cdn.ddjf.com/static/images/bpms-workBench/clound-bean-select-icon.png"
62
+ />
53
63
  </div>
54
64
  </div>
55
65
  <div class="operation-list">
56
66
  <div class="box" v-if="consumptionGroups.length > 0">
57
- <div class="box-detail" v-for="(item, index) in consumptionGroups" :key="index">
67
+ <div
68
+ class="box-detail"
69
+ v-for="(item, index) in consumptionGroups"
70
+ :key="index"
71
+ >
58
72
  <div class="title number">{{ item.date }}</div>
59
- <div
60
- class="item"
61
- v-for="(it, i) in item.consumptions"
62
- :key="i">
73
+ <div class="item" v-for="(it, i) in item.consumptions" :key="i">
63
74
  <div class="item-type">
64
75
  {{ it.交易类型 }}
65
76
  </div>
@@ -72,7 +83,7 @@
72
83
  <div class="item-info-title">{{ it.title }}</div>
73
84
  </div>
74
85
  <div class="item-info-amount number">
75
- {{ it.收入还是支出 == '支出' ? '-' : '+' }}{{ it.amount }}
86
+ {{ it.收入还是支出 == "支出" ? "-" : "+" }}{{ it.amount }}
76
87
  </div>
77
88
  </div>
78
89
  <div class="item-detail-remark">{{ it.description }}</div>
@@ -88,7 +99,8 @@
88
99
  <nut-popup
89
100
  pop-class="consumption-rules-popup"
90
101
  v-model:visible="rulesPopupOpen"
91
- :close-on-click-overlay="false">
102
+ :close-on-click-overlay="false"
103
+ >
92
104
  <consumption-rules @complete="rulesPopupOpen = false" />
93
105
  </nut-popup>
94
106
  <nut-popup
@@ -96,244 +108,252 @@
96
108
  :style="{ height: '40%' }"
97
109
  round
98
110
  :close-on-click-overlay="true"
99
- v-model:visible="datePickerOpen">
111
+ v-model:visible="datePickerOpen"
112
+ >
100
113
  <date-filter
101
114
  v-if="datePickerOpen"
102
115
  :from="filtering.dateFrom"
103
116
  :to="filtering.dateTo"
104
117
  @reset="onDateReset"
105
- @complete="onDateFilterComplete"/>
118
+ @complete="onDateFilterComplete"
119
+ />
106
120
  </nut-popup>
107
121
  <nut-popup
108
122
  position="bottom"
109
123
  :style="{ height: '75%' }"
110
124
  round
111
125
  :close-on-click-overlay="true"
112
- v-model:visible="filterOpen">
113
- <consumption-filter :modelValue="[
114
- filtering.账户类型,
115
- filtering.收入还是支出,
116
- filtering.交易类型,
117
- filtering.权益类目
118
- ]" @complete="onFilterComplete" />
126
+ v-model:visible="filterOpen"
127
+ >
128
+ <consumption-filter
129
+ :modelValue="[
130
+ filtering.账户类型,
131
+ filtering.收入还是支出,
132
+ filtering.交易类型,
133
+ filtering.权益类目,
134
+ ]"
135
+ @complete="onFilterComplete"
136
+ />
119
137
  </nut-popup>
120
- <app-drawer
121
- v-model="secondBalanceOpen"
122
- title="小云豆余额">
138
+ <app-drawer v-model="secondBalanceOpen" title="权益余额">
123
139
  <second-balance :data="balance.privileges" />
124
140
  </app-drawer>
125
141
  </template>
126
142
 
127
143
  <script lang="ts" setup>
128
- import Taro, { useDidShow } from '@tarojs/taro'
129
- import { computed, onMounted, reactive, ref, watch } from 'vue'
130
- import { endpoints, useHttp } from '../api'
131
- import { 账户流水筛选项, Balance, ConsumptionGroup, 账户流水 } from '../types'
132
- import ConsumptionFilter from './ConsumptionFilter.vue'
133
- import DateFilter from './DateFilter.vue'
134
- import ConsumptionRules from './ConsumptionRules.vue'
135
- import { AppDrawer, PageHeader, WithPaging } from '../../shared'
136
- import SecondBalance from './SecondBalance.vue'
137
- import dayjs from 'dayjs'
138
- import EmptyView from '../../shared/components/EmptyView.vue'
139
- import { useSafeArea } from '../../shared'
140
-
141
- const safeArea = useSafeArea()
142
-
143
- const refreshing = ref(false)
144
+ import Taro, { useDidShow } from "@tarojs/taro";
145
+ import { computed, onMounted, reactive, ref, watch } from "vue";
146
+ import { endpoints, useHttp } from "../api";
147
+ import { 账户流水筛选项, Balance, ConsumptionGroup, 账户流水 } from "../types";
148
+ import ConsumptionFilter from "./ConsumptionFilter.vue";
149
+ import DateFilter from "./DateFilter.vue";
150
+ import ConsumptionRules from "./ConsumptionRules.vue";
151
+ import { AppDrawer, PageHeader, WithPaging } from "../../shared";
152
+ import SecondBalance from "./SecondBalance.vue";
153
+ import dayjs from "dayjs";
154
+ import EmptyView from "../../shared/components/EmptyView.vue";
155
+ import { useSafeArea } from "../../shared";
156
+
157
+ const safeArea = useSafeArea();
158
+
159
+ const refreshing = ref(false);
144
160
 
145
161
  type AccountViewProps = {
146
- app: string
147
- }
148
- const props = withDefaults(
149
- defineProps<AccountViewProps>(), {
150
- app: ''
151
- }
152
- )
162
+ app: string;
163
+ };
164
+ const props = withDefaults(defineProps<AccountViewProps>(), {
165
+ app: "",
166
+ });
153
167
 
154
- const emit = defineEmits(['recharge'])
168
+ const emit = defineEmits(["recharge"]);
155
169
 
156
- const filterOpen = ref<boolean>(false)
170
+ const filterOpen = ref<boolean>(false);
157
171
 
158
172
  // 规则说明弹窗
159
- const rulesPopupOpen = ref<boolean>(false)
173
+ const rulesPopupOpen = ref<boolean>(false);
160
174
 
161
175
  const filtering = reactive<账户流水筛选项>({
162
- 账户类型: '全部',
163
- 收入还是支出: '全部',
164
- 交易类型: '全部',
165
- 权益类目: '',
166
- dateFrom: '',
167
- dateTo: '',
176
+ 账户类型: "全部",
177
+ 收入还是支出: "全部",
178
+ 交易类型: "全部",
179
+ 权益类目: "",
180
+ dateFrom: "",
181
+ dateTo: "",
168
182
  page: 1,
169
183
  pageSize: 20,
170
- })
184
+ });
171
185
 
172
- const reachedLastPage = ref<boolean>(false)
186
+ const reachedLastPage = ref<boolean>(false);
173
187
 
174
188
  /**
175
189
  * 全新搜索
176
190
  * 重置某些查询条件
177
191
  */
178
- function restartSearch () {
192
+ function restartSearch() {
179
193
  // 从第一页开始
180
- filtering.page = 1
181
- consumptionGroups.value = []
182
- loadConsumptions()
194
+ filtering.page = 1;
195
+ consumptionGroups.value = [];
196
+ loadConsumptions();
183
197
  }
184
198
 
185
199
  // 时间筛选
186
- const datePickerOpen = ref<boolean>(false)
200
+ const datePickerOpen = ref<boolean>(false);
187
201
 
188
- function openDateFilter () {
189
- datePickerOpen.value = true
202
+ function openDateFilter() {
203
+ datePickerOpen.value = true;
190
204
  }
191
205
 
192
206
  const dateRangeDisplay = computed(() => {
193
- let startTime = filtering.dateFrom?.replace(/-/g, '.').substring(2)
194
- let endTime = filtering.dateTo?.replace(/-/g, '.').substring(2)
195
- return startTime + ' - ' + endTime
196
- })
207
+ let startTime = filtering.dateFrom?.replace(/-/g, ".").substring(2);
208
+ let endTime = filtering.dateTo?.replace(/-/g, ".").substring(2);
209
+ return startTime + " - " + endTime;
210
+ });
197
211
 
198
- const consumptionGroups = ref<ConsumptionGroup[]>([])
212
+ const consumptionGroups = ref<ConsumptionGroup[]>([]);
199
213
 
200
214
  /**
201
215
  * 余额数据
202
216
  */
203
217
  const balance = ref<Balance>({
204
218
  total: 0,
205
- privileges: []
206
- })
219
+ privileges: [],
220
+ });
207
221
 
208
222
  useDidShow(() => {
209
223
  Taro.setNavigationBarTitle({
210
- title: '我的账户',
211
- })
212
- loadConsumptions()
213
- loadBalance()
214
- })
224
+ title: "我的账户",
225
+ });
226
+ loadConsumptions();
227
+ loadBalance();
228
+ });
215
229
 
216
- function groupDataByDate (data: 账户流水[]): ConsumptionGroup[] {
230
+ function groupDataByDate(data: 账户流水[]): ConsumptionGroup[] {
217
231
  // 按照日期分组
218
- const groups: ConsumptionGroup[] = consumptionGroups.value || []
232
+ const groups: ConsumptionGroup[] = consumptionGroups.value || [];
219
233
  // [
220
234
  // date: '2023-10-1',
221
235
  // consumptions: []
222
236
  // ]
223
237
  // 组装成按日期分组
224
- data.forEach(d => {
225
- const date = dayjs(d.time).format('YYYY-MM-DD')
226
- let group: ConsumptionGroup | undefined = groups.find(g => g.date === date)
238
+ data.forEach((d) => {
239
+ const date = dayjs(d.time).format("YYYY-MM-DD");
240
+ let group: ConsumptionGroup | undefined = groups.find(
241
+ (g) => g.date === date
242
+ );
227
243
  if (!group) {
228
244
  group = {
229
245
  date,
230
- consumptions: []
231
- }
232
- groups.push(group)
246
+ consumptions: [],
247
+ };
248
+ groups.push(group);
233
249
  }
234
- group.consumptions.push(d)
235
- })
236
- groups.sort((a, b) => a.date > b.date ? -1 : 1)
237
- return groups
250
+ group.consumptions.push(d);
251
+ });
252
+ groups.sort((a, b) => (a.date > b.date ? -1 : 1));
253
+ return groups;
238
254
  }
239
255
 
240
256
  /**
241
257
  * 请求账户流水
242
258
  * @param append 搜索结果累加 上拉分页时
243
259
  */
244
- async function loadConsumptions (append: boolean = false) {
260
+ async function loadConsumptions(append: boolean = false) {
245
261
  if (!append) {
246
- consumptionGroups.value = []
262
+ consumptionGroups.value = [];
247
263
  }
248
- const $http = useHttp()
264
+ const $http = useHttp();
249
265
  Taro.showLoading({
250
266
  title: `加载中...`,
251
267
  mask: true,
252
- })
253
- $http.get<WithPaging<账户流水[]>>(endpoints.获取账户流水, {
268
+ });
269
+ $http
270
+ .get<WithPaging<账户流水[]>>(endpoints.获取账户流水, {
254
271
  app: props.app,
255
- ...filtering
256
- }).then(response => {
257
- consumptionGroups.value = groupDataByDate(response.data)
272
+ ...filtering,
273
+ })
274
+ .then((response) => {
275
+ consumptionGroups.value = groupDataByDate(response.data);
258
276
  if (filtering.page >= response.totalPages) {
259
- filtering.page = response.totalPages
260
- reachedLastPage.value = true
277
+ filtering.page = response.totalPages;
278
+ reachedLastPage.value = true;
261
279
  } else {
262
- reachedLastPage.value = false
280
+ reachedLastPage.value = false;
263
281
  }
264
- Taro.hideLoading()
265
- })
282
+ Taro.hideLoading();
283
+ });
266
284
  }
267
285
 
268
286
  /**
269
287
  * 获取账户余额明细
270
288
  */
271
289
  async function loadBalance() {
272
- const $http = useHttp()
273
- $http.get<Balance>(endpoints.获取余额明细, {
274
- app: props.app,
275
- }).then(data => {
276
- balance.value = data
277
- })
290
+ const $http = useHttp();
291
+ $http
292
+ .get<Balance>(endpoints.获取余额明细, {
293
+ app: props.app,
294
+ })
295
+ .then((data) => {
296
+ balance.value = data;
297
+ });
278
298
  }
279
299
 
280
300
  const onFilterComplete = (value) => {
281
- filtering.账户类型 = value[0]
282
- filtering.收入还是支出 = value[1]
283
- filtering.交易类型 = value[2]
284
- filtering.权益类目 = value[3]
285
- filterOpen.value = false
286
- restartSearch()
287
- }
301
+ filtering.账户类型 = value[0];
302
+ filtering.收入还是支出 = value[1];
303
+ filtering.交易类型 = value[2];
304
+ filtering.权益类目 = value[3];
305
+ filterOpen.value = false;
306
+ restartSearch();
307
+ };
288
308
 
289
309
  const onDateFilterComplete = (value) => {
290
- filtering.dateFrom = value.from
291
- filtering.dateTo = value.to
292
- datePickerOpen.value = false
293
- restartSearch()
294
- }
295
-
296
- function gotoRecharge () {
297
- emit('recharge')
310
+ filtering.dateFrom = value.from;
311
+ filtering.dateTo = value.to;
312
+ datePickerOpen.value = false;
313
+ restartSearch();
314
+ };
315
+
316
+ function gotoRecharge() {
317
+ emit("recharge");
298
318
  }
299
319
 
300
- function loadNextPage () {
301
- filtering.page ++
302
- loadConsumptions(true)
320
+ function loadNextPage() {
321
+ filtering.page++;
322
+ loadConsumptions(true);
303
323
  }
304
324
 
305
325
  // 以下这一大段处理下拉刷新、上滑分页以及弹窗与页面滑动的逻辑
306
- const scrolled = ref<number>(0)
326
+ const scrolled = ref<number>(0);
307
327
 
308
328
  /**
309
329
  * 记录 scroll-view 滚动的位置
310
330
  */
311
331
  const onScroll = (e) => {
312
- const { scrollTop } = e
313
- scrolled.value = scrollTop
314
- }
332
+ const { scrollTop } = e;
333
+ scrolled.value = scrollTop;
334
+ };
315
335
 
316
336
  /**
317
337
  * 下拉刷新 pull down refresh
318
338
  */
319
339
  const onPullDownRefresh = () => {
320
- refreshing.value = true
340
+ refreshing.value = true;
321
341
  // 重新请求余额数据
322
- loadBalance()
342
+ loadBalance();
323
343
  setTimeout(() => {
324
- refreshing.value = false
344
+ refreshing.value = false;
325
345
  }, 500);
326
- }
346
+ };
327
347
 
328
348
  /**
329
349
  * 滑动到底部请求下一页并合并查询结果
330
350
  */
331
351
  const onReachBottom = () => {
332
352
  if (reachedLastPage.value) {
333
- return false
353
+ return false;
334
354
  }
335
- loadNextPage()
336
- }
355
+ loadNextPage();
356
+ };
337
357
 
338
358
  /**
339
359
  * 浮窗弹出时不允许
@@ -341,51 +361,53 @@ const onReachBottom = () => {
341
361
  * 2. 上滑分页
342
362
  */
343
363
  const isAnyPopupOpen = computed(() => {
344
- return rulesPopupOpen.value ||
364
+ return (
365
+ rulesPopupOpen.value ||
345
366
  datePickerOpen.value ||
346
367
  filterOpen.value ||
347
368
  secondBalanceOpen.value
348
- })
369
+ );
370
+ });
349
371
 
350
- const secondBalanceOpen = ref<boolean>(false)
372
+ const secondBalanceOpen = ref<boolean>(false);
351
373
 
352
- function onSecondBalanceButtonClick () {
353
- secondBalanceOpen.value = true
374
+ function onSecondBalanceButtonClick() {
375
+ secondBalanceOpen.value = true;
354
376
  }
355
377
 
356
378
  watch(secondBalanceOpen, () => {
357
379
  Taro.setNavigationBarColor({
358
- frontColor: secondBalanceOpen.value ? '#000000' : '#ffffff',
359
- backgroundColor: '#ffffff',
380
+ frontColor: secondBalanceOpen.value ? "#000000" : "#ffffff",
381
+ backgroundColor: "#ffffff",
360
382
  animation: {
361
383
  duration: 400,
362
- timingFunc: 'easeIn'
363
- }
364
- })
365
- })
384
+ timingFunc: "easeIn",
385
+ },
386
+ });
387
+ });
366
388
 
367
- function onDateReset () {
368
- resetDateRange()
389
+ function onDateReset() {
390
+ resetDateRange();
369
391
  }
370
392
 
371
393
  /**
372
394
  * 充值筛选的起止时间
373
395
  */
374
- function resetDateRange () {
396
+ function resetDateRange() {
375
397
  // 筛选的起止时间
376
- filtering.dateTo = dayjs().format('YYYY-MM-DD')
377
- filtering.dateFrom = dayjs().add(-3, 'M').format('YYYY-MM-DD')
398
+ filtering.dateTo = dayjs().format("YYYY-MM-DD");
399
+ filtering.dateFrom = dayjs().add(-3, "M").format("YYYY-MM-DD");
378
400
  }
379
401
 
380
- function onPageHeaderClose () {
402
+ function onPageHeaderClose() {
381
403
  Taro.navigateBack({
382
- delta: 1
383
- })
404
+ delta: 1,
405
+ });
384
406
  }
385
407
 
386
408
  onMounted(() => {
387
- resetDateRange()
388
- })
409
+ resetDateRange();
410
+ });
389
411
  </script>
390
412
 
391
413
  <style lang="scss">
@@ -397,13 +419,13 @@ onMounted(() => {
397
419
  background-repeat: no-repeat;
398
420
  }
399
421
  .page-header {
400
- background-color: #3B393C;
422
+ background-color: #3b393c;
401
423
  position: sticky;
402
424
  top: 0;
403
425
  z-index: 1;
404
- transition: background-color .3s;
426
+ transition: background-color 0.3s;
405
427
  &.with-background {
406
- background-color: #3B393C;
428
+ background-color: #3b393c;
407
429
  }
408
430
  }
409
431
  &.popupOpen {
@@ -431,7 +453,7 @@ onMounted(() => {
431
453
  display: inline-block;
432
454
  padding: 0 10px;
433
455
  line-height: 22px;
434
- color: #E7CAAD;
456
+ color: #e7caad;
435
457
  font-size: 12px;
436
458
  label {
437
459
  background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEwIDZMMTYgMTJMMTAgMThWNloiIGZpbGw9IiNFN0NBQUQiIHN0cm9rZT0iI0U3Q0FBRCIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPgo=");
@@ -443,7 +465,7 @@ onMounted(() => {
443
465
  }
444
466
  .balance {
445
467
  border-radius: 15px;
446
- background: linear-gradient(105deg, #F4E2CE 1.88%, #DEBB9B 98.18%);
468
+ background: linear-gradient(105deg, #f4e2ce 1.88%, #debb9b 98.18%);
447
469
  box-shadow: 0px -10px 9px -3px rgba(0, 0, 0, 0.33);
448
470
  height: 112px;
449
471
  padding: 20px;
@@ -491,11 +513,7 @@ onMounted(() => {
491
513
  padding: 0 20px;
492
514
  height: 32px;
493
515
  line-height: 32px;
494
- background: linear-gradient(
495
- 187.18deg,
496
- #353535 10.04%,
497
- #433f46 90.21%
498
- );
516
+ background: linear-gradient(187.18deg, #353535 10.04%, #433f46 90.21%);
499
517
  border-radius: 16px;
500
518
  color: #e7caad;
501
519
  font-size: 15px;
@@ -507,9 +525,9 @@ onMounted(() => {
507
525
  background: #fff;
508
526
  position: sticky;
509
527
  z-index: 10;
510
- transition: box-shadow .3s;
528
+ transition: box-shadow 0.3s;
511
529
  &.with-shadow {
512
- box-shadow: 0px 1px 10px 0px #99999933
530
+ box-shadow: 0px 1px 10px 0px #99999933;
513
531
  }
514
532
  .text {
515
533
  color: #353535;
@@ -562,7 +580,7 @@ onMounted(() => {
562
580
  }
563
581
  .item {
564
582
  border-radius: 5px;
565
- background: rgba(255, 255, 255, 0.50);
583
+ background: rgba(255, 255, 255, 0.5);
566
584
  box-shadow: 0px 2.5px 9.5px 2px rgba(0, 0, 0, 0.05);
567
585
  border-radius: 5px;
568
586
  padding: 12px 10px;