Commit 5fe46b707d0a11d9b29d4d7c59ae3b046fbbc75c
1 parent
e0afa52e
卡券购买回到上一页面刷新页面
Showing
2 changed files
with
28 additions
and
15 deletions
pages/businessCard/businessCard.vue
| ... | ... | @@ -47,6 +47,7 @@ export default { |
| 47 | 47 | pageSize: 10,//每页条数 |
| 48 | 48 | totalPages: '1', // 总条数 |
| 49 | 49 | status: 'no-more', |
| 50 | + refreshIfNeeded: false, | |
| 50 | 51 | } |
| 51 | 52 | }, |
| 52 | 53 | onLoad(params) { |
| ... | ... | @@ -56,8 +57,24 @@ export default { |
| 56 | 57 | this.couponRuleParkPage() |
| 57 | 58 | }, |
| 58 | 59 | onShow() { |
| 59 | - var me = this; | |
| 60 | - | |
| 60 | + var pages = getCurrentPages(); // 获取当前页面栈 | |
| 61 | + var currentPage = pages[pages.length - 1]; // 当前页面 | |
| 62 | + if (currentPage.data.refreshIfNeeded) { | |
| 63 | + console.log('show') | |
| 64 | + currentPage.data.refreshIfNeeded = false; | |
| 65 | + this.pageNum = 1//当前页 | |
| 66 | + this.pageSize = 10//每页条数 | |
| 67 | + this.dataList = [] | |
| 68 | + this.status = 'no-more' | |
| 69 | + this.couponRuleParkPage(); // 当前页面 method中的方法,用来刷新当前页面 | |
| 70 | + } | |
| 71 | + }, | |
| 72 | + watch: { | |
| 73 | + // //监听reFresh,如果有修改就执行监听器 | |
| 74 | + // reFresh: function() { | |
| 75 | + // //调接口刷新数据 | |
| 76 | + // this.couponRuleParkPage() | |
| 77 | + // } | |
| 61 | 78 | }, |
| 62 | 79 | // 下拉刷新触发 |
| 63 | 80 | onPullDownRefresh(val) { |
| ... | ... | @@ -97,14 +114,14 @@ export default { |
| 97 | 114 | method: 'POST', |
| 98 | 115 | data: that.$common.requestSign(paramsData) |
| 99 | 116 | }).then(res => { |
| 100 | - if(res.data.dataList.length>0){ | |
| 117 | + if (res.data.dataList.length > 0) { | |
| 101 | 118 | if (res.data.pageTotals < 10) { |
| 102 | 119 | that.status = 'no-more' |
| 103 | 120 | } else { |
| 104 | 121 | that.status = 'more' |
| 105 | 122 | console.log('more') |
| 106 | 123 | } |
| 107 | - }else{ | |
| 124 | + } else { | |
| 108 | 125 | that.status = 'no-more' |
| 109 | 126 | } |
| 110 | 127 | that.totalPages = res.data.pageTotals; |
| ... | ... | @@ -117,7 +134,6 @@ export default { |
| 117 | 134 | uni.navigateTo({ |
| 118 | 135 | url: '../businessCard/buyCard?optionData=' + JSON.stringify(i) |
| 119 | 136 | }); |
| 120 | - | |
| 121 | 137 | }, |
| 122 | 138 | printClick(i) { |
| 123 | 139 | // uni.navigateTo({ |
| ... | ... | @@ -130,20 +146,17 @@ export default { |
| 130 | 146 | }); |
| 131 | 147 | }, |
| 132 | 148 | provideCard(i) { |
| 133 | - | |
| 134 | - if(i.cardNum==0){ | |
| 149 | + if (i.cardNum == 0) { | |
| 135 | 150 | uni.showToast({ |
| 136 | 151 | title: '暂无卡券库存,无法发放', |
| 137 | 152 | icon: 'none', |
| 138 | 153 | duration: 2000 |
| 139 | 154 | }); |
| 140 | - }else{ | |
| 155 | + } else { | |
| 141 | 156 | uni.navigateTo({ |
| 142 | 157 | url: '../businessCard/provideCard?optionData=' + JSON.stringify(i) |
| 143 | 158 | }); |
| 144 | 159 | } |
| 145 | - | |
| 146 | - | |
| 147 | 160 | } |
| 148 | 161 | } |
| 149 | 162 | } |
| ... | ... | @@ -154,8 +167,6 @@ export default { |
| 154 | 167 | padding-bottom: 10px; |
| 155 | 168 | } |
| 156 | 169 | |
| 157 | - | |
| 158 | - | |
| 159 | 170 | .card-actions { |
| 160 | 171 | display: flex; |
| 161 | 172 | flex-direction: row; | ... | ... |
pages/businessCard/buyCard.vue
| ... | ... | @@ -210,9 +210,11 @@ export default { |
| 210 | 210 | duration: 1000 |
| 211 | 211 | }) |
| 212 | 212 | setTimeout(()=>{ |
| 213 | - uni.navigateBack({ | |
| 214 | - delta:1,//返回层数,2则上上页 | |
| 215 | - }) | |
| 213 | + let pages = getCurrentPages(); // 当前页面 | |
| 214 | + let beforePage = pages[pages.length - 2]; // 上一页 | |
| 215 | + beforePage.data.refreshIfNeeded = true; | |
| 216 | + // 返回上一页 delta返回的页面数 如果delta大于现有页面数,则返回首页 | |
| 217 | + uni.navigateBack({ delta: 1 }); | |
| 216 | 218 | },1000) |
| 217 | 219 | |
| 218 | 220 | }) | ... | ... |