优化代码

xsign
nineven 3 years ago
parent fb77c251c3
commit 98fe1d5f61
  1. 3
      fir_client/src/components/FirLogin.vue
  2. 3
      fir_client/src/components/user/FirUserOrders.vue
  3. 9
      fir_client/src/components/user/FirUserProfileInfo.vue
  4. 6
      fir_ser/common/base/magic.py

@ -144,6 +144,9 @@ export default {
this.$message.error("获取登陆码失败,请稍后再试");
return
}
if (!this.wx_visible) {
return;
}
wxLoginFun(data => {
c_count += 1;
if (c_count > 30) {

@ -299,6 +299,9 @@ export default {
},
loop_get_order_info(order_number, c_count = 1) {
if (!this.wx_pay) {
return
}
order_sync(data => {
c_count += 1;
if (c_count > 30) {

@ -329,7 +329,6 @@ export default {
form: {},
wx_login_qr_url: '',
wx_visible: false,
loop_flag: false,
show_wx_visible: false,
show_web_visible: false,
qrinfo: {
@ -403,6 +402,9 @@ export default {
this.$message.error("获取登陆码失败,请稍后再试");
return
}
if (!this.wx_visible) {
return;
}
wxLoginFun(data => {
c_count += 1;
if (c_count > 30) {
@ -412,7 +414,6 @@ export default {
if (this.userinfo.uid === data.userinfo.uid) {
this.$message.success("绑定成功");
this.wx_visible = false;
this.loop_flag = false;
}
} else if (data.code === 1005) {
this.$message({
@ -435,18 +436,14 @@ export default {
wxBindFun(data => {
if (data.code === 1000) {
this.wx_login_qr_url = data.data.qr;
this.loop_flag = true;
this.loop_get_wx_info(data.data.ticket);
} else {
this.$message.error(data.msg);
this.wx_visible = false;
this.loop_flag = false;
}
}, {
"methods": "POST",
})
} else {
this.loop_flag = false;
}
},
get_auth_code() {

@ -65,9 +65,9 @@ def call_function_try_attempts(try_attempts=3, sleep_time=2, failed_callback=Non
return decorator
def get_pending_result(func, expect_func, timeout=30, sleep_time=3, *args, **kwargs):
def get_pending_result(func, expect_func, loop_count=10, sleep_time=3, *args, **kwargs):
try:
with cache.lock("%s_%s" % ('get_pending_result', kwargs.get('locker_key')), timeout=timeout + sleep_time):
with cache.lock("%s_%s" % ('get_pending_result', kwargs.get('locker_key')), timeout=loop_count * sleep_time):
count = 1
del kwargs['locker_key']
while True:
@ -75,7 +75,7 @@ def get_pending_result(func, expect_func, timeout=30, sleep_time=3, *args, **kwa
if expect_func(result, *args, **kwargs):
return True, result
time.sleep(sleep_time)
if timeout < count * sleep_time:
if loop_count < count:
return False, result
count += 1
except Exception as e:

Loading…
Cancel
Save