wangfei hace 6 años
padre
commit
1be1b4664f
Se han modificado 6 ficheros con 84 adiciones y 2 borrados
  1. 2
    2
      app.json
  2. 18
    0
      config/api.js
  3. 4
    0
      config/baseUrl.js
  4. 14
    0
      config/code.js
  5. 4
    0
      config/wxId.js
  6. 42
    0
      utils/http.js

+ 2
- 2
app.json Ver fichero

@@ -1,6 +1,5 @@
1 1
 {
2 2
   "pages":[
3
-    "pages/SelfServiceTool/MortgageCalculator/index",
4 3
     "pages/index/index",
5 4
     "pages/EstateDetail/index",
6 5
     "pages/AppointmentTime/index",
@@ -12,7 +11,8 @@
12 11
     "pages/SelfServiceTool/index",
13 12
     "pages/SelfServiceTool/QualifyingTest/index",
14 13
     "pages/SelfServiceTool/Cyclopedia/index",
15
-    "pages/SelfServiceTool/Cyclopedia/Detail"
14
+    "pages/SelfServiceTool/Cyclopedia/Detail",
15
+    "pages/SelfServiceTool/MortgageCalculator/index"
16 16
   ],
17 17
   "window":{
18 18
     "backgroundTextStyle":"light",

+ 18
- 0
config/api.js Ver fichero

@@ -0,0 +1,18 @@
1
+// api基础域名
2
+const BaseAPIURl = require('./baseUrl.js').basePath.BASE_API_URL;
3
+const $api = {
4
+  user: {
5
+    login: { // 模拟用户登陆
6
+      methods: 'POST',
7
+      url: `${BaseAPIURl}/wx/registered`
8
+    },
9
+    info: {
10
+      methods: 'GET',
11
+      url: `${BaseAPIURl}/wx/info/:appid`
12
+    },
13
+  }
14
+}
15
+
16
+module.exports = {
17
+  $api: $api
18
+}

+ 4
- 0
config/baseUrl.js Ver fichero

@@ -0,0 +1,4 @@
1
+module.exports.basePath = {
2
+  BASE_API_URL: 'https://api.jinchengjiaye.com/newnbapi',
3
+  BASE_IMG_URL: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/',
4
+}

+ 14
- 0
config/code.js Ver fichero

@@ -0,0 +1,14 @@
1
+/**
2
+ *  请求返回值 
3
+ *  common 成功和失败
4
+ *  user 用户未登录
5
+ */
6
+module.exports.apiCode = {
7
+  common: {
8
+    successCode: 200,
9
+    errorCode: 400
10
+  },
11
+  user: {
12
+    notLogin: 401,
13
+  }
14
+}

+ 4
- 0
config/wxId.js Ver fichero

@@ -0,0 +1,4 @@
1
+module.exports.wxId = {
2
+  appId: 'wx8d70a491c45b400e',
3
+  secret: '7f995c77ef093410a3fe9909229796a5'
4
+}

+ 42
- 0
utils/http.js Ver fichero

@@ -0,0 +1,42 @@
1
+const apiCode = require('../config/code.js').apiCode;
2
+const $api = require('../config/api.js').$api;
3
+const $HttpSever = function () { }
4
+
5
+var app = getApp();
6
+
7
+$HttpSever.prototype = {
8
+  /**
9
+   *  通用请求方法
10
+   * 
11
+   * @param {any} [config={}] 
12
+   * @returns 
13
+   */
14
+  Ajax(config = {}) {
15
+    return new Promise((resolve, reject) => {
16
+      wx.request({
17
+        url: config.url,
18
+        method: config.method,
19
+        data: {
20
+          ...config.data,
21
+          openid: app.globalData.openID
22
+        },
23
+        header: {
24
+          'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
25
+        },
26
+        success(res) {
27
+          if (res.statusCode && res.statusCode === apiCode.common.successCode) {
28
+            resolve(res.data.message)
29
+          } else {
30
+            resolve(res.data.message + "失败")
31
+          }
32
+        },
33
+        error(msg) {
34
+          reject(msg)
35
+        }
36
+      })
37
+    })
38
+  },
39
+}
40
+module.exports = {
41
+  HttpSever: new $HttpSever()
42
+}