Commit b9ec53859b5141f80b37339cd2ab7e4cd65b0bb5

Authored by chenbiao
1 parent 10ba946f

add 余额明细 刷新下拉分页请求

pages.json
@@ -127,8 +127,10 @@ @@ -127,8 +127,10 @@
127 { 127 {
128 "path": "pages/rechargeDetail/rechargeDetail", 128 "path": "pages/rechargeDetail/rechargeDetail",
129 "style": { 129 "style": {
130 - "navigationBarTitleText": "充值明细" 130 + "navigationBarTitleText": "充值明细",
  131 + "enablePullDownRefresh": true
131 } 132 }
  133 +
132 }, 134 },
133 { 135 {
134 "path": "pages/rechargeDetail/outDetail", 136 "path": "pages/rechargeDetail/outDetail",
pages/rechargeDetail/rechargeDetail.vue
@@ -7,8 +7,7 @@ @@ -7,8 +7,7 @@
7 消费类型 7 消费类型
8 </view> 8 </view>
9 <view class="uni-list-cell-db"> 9 <view class="uni-list-cell-db">
10 - <picker @change="bindPickerChange" :value="index"  
11 - :range="kindArray" :range-key="'kindName'"> 10 + <picker @change="bindPickerChange" :value="index" :range="kindArray" :range-key="'kindName'">
12 <view class="uni-input">{{kindArray[index].kindName}}</view> 11 <view class="uni-input">{{kindArray[index].kindName}}</view>
13 </picker> 12 </picker>
14 </view> 13 </view>
@@ -21,8 +20,7 @@ @@ -21,8 +20,7 @@
21 充值方式 20 充值方式
22 </view> 21 </view>
23 <view class="uni-list-cell-db"> 22 <view class="uni-list-cell-db">
24 - <picker @change="bindPickerChangeWay" :value="indexWay"  
25 - :range="arrayWay" :range-key="'typeName'"> 23 + <picker @change="bindPickerChangeWay" :value="indexWay" :range="arrayWay" :range-key="'typeName'">
26 <view class="uni-input">{{arrayWay[indexWay].typeName}}</view> 24 <view class="uni-input">{{arrayWay[indexWay].typeName}}</view>
27 </picker> 25 </picker>
28 </view> 26 </view>
@@ -58,9 +56,7 @@ @@ -58,9 +56,7 @@
58 56
59 <view class="border-bg"></view> 57 <view class="border-bg"></view>
60 58
61 -  
62 - <uni-load-more class="load" :content-text="contentText" :status="status" :icon-size="24" :iconType="iconType"  
63 - v-if="rows.length == 0"> 59 + <view class="" v-if="orderList.length > 0">
64 60
65 <uni-list class="rechargeWrap"> 61 <uni-list class="rechargeWrap">
66 <view class="recordCon uni-list-cell-pd"> 62 <view class="recordCon uni-list-cell-pd">
@@ -124,8 +120,13 @@ @@ -124,8 +120,13 @@
124 > 120 >
125 </view> 121 </view>
126 </uni-list> 122 </uni-list>
  123 + </view>
  124 + <!-- 底部文案 -->
  125 + <view class="">
  126 + <text>{{status === 'more' ? contentText.contentdown : (status === 'loading' ? contentText.contentrefresh : contentText.contentnomore)}}</text>
  127 + </view>
  128 +
127 129
128 - </uni-load-more>  
129 130
130 131
131 </view> 132 </view>
@@ -138,7 +139,8 @@ @@ -138,7 +139,8 @@
138 format: true 139 format: true
139 }) 140 })
140 return { 141 return {
141 - detailText:'', 142 +
  143 + detailText: '',
142 title: 'picker', 144 title: 'picker',
143 kindArray: [], 145 kindArray: [],
144 arrayWay: [], 146 arrayWay: [],
@@ -146,17 +148,16 @@ @@ -146,17 +148,16 @@
146 indexWay: 0, 148 indexWay: 0,
147 beginDate: currentDate, 149 beginDate: currentDate,
148 overDate: currentDate, 150 overDate: currentDate,
149 - rows: [],  
150 - pageNum: 1, //当前页  
151 - pageSize: 1, //每页条数  
152 - reload: false,  
153 - status: 'more', 151 + orderList: [],
  152 + page: 1,
  153 + pageSize: 10,
  154 + status: 'more', // 默认展示上拉显示更多
154 contentText: { 155 contentText: {
155 - contentdown: '上拉加载更多~',  
156 - contentrefresh: '正在加载更多~',  
157 - contentmore: '我是有底线的~'  
158 - },  
159 - iconType: 'auto', // 图标样式 156 + contentdown: "上拉显示更多",
  157 + contentrefresh: "正在加载...",
  158 + contentnomore: "没有更多数据了"
  159 + }
  160 +
160 } 161 }
161 }, 162 },
162 onLoad(params) { 163 onLoad(params) {
@@ -164,12 +165,56 @@ @@ -164,12 +165,56 @@
164 withShareTicket: true 165 withShareTicket: true
165 }); 166 });
166 this.getKindType(); 167 this.getKindType();
  168 + // 页码归为第1页
  169 + this.page = 1
  170 + // 初始化获取列表数据
  171 + this.fetchData()
167 172
168 }, 173 },
169 onShow() { 174 onShow() {
170 - this.getDetailSummary(); 175 + this.getDetailSummary();
  176 + this.page = 1
  177 + this.pageSize = 10
  178 + this.orderList = []
  179 + this.fetchData()
  180 + },
  181 + // 下拉刷新触发
  182 + onPullDownRefresh(val) {
  183 + this.page = 1
  184 + this.pageSize = 10
  185 + console.log('下拉刷新', val)
  186 + this.fetchData().then(() => {
  187 + uni.stopPullDownRefresh();
  188 + }).catch(err => {
  189 + uni.stopPullDownRefresh();
  190 + // 弹窗提示
  191 + uni.showToast({
  192 + title: '请求出错了',
  193 + icon: 'none'
  194 + })
  195 + })
  196 + },
  197 + // 上拉加载触发
  198 + onReachBottom() {
  199 + // 改变状态为加载中
  200 + this.status = 'loading'
  201 + // 页码发生变化
  202 + ++this.page
  203 + // 加载更多
  204 + this.fetchData('loadMore').then(resArray => {
  205 + // 此时判断当前有没有请求到数据
  206 + if (resArray.length) {
  207 + this.status = 'more'
171 208
  209 + } else {
  210 + this.status = 'noMore';
  211 + --this.page;
  212 + }
  213 + }).catch(err => {
  214 + console.log('网络请求失败')
  215 + })
172 }, 216 },
  217 +
173 computed: { 218 computed: {
174 startDate() { 219 startDate() {
175 return this.getDate('start'); 220 return this.getDate('start');
@@ -198,17 +243,20 @@ @@ -198,17 +243,20 @@
198 let that = this; 243 let that = this;
199 that.index = e.detail.value 244 that.index = e.detail.value
200 that.arrayWay = that.kindArray[that.index].typeList; 245 that.arrayWay = that.kindArray[that.index].typeList;
201 - 246 + that.fetchData()
202 }, 247 },
203 bindPickerChangeWay: function(e) { 248 bindPickerChangeWay: function(e) {
204 console.log('picker发送选择改变,携带值为', e.detail.value) 249 console.log('picker发送选择改变,携带值为', e.detail.value)
205 this.indexWay = e.detail.value 250 this.indexWay = e.detail.value
  251 + that.fetchData()
206 }, 252 },
207 bindStartDateChange: function(e) { 253 bindStartDateChange: function(e) {
208 this.beginDate = e.detail.value 254 this.beginDate = e.detail.value
  255 + that.fetchData()
209 }, 256 },
210 bindEndDateChange: function(e) { 257 bindEndDateChange: function(e) {
211 this.overDate = e.detail.value 258 this.overDate = e.detail.value
  259 + that.fetchData()
212 }, 260 },
213 getDate(type) { 261 getDate(type) {
214 const date = new Date(); 262 const date = new Date();
@@ -224,13 +272,13 @@ @@ -224,13 +272,13 @@
224 day = day > 9 ? day : '0' + day; 272 day = day > 9 ? day : '0' + day;
225 return `${year}-${month}-${day}`; 273 return `${year}-${month}-${day}`;
226 }, 274 },
227 - getDetailSummary(){  
228 - let that=this;  
229 - let data ={ 275 + getDetailSummary() {
  276 + let that = this;
  277 + let data = {
230 kind: '1', 278 kind: '1',
231 type: '1', 279 type: '1',
232 - beginDate:new Date(that.beginDate + " 00:00:00") ,  
233 - endDate:new Date(that.overDate + " 23:59:59") 280 + beginDate: new Date(that.beginDate + " 00:00:00"),
  281 + endDate: new Date(that.overDate + " 23:59:59")
234 }; 282 };
235 console.log(data) 283 console.log(data)
236 that.$myRequest({ 284 that.$myRequest({
@@ -238,21 +286,51 @@ @@ -238,21 +286,51 @@
238 method: 'POST', 286 method: 'POST',
239 data: that.$common.requestSign(data) 287 data: that.$common.requestSign(data)
240 }).then(res => { 288 }).then(res => {
241 - 289 +
242 let data = res.data; 290 let data = res.data;
243 - if(data.rechargeSummary){ 291 + if (data.rechargeSummary) {
244 that.detailText = data.rechargeSummary 292 that.detailText = data.rechargeSummary
245 } 293 }
246 - if(data.paySummary){ 294 + if (data.paySummary) {
247 that.detailText = data.paySummary 295 that.detailText = data.paySummary
248 } 296 }
249 - 297 +
250 }) 298 })
251 -  
252 - }  
253 -  
254 -  
255 - 299 +
  300 + },
  301 +
  302 + fetchData(way) {
  303 + let that = this
  304 + let paramsData = {
  305 + pageNum: that.page,
  306 + pageSize: that.pageSize,
  307 + kind: '1',
  308 + type: '1',
  309 + beginDate: new Date(that.beginDate + " 00:00:00"),
  310 + endDate: new Date(that.overDate + " 23:59:59")
  311 + }
  312 + // 首页信息获取 接口
  313 + that.$myRequest({
  314 + url: that.$common.walletDetailsPage,
  315 + method: 'POST',
  316 + data: that.$common.requestSign(paramsData)
  317 + }).then(res => {
  318 +
  319 + // 当页的数据
  320 + const resDataArray = res.data
  321 + if (way === 'loadMore') {
  322 + that.orderList = that.orderList.concat(resDataArray)
  323 + } else {
  324 + that.orderList = resDataArray
  325 + }
  326 +
  327 + })
  328 +
  329 +
  330 +
  331 +
  332 + },
  333 +
256 } 334 }
257 } 335 }
258 </script> 336 </script>