From a0e2b994607be1479a0ea719fe21e50d1d18fb58 Mon Sep 17 00:00:00 2001 From: "liujw155@outlook.com" Date: Wed, 7 Jul 2021 14:59:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../write_off/search_result/search_result.vue | 62 ++++++++++++---------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/pages/write_off/search_result/search_result.vue b/src/pages/write_off/search_result/search_result.vue index f8be054..b3391c6 100644 --- a/src/pages/write_off/search_result/search_result.vue +++ b/src/pages/write_off/search_result/search_result.vue @@ -61,51 +61,54 @@ export default { curStadium: {}, // 当前店铺 writeOffList: [], // 核销列表, curDate: util.formatDate({}), + page: 1, } }, + onReachBottom(){ + let { page, curDate, curStadium } = this; + this.getList({ + brand_id: curStadium.brand_id || '', + stadium_id: curStadium.id || '', + date: curDate || '', + page: ++page, + }); + }, onLoad(){ this.initPage(); }, onShow(){ - let { curStadium, curDate } = this; - if(curStadium&&curStadium.id)this.getList({ - brand_id: curStadium.brand_id || '', - stadium_id: curStadium.id, - date: curDate, - }); + let { curStadium } = this; + if(curStadium&&curStadium.id)this.refreshList(); }, methods: { - dateChange(e){ - let { curStadium } = this; - this.curDate = e.detail.value; + refreshList(){ + let { curDate, curStadium } = this; + this.page = 1; + this.writeOffList = []; this.getList({ brand_id: curStadium.brand_id || '', - stadium_id: curStadium.id, - date: e.detail.value, + stadium_id: curStadium.id || '', + date: curDate || '', }); }, + + dateChange(e){ + this.curDate = e.detail.value; + this.$nextTick(this.refreshList); + }, stadiumChange(e){ - let { stadiumList, curDate } = this; + let { stadiumList } = this; this.curStadium = stadiumList[e.detail.value]; - - this.getList({ - brand_id: stadiumList[e.detail.value].brand_id || '', - stadium_id: stadiumList[e.detail.value].id, - date: curDate, - }); + this.$nextTick(this.refreshList); }, + async initPage(){ let { brandInfo } = this; try{ let _storeList = await this.getStoreList({ brand_id: brandInfo.brand.id || '' }); this.stadiumList = _storeList || []; if(_storeList.length) this.curStadium = _storeList[0]; - console.warn(util.formatDate({})) - this.getList({ - brand_id: brandInfo.brand.id || '', - stadium_id: _storeList[0].id, - date: util.formatDate({}), - }); + this.$nextTick(this.refreshList); }catch(err){ console.warn('加载数据失败!', err); } @@ -118,18 +121,21 @@ export default { }) util.routeTo(`/pages/write_off/operate/operate`, 'nT'); }, - getList({ brand_id, stadium_id = '', date = '' }){ + getList({ brand_id, stadium_id = '', date = '', page = 1, page_size = 15 }){ util.showLoad(); servers.get({ url: API.writeOff.listVerifyRecord, - data: { brand_id, stadium_id, date }, + data: { brand_id, stadium_id, date, page, page_size }, failMsg: '加载失败!', }) .then(res=>{ util.hideLoad(); let _list = res.list || []; - this.writeOffList = _list; - console.warn(res, 'jijjjjjjjjj') + if(page == 1)return this.writeOffList = _list; + if(!_list.length)return util.showNone('没有更多!'); + this.page = page; + this.writeOffList = [...this.writeOffList, ..._list]; + }) }, getStoreList({