支付宝打开时判断是否初始化增加等待时间
authorp15692025051 <846603105@qq.com>
Fri, 21 Apr 2023 07:22:33 +0000 (15:22 +0800)
committerp15692025051 <846603105@qq.com>
Fri, 21 Apr 2023 07:22:33 +0000 (15:22 +0800)
3.code/1.watch/2.code/appAlipay.py

index b5e25fe..57db3f5 100644 (file)
@@ -79,13 +79,13 @@ class Alipay(Abstract):
         #print("timeout_Alipay1:{}".format(EventMesh.publish(constants.EVENT.GET_CONNECT)))
         time = utime.localtime()
 
-        #if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and self.alipay != None and (self.is_simcard_identify != 0 or time[3] == 0 or time[3] == 12):
-        if self.alipay != None and (self.is_simcard_identify != 0 or time[3] == 0 or time[3] == 12):
+        if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and self.alipay != None and (self.is_simcard_identify != 0 or time[3] == 0 or time[3] == 12):
+        #if self.alipay != None and (self.is_simcard_identify != 0 or time[3] == 0 or time[3] == 12):
             self.is_simcard_identify = self.alipay.start_simcard_identify()
             print("is_simcard_identify:%d"%self.is_simcard_identify)
         
         #if self.is_simcard_identify == 0 and EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and self.is_init != 0:
-        if self.is_simcard_identify == 0  and self.is_init != 0:
+        if self.is_init != 0:
             id2_st = bytearray([0])
             id2_ret = self.alipay.id2_init()
             #print("id2_ret:%d"%id2_ret)
@@ -267,10 +267,17 @@ class Alipay(Abstract):
 
 
     def alipay_1(self, event, msg):
+        for i in range(5) :
+            if self.is_init == 0 :
+                utime.sleep(2)
+            else :
+                break 
+        
         #本地判断是否绑定
         check_bind = self.alipay.check_bind_status()
         check_bind_online = self.alipay.check_bind_status()
         print("check_bind:{} check_bind_online:{}".format(check_bind,check_bind_online))
+        
         if check_bind == 4: #已绑定
            EventMesh.publish("load_screen", {"screen": "alipay_1_1"})
             # if self.is_init == 0 : 
@@ -279,26 +286,14 @@ class Alipay(Abstract):
                 # ret = self.alipay.msg_send(3,args,userdata) #发送获取付款码消息
                 # ret = self.alipay.msg_send(5,args,userdata) #发送获取收款码消息
         elif check_bind == 5: #未绑定
-            #EventMesh.publish("load_screen", {"screen": "alipay_invite"})
-            if self.is_init == 0 :   
-                # bindcode = bytearray(500)
-                # bindcode_len = bytearray([500])
-                # self.alipay.get_bindcode(bindcode,bindcode_len)
-                # print("len:{} qrcode:{}".format(bindcode_len,bindcode))
-                # self.timer_Alipay_check.start(2000, 1, self.timeout_Alipay_check_cb)
-                args = ""
-                userdata = ""
-                print("--000--")
-                ret = self.alipay.msg_send(1,args,userdata) #发送获取绑定码消息
-                print("alipay_1 send msg:HELIOS_PAY_MSG_GET_BIND_CODE:{}".format(ret))
+            args = ""
+            userdata = ""
+            # print("--000--")
+            ret = self.alipay.msg_send(1,args,userdata) #发送获取绑定码消息,在回调函数里打开界面
+            print("alipay_1 send msg:HELIOS_PAY_MSG_GET_BIND_CODE:{}".format(ret))
         else :
             print("check bind error!!!")
 
-    def timeout_Alipay_check_cb(self, *args, **kwargs):
-        
-        ret = self.alipay.query_bind_result()
-        print("query_bind_result:{}".format(ret))
-
 style_alipay_screen_default = lv.style_t()
 style_alipay_screen_default.init()
 style_alipay_screen_default.set_radius(0)