Skip to content

Commit e92fe2b

Browse files
authored
Feature/update (#197)
* spell修复 * pull-down-refresh组件用法更新
1 parent d74faae commit e92fe2b

11 files changed

Lines changed: 85 additions & 54 deletions

File tree

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626

2727
TDesign 零售模版示例小程序采用 [TDesign 企业级设计体系小程序解决方案](https://tdesign.tencent.com/miniprogram/overview) 进行搭建,依赖 [TDesign 微信小程序组件库](https://github.com/Tencent/tdesign-miniprogram),涵盖完整的基本零售场景需求。
2828

29-
## :high_brightness: 预览
30-
31-
<p>请使用微信扫描以下二维码:</p>
32-
33-
<img src="https://tdesign.gtimg.com/miniprogram/template/retail/common/qrcode.jpg" width = "200" height = "200" alt="模版小程序二维码" align=center />
34-
3529
## :pushpin: 项目介绍
3630

3731
### 1. 业务介绍

pages/coupon/coupon-list/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { fetchCouponList } from '../../../services/coupon/index';
22

33
Page({
44
data: {
5+
pullDownRefreshing: false,
56
status: 0,
67
list: [
78
{
@@ -48,7 +49,7 @@ Page({
4849
throw new Error(`unknown fetchStatus: ${statusInFetch}`);
4950
}
5051
}
51-
fetchCouponList(statusInFetch).then((couponList) => {
52+
return fetchCouponList(statusInFetch).then((couponList) => {
5253
this.setData({ couponList });
5354
});
5455
},
@@ -68,9 +69,18 @@ Page({
6869
this.setData(
6970
{
7071
couponList: [],
72+
pullDownRefreshing: true,
7173
},
7274
() => {
73-
this.fetchList();
75+
this.fetchList()
76+
.then(() => {
77+
this.setData({ pullDownRefreshing: false });
78+
})
79+
.catch(() => {
80+
this.setData({
81+
pullDownRefreshing: false,
82+
});
83+
});
7484
},
7585
);
7686
},

pages/coupon/coupon-list/index.wxml

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,35 @@
33
bind:change="tabChange"
44
tabList="{{list}}"
55
t-class="tabs-external__inner"
6-
t-class-item="tabs-external__item"
6+
t-class-item="tabs-external__item"
77
t-class-active="tabs-external__active"
88
t-class-track="tabs-external__track"
99
>
10-
<t-tab-panel
11-
wx:for="{{list}}"
12-
wx:for-index="index"
13-
wx:for-item="tab"
14-
wx:key="key"
15-
label="{{tab.text}}"
16-
value="{{tab.key}}"
17-
/>
10+
<t-tab-panel
11+
wx:for="{{list}}"
12+
wx:for-index="index"
13+
wx:for-item="tab"
14+
wx:key="key"
15+
label="{{tab.text}}"
16+
value="{{tab.key}}"
17+
/>
1818
</t-tabs>
1919
<view class="coupon-list-wrap">
20-
<t-pull-down-refresh
21-
t-class-indicator="t-class-indicator"
22-
id="t-pull-down-refresh"
23-
bind:refresh="onPullDownRefresh_"
24-
background="#fff"
25-
>
26-
<view class="coupon-list-item" wx:for="{{couponList}}" wx:key="key">
27-
<coupon-card couponDTO="{{item}}" />
28-
</view>
29-
</t-pull-down-refresh>
30-
<view class="center-entry">
31-
<view class="center-entry-btn" bind:tap="goCouponCenterHandle">
32-
<view>领券中心</view>
33-
<t-icon
34-
name="chevron-right"
35-
color="#fa4126"
36-
size="40rpx"
37-
style="line-height: 28rpx;"
38-
/>
39-
</view>
40-
</view>
20+
<t-pull-down-refresh
21+
t-class-indicator="t-class-indicator"
22+
id="t-pull-down-refresh"
23+
value="{{pullDownRefreshing}}"
24+
bind:refresh="onPullDownRefresh_"
25+
background="#fff"
26+
>
27+
<view class="coupon-list-item" wx:for="{{couponList}}" wx:key="key">
28+
<coupon-card couponDTO="{{item}}" />
29+
</view>
30+
</t-pull-down-refresh>
31+
<view class="center-entry">
32+
<view class="center-entry-btn" bind:tap="goCouponCenterHandle">
33+
<view>领券中心</view>
34+
<t-icon name="chevron-right" color="#fa4126" size="40rpx" style="line-height: 28rpx" />
35+
</view>
36+
</view>
4137
</view>
42-

pages/order/after-service-detail/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const TitleConfig = {
1010

1111
Page({
1212
data: {
13+
pullDownRefreshing: false,
1314
pageLoading: true,
1415
serviceRaw: {},
1516
service: {},
@@ -37,9 +38,18 @@ Page({
3738
},
3839

3940
// 页面刷新,展示下拉刷新
40-
onPullDownRefresh_(e) {
41-
const { callback } = e.detail;
42-
return this.getService().then(() => callback && callback());
41+
onPullDownRefresh_() {
42+
this.setData({ pullDownRefreshing: true }, () => {
43+
this.getService()
44+
.then(() => {
45+
this.setData({ pullDownRefreshing: false });
46+
})
47+
.catch(() => {
48+
this.setData({
49+
pullDownRefreshing: false,
50+
});
51+
});
52+
});
4353
},
4454

4555
init() {

pages/order/after-service-detail/index.wxml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<wr-loading-content position="fixed" type="spinner" wx:if="{{pageLoading}}" />
22
<view class="page-container">
3-
<t-pull-down-refresh id="t-pull-down-refresh" bind:refresh="onPullDownRefresh_" t-class-indicator="t-class-indicator">
3+
<t-pull-down-refresh
4+
id="t-pull-down-refresh"
5+
value="{{pullDownRefreshing}}"
6+
bind:refresh="onPullDownRefresh_"
7+
t-class-indicator="t-class-indicator"
8+
>
49
<!-- 页面内容 -->
510
<view class="service-detail safe-bottom">
611
<!-- 状态及描述 -->

pages/order/after-service-list/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ Page({
6464
this.pullDownRefresh && this.pullDownRefresh.onPageScroll(e);
6565
},
6666

67-
onPullDownRefresh_(e) {
68-
const { callback } = e.detail;
67+
onPullDownRefresh_() {
6968
this.setData({
7069
pullDownRefreshing: true,
7170
}); // 下拉刷新时不显示load-more
@@ -74,7 +73,6 @@ Page({
7473
this.setData({
7574
pullDownRefreshing: false,
7675
});
77-
callback && callback();
7876
})
7977
.catch((err) => {
8078
this.setData({

pages/order/after-service-list/index.wxml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<view class="page-container">
2-
<t-pull-down-refresh id="t-pull-down-refresh" bindrefresh="onPullDownRefresh_" t-class-indicator="t-class-indicator">
2+
<t-pull-down-refresh
3+
id="t-pull-down-refresh"
4+
value="{{pullDownRefreshing}}"
5+
bindrefresh="onPullDownRefresh_"
6+
t-class-indicator="t-class-indicator"
7+
>
38
<wr-order-card
49
wx:for="{{dataList}}"
510
wx:key="id"

pages/order/order-detail/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getAddressPromise } from '../../../services/address/list';
66

77
Page({
88
data: {
9+
pullDownRefreshing: false,
910
pageLoading: true,
1011
order: {}, // 后台返回的原始数据
1112
_order: {}, // 内部使用和提供给 order-card 的数据
@@ -68,9 +69,18 @@ Page({
6869
},
6970

7071
// 页面刷新,展示下拉刷新
71-
onPullDownRefresh_(e) {
72-
const { callback } = e.detail;
73-
return this.getDetail().then(() => callback && callback());
72+
onPullDownRefresh_() {
73+
this.setData({ pullDownRefreshing: true }, () => {
74+
this.getDetail()
75+
.then(() => {
76+
this.setData({ pullDownRefreshing: false });
77+
})
78+
.catch(() => {
79+
this.setData({
80+
pullDownRefreshing: false,
81+
});
82+
});
83+
});
7484
},
7585

7686
getDetail() {

pages/order/order-detail/index.wxml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<t-pull-down-refresh id="t-pull-down-refresh" bindrefresh="onPullDownRefresh_" t-class-indicator="t-class-indicator">
1+
<t-pull-down-refresh
2+
id="t-pull-down-refresh"
3+
value="{{pullDownRefreshing}}"
4+
bindrefresh="onPullDownRefresh_"
5+
t-class-indicator="t-class-indicator"
6+
>
27
<!-- 页面内容 -->
38
<view class="order-detail">
49
<view class="header">

pages/order/order-list/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ Page({
4848
this.pullDownRefresh && this.pullDownRefresh.onPageScroll(e);
4949
},
5050

51-
onPullDownRefresh_(e) {
52-
const { callback } = e.detail;
51+
onPullDownRefresh_() {
5352
this.setData({ pullDownRefreshing: true });
5453
this.refreshList(this.data.curTab)
5554
.then(() => {
5655
this.setData({ pullDownRefreshing: false });
57-
callback && callback();
5856
})
5957
.catch((err) => {
6058
this.setData({ pullDownRefreshing: false });

0 commit comments

Comments
 (0)