1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // 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;
- wx.request(
- {
- url: url,
- data: param,
- method: method.toUpperCase(),
- header: header,
- success: function (res) {
- if (res.data.status == 1) {
- if (res.data.data.config) {
- self.dever.setSetting(res.data.data.config);
- }
- 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
- }
|