优化代码

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("获取登陆码失败,请稍后再试"); this.$message.error("获取登陆码失败,请稍后再试");
return return
} }
if (!this.wx_visible) {
return;
}
wxLoginFun(data => { wxLoginFun(data => {
c_count += 1; c_count += 1;
if (c_count > 30) { if (c_count > 30) {

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

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

@ -65,9 +65,9 @@ def call_function_try_attempts(try_attempts=3, sleep_time=2, failed_callback=Non
return decorator 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: 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 count = 1
del kwargs['locker_key'] del kwargs['locker_key']
while True: 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): if expect_func(result, *args, **kwargs):
return True, result return True, result
time.sleep(sleep_time) time.sleep(sleep_time)
if timeout < count * sleep_time: if loop_count < count:
return False, result return False, result
count += 1 count += 1
except Exception as e: except Exception as e:

Loading…
Cancel
Save