From f279f4c00d0c82b03f2f2de8dcc12a4b5c39c1c5 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Tue, 9 Jan 2024 14:00:58 +0800 Subject: [PATCH] 积分充值的链接的优化 --- packageD/pages/user/integral/integral.js | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------ packageD/pages/user/integral/integral.json | 4 +++- packageD/pages/user/integral/integral.wxml | 11 ++++++++++- packageD/pages/user/integral/integral.wxss | 9 ++++++++- 4 files changed, 143 insertions(+), 45 deletions(-) diff --git a/packageD/pages/user/integral/integral.js b/packageD/pages/user/integral/integral.js index 5525f1b..d8609c6 100644 --- a/packageD/pages/user/integral/integral.js +++ b/packageD/pages/user/integral/integral.js @@ -34,27 +34,60 @@ Page({ iurl: o.imghost, is_show_jfcz:0, + tab:0, + is_no_more_e:0, //充值使用 + current_page_e:0, //充值使 + is_loading:0, //避免重复request请求 + is_loading_c:0 //避免重复request请求 }, /** * 刷出积分劵 */ async exchange() { - var e = this, result; + + if (this.data.is_no_more_e) return; + if (this.data.is_loading_c) return; + this.data.current_page_e++; + this.data.is_loading_c=1; + + var e = this, result=[]; var user_id = getApp().globalData.user_id; var store_id = os.stoid; var get_data = { user_id: user_id, store_id: store_id, - pageSize: 10, page: e.data.current_page + pageSize: 10, page: e.data.current_page_e ///api/weshop/users/listExchangeCoupons }; //api/index/yuck + + wx.showLoading(); await getApp().request.promiseGet("/api/weshop/users/listExchangeCoupons", { data:get_data }).then(res => { - var msg = res.data; - result = msg.data.pageData; + + wx.hideLoading(); + e.data.is_loading_c=0; + if(ut.ajax_ok(res)){ + var msg = res.data; + let result2 = msg.data.pageData; + let arr=e.data.result; + result = arr.concat(result2); + + //-- 显示没有更多的优化 -- + if (msg.data.total <=10*e.data.current_page_e) { + e.setData({ + is_no_more_e: 1 + }) + } + + }else{ + e.setData({ + is_no_more_e: 1 + }) + } + }) e.setData({ - result: result + result: result,is_get_c:1 }) }, @@ -63,36 +96,57 @@ Page({ */ async detaileds() { if (this.data.is_no_more) return; + if (this.data.is_loading) return; this.data.current_page++; + this.data.is_loading=1; + var e = this, details; var user_id = getApp().globalData.user_id; var store_id = os.stoid; var get_data = { user_id: user_id, store_id: store_id, - pageSize: 10, page: e.data.current_page + pageSize: 15, page: e.data.current_page }; var big_arr = this.data.details; + + wx.showLoading(); + await getApp().request.promiseGet("/api/weshop/users/listPoints", { data: get_data }).then(res => { - var msg = res.data; - if(!msg || !msg.data.pageData || msg.data.pageData.length == 0){ - this.data.is_no_more = 1; - getApp().showWarning("未找更多数据"); - return false; + wx.hideLoading(); + e.data.is_loading=0; + + if(ut.ajax_ok(res)){ + var msg = res.data; + + details = msg.data.pageData; + details.forEach(function (val, ind) { + big_arr.push(val); + }) + + //-- 显示没有更多的优化 -- + if (msg.data.total <=15*e.data.current_page) { + e.setData({ + is_no_more: 1 + }) + } + }else{ + e.setData({ + is_no_more: 1 + }) } - details = msg.data.pageData; - details.forEach(function (val, ind) { - big_arr.push(val); - }) - setTimeout(() => { - this.setData({ - details: big_arr - }); - }, 1500) + + }) + + + this.setData({ + details: big_arr,is_get_d:1 + }); + var get_datas= { user_id: user_id, store_id: store_id, }; @@ -105,11 +159,18 @@ Page({ this.setData({number: integrals}) }) + + }, //---加载更多是靠这个函数---- onReachBottom: function () { - console.log("加载跟多"); - this.detaileds(); + //0是积分明细 1是积分充值 + if(this.data.currentTab==0){ + this.detaileds(); + }else{ + this.exchange(); + } + }, //积分弹框控制器 @@ -180,14 +241,14 @@ Page({ console.log("积分明细", e.target.dataset.current); var jfmx=true; var jfcz= false; - this.setData({ jfmx: jfmx, jfcz: jfcz, current_page: 0,details:[] }); + this.setData({ jfmx: jfmx, jfcz: jfcz, current_page: 0,details:[],is_get_d:0,is_no_more:0 }); this.detaileds(); }else{ if(this.data.is_show_jfcz) { console.log("积分充值", e.target.dataset.current); var jfmx = false; var jfcz = true; - this.setData({jfmx: jfmx, jfcz: jfcz, current_page:1,result:[] }); + this.setData({jfmx: jfmx, jfcz: jfcz, current_page_e:0,result:[],is_get_c:0,is_no_more_e:0}); this.exchange(); }else{ return false; @@ -211,19 +272,25 @@ Page({ //定义第一次进入 this.data.fir_in=1; - var th=this; - getApp().request.get("/api/wx/weappSendlist/page", { - data: { - store_id: os.stoid, - typeid: "1002" - }, - success: function(res) { - if (res.data.code == 0 && res.data.data.pageData.length > 0) { - var template_id = res.data.data.pageData[0].template_id; - th.setData({template_id:template_id}); - } - } - }); + var th=this; + getApp().request.get("/api/wx/weappSendlist/page", { + data: { + store_id: os.stoid, + typeid: "1002" + }, + success: function(res) { + if (res.data.code == 0 && res.data.data.pageData.length > 0) { + var template_id = res.data.data.pageData[0].template_id; + th.setData({template_id:template_id}); + } + } + }); + + if(options.tab==1){ + th.data.tab=1; + } + + }, @@ -380,18 +447,31 @@ Page({ return false; } - this.exchange(); - this.detaileds(); wx.setNavigationBarTitle({ title: "我的积分", }) + + if(this.data.has_init) return false; + this.data.has_init=1; + + this.detaileds(); + //要实时获取开关是显示 - var th=this; - getApp().getConfig2(function(ee){ + getApp().getConfig2(function(ee){ var json_d = JSON.parse(ee.switch_list); th.setData({ is_show_jfcz: json_d.jfcz_switch }); - },1) + //-- 如果有开启积分充值,就调用积分充值的界面 -- + if(json_d.jfcz_switch && th.data.tab==1 ){ + th.data.tab=0; + var jfmx = false; + var jfcz = true; + th.setData({jfmx: jfmx, jfcz: jfcz, current_page_e:0,result:[],currentTab:1 }); + th.exchange(); + + } + + },1) }, diff --git a/packageD/pages/user/integral/integral.json b/packageD/pages/user/integral/integral.json index 8835af0..52632af 100644 --- a/packageD/pages/user/integral/integral.json +++ b/packageD/pages/user/integral/integral.json @@ -1,3 +1,5 @@ { - "usingComponents": {} + "usingComponents": { + "nodata": "/components/nodata/nodata" + } } \ No newline at end of file diff --git a/packageD/pages/user/integral/integral.wxml b/packageD/pages/user/integral/integral.wxml index e980d75..2a05695 100644 --- a/packageD/pages/user/integral/integral.wxml +++ b/packageD/pages/user/integral/integral.wxml @@ -30,7 +30,7 @@ - + @@ -45,6 +45,11 @@ + + + + —— 已经到底了 —— + @@ -63,6 +68,10 @@ + + + —— 已经到底了 —— + diff --git a/packageD/pages/user/integral/integral.wxss b/packageD/pages/user/integral/integral.wxss index 9fec40e..d3694ab 100644 --- a/packageD/pages/user/integral/integral.wxss +++ b/packageD/pages/user/integral/integral.wxss @@ -466,4 +466,11 @@ line-height:85rpx; .gd{ color: #999999; font-size: 25rpx; -} \ No newline at end of file +} + + .noMore { + padding: 20rpx; + color: #bbb; + text-align: center; + font-size: 22rpx; + } \ No newline at end of file -- libgit2 0.21.4