首先封装公共的request
request为封装的请求。写在util页面中导出,然后其他页面调用
module.exports = {
request:request
}
/**
* loading_type 等待类型 枚举值: 'center' 'bottom' 默认center 为bottom时不显示加载中,调用时自行处理
*/
function request(cmd, data, fnsuccess, fnfail, fncomplete, that, hideload, loading_type) {
//app.globalData.sync.LoginSync.then(function (r) {
//if (r.errcode == 0) { //注释部分是防止小程序网络延迟未获取全局变量中的值
if (!loading_type || loading_type == "center") {
wx.showLoading({
mask: true,
title: '努力加载中'
})
}
data.id = id;
wx.request({
url: requesturl + cmd,
data: data,
header: {
Authorization: app.globalData.token
},
method: 'POST',
dataType: 'json',