李志伟 3 anos atrás
pai
commit
487e89f9c1
6 arquivos alterados com 76 adições e 15 exclusões
  1. 6
    2
      config/dev.js
  2. 4
    1
      config/prod.js
  3. 38
    5
      project.config.json
  4. 12
    6
      src/app.js
  5. 8
    0
      src/services/login.js
  6. 8
    1
      src/utils/request.js

+ 6
- 2
config/dev.js Ver arquivo

@@ -1,9 +1,13 @@
1 1
 module.exports = {
2 2
   env: {
3
-    NODE_ENV: '"development"'
3
+    NODE_ENV: '"development"',
4 4
   },
5 5
   defineConstants: {
6
+    HOST: '"https://machine.njyunzhi.com"',
7
+    // OSS: '"yz-shigongli.oss-accelerate.aliyuncs.com"',
8
+    // VERSION: '"3.0.3_2021-12-23"',
6 9
   },
7 10
   mini: {},
8
-  h5: {}
11
+  h5: {},
12
+  projectConfigName: 'project.config.dev.json'
9 13
 }

+ 4
- 1
config/prod.js Ver arquivo

@@ -1,8 +1,11 @@
1 1
 module.exports = {
2 2
   env: {
3
-    NODE_ENV: '"production"'
3
+    NODE_ENV: '"production"',
4 4
   },
5 5
   defineConstants: {
6
+    HOST: '"https://machine.njyunzhi.com"',
7
+    // OSS: '"yz-shigongli.oss-accelerate.aliyuncs.com"',
8
+    // VERSION: '"3.0.3_2021-12-23"',
6 9
   },
7 10
   mini: {},
8 11
   h5: {

+ 38
- 5
project.config.json Ver arquivo

@@ -1,13 +1,46 @@
1 1
 {
2
-  "miniprogramRoot": "./dist",
2
+  "miniprogramRoot": "dist/",
3 3
   "projectname": "machinery-person",
4 4
   "description": "农机手小程序",
5 5
   "appid": "wx6d749c13e3f8b39a",
6 6
   "setting": {
7
-    "urlCheck": true,
7
+    "urlCheck": false,
8 8
     "es6": false,
9
+    "enhance": true,
9 10
     "postcss": false,
10
-    "minified": false
11
+    "preloadBackgroundData": false,
12
+    "minified": false,
13
+    "newFeature": false,
14
+    "coverView": true,
15
+    "nodeModules": false,
16
+    "autoAudits": false,
17
+    "showShadowRootInWxmlPanel": true,
18
+    "scopeDataCheck": false,
19
+    "uglifyFileName": false,
20
+    "checkInvalidKey": true,
21
+    "checkSiteMap": true,
22
+    "uploadWithSourceMap": true,
23
+    "compileHotReLoad": false,
24
+    "lazyloadPlaceholderEnable": false,
25
+    "useMultiFrameRuntime": true,
26
+    "useApiHook": true,
27
+    "useApiHostProcess": true,
28
+    "babelSetting": {
29
+      "ignore": [],
30
+      "disablePlugins": [],
31
+      "outputPath": ""
32
+    },
33
+    "useIsolateContext": false,
34
+    "userConfirmedBundleSwitch": false,
35
+    "packNpmManually": false,
36
+    "packNpmRelationList": [],
37
+    "minifyWXSS": true,
38
+    "disableUseStrict": false,
39
+    "minifyWXML": true,
40
+    "showES6CompileOption": false,
41
+    "useCompilerPlugins": false,
42
+    "ignoreUploadUnusedFiles": true
11 43
   },
12
-  "compileType": "miniprogram"
13
-}
44
+  "compileType": "miniprogram",
45
+  "condition": {}
46
+}

+ 12
- 6
src/app.js Ver arquivo

@@ -2,21 +2,27 @@ import { Component } from 'react'
2 2
 import Taro from '@tarojs/taro'
3 3
 // import preFetchData from '@/utils/preFetchData'
4 4
 // import store, { StoreRoot } from './store'
5
+import {signIn} from '@/services/login'
5 6
 import './app.less'
6 7
 
7 8
 class App extends Component {
8 9
 
9
-  componentDidShow(options) {
10
-    if (options.path === 'pages/index/index' && options.query?.tab === '1' && options.query?.roomId) {
11
-      // const { setRoomId } = store.getModel('hotel').getState()
12
-      // setRoomId(options.query?.roomId)
13
-    }
14
-  }
10
+  // componentDidShow(options) {
11
+  //   if (options.path === 'pages/index/index' && options.query?.tab === '1') {
12
+  //   }
13
+  // }
15 14
 
16 15
   onLaunch(options) {
17 16
     console.group('APP Launch')
18 17
     console.debug(options)
19 18
     console.groupEnd()
19
+   
20
+      Taro.login({
21
+        success: (res) => {
22
+          const { code } = res;
23
+          signIn({ code })
24
+        }
25
+      })
20 26
 
21 27
     // const { login } = store.getModel('person').getState()
22 28
 

+ 8
- 0
src/services/login.js Ver arquivo

@@ -0,0 +1,8 @@
1
+import request from '@/utils/request'
2
+
3
+/**
4
+ * 登录
5
+ * @param {*} data 
6
+ * @returns 
7
+ */
8
+export const signIn = (data) => request('/login', { data, method: 'post' })

+ 8
- 1
src/utils/request.js Ver arquivo

@@ -4,12 +4,19 @@ import { getQueryString } from '.'
4 4
 
5 5
 const logger = Taro.getRealtimeLogManager()
6 6
 
7
+let appid = null;
8
+
7 9
 export default (url, options) => {
8 10
   const { params, skipError, header, ...leftOptions } = options || {}
9 11
   const queryStr = getQueryString(params)
10 12
 
13
+  if (!appid) {
14
+    const { miniProgram } = Taro.getAccountInfoSync();
15
+    appid = miniProgram.appId
16
+  }
17
+
11 18
   const urlWithParams = queryStr ? `${url}?${queryStr}` : url;
12
-  const nwUrl = `${HOST}/api/wx${urlWithParams}`
19
+  const nwUrl = `${HOST}/api/wx/${appid}${urlWithParams}`
13 20
 
14 21
   const authToken = Taro.getStorageSync('token')
15 22
   const tokenHeader = authToken ? { 'X-Authorization-JWT': authToken } : {}