Browse Source

优化扫码轮询

master
邓平艺 4 years ago
parent
commit
269d711e17
  1. 35
      pages/user/member/code.vue

35
pages/user/member/code.vue

@ -63,7 +63,9 @@
centerInfo: {balance: 0}, centerInfo: {balance: 0},
show_code: false, show_code: false,
show_code_count: 0, show_code_count: 0,
show_count: 0
show_count: 0,
is_scan_code: false,
first_http: 0
} }
}, },
onLoad(){ onLoad(){
@ -72,7 +74,14 @@
this.getIsSetPayPwd(); this.getIsSetPayPwd();
this.getMeInfo(); this.getMeInfo();
this.getUcenter(); this.getUcenter();
},
onShow(){
this.show_count++;
if(this.show_count > 1){
this.first_http = 0;
this.is_scan_code = false;
this.getIsSetPayPwd();
}
// //
uni.getScreenBrightness({ uni.getScreenBrightness({
success: (res) => { success: (res) => {
@ -84,20 +93,16 @@
} }
}) })
}, },
onShow(){
this.show_count++;
if(this.show_count > 1){
this.getIsSetPayPwd();
}
onHide(){
uni.setScreenBrightness({
value: this.brightness
})
}, },
onUnload(){ onUnload(){
if(this.timer){ if(this.timer){
clearInterval(this.timer); clearInterval(this.timer);
this.timer = null; this.timer = null;
} }
uni.setScreenBrightness({
value: this.brightness
})
}, },
methods: { methods: {
// //
@ -187,10 +192,11 @@
}) })
} }
} }
this.first_http++;
this.$http.get({ this.$http.get({
api: 'api/offline/get_pay', api: 'api/offline/get_pay',
data: { data: {
refresh: 0
refresh: this.first_http <= 1 ? 1 : 0
}, },
header: { header: {
Authorization: this.token Authorization: this.token
@ -219,8 +225,15 @@
url += `?clerk_id=${clerk_id}`; url += `?clerk_id=${clerk_id}`;
url += `&brand_id=${brand_id}`; url += `&brand_id=${brand_id}`;
url += `&amount=${amount}`; url += `&amount=${amount}`;
if(this.timer){
clearInterval(this.timer);
this.timer = null;
}
if(!this.is_scan_code){
this.$url(url); this.$url(url);
} }
this.is_scan_code = true;
}
} }
if(!options.silence){ if(!options.silence){
uni.hideLoading(); uni.hideLoading();

Loading…
Cancel
Save