Commit f279f4c00d0c82b03f2f2de8dcc12a4b5c39c1c5
1 parent
420105c7
积分充值的链接的优化
Showing
4 changed files
with
143 additions
and
45 deletions
packageD/pages/user/integral/integral.js
| ... | ... | @@ -34,27 +34,60 @@ Page({ |
| 34 | 34 | iurl: o.imghost, |
| 35 | 35 | |
| 36 | 36 | is_show_jfcz:0, |
| 37 | + tab:0, | |
| 38 | + is_no_more_e:0, //充值使用 | |
| 39 | + current_page_e:0, //充值使 | |
| 40 | + is_loading:0, //避免重复request请求 | |
| 41 | + is_loading_c:0 //避免重复request请求 | |
| 37 | 42 | }, |
| 38 | 43 | /** |
| 39 | 44 | * 刷出积分劵 |
| 40 | 45 | */ |
| 41 | 46 | async exchange() { |
| 42 | - var e = this, result; | |
| 47 | + | |
| 48 | + if (this.data.is_no_more_e) return; | |
| 49 | + if (this.data.is_loading_c) return; | |
| 50 | + this.data.current_page_e++; | |
| 51 | + this.data.is_loading_c=1; | |
| 52 | + | |
| 53 | + var e = this, result=[]; | |
| 43 | 54 | var user_id = getApp().globalData.user_id; |
| 44 | 55 | var store_id = os.stoid; |
| 45 | 56 | var get_data = { |
| 46 | 57 | user_id: user_id, store_id: store_id, |
| 47 | - pageSize: 10, page: e.data.current_page | |
| 58 | + pageSize: 10, page: e.data.current_page_e | |
| 48 | 59 | ///api/weshop/users/listExchangeCoupons |
| 49 | 60 | }; //api/index/yuck |
| 61 | + | |
| 62 | + wx.showLoading(); | |
| 50 | 63 | await getApp().request.promiseGet("/api/weshop/users/listExchangeCoupons", { |
| 51 | 64 | data:get_data |
| 52 | 65 | }).then(res => { |
| 53 | - var msg = res.data; | |
| 54 | - result = msg.data.pageData; | |
| 66 | + | |
| 67 | + wx.hideLoading(); | |
| 68 | + e.data.is_loading_c=0; | |
| 69 | + if(ut.ajax_ok(res)){ | |
| 70 | + var msg = res.data; | |
| 71 | + let result2 = msg.data.pageData; | |
| 72 | + let arr=e.data.result; | |
| 73 | + result = arr.concat(result2); | |
| 74 | + | |
| 75 | + //-- 显示没有更多的优化 -- | |
| 76 | + if (msg.data.total <=10*e.data.current_page_e) { | |
| 77 | + e.setData({ | |
| 78 | + is_no_more_e: 1 | |
| 79 | + }) | |
| 80 | + } | |
| 81 | + | |
| 82 | + }else{ | |
| 83 | + e.setData({ | |
| 84 | + is_no_more_e: 1 | |
| 85 | + }) | |
| 86 | + } | |
| 87 | + | |
| 55 | 88 | }) |
| 56 | 89 | e.setData({ |
| 57 | - result: result | |
| 90 | + result: result,is_get_c:1 | |
| 58 | 91 | }) |
| 59 | 92 | |
| 60 | 93 | }, |
| ... | ... | @@ -63,36 +96,57 @@ Page({ |
| 63 | 96 | */ |
| 64 | 97 | async detaileds() { |
| 65 | 98 | if (this.data.is_no_more) return; |
| 99 | + if (this.data.is_loading) return; | |
| 66 | 100 | this.data.current_page++; |
| 101 | + this.data.is_loading=1; | |
| 102 | + | |
| 67 | 103 | var e = this, details; |
| 68 | 104 | var user_id = getApp().globalData.user_id; |
| 69 | 105 | var store_id = os.stoid; |
| 70 | 106 | var get_data = { |
| 71 | 107 | user_id: user_id, store_id: store_id, |
| 72 | - pageSize: 10, page: e.data.current_page | |
| 108 | + pageSize: 15, page: e.data.current_page | |
| 73 | 109 | }; |
| 74 | 110 | var big_arr = this.data.details; |
| 111 | + | |
| 112 | + wx.showLoading(); | |
| 113 | + | |
| 75 | 114 | await getApp().request.promiseGet("/api/weshop/users/listPoints", { |
| 76 | 115 | data: get_data |
| 77 | 116 | }).then(res => { |
| 78 | 117 | |
| 79 | - var msg = res.data; | |
| 80 | - if(!msg || !msg.data.pageData || msg.data.pageData.length == 0){ | |
| 81 | - this.data.is_no_more = 1; | |
| 82 | - getApp().showWarning("未找更多数据"); | |
| 83 | - return false; | |
| 118 | + wx.hideLoading(); | |
| 119 | + e.data.is_loading=0; | |
| 120 | + | |
| 121 | + if(ut.ajax_ok(res)){ | |
| 122 | + var msg = res.data; | |
| 123 | + | |
| 124 | + details = msg.data.pageData; | |
| 125 | + details.forEach(function (val, ind) { | |
| 126 | + big_arr.push(val); | |
| 127 | + }) | |
| 128 | + | |
| 129 | + //-- 显示没有更多的优化 -- | |
| 130 | + if (msg.data.total <=15*e.data.current_page) { | |
| 131 | + e.setData({ | |
| 132 | + is_no_more: 1 | |
| 133 | + }) | |
| 134 | + } | |
| 135 | + }else{ | |
| 136 | + e.setData({ | |
| 137 | + is_no_more: 1 | |
| 138 | + }) | |
| 84 | 139 | } |
| 85 | 140 | |
| 86 | - details = msg.data.pageData; | |
| 87 | - details.forEach(function (val, ind) { | |
| 88 | - big_arr.push(val); | |
| 89 | - }) | |
| 90 | - setTimeout(() => { | |
| 91 | - this.setData({ | |
| 92 | - details: big_arr | |
| 93 | - }); | |
| 94 | - }, 1500) | |
| 141 | + | |
| 142 | + | |
| 95 | 143 | }) |
| 144 | + | |
| 145 | + | |
| 146 | + this.setData({ | |
| 147 | + details: big_arr,is_get_d:1 | |
| 148 | + }); | |
| 149 | + | |
| 96 | 150 | var get_datas= { |
| 97 | 151 | user_id: user_id, store_id: store_id, |
| 98 | 152 | }; |
| ... | ... | @@ -105,11 +159,18 @@ Page({ |
| 105 | 159 | this.setData({number: integrals}) |
| 106 | 160 | }) |
| 107 | 161 | |
| 162 | + | |
| 163 | + | |
| 108 | 164 | }, |
| 109 | 165 | //---加载更多是靠这个函数---- |
| 110 | 166 | onReachBottom: function () { |
| 111 | - console.log("加载跟多"); | |
| 112 | - this.detaileds(); | |
| 167 | + //0是积分明细 1是积分充值 | |
| 168 | + if(this.data.currentTab==0){ | |
| 169 | + this.detaileds(); | |
| 170 | + }else{ | |
| 171 | + this.exchange(); | |
| 172 | + } | |
| 173 | + | |
| 113 | 174 | |
| 114 | 175 | }, |
| 115 | 176 | //积分弹框控制器 |
| ... | ... | @@ -180,14 +241,14 @@ Page({ |
| 180 | 241 | console.log("积分明细", e.target.dataset.current); |
| 181 | 242 | var jfmx=true; |
| 182 | 243 | var jfcz= false; |
| 183 | - this.setData({ jfmx: jfmx, jfcz: jfcz, current_page: 0,details:[] }); | |
| 244 | + this.setData({ jfmx: jfmx, jfcz: jfcz, current_page: 0,details:[],is_get_d:0,is_no_more:0 }); | |
| 184 | 245 | this.detaileds(); |
| 185 | 246 | }else{ |
| 186 | 247 | if(this.data.is_show_jfcz) { |
| 187 | 248 | console.log("积分充值", e.target.dataset.current); |
| 188 | 249 | var jfmx = false; |
| 189 | 250 | var jfcz = true; |
| 190 | - this.setData({jfmx: jfmx, jfcz: jfcz, current_page:1,result:[] }); | |
| 251 | + this.setData({jfmx: jfmx, jfcz: jfcz, current_page_e:0,result:[],is_get_c:0,is_no_more_e:0}); | |
| 191 | 252 | this.exchange(); |
| 192 | 253 | }else{ |
| 193 | 254 | return false; |
| ... | ... | @@ -211,19 +272,25 @@ Page({ |
| 211 | 272 | //定义第一次进入 |
| 212 | 273 | this.data.fir_in=1; |
| 213 | 274 | |
| 214 | - var th=this; | |
| 215 | - getApp().request.get("/api/wx/weappSendlist/page", { | |
| 216 | - data: { | |
| 217 | - store_id: os.stoid, | |
| 218 | - typeid: "1002" | |
| 219 | - }, | |
| 220 | - success: function(res) { | |
| 221 | - if (res.data.code == 0 && res.data.data.pageData.length > 0) { | |
| 222 | - var template_id = res.data.data.pageData[0].template_id; | |
| 223 | - th.setData({template_id:template_id}); | |
| 224 | - } | |
| 225 | - } | |
| 226 | - }); | |
| 275 | + var th=this; | |
| 276 | + getApp().request.get("/api/wx/weappSendlist/page", { | |
| 277 | + data: { | |
| 278 | + store_id: os.stoid, | |
| 279 | + typeid: "1002" | |
| 280 | + }, | |
| 281 | + success: function(res) { | |
| 282 | + if (res.data.code == 0 && res.data.data.pageData.length > 0) { | |
| 283 | + var template_id = res.data.data.pageData[0].template_id; | |
| 284 | + th.setData({template_id:template_id}); | |
| 285 | + } | |
| 286 | + } | |
| 287 | + }); | |
| 288 | + | |
| 289 | + if(options.tab==1){ | |
| 290 | + th.data.tab=1; | |
| 291 | + } | |
| 292 | + | |
| 293 | + | |
| 227 | 294 | |
| 228 | 295 | |
| 229 | 296 | }, |
| ... | ... | @@ -380,18 +447,31 @@ Page({ |
| 380 | 447 | return false; |
| 381 | 448 | } |
| 382 | 449 | |
| 383 | - this.exchange(); | |
| 384 | - this.detaileds(); | |
| 385 | 450 | wx.setNavigationBarTitle({ |
| 386 | 451 | title: "我的积分", |
| 387 | 452 | }) |
| 388 | 453 | |
| 454 | + | |
| 455 | + if(this.data.has_init) return false; | |
| 456 | + this.data.has_init=1; | |
| 457 | + | |
| 458 | + this.detaileds(); | |
| 459 | + | |
| 389 | 460 | //要实时获取开关是显示 |
| 390 | - var th=this; | |
| 391 | - getApp().getConfig2(function(ee){ | |
| 461 | + getApp().getConfig2(function(ee){ | |
| 392 | 462 | var json_d = JSON.parse(ee.switch_list); |
| 393 | 463 | th.setData({ is_show_jfcz: json_d.jfcz_switch }); |
| 394 | - },1) | |
| 464 | + //-- 如果有开启积分充值,就调用积分充值的界面 -- | |
| 465 | + if(json_d.jfcz_switch && th.data.tab==1 ){ | |
| 466 | + th.data.tab=0; | |
| 467 | + var jfmx = false; | |
| 468 | + var jfcz = true; | |
| 469 | + th.setData({jfmx: jfmx, jfcz: jfcz, current_page_e:0,result:[],currentTab:1 }); | |
| 470 | + th.exchange(); | |
| 471 | + | |
| 472 | + } | |
| 473 | + | |
| 474 | + },1) | |
| 395 | 475 | |
| 396 | 476 | }, |
| 397 | 477 | ... | ... |
packageD/pages/user/integral/integral.json
packageD/pages/user/integral/integral.wxml
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | </view> |
| 31 | 31 | |
| 32 | 32 | </view> |
| 33 | - <view wx:if="{{details}}!=[]"> | |
| 33 | + <view wx:if="{{details}}"> | |
| 34 | 34 | <block wx:for="{{details}}" wx:for-index="idx" wx:for-item="details"> |
| 35 | 35 | <view class="data"> |
| 36 | 36 | <view class="left"> |
| ... | ... | @@ -45,6 +45,11 @@ |
| 45 | 45 | </block> |
| 46 | 46 | |
| 47 | 47 | </view> |
| 48 | + | |
| 49 | + <!-- 暂无数据 --> | |
| 50 | + <nodata nodataContainer="t-c" wx:if="{{(is_get_d && details.length == 0)}}"></nodata> | |
| 51 | + <view class="noMore" wx:if="{{is_no_more == 1 && details.length>0}}">—— 已经到底了 ——</view> | |
| 52 | + | |
| 48 | 53 | </view> |
| 49 | 54 | |
| 50 | 55 | <!-- 充值 --> |
| ... | ... | @@ -63,6 +68,10 @@ |
| 63 | 68 | </view> |
| 64 | 69 | </block> |
| 65 | 70 | |
| 71 | + <!-- 暂无数据 --> | |
| 72 | + <nodata nodataContainer="t-c" wx:if="{{is_get_c && result.length == 0}}"></nodata> | |
| 73 | + <view class="noMore" wx:if="{{is_no_more_e == 1 && result.length>0}}">—— 已经到底了 ——</view> | |
| 74 | + | |
| 66 | 75 | |
| 67 | 76 | <!-- 积分劵的弹框 --> |
| 68 | 77 | <view class="mask" catchtouchmove="preventTouchMove" wx:if="{{showModal}}"></view> | ... | ... |
packageD/pages/user/integral/integral.wxss
| ... | ... | @@ -466,4 +466,11 @@ line-height:85rpx; |
| 466 | 466 | .gd{ |
| 467 | 467 | color: #999999; |
| 468 | 468 | font-size: 25rpx; |
| 469 | -} | |
| 470 | 469 | \ No newline at end of file |
| 470 | +} | |
| 471 | + | |
| 472 | + .noMore { | |
| 473 | + padding: 20rpx; | |
| 474 | + color: #bbb; | |
| 475 | + text-align: center; | |
| 476 | + font-size: 22rpx; | |
| 477 | + } | |
| 471 | 478 | \ No newline at end of file | ... | ... |