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