zjxpcyc пре 6 година
родитељ
комит
66e4f441e1
2 измењених фајлова са 1 додато и 32 уклоњено
  1. 1
    4
      app.js
  2. 0
    28
      utils/http.js

+ 1
- 4
app.js Прегледај датотеку

2
 import fetch from '/utils/http'
2
 import fetch from '/utils/http'
3
 const $api = require('/config/api.js').$api
3
 const $api = require('/config/api.js').$api
4
 
4
 
5
-const HttpSever = require('./utils/http.js').HttpSever;
6
-const $api = require('./config/api.js').$api;
7
-
8
 App({
5
 App({
9
   onLaunch: function() {
6
   onLaunch: function() {
10
     let _self = this
7
     let _self = this
52
       }
49
       }
53
     })
50
     })
54
 
51
 
55
-    HttpSever.Ajax({
52
+    fetch({
56
       url: $api.dict.list.url,
53
       url: $api.dict.list.url,
57
       method: $api.dict.list.method,
54
       method: $api.dict.list.method,
58
     }).then((data) => {
55
     }).then((data) => {

+ 0
- 28
utils/http.js Прегледај датотеку

1
 import { apiCode } from '../config/code'
1
 import { apiCode } from '../config/code'
2
 
2
 
3
-<<<<<<< HEAD
4
-$HttpSever.prototype = {
5
-  /**
6
-   *  通用请求方法
7
-   * 
8
-   * @param {any} [config={}] 
9
-   * @returns 
10
-   */
11
-  Ajax(config = {}) {
12
-    return new Promise((resolve, reject) => {
13
-      wx.request({
14
-        url: config.url,
15
-        method: config.method,
16
-        data: {
17
-          ...config.data
18
-        },
19
-        success(res) {
20
-          if (res.statusCode && res.statusCode === apiCode.common.successCode) {
21
-            resolve(res.data)
22
-          } else {
23
-            resolve(res.data.message + "失败")
24
-          }
25
-        },
26
-        error(msg) {
27
-          reject(msg)
28
-=======
29
 export default (config = {}) => {
3
 export default (config = {}) => {
30
   return new Promise((resolve, reject) => {
4
   return new Promise((resolve, reject) => {
31
     wx.request({
5
     wx.request({
35
         ...config.data
9
         ...config.data
36
       },
10
       },
37
       success(res) {
11
       success(res) {
38
-        console.log(res, apiCode)
39
         if (res.statusCode && res.statusCode === apiCode.success) {
12
         if (res.statusCode && res.statusCode === apiCode.success) {
40
           resolve(res.data)
13
           resolve(res.data)
41
         } else {
14
         } else {
42
           resolve(res.data.message + "失败")
15
           resolve(res.data.message + "失败")
43
->>>>>>> 02bbb13da6392818f573d7fc66c72524bffeb347
44
         }
16
         }
45
       },
17
       },
46
       error(msg) {
18
       error(msg) {