Yansen пре 2 година
родитељ
комит
c10265e7a5
18 измењених фајлова са 4066 додато и 198 уклоњено
  1. 3
    0
      .gitignore
  2. 1
    0
      .npmrc
  3. 12
    1
      babel.config.js
  4. 2
    0
      config/dev.js
  5. 10
    0
      config/index.js
  6. 2
    0
      config/prod.js
  7. 0
    18
      global.d.ts
  8. 11
    0
      jsconfig.json
  9. 14
    10
      package.json
  10. 12
    2
      src/app.config.js
  11. 1
    1
      src/pages/index/index.config.js
  12. 8
    19
      src/pages/index/index.jsx
  13. 3
    0
      src/pages/mine/index.config.js
  14. 13
    0
      src/pages/mine/index.jsx
  15. 0
    0
      src/pages/mine/index.less
  16. 80
    0
      src/utils/request.js
  17. 0
    31
      tsconfig.json
  18. 3894
    116
      yarn.lock

+ 3
- 0
.gitignore Прегледај датотеку

@@ -4,3 +4,6 @@ deploy_versions/
4 4
 .rn_temp/
5 5
 node_modules/
6 6
 .DS_Store
7
+*.lock
8
+pnpm-lock.yml
9
+yarn-error.log

+ 1
- 0
.npmrc Прегледај датотеку

@@ -0,0 +1 @@
1
+registry=https://registry.npm.taobao.org

+ 12
- 1
babel.config.js Прегледај датотеку

@@ -4,7 +4,18 @@ module.exports = {
4 4
   presets: [
5 5
     ['taro', {
6 6
       framework: 'react',
7
-      ts: true
7
+      ts: false
8 8
     }]
9
+  ],
10
+  plugins: [
11
+    [
12
+      'import',
13
+      {
14
+        libraryName: '@antmjs/vantui',
15
+        libraryDirectory: 'es',
16
+        style: (name) => `${name}/style/less`
17
+      },
18
+      '@antmjs/vantui'
19
+    ],
9 20
   ]
10 21
 }

+ 2
- 0
config/dev.js Прегледај датотеку

@@ -3,6 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"development"'
4 4
   },
5 5
   defineConstants: {
6
+    // HOST: '"https://machine.njyunzhi.com"',
7
+    HOST: '"http://192.168.89.147:7083"',
6 8
   },
7 9
   mini: {},
8 10
   h5: {}

+ 10
- 0
config/index.js Прегледај датотеку

@@ -1,3 +1,5 @@
1
+const path = require('path')
2
+
1 3
 const config = {
2 4
   projectName: 'myApp',
3 5
   date: '2022-11-16',
@@ -18,6 +20,14 @@ const config = {
18 20
     options: {
19 21
     }
20 22
   },
23
+  alias: {
24
+    '@/assets': path.resolve(__dirname, '..', 'src/assets'),
25
+    '@/components': path.resolve(__dirname, '..', 'src/components'),
26
+    '@/layouts': path.resolve(__dirname, '..', 'src/layouts'),
27
+    '@/utils': path.resolve(__dirname, '..', 'src/utils'),
28
+    '@/store': path.resolve(__dirname, '..', 'src/store'),
29
+    '@/services': path.resolve(__dirname, '..', 'src/services'),
30
+  },
21 31
   framework: 'react',
22 32
   mini: {
23 33
     postcss: {

+ 2
- 0
config/prod.js Прегледај датотеку

@@ -3,6 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"production"'
4 4
   },
5 5
   defineConstants: {
6
+    // HOST: '"https://machine.njyunzhi.com"',
7
+    HOST: '"http://192.168.89.147:7083"',
6 8
   },
7 9
   mini: {},
8 10
   h5: {

+ 0
- 18
global.d.ts Прегледај датотеку

@@ -1,18 +0,0 @@
1
-/// <reference path="node_modules/@tarojs/plugin-platform-weapp/types/shims-weapp.d.ts" />
2
-
3
-declare module '*.png';
4
-declare module '*.gif';
5
-declare module '*.jpg';
6
-declare module '*.jpeg';
7
-declare module '*.svg';
8
-declare module '*.css';
9
-declare module '*.less';
10
-declare module '*.scss';
11
-declare module '*.sass';
12
-declare module '*.styl';
13
-
14
-declare namespace NodeJS {
15
-  interface ProcessEnv {
16
-    TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
17
-  }
18
-}

+ 11
- 0
jsconfig.json Прегледај датотеку

@@ -0,0 +1,11 @@
1
+{
2
+  "compilerOptions": {
3
+    "jsx": "react-jsx",
4
+    "emitDecoratorMetadata": true,
5
+    "experimentalDecorators": true,
6
+    "baseUrl": ".",
7
+    "paths": {
8
+      "@/*": ["./src/*"]
9
+    }
10
+  }
11
+}

+ 14
- 10
package.json Прегледај датотеку

@@ -9,6 +9,8 @@
9 9
     "css": "less"
10 10
   },
11 11
   "scripts": {
12
+    "dev": "npm run build:weapp -- --watch",
13
+    "build": "taro build --type weapp",
12 14
     "build:weapp": "taro build --type weapp",
13 15
     "build:swan": "taro build --type swan",
14 16
     "build:alipay": "taro build --type alipay",
@@ -35,29 +37,31 @@
35 37
   ],
36 38
   "author": "",
37 39
   "dependencies": {
40
+    "@antmjs/vantui": "^2.2.8",
38 41
     "@babel/runtime": "^7.7.7",
39 42
     "@tarojs/components": "3.3.6",
43
+    "@tarojs/react": "3.3.6",
40 44
     "@tarojs/runtime": "3.3.6",
41 45
     "@tarojs/taro": "3.3.6",
42
-    "@tarojs/react": "3.3.6",
43
-    "react-dom": "^17.0.0",
44
-    "react": "^17.0.0"
46
+    "react": "^17.0.0",
47
+    "react-dom": "^17.0.0"
45 48
   },
46 49
   "devDependencies": {
47
-    "@types/webpack-env": "^1.13.6",
48
-    "@types/react": "^17.0.2",
49
-    "@tarojs/mini-runner": "3.3.6",
50 50
     "@babel/core": "^7.8.0",
51
+    "@tarojs/mini-runner": "3.3.6",
51 52
     "@tarojs/webpack-runner": "3.3.6",
53
+    "@types/react": "^17.0.2",
54
+    "@types/webpack-env": "^1.13.6",
55
+    "@typescript-eslint/eslint-plugin": "^4.15.1",
56
+    "@typescript-eslint/parser": "^4.15.1",
57
+    "babel-plugin-import": "^1.13.5",
52 58
     "babel-preset-taro": "3.3.6",
53
-    "eslint-config-taro": "3.3.6",
54 59
     "eslint": "^6.8.0",
55
-    "eslint-plugin-react": "^7.8.2",
60
+    "eslint-config-taro": "3.3.6",
56 61
     "eslint-plugin-import": "^2.12.0",
62
+    "eslint-plugin-react": "^7.8.2",
57 63
     "eslint-plugin-react-hooks": "^4.2.0",
58 64
     "stylelint": "9.3.0",
59
-    "@typescript-eslint/parser": "^4.15.1",
60
-    "@typescript-eslint/eslint-plugin": "^4.15.1",
61 65
     "typescript": "^4.1.0"
62 66
   }
63 67
 }

+ 12
- 2
src/app.config.js Прегледај датотеку

@@ -1,11 +1,21 @@
1 1
 export default {
2 2
   pages: [
3
-    'pages/index/index'
3
+    'pages/index/index',
4
+    'pages/mine/index'
4 5
   ],
5 6
   window: {
6 7
     backgroundTextStyle: 'light',
7 8
     navigationBarBackgroundColor: '#fff',
8 9
     navigationBarTitleText: 'WeChat',
9 10
     navigationBarTextStyle: 'black'
10
-  }
11
+  },
12
+  tabBar: {
13
+    list: [{
14
+      pagePath: "pages/index/index",
15
+      text: "设备绑定"
16
+    }, {
17
+      pagePath: "pages/mine/index",
18
+      text: "我的"
19
+    }]
20
+  },
11 21
 }

+ 1
- 1
src/pages/index/index.config.js Прегледај датотеку

@@ -1,3 +1,3 @@
1 1
 export default {
2
-  navigationBarTitleText: '首页'
2
+  navigationBarTitleText: '绑定设备'
3 3
 }

+ 8
- 19
src/pages/index/index.jsx Прегледај датотеку

@@ -1,24 +1,13 @@
1 1
 import { Component } from 'react'
2
-import { View, Text } from '@tarojs/components'
2
+import { View } from '@tarojs/components'
3
+import { Button } from '@antmjs/vantui'
3 4
 import './index.less'
4 5
 
5
-export default class Index extends Component {
6
+export default (props) => {
6 7
 
7
-  componentWillMount () { }
8
-
9
-  componentDidMount () { }
10
-
11
-  componentWillUnmount () { }
12
-
13
-  componentDidShow () { }
14
-
15
-  componentDidHide () { }
16
-
17
-  render () {
18
-    return (
19
-      <View className='index'>
20
-        <Text>Hello world!</Text>
21
-      </View>
22
-    )
23
-  }
8
+  return (
9
+    <View>
10
+      <Button type="warning">123</Button>
11
+    </View>
12
+  )
24 13
 }

+ 3
- 0
src/pages/mine/index.config.js Прегледај датотеку

@@ -0,0 +1,3 @@
1
+export default {
2
+  navigationBarTitleText: '我的'
3
+}

+ 13
- 0
src/pages/mine/index.jsx Прегледај датотеку

@@ -0,0 +1,13 @@
1
+import { Component } from 'react'
2
+import { View } from '@tarojs/components'
3
+import { Button } from '@antmjs/vantui'
4
+import './index.less'
5
+
6
+export default (props) => {
7
+
8
+  return (
9
+    <View>
10
+      <Button type="warning">123</Button>
11
+    </View>
12
+  )
13
+}

+ 0
- 0
src/pages/mine/index.less Прегледај датотеку


+ 80
- 0
src/utils/request.js Прегледај датотеку

@@ -0,0 +1,80 @@
1
+import Taro from '@tarojs/taro'
2
+
3
+/**
4
+ * object 转 queryStr
5
+ * @param {*} params 
6
+ * @returns 
7
+ */
8
+ export function getQueryString (params) {
9
+  if (!params) return;
10
+
11
+  const keys = Object.keys(params)
12
+  const arr = keys.map((key) => {
13
+    const val = params[key]
14
+    if (val === null || val === undefined) return false;
15
+
16
+    return `${key}=${encodeURIComponent(val)}`
17
+  })
18
+
19
+  return arr.filter(Boolean).join('&')
20
+}
21
+
22
+
23
+export default (url, options) => {
24
+  const { params, skipError, header, ...leftOptions } = options || {}
25
+  const queryStr = getQueryString(params)
26
+
27
+  const urlWithParams = queryStr ? `${url}?${queryStr}` : url;
28
+  // eslint-disable-next-line no-undef
29
+  const nwUrl = `${HOST}/api/${urlWithParams}`
30
+
31
+  const authToken = Taro.getStorageSync('token')
32
+  const tokenHeader = authToken ? { Authorization: authToken } : {}
33
+  const nwHeader = {
34
+    ...(header || {}),
35
+    ...tokenHeader,
36
+  }
37
+
38
+  return new Promise((resolve, reject) => {
39
+    Taro.request({
40
+      ...leftOptions,
41
+      url: nwUrl,
42
+      header: nwHeader,
43
+      success: (res) => {
44
+        const { code, message, data, token } = res.data
45
+
46
+        if (token || data?.token) {
47
+          Taro.setStorage({ key: 'token', data: token || data?.token })
48
+        }
49
+
50
+        if (code === 1000) {
51
+          resolve(data)
52
+
53
+        } else {
54
+          if (!skipError) {
55
+            Taro.showToast({
56
+              title: message || '网络异常',
57
+              icon: 'none',
58
+            })
59
+          }
60
+          reject(message?.indexOf('java') > -1 ? '系统内部错误' : message)
61
+        }
62
+      },
63
+
64
+      fail: (err) => {
65
+        console.error(err)
66
+
67
+        const message = err.message || err.errMsg || err
68
+
69
+        if (!skipError) {
70
+          Taro.showToast({
71
+            title: message,
72
+            icon: 'none',
73
+          })
74
+        }
75
+
76
+        reject(message)
77
+      }
78
+    })
79
+  })
80
+}

+ 0
- 31
tsconfig.json Прегледај датотеку

@@ -1,31 +0,0 @@
1
-{
2
-  "compilerOptions": {
3
-    "target": "es2017",
4
-    "module": "commonjs",
5
-    "removeComments": false,
6
-    "preserveConstEnums": true,
7
-    "moduleResolution": "node",
8
-    "experimentalDecorators": true,
9
-    "noImplicitAny": false,
10
-    "allowSyntheticDefaultImports": true,
11
-    "outDir": "lib",
12
-    "noUnusedLocals": true,
13
-    "noUnusedParameters": true,
14
-    "strictNullChecks": true,
15
-    "sourceMap": true,
16
-    "baseUrl": ".",
17
-    "rootDir": ".",
18
-    "jsx": "react-jsx",
19
-    "allowJs": true,
20
-    "resolveJsonModule": true,
21
-    "typeRoots": [
22
-      "node_modules/@types",
23
-      "global.d.ts"
24
-    ]
25
-  },
26
-  "exclude": [
27
-    "node_modules",
28
-    "dist"
29
-  ],
30
-  "compileOnSave": false
31
-}

+ 3894
- 116
yarn.lock
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку