diff --git a/pages/businessCard/businessCard.vue b/pages/businessCard/businessCard.vue index c410cf5..d759e25 100644 --- a/pages/businessCard/businessCard.vue +++ b/pages/businessCard/businessCard.vue @@ -47,6 +47,7 @@ export default { pageSize: 10,//每页条数 totalPages: '1', // 总条数 status: 'no-more', + refreshIfNeeded: false, } }, onLoad(params) { @@ -56,8 +57,24 @@ export default { this.couponRuleParkPage() }, onShow() { - var me = this; - + var pages = getCurrentPages(); // 获取当前页面栈 + var currentPage = pages[pages.length - 1]; // 当前页面 + if (currentPage.data.refreshIfNeeded) { + console.log('show') + currentPage.data.refreshIfNeeded = false; + this.pageNum = 1//当前页 + this.pageSize = 10//每页条数 + this.dataList = [] + this.status = 'no-more' + this.couponRuleParkPage(); // 当前页面 method中的方法,用来刷新当前页面 + } + }, + watch: { + // //监听reFresh,如果有修改就执行监听器 + // reFresh: function() { + // //调接口刷新数据 + // this.couponRuleParkPage() + // } }, // 下拉刷新触发 onPullDownRefresh(val) { @@ -97,14 +114,14 @@ export default { method: 'POST', data: that.$common.requestSign(paramsData) }).then(res => { - if(res.data.dataList.length>0){ + if (res.data.dataList.length > 0) { if (res.data.pageTotals < 10) { that.status = 'no-more' } else { that.status = 'more' console.log('more') } - }else{ + } else { that.status = 'no-more' } that.totalPages = res.data.pageTotals; @@ -117,7 +134,6 @@ export default { uni.navigateTo({ url: '../businessCard/buyCard?optionData=' + JSON.stringify(i) }); - }, printClick(i) { // uni.navigateTo({ @@ -130,20 +146,17 @@ export default { }); }, provideCard(i) { - - if(i.cardNum==0){ + if (i.cardNum == 0) { uni.showToast({ title: '暂无卡券库存,无法发放', icon: 'none', duration: 2000 }); - }else{ + } else { uni.navigateTo({ url: '../businessCard/provideCard?optionData=' + JSON.stringify(i) }); } - - } } } @@ -154,8 +167,6 @@ export default { padding-bottom: 10px; } - - .card-actions { display: flex; flex-direction: row; diff --git a/pages/businessCard/buyCard.vue b/pages/businessCard/buyCard.vue index aec2624..ac82670 100644 --- a/pages/businessCard/buyCard.vue +++ b/pages/businessCard/buyCard.vue @@ -210,9 +210,11 @@ export default { duration: 1000 }) setTimeout(()=>{ - uni.navigateBack({ - delta:1,//返回层数,2则上上页 - }) + let pages = getCurrentPages(); // 当前页面 + let beforePage = pages[pages.length - 2]; // 上一页 + beforePage.data.refreshIfNeeded = true; + // 返回上一页 delta返回的页面数 如果delta大于现有页面数,则返回首页 + uni.navigateBack({ delta: 1 }); },1000) })