要求如下:
1、完成(注册,登录,重置支付密码,下订单,支付订单,获取订单列表)
2、下订单备注信息用中文(lr_convert_string_encoding)进行处理
3、web_convert_param对token进行URLcode
脚本如下:
Action()
{
lr_save_string("192.168.204.133:8080","IP");
lr_save_string(CMd5("123456"),"PayPassWord");
web_reg_save_param("zhuce",
"LB=\"code\":",
"RB=,",
"Search=All",
LAST);
web_reg_save_param("zhuce_msg",
"LB=\"msg\":\"",
"RB=\"",
"Search=All",
LAST);
lr_start_transaction("注册");
web_custom_request("zhuce_request",
"URL= http://{IP}/mobile/api/user/register/",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTTP",
"EncType=application/json",
"Body={\"mobile\":\"{mobile}\",\"password\":\"{password}\",\"platform\":\"windows\",\"username\":\"{username}\",\"sex\":1,\"age\":2,\"email\":\"{email}\",\"code\":\"3367\"}",
LAST);
if(strcmp(lr_eval_string("{zhuce}"),"0")==0)
{
lr_end_transaction("注册", LR_PASS);
}
else
{
lr_end_transaction("注册", LR_FAIL);
}
lr_convert_string_encoding(lr_eval_string("{zhuce_msg}"),LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"zhuce_msg_1");
lr_error_message("登陆具体返回值是:%s",lr_eval_string("{zhuce_msg_1}"));
//登陆
web_reg_save_param("login1",
"LB=\"code\":",
"RB=,",
"Search=All",
LAST);
web_reg_save_param("token_test",
"LB=\"token\":\"",
"RB=\"",
"Search=All",
LAST);
web_reg_save_param("login_msg",
"LB=\"msg\":\"",
"RB=\"",
"Search=All",
LAST);
lr_start_transaction("login");
web_custom_request("web_custom_request",
"URL= http://{IP}/mobile/api/user/login",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTTP",
"EncType=application/json",
"Body={\"mobile\":\"{mobile}\",\"password\":\"{password}\"}",
LAST);
if(strcmp(lr_eval_string("{login1}"),"0")==0)
{
lr_end_transaction("login", LR_PASS);
}
else
{
lr_end_transaction("login", LR_FAIL);
}
lr_convert_string_encoding(lr_eval_string("{login_msg}"),LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"login_msg_1");
lr_error_message("登陆具体返回值是:%s",lr_eval_string("{login_msg_1}"));
//"重置密码
web_reg_save_param("resetpaypwd_code",
"LB=\"code\":",
"RB=,",
"Search=All",
LAST);
web_reg_save_param("resetpaypwd_msg",
"LB=\"msg\":\"",
"RB=\"",
"Search=All",
LAST);
lr_start_transaction("resetpaypwd");
web_custom_request("resetpaypwd_request",
"URL= http://{IP}/mobile/api/user/resetpaypwd",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTTP",
"EncType=application/json",
"Body={\"token\":\"{token_test}\",\"password\":\"{PayPassWord}\"}",
LAST);
if(strcmp(lr_eval_string("{resetpaypwd_code}"),"0")==0)
{
lr_end_transaction("resetpaypwd", LR_PASS);
}
else
{
lr_end_transaction("resetpaypwd", LR_FAIL);
}
lr_convert_string_encoding(lr_eval_string("{resetpaypwd_msg}"),LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"resetpaypwd_msg_1");
lr_error_message("重置密码具体返回值是:%s",lr_eval_string("{resetpaypwd_msg_1}"));
//下订单
web_reg_save_param("addorder_code",
"LB=\"code\":",
"RB=,",
"Search=All",
LAST);
web_reg_save_param("addorder_msg",
"LB=\"msg\":\"",
"RB=\"",
"Search=All",
LAST);
web_reg_save_param("payid",
"LB=\"payId\":\"",
"RB=\"",
"Search=All",
LAST);
//下单备注内容为中文时,需要进行转译
lr_convert_string_encoding("下单备注信息内容",LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"remark_string");
lr_save_string(lr_eval_string("{remark_string}"),"remark_msg");
lr_start_transaction("addorder");
web_custom_request("addorder_request",
"URL= http://{IP}/mobile/api/order/addorder",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTTP",
"EncType=application/json",
"Body={\"token\":\"{token_test}\",\"getAddrId\":1,\"getCarId\":23,\"payType\":2,\"remark\":\"{remark_msg}\",\"price\":2.50,\"orders\":[{\"getTime\":1450921104000,\"goodss\":[{\"goodsId\":93,\"count\":1},{\"goodsId\":93,\"count\":1}]}],\"invoiceTitle\":\"abcd\"}",
LAST);
//\"orders\":[{\"getTime\":1450921104000,\"goodss\":[{\"goodsId\":93,\"count\":1},{\"goodsId\":93,\"count\":1}]}],
if(strcmp(lr_eval_string("{addorder_code}"),"0")==0)
{
lr_end_transaction("addorder", LR_PASS);
}
else
{
lr_end_transaction("addorder", LR_FAIL);
}
lr_convert_string_encoding(lr_eval_string("{addorder_msg}"),LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"addorder_msg_1");
lr_error_message("下订单具体返回值是:%s",lr_eval_string("{addorder_msg_1}"));
//支付订单
web_reg_save_param("pay_code",
"LB=\"code\":",
"RB=,",
"Search=All",
LAST);
web_reg_save_param("pay_msg",
"LB=\"msg\":\"",
"RB=\"",
"Search=All",
LAST);
lr_start_transaction("pay");
web_custom_request("pay_request",
"URL= http://{IP}/mobile/api/pay/pay",
"Method=POST",
"TargetFrame=",
"Resource=1",
"Referer=",
"Mode=HTTP",
"EncType=application/json",
"Body={\"token\":\"{token_test}\",\"payId\":\"{payid}\",\"payPwd\":\"{PayPassWord}\",\"platform\":1}",
LAST);
if(strcmp(lr_eval_string("{pay_code}"),"0")==0)
{
lr_end_transaction("pay", LR_PASS);
}
else
{
lr_end_transaction("pay", LR_FAIL);
}
lr_convert_string_encoding(lr_eval_string("{pay_msg}"),LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"pay_msg_1");
lr_error_message("支付订单具体返回值是:%s",lr_eval_string("{pay_msg_1}"));
//获取订单列表
web_reg_save_param("getorders_code",
"LB=\"code\":",
"RB=,",
"Search=All",
LAST);
web_reg_save_param("getorders_msg",
"LB=\"msg\":\"",
"RB=\"",
"Search=All",
LAST);
lr_save_string("{token_test}","tokenURL");//把token进行urlcode编码
web_convert_param("tokenURL",//参数的名称,转换后的字符串被保存在该参数中
"SourceEncoding=PLAIN",//编码的数据类型HTML,URL,Plain
"TargetEncoding=URL",//目标数据的编码类型
LAST);
lr_start_transaction("getorders");
web_custom_request("getorders_request",
"URL= http://{IP}/mobile/api/order/getorders?offset=0&token={token_test}",
"Method=GET",
"TargetFrame=",
"Resource=0",
"Referer=",
"RecContentType=application/json",
"EncType=application/json",
"Mode=HTTP",
LAST);
if(strcmp(lr_eval_string("{getorders_code}"),"0")==0)
{
lr_end_transaction("getorders", LR_PASS);
}
else
{
lr_end_transaction("getorders", LR_FAIL);
}
lr_convert_string_encoding(lr_eval_string("{getorders_msg}"),LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"getorders_msg_1");
lr_error_message("获取订单列表具体返回值是:%s",lr_eval_string("{getorders_msg_1}"));
return 0;
}