From 98fe1d5f61280839f42c6dcc87c07916f98ba005 Mon Sep 17 00:00:00 2001 From: nineven Date: Tue, 1 Mar 2022 21:13:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_client/src/components/FirLogin.vue | 3 +++ fir_client/src/components/user/FirUserOrders.vue | 3 +++ fir_client/src/components/user/FirUserProfileInfo.vue | 9 +++------ fir_ser/common/base/magic.py | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/fir_client/src/components/FirLogin.vue b/fir_client/src/components/FirLogin.vue index 430a520..0476f35 100644 --- a/fir_client/src/components/FirLogin.vue +++ b/fir_client/src/components/FirLogin.vue @@ -144,6 +144,9 @@ export default { this.$message.error("获取登陆码失败,请稍后再试"); return } + if (!this.wx_visible) { + return; + } wxLoginFun(data => { c_count += 1; if (c_count > 30) { diff --git a/fir_client/src/components/user/FirUserOrders.vue b/fir_client/src/components/user/FirUserOrders.vue index f87c130..bb45f1e 100644 --- a/fir_client/src/components/user/FirUserOrders.vue +++ b/fir_client/src/components/user/FirUserOrders.vue @@ -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) { diff --git a/fir_client/src/components/user/FirUserProfileInfo.vue b/fir_client/src/components/user/FirUserProfileInfo.vue index aa17ca7..9287ae0 100644 --- a/fir_client/src/components/user/FirUserProfileInfo.vue +++ b/fir_client/src/components/user/FirUserProfileInfo.vue @@ -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() { diff --git a/fir_ser/common/base/magic.py b/fir_ser/common/base/magic.py index 4b2a228..08e967c 100644 --- a/fir_ser/common/base/magic.py +++ b/fir_ser/common/base/magic.py @@ -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: