(account_id)
| 89 | } |
| 90 | |
| 91 | def get_wx_code(account_id): |
| 92 | if not WX_AUTH: |
| 93 | raise RuntimeError("缺少wx_auth,无法从wx_server获取code") |
| 94 | resp = session.post( |
| 95 | f"{WX_SERVER_URL}/wx/code", |
| 96 | json={"appid": MINI_APP_ID, "openid": account_id}, |
| 97 | headers=wx_headers(), |
| 98 | timeout=30, |
| 99 | ) |
| 100 | resp.raise_for_status() |
| 101 | data = resp.json() |
| 102 | code = data.get("code") or (data.get("data") or {}).get("code") |
| 103 | if not code: |
| 104 | raise RuntimeError(f"wx_server未返回code: {data}") |
| 105 | return code |
| 106 | |
| 107 | def login_with_code(account_id): |
| 108 | code = get_wx_code(account_id) |
no test coverage detected