appLogin()
{
web_set_max_html_param_len("100000");
web_add_auto_header("appKey","f50c76fbc8271d361e1f6b5973f54585");
web_add_auto_header("clientId", "2014022801010");
web_add_auto_header("appVersion","V0.5.01_0228");
web_add_auto_header("appId","MB-UZHSH-0000");
web_add_auto_header("Content-Type","application/json;charset=UTF-8");
web_add_auto_header("funcName","addBonusPoint");
web_add_auto_header("SysName","SCRM-YXB");
web_add_auto_header("timestamp","20180510113725");
lr_start_transaction("step1-login");
web_save_header(REQUEST, "RequestHeader");// REQUEST为内置变量,保存请求的头信息,需在发送URL请求前注册使用
web_save_header(RESPONSE, "ResponseHeader");// RESPONSE保存响应的头信息
web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
web_reg_save_param("retCode", "LB=\"retCode\":\"", "RB=\",","Notfound=error", "Search=Body", LAST);
web_reg_save_param("userId", "LB=chiefUserId\":\"", "RB=\",", "Notfound=error","Search=Body", LAST);
web_reg_save_param("accessToken","LB=accessToken: ","RB=\n","Notfound=error","Search=ALL",LAST);
web_reg_save_param("sdToken","LB=sdToken: ","RB=\n","Notfound=error","Search=ALL",LAST);
web_custom_request("web_custom_request",
"URL=http://210.51.17.150:7500/emuplus/secuag/security/userLogin",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"EncType=application/json",
"Body={\"sequenceId\":\"20140305102633000001\",\"accType\":0,\"loginId\":\"18109286803\",\"password\":\"123456!\",\"thirdpartyAppId\":\"\",\"thirdpartyAccessToken\":\"\",\"loginType\":\"1\"}",
LAST);
//字符转义,转义承UTF-8格式
lr_convert_string_encoding(lr_eval_string("{RequestHeader}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"RequestHeaderUTF8");
lr_convert_string_encoding(lr_eval_string("{ResponseHeader}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseHeaderUTF8");
lr_convert_string_encoding(lr_eval_string("{ResponseBody}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseBodyUTF8");
//输出信息
lr_output_message("# 请求头信息:\n %s", lr_eval_string("{RequestHeaderUTF8}"));
//lr_output_message("# 响应header:\n %s", lr_eval_string("{ResponseHeaderUTF8}"));
//lr_output_message("# 响应Body:\n %s", lr_eval_string("{ResponseBodyUTF8}"));
if(strcmp(lr_eval_string("{retCode}"),"00000")==0){
lr_output_message("登录成功");
}
else {
lr_set_transaction_status(LR_FAIL);
lr_end_transaction("step1-login", LR_AUTO);
return 0;
}
lr_end_transaction("step1-login", LR_AUTO);
lr_start_transaction("step2-getSign");
web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
web_reg_save_param("retCode", "LB=\"retCode\":\"", "RB=\",","Notfound=error", "Search=Body", LAST);
web_reg_save_param("sign", "LB=data\":\"", "RB=\"", "Notfound=error","Search=Body", LAST);
web_custom_request("getAddressSign",
"URL=http://210.51.17.150:7500/emuplus/secuag/invite/getSignCode",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"EncType=application/json",
"Body={\"sdToken\": \"{sdToken}\", \"checkIntegral\": \"1\", \"id\": \"\", \"name\": \"张7\", \"phone\": \"13259901209\", \"province\": \"水电\", \"cityCode\": \"0298\", \"city\":\"收到\", \"areaCode\":\"120089\", \"address\": \"金\", \"isDefault\": 1 }",
LAST);
if(strcmp(lr_eval_string("{retCode}"),"00000")==0){
lr_output_message("获取sign成功");
lr_convert_string_encoding(lr_eval_string("{ResponseBody}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseBodyUTF8");
lr_output_message(lr_eval_string("{ResponseBodyUTF8}"));
}
else {
lr_set_transaction_status(LR_FAIL);
lr_end_transaction("step1-login", LR_AUTO);
return 0;
}
lr_end_transaction("step2-getSign", LR_AUTO);
lr_start_transaction("step3-addNewAddress");
web_add_auto_header("sign",lr_eval_string("{sign}"));
web_add_auto_header("accessToken","TGT3150VB9MDDKXF2ENCN6C9RVHMR0");
web_save_header(RESPONSE, "ResponseHeader");// RESPONSE保存响应的头信息
web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
web_save_header(REQUEST, "RequestHeader");
web_custom_request("getAddressSign",
"URL=http://210.51.17.150:7500/emuplus/user/{userId}/addr/v0.1/addAddr",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"EncType=application/json",
"Body={\"sdToken\": \"{sdToken}\", \"checkIntegral\": \"1\", \"id\": \"\", \"name\": \"张7\", \"phone\": \"13259901209\", \"province\": \"水电\", \"cityCode\": \"0298\", \"city\":\"收到\", \"areaCode\":\"120089\", \"address\": \"金\", \"isDefault\": 1 }",
LAST);
lr_convert_string_encoding(lr_eval_string("{RequestHeader}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"RequestHeaderUTF8");
lr_convert_string_encoding(lr_eval_string("{ResponseBody}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseBodyUTF8");
lr_output_message(lr_eval_string("{ResponseBodyUTF8}"));
lr_output_message(lr_eval_string("{RequestHeaderUTF8}"));
lr_end_transaction("step3-addNewAddress", LR_AUTO);
return 0;
}