Commit 5fe46b707d0a11d9b29d4d7c59ae3b046fbbc75c

Authored by 刘淇
1 parent e0afa52e

卡券购买回到上一页面刷新页面

pages/businessCard/businessCard.vue
@@ -47,6 +47,7 @@ export default { @@ -47,6 +47,7 @@ export default {
47 pageSize: 10,//每页条数 47 pageSize: 10,//每页条数
48 totalPages: '1', // 总条数 48 totalPages: '1', // 总条数
49 status: 'no-more', 49 status: 'no-more',
  50 + refreshIfNeeded: false,
50 } 51 }
51 }, 52 },
52 onLoad(params) { 53 onLoad(params) {
@@ -56,8 +57,24 @@ export default { @@ -56,8 +57,24 @@ export default {
56 this.couponRuleParkPage() 57 this.couponRuleParkPage()
57 }, 58 },
58 onShow() { 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 onPullDownRefresh(val) { 80 onPullDownRefresh(val) {
@@ -97,14 +114,14 @@ export default { @@ -97,14 +114,14 @@ export default {
97 method: 'POST', 114 method: 'POST',
98 data: that.$common.requestSign(paramsData) 115 data: that.$common.requestSign(paramsData)
99 }).then(res => { 116 }).then(res => {
100 - if(res.data.dataList.length>0){ 117 + if (res.data.dataList.length > 0) {
101 if (res.data.pageTotals < 10) { 118 if (res.data.pageTotals < 10) {
102 that.status = 'no-more' 119 that.status = 'no-more'
103 } else { 120 } else {
104 that.status = 'more' 121 that.status = 'more'
105 console.log('more') 122 console.log('more')
106 } 123 }
107 - }else{ 124 + } else {
108 that.status = 'no-more' 125 that.status = 'no-more'
109 } 126 }
110 that.totalPages = res.data.pageTotals; 127 that.totalPages = res.data.pageTotals;
@@ -117,7 +134,6 @@ export default { @@ -117,7 +134,6 @@ export default {
117 uni.navigateTo({ 134 uni.navigateTo({
118 url: '../businessCard/buyCard?optionData=' + JSON.stringify(i) 135 url: '../businessCard/buyCard?optionData=' + JSON.stringify(i)
119 }); 136 });
120 -  
121 }, 137 },
122 printClick(i) { 138 printClick(i) {
123 // uni.navigateTo({ 139 // uni.navigateTo({
@@ -130,20 +146,17 @@ export default { @@ -130,20 +146,17 @@ export default {
130 }); 146 });
131 }, 147 },
132 provideCard(i) { 148 provideCard(i) {
133 -  
134 - if(i.cardNum==0){ 149 + if (i.cardNum == 0) {
135 uni.showToast({ 150 uni.showToast({
136 title: '暂无卡券库存,无法发放', 151 title: '暂无卡券库存,无法发放',
137 icon: 'none', 152 icon: 'none',
138 duration: 2000 153 duration: 2000
139 }); 154 });
140 - }else{ 155 + } else {
141 uni.navigateTo({ 156 uni.navigateTo({
142 url: '../businessCard/provideCard?optionData=' + JSON.stringify(i) 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,8 +167,6 @@ export default {
154 padding-bottom: 10px; 167 padding-bottom: 10px;
155 } 168 }
156 169
157 -  
158 -  
159 .card-actions { 170 .card-actions {
160 display: flex; 171 display: flex;
161 flex-direction: row; 172 flex-direction: row;
pages/businessCard/buyCard.vue
@@ -210,9 +210,11 @@ export default { @@ -210,9 +210,11 @@ export default {
210 duration: 1000 210 duration: 1000
211 }) 211 })
212 setTimeout(()=>{ 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 },1000) 218 },1000)
217 219
218 }) 220 })