import win.ui;
/*DSG{{*/
winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="button";left=109;top=342;right=637;bottom=411;z=2};
edit={cls="edit";left=30;top=32;right=725;bottom=301;db=1;dl=1;dr=1;dt=1;edge=1;multiline=1;z=1}
)
/*}}*/
import inet.whttp;
import inet.url;
import web.json;
import crypt;
var tab = {
app_key = ""; //app_key
format = "json";
method = "taobao.tbk.item.get";
sign_method = "md5";
timestamp = tostring(time(, "%Y-%m-%d %H:%M:%S"));
cat = "16,18";
fields = "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,seller_id,volume,nick";
q = "女装";
v = "2.0";
}; //请求参数
var app_secret = ""; //app_secret
var url = ""; //请求地址
/**
* taoapi
* @param {table} tab 请求参数
* @param {string} url 请求地址
* @param {string} app_secret app_secret
* @return {table} 响应参数
**/
var taoapi = function(tab, url, app_secret) {
var sign = "";
var body = "";
var http = inet.whttp();
for k, v in table.eachName(tab) {
sign = sign + k + v; //拼接按字典排序后的参数
body = body + "&" + k + "=" + v; //拼接URL请求参数
}
sign = crypt.md5(app_secret + sign + app_secret); //生成签名
body = url + "?" + "sign=" + sign + body; //组装HTTP请求
return web.json.parse(http.get(inet.url.encodeUri(body))); //返回响应参数的表对象
}
winform.button.oncommand = function(id, event) {
//winform.msgbox( winform.button.text );
winform.edit.text = table.tostring(taoapi(tab,url,app_secret));
}
winform.enableDpiScaling();
winform.show();
win.loopMessage();
return winform;