处理代码
function ajax_request(url, data,method) {
return new Promise((resolve, reject) => {
wx.request({
url: url,
data: data,
header: {
"content-type": "application/x-www-form-urlencoded"
},
method: method, //http请求方法 GET POST OPTIONS
responseType: "text",
success(res) {
resolve(res)
},
fail(err) {
console.log(err);
wx.showModal({
title: "提示",
content: "出错啦,请稍后重试",
showCancel: false
})
reject({
errCode: 0
})
}
})
})
}
function ajax_LoadData(pg, opts) {
if (opts.debug) console.log(opts)
wx.showNavigationBarLoading();
// wx.hideNavigationBarLoading()
let loginInfo = wx.getStorageSync('loginInfo');
if (!loginInfo) loginInfo = {}
// let params = {
// UserID: loginInfo.UserID
// }
// let values = mergeObject(params, opts.values);
ajax_request(opts.url, opts.values,opts.method).then(res => {
if (opts.debug) console.log(res)
let data = res.data;
if (!data) data = {}
//++ 没有数据 返回状态吗 为300
if (data.status == 300) {
return reject({
"errCode": "01"
})
}
pg.setData({
Data: data
})
if (typeof (opts.funOk) == "function") opts.funOK(data)
resolve("success")
}).catch(err => {
console.log(err)
}).finally(res => {
// wx.hideToast()
wx.hideNavigationBarLoading();
wx.stopPullDownRefresh();
})
}
调用代码
var values = {
'floorid':2
};
var opts = {
method:'POST',
values: values,
url: app.globalData.rootURL + '/' + app.globalData.mainMDL + '/getcategoryinfo',
debug: false
};
opts.funOk = function (res) {
pg.setData({
showData:res.Cont,
})
const html=WxParse.wxParse('article', 'html', res.Cont.Content, pg, 5);
}
fun.loadData(pg, opts, "Data", app);
开发者工具报错
请各位大佬看看是那块出错了,promise的使用也换了两种方式,但就是出错了,我都懵了
我也是这样报错,自从重新发布了就出问题了,之前的版本不会