123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- module.exports = {
- getInstance: function() {
- return {
- _sucCallback: null,
- _failCallback: null,
- _method: 'GET',
- _data: {},
- _header: { 'content-type': 'application/json' },
- _url: '',
- send: function() {
- wx.request({
- url: this._url,
- data: this._data,
- method: this._method,
- header: this._header,
- success: function(res) {
- this._sucCallback(res);
- }.bind(this),
- fail: function(res) {
- this._failCallback(res);
- }.bind(this)
- });
- return this;
- },
- success: function(callback) {
- this._sucCallback = callback;
- return this;
- },
- fail: function(callback) {
- this._failCallback = callback;
- return this;
- },
- url: function(url) {
- this._url = url;
- return this;
- },
- data: function(data) {
- this._data = data;
- return this;
- },
- header: function(header) {
- this._header = header;
- return this;
- },
- method: function(method) {
- this._method = method;
- return this;
- }
- };
- }
- };
|