var Promise = require('../plugins/es6-promise.js')
function wxPromisify(fn) {
return function (obj = {}) {
return new Promise((resolve, reject) => {
obj.success = function (res) {
//成功
resolve(res);
}
obj.fail = function (res) {
//失败
reject(res)
}
fn(obj)
})
}
}
function postRequest(url, data) {
var postRequest = wxPromisify(wx.request)
return postRequest({
url: url,
method: 'POST',
data: data,
dataType: 'json',
header: { 'content-type': 'application/x-www-form-urlencoded' },
})
}
module.exports = {
postRequest: postRequest,
}
var DataList = require("./utils/wxRequest.js")
var returnData = DataList.postRequest('https://sp.shykjgf.com/?s=/seller/seller/getDate', { pid: 40 })
returnData.then(function (res) {
console.log(res);
var data = res.data.data.data.id;
}, function (err) {
console.log(1);
});