File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626
2727TDesign 零售模版示例小程序采用 [ 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. 业务介绍
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { fetchCouponList } from '../../../services/coupon/index';
22
33Page ( {
44 data : {
5+ pullDownRefreshing : false ,
56 status : 0 ,
67 list : [
78 {
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 } ,
Original file line number Diff line number Diff line change 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-
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const TitleConfig = {
1010
1111Page ( {
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 ( ) {
Original file line number Diff line number Diff line change 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 <!-- 状态及描述 -->
Original file line number Diff line number Diff line change 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
7473 this . setData ( {
7574 pullDownRefreshing : false ,
7675 } ) ;
77- callback && callback ( ) ;
7876 } )
7977 . catch ( ( err ) => {
8078 this . setData ( {
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { getAddressPromise } from '../../../services/address/list';
66
77Page ( {
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 ( ) {
Original file line number Diff line number Diff line change 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">
Original file line number Diff line number Diff 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 } ) ;
You can’t perform that action at this time.
0 commit comments