// method OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT function request(self, url, param, callback, method, header) { if (!header) { var header = {}; header['content-type'] = 'application/x-www-form-urlencoded'; } var types = url; for (var i in self.dever.config.host) { if (url.indexOf(i + '.') != -1) { url = url.replace(i + '.', self.dever.config.host[i]); break; } } if (url.indexOf('http') == -1 || self.dever.config.local) { return self.dever.package('analog').data(self.dever, types, param, callback); } self.set('loading', true); param.json = 1; var log = param; log.url = url; self.set('url', log); wx.request( { url: url, data: param, method: method.toUpperCase(), header: header, success: function (res) { if (res.data.status == 1) { if (res.data.data.setting) { self.dever.setSetting(self, res.data.data.setting); } self.set('loading', false); callback.success(res.data.data, res); } else { self.dever.alert(res.msg); } }, fail: function () { //callback.fail(); }, complete: function () { //callback.complete(); } }) } module.exports = { request:request }