12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- export function getInstance() {
- 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;
- }
- };
- }
|