微信小程序-对网络请求的封装
/*
* A JavaScript Of The WeChat Miniprogram For The Network Request
* See https://www.jianshu.com/p/2e80c96ce712.html for details.
*
* author: cxr
*
* */
/**
*@header 请求头
*/
var header = {
'content-type': 'application/x-www-form-urlencoded',
'Authorization': app.globalData.codeInfo.new_authorization,
}
/**
* function: 封装网络请求
* @url URL地址
* @params 请求参数
* @method 请求方式:GET/POST
* @onSuccess 成功回调
* @onFailed 失败回调
**/
function request(url, params, method, onSuccess, onFailed) {
console.log('请求url:' + url);
wx.showLoading