const session = httpCore.getApiEngine();
//加密
let aesetPhone = await aesUtils.aesEncrypt(this.etPhone);
let aesetCode = await aesUtils.aesEncrypt(this.etCode);
let grant_type = 'sms_code';
let client_id = 'xxx';
let client_secret = 'xxx';
let ptc = 'YHL-APP';
const codeLogin: rcp.FormFields = {
"grant_type": grant_type,
"username": aesetPhone,
"sms_code": aesetCode,
"client_id": client_id,
"client_secret": client_secret,
"ptc": ptc
};
session.post(httpCore.getJointUrl()+apiService.getLoginPhone,codeLogin)
.then(async (response) => {
let loginResult = new LoginResult();
loginResult = JSON.parse(JSON.stringify(response))
console.error('=返回值===' + JSON.stringify(response));
if (loginResult.access_token != '' || loginResult.access_token != undefined) {
} else {
promptAction.showToast({ message: loginResult.error_description, bottom: 100, duration: 1000 })
}
})
.catch((err: BusinessError) => {
console.error("err:" + JSON.stringify(err));
});
这样写对吗?post表单形式的传参是这样写吗?HarmonyOS这边如何添加拦截器拦截打印?
可以参考下这个拦截器的写法:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/remote-communication-interceptor-V5\#section123091617105820
1、全局定义拦截器对象用于修改或接收数据:
2、调用rcp库能力通过定义的拦截器拿数据:
rcp各种请求传参示例: