微信小商城共用接口数据请求

Original 2019-02-23 21:35:02 258
abstract:var requestUrl = "http://tp51.io/api.php/";function post(url, data, fun, that) {if (url == 'undefined') {return false;}var postUrl = requestUrl + url;wx.request({url: postUrl,data: d

var requestUrl = "http://tp51.io/api.php/";


function post(url, data, fun, that) {

if (url == 'undefined') {

return false;

}

var postUrl = requestUrl + url;

wx.request({

url: postUrl,

data: data,

method: "POST",

dataType: "json",

header: {

'content-type': 'application/json'

},

success: function (res) {

that[fun](res.data.result);

},

fail: function (res) {

console.log('请求失败,请重试');

return {};

}

})

}


module.exports.post=post;


Correcting teacher:西门大官人Correction time:2019-02-24 09:25:56
Teacher's summary:注意一下,在js中对变量是否定义的判断用undefined,不能加引号。

Release Notes

Popular Entries