开发工具返回的:{errno: 0, message: “”, data: Array(1)}
- accountid: null
- action: null
- area: null
- back_img: ""
- commission: "0"
- createtime: "1587566664"
- credit: "0.00"
- displayorder: "0"
- id: "1"
- keyword: ""
- lat: " "
- linkmen: "总机"
- linkway: ""
- lng: " "
- parent_accountid: null
- pic: "images/0/2021/05/UruJzh823UTezeq52QEqRURURyUjJa.png"
- pid: "0"
- province: "广东省"
- qq: " "
- region_qr: ""
- region_type: "4"
- rid: "0"
- service_url: ""
- stamp: ""
- status: "1"
- thumb: ""
- uid: "1"
- uniacid: "4"
- url: ""
- villageid: null
- yybcommunityid: null
- yybstatus: "33"
- zoneId: null
真机调试返回的:{“errno”:0,“message”:"",“data”:[{“id”:“1”,“uniacid”:“4”,“linkmen”:"\u603b\u673a",“linkway”:"",“lng”:" “,“lat”:” “,“pid”:“0”,“url”:”",“thumb”:"",“pic”:“images\/1\/2020\/04\/2263323556162116.jpg”,“province”:"\u5e7f\u4e1c\u7701",“qq”:" “,“rid”:“0”,“keyword”:”",“commission”:“0”,“status”:“1”,“area”:null,“stamp”:"",“credit”:“0.00”,“action”:null,“yybstatus”:“33”,“yybcommunityid”:null,“accountid”:null,“villageid”:null,“zoneId”:null,“parent_accountid”:null,“back_img”:"",“displayorder”:“0”,“service_url”:"",“region_type”:“4”,“region_qr”:"",“uid”:“1”,“createtime”:“1587566664”}]}
wx.request({
'url': url,
'data': option.data ? option.data : {},
'header': option.header ? option.header : {},
'method': option.method ? option.method : 'GET',
'header': {
'content-type': 'application/x-www-form-urlencoded'
},
'success': function (response) {
wx.hideNavigationBarLoading();
if (response.data.errno) {
if (response.data.errno == '41009') {
wx.setStorageSync('userInfo', '');
util.getUserInfo(function () {
util.request(option)
});
return;
} else {
if (option.fail && typeof option.fail == 'function') {
option.fail(response);
} else {
if (response.data.message) {
if (response.data.data != null && response.data.data.redirect) {
var redirect = response.data.data.redirect;
} else {
var redirect = '';
}
app.util.message(response.data.message, redirect, 'error');
}
}
return;
}
} else {
if (option.success && typeof option.success == 'function') {
option.success(response);
}
//写入缓存,减少HTTP请求,并且如果网络异常可以读取缓存数据
if (option.cachetime) {
var cachedata = { 'data': response.data, 'expire': timestamp + option.cachetime \* 1000 };
wx.setStorageSync(cachekey, cachedata);
}
}
},
'fail': function (response) {
wx.hideNavigationBarLoading();
//wx.hideLoading();
//如果请求失败,尝试从缓存中读取数据
var md5 = require('md5.js');
var cachekey = md5(url);
var cachedata = wx.getStorageSync(cachekey);
if (cachedata && cachedata.data) {
if (option.success && typeof option.success == 'function') {
option.success(cachedata);
}
console.log('failreadcache:' + url);
return true;
} else {
if (option.fail && typeof option.fail == 'function') {
option.fail(response);
}
}
},
'complete': function (response) {
// wx.hideNavigationBarLoading();
// wx.hideLoading();
if (option.complete && typeof option.complete == 'function') {
option.complete(response);
}
}
});
还不时伴有 cmdId 10005 errCode 1的白屏出现