Browse Source

初始化

HW 4 years ago
parent
commit
176aba7d60
95 changed files with 24711 additions and 0 deletions
  1. 12 0
      .editorconfig
  2. 7 0
      .eslintrc.js
  3. 6 0
      .gitignore
  4. 10 0
      babel.config.js
  5. 9 0
      config/dev.js
  6. 70 0
      config/index.js
  7. 18 0
      config/prod.js
  8. 10 0
      iconfont.json
  9. 70 0
      package.json
  10. 44 0
      project.config.json
  11. 31 0
      src/actions/counter.js
  12. 27 0
      src/app.config.js
  13. 31 0
      src/app.jsx
  14. 0 0
      src/app.less
  15. BIN
      src/assets/images/background.png
  16. 8 0
      src/components/common/mp-weixin/index.js
  17. 1 0
      src/components/common/mp-weixin/index.json
  18. 1 0
      src/components/common/mp-weixin/index.wxml
  19. 1 0
      src/components/common/mp-weixin/index.wxss
  20. 1 0
      src/components/common/mp-weixin/node/node.js
  21. 1 0
      src/components/common/mp-weixin/node/node.json
  22. 1 0
      src/components/common/mp-weixin/node/node.wxml
  23. 1 0
      src/components/common/mp-weixin/node/node.wxss
  24. 1 0
      src/components/common/mp-weixin/parser.js
  25. 3 0
      src/components/iconfont/alipay/alipay.acss
  26. 5 0
      src/components/iconfont/alipay/alipay.axml
  27. 44 0
      src/components/iconfont/alipay/alipay.js
  28. 3 0
      src/components/iconfont/alipay/alipay.json
  29. 467 0
      src/components/iconfont/h5/Changyouhuashi.js
  30. 27 0
      src/components/iconfont/h5/Gift.js
  31. 17 0
      src/components/iconfont/h5/helper.js
  32. 19 0
      src/components/iconfont/h5/index.js
  33. 2 0
      src/components/iconfont/helper.d.ts
  34. 9 0
      src/components/iconfont/helper.js
  35. 16 0
      src/components/iconfont/index.alipay.js
  36. 13 0
      src/components/iconfont/index.d.ts
  37. 17 0
      src/components/iconfont/index.h5.js
  38. 7 0
      src/components/iconfont/index.js
  39. 16 0
      src/components/iconfont/index.qq.js
  40. 17 0
      src/components/iconfont/index.rn.js
  41. 16 0
      src/components/iconfont/index.swan.js
  42. 16 0
      src/components/iconfont/index.tt.js
  43. 16 0
      src/components/iconfont/index.weapp.js
  44. 31 0
      src/components/iconfont/qq/qq.js
  45. 4 0
      src/components/iconfont/qq/qq.json
  46. 5 0
      src/components/iconfont/qq/qq.qml
  47. 3 0
      src/components/iconfont/qq/qq.qss
  48. 462 0
      src/components/iconfont/rn/Changyouhuashi.js
  49. 22 0
      src/components/iconfont/rn/Gift.js
  50. 17 0
      src/components/iconfont/rn/helper.js
  51. 19 0
      src/components/iconfont/rn/index.js
  52. 3 0
      src/components/iconfont/swan/swan.css
  53. 32 0
      src/components/iconfont/swan/swan.js
  54. 4 0
      src/components/iconfont/swan/swan.json
  55. 5 0
      src/components/iconfont/swan/swan.swan
  56. 32 0
      src/components/iconfont/tt/tt.js
  57. 3 0
      src/components/iconfont/tt/tt.json
  58. 5 0
      src/components/iconfont/tt/tt.ttml
  59. 3 0
      src/components/iconfont/tt/tt.ttss
  60. 63 0
      src/components/iconfont/weapp/weapp.js
  61. 4 0
      src/components/iconfont/weapp/weapp.json
  62. 5 0
      src/components/iconfont/weapp/weapp.wxml
  63. 3 0
      src/components/iconfont/weapp/weapp.wxss
  64. 3 0
      src/constants/counter.js
  65. BIN
      src/custom-tab-bar/image/icon_API.png
  66. BIN
      src/custom-tab-bar/image/icon_API_HL.png
  67. BIN
      src/custom-tab-bar/image/icon_component.png
  68. BIN
      src/custom-tab-bar/image/icon_component_HL.png
  69. 94 0
      src/custom-tab-bar/index.jsx
  70. 66 0
      src/custom-tab-bar/index.less
  71. 20 0
      src/index.html
  72. 8 0
      src/pages/details/index.config.js
  73. 285 0
      src/pages/details/index.jsx
  74. 93 0
      src/pages/details/index.less
  75. 11 0
      src/pages/index/index.config.js
  76. 210 0
      src/pages/index/index.jsx
  77. 67 0
      src/pages/index/index.less
  78. 5 0
      src/pages/user/index.config.js
  79. 141 0
      src/pages/user/index.jsx
  80. 3 0
      src/pages/user/index.less
  81. 27 0
      src/reducers/counter.js
  82. 6 0
      src/reducers/index.js
  83. 28 0
      src/store/index.js
  84. 7 0
      src/utils/API/h5.js
  85. 8 0
      src/utils/API/index.js
  86. 9 0
      src/utils/API/wx.js
  87. 1 0
      src/utils/config.js
  88. 13 0
      src/utils/servers/baseUrl.js
  89. 13 0
      src/utils/servers/config.js
  90. 49 0
      src/utils/servers/http.js
  91. 38 0
      src/utils/servers/interceptors.js
  92. 27 0
      src/utils/servers/servers.js
  93. 19 0
      src/utils/servers/utils.js
  94. 10814 0
      yarn-error.log
  95. 10830 0
      yarn.lock

+ 12 - 0
.editorconfig

@@ -0,0 +1,12 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false

+ 7 - 0
.eslintrc.js

@@ -0,0 +1,7 @@
+module.exports = {
+  "extends": ["taro/react"],
+  "rules": {
+    "react/jsx-uses-react": "off",
+    "react/react-in-jsx-scope": "off"
+  }
+}

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
+dist/
+deploy_versions/
+.temp/
+.rn_temp/
+node_modules/
+.DS_Store

+ 10 - 0
babel.config.js

@@ -0,0 +1,10 @@
+// babel-preset-taro 更多选项和默认值:
+// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
+module.exports = {
+  presets: [
+    ['taro', {
+      framework: 'react',
+      ts: false
+    }]
+  ]
+}

+ 9 - 0
config/dev.js

@@ -0,0 +1,9 @@
+module.exports = {
+  env: {
+    NODE_ENV: '"development"'
+  },
+  defineConstants: {
+  },
+  mini: {},
+  h5: {}
+}

+ 70 - 0
config/index.js

@@ -0,0 +1,70 @@
+const config = {
+  projectName: 'myApp',
+  date: '2021-3-30',
+  designWidth: 750,
+  deviceRatio: {
+    640: 2.34 / 2,
+    750: 1,
+    828: 1.81 / 2
+  },
+  sourceRoot: 'src',
+  outputRoot: 'dist',
+  plugins: [],
+  defineConstants: {
+  },
+  copy: {
+    patterns: [
+    ],
+    options: {
+    }
+  },
+  framework: 'react',
+  mini: {
+    postcss: {
+      pxtransform: {
+        enable: true,
+        config: {
+
+        }
+      },
+      url: {
+        enable: true,
+        config: {
+          limit: 1024 // 设定转换尺寸上限
+        }
+      },
+      cssModules: {
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
+        config: {
+          namingPattern: 'module', // 转换模式,取值为 global/module
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
+        }
+      }
+    }
+  },
+  h5: {
+    publicPath: '/',
+    staticDirectory: 'static',
+    postcss: {
+      autoprefixer: {
+        enable: true,
+        config: {
+        }
+      },
+      cssModules: {
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
+        config: {
+          namingPattern: 'module', // 转换模式,取值为 global/module
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
+        }
+      }
+    }
+  }
+}
+
+module.exports = function (merge) {
+  if (process.env.NODE_ENV === 'development') {
+    return merge({}, config, require('./dev'))
+  }
+  return merge({}, config, require('./prod'))
+}

+ 18 - 0
config/prod.js

@@ -0,0 +1,18 @@
+module.exports = {
+  env: {
+    NODE_ENV: '"production"'
+  },
+  defineConstants: {
+  },
+  mini: {},
+  h5: {
+    /**
+     * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
+     * 参考代码如下:
+     * webpackChain (chain) {
+     *   chain.plugin('analyzer')
+     *     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
+     * }
+     */
+  }
+}

+ 10 - 0
iconfont.json

@@ -0,0 +1,10 @@
+{
+    "symbol_url": "http://at.alicdn.com/t/font_2471127_54wgv5uynm.js",
+    "save_dir": "./src/components/iconfont",
+    "use_typescript": false,
+    "platforms": "*",
+    "use_rpx": true,
+    "trim_icon_prefix": "icon",
+    "default_icon_size": 18,
+    "design_width": 750
+}

+ 70 - 0
package.json

@@ -0,0 +1,70 @@
+{
+  "name": "myApp",
+  "version": "1.0.0",
+  "private": true,
+  "description": "我的项目",
+  "templateInfo": {
+    "name": "redux",
+    "typescript": false,
+    "css": "less"
+  },
+  "scripts": {
+    "build:weapp": "taro build --type weapp",
+    "build:swan": "taro build --type swan",
+    "build:alipay": "taro build --type alipay",
+    "build:tt": "taro build --type tt",
+    "build:h5": "taro build --type h5",
+    "build:rn": "taro build --type rn",
+    "build:qq": "taro build --type qq",
+    "build:jd": "taro build --type jd",
+    "build:quickapp": "taro build --type quickapp",
+    "dev:weapp": "npm run build:weapp -- --watch",
+    "dev:swan": "npm run build:swan -- --watch",
+    "dev:alipay": "npm run build:alipay -- --watch",
+    "dev:tt": "npm run build:tt -- --watch",
+    "dev:h5": "npm run build:h5 -- --watch",
+    "dev:rn": "npm run build:rn -- --watch",
+    "dev:qq": "npm run build:qq -- --watch",
+    "dev:jd": "npm run build:jd -- --watch",
+    "dev:quickapp": "npm run build:quickapp -- --watch"
+  },
+  "browserslist": [
+    "last 3 versions",
+    "Android >= 4.1",
+    "ios >= 8"
+  ],
+  "author": "",
+  "license": "MIT",
+  "dependencies": {
+    "@babel/runtime": "^7.7.7",
+    "@tarojs/components": "3.1.4",
+    "@tarojs/react": "3.1.4",
+    "@tarojs/runtime": "3.1.4",
+    "@tarojs/taro": "3.1.4",
+    "mp-html": "^2.1.0",
+    "qs": "^6.10.1",
+    "react": "^17.0.0",
+    "react-dom": "^17.0.0",
+    "react-redux": "^7.2.0",
+    "redux": "^4.0.0",
+    "redux-logger": "^3.0.6",
+    "redux-thunk": "^2.3.0",
+    "taro-listview": "^2.0.4"
+  },
+  "devDependencies": {
+    "@babel/core": "^7.8.0",
+    "@tarojs/mini-runner": "3.1.4",
+    "@tarojs/webpack-runner": "3.1.4",
+    "@types/react": "^17.0.2",
+    "@types/webpack-env": "^1.13.6",
+    "babel-preset-taro": "3.1.4",
+    "eslint": "^6.8.0",
+    "eslint-config-taro": "3.1.4",
+    "eslint-plugin-import": "^2.12.0",
+    "eslint-plugin-react": "^7.8.2",
+    "eslint-plugin-react-hooks": "^4.2.0",
+    "stylelint": "9.3.0",
+    "taro-iconfont-cli": "^3.2.1",
+    "taro-ui": "^3.0.0-alpha"
+  }
+}

+ 44 - 0
project.config.json

@@ -0,0 +1,44 @@
+{
+  "miniprogramRoot": "dist/",
+  "projectname": "myApp",
+  "description": "我的项目",
+  "appid": "wx466d25d822867332",
+  "setting": {
+    "urlCheck": false,
+    "es6": false,
+    "enhance": false,
+    "postcss": false,
+    "preloadBackgroundData": false,
+    "minified": false,
+    "newFeature": false,
+    "coverView": true,
+    "nodeModules": false,
+    "autoAudits": false,
+    "showShadowRootInWxmlPanel": true,
+    "scopeDataCheck": false,
+    "uglifyFileName": false,
+    "checkInvalidKey": true,
+    "checkSiteMap": true,
+    "uploadWithSourceMap": true,
+    "compileHotReLoad": false,
+    "useMultiFrameRuntime": true,
+    "useApiHook": true,
+    "useApiHostProcess": true,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "enableEngineNative": false,
+    "bundle": false,
+    "useIsolateContext": true,
+    "useCompilerModule": true,
+    "userConfirmedUseCompilerModuleSwitch": false,
+    "userConfirmedBundleSwitch": false,
+    "packNpmManually": false,
+    "packNpmRelationList": [],
+    "minifyWXSS": true
+  },
+  "compileType": "miniprogram",
+  "condition": {}
+}

+ 31 - 0
src/actions/counter.js

@@ -0,0 +1,31 @@
+import {
+  ADD,
+  MINUS,
+  SET
+} from '../constants/counter'
+
+export const add = () => {
+  return {
+    type: ADD
+  }
+}
+export const minus = () => {
+  return {
+    type: MINUS
+  }
+}
+export const set = (value) => {
+  return {
+    type: SET,
+    value,
+  }
+}
+
+// 异步的action
+export function asyncAdd () {
+  return dispatch => {
+    setTimeout(() => {
+      dispatch(add())
+    }, 2000)
+  }
+}

+ 27 - 0
src/app.config.js

@@ -0,0 +1,27 @@
+import { useGlobalIconFont } from './components/iconfont/helper';
+export default {
+  pages: [
+    'pages/index/index',
+    'pages/user/index',
+    'pages/details/index'
+  ],
+  window: {
+    backgroundTextStyle: 'light',
+    navigationBarBackgroundColor: '#fff',
+    navigationBarTitleText: 'WeChat',
+    navigationBarTextStyle: 'black',
+
+  },
+  usingComponents: Object.assign(useGlobalIconFont()),
+  tabBar: {
+    custom: true,
+    list: [{
+      pagePath: "pages/index/index",
+      text: "首页"
+    }, {
+      pagePath: "pages/user/index",
+      text: "我的",
+      badge: '444'
+    }]
+  },
+}

+ 31 - 0
src/app.jsx

@@ -0,0 +1,31 @@
+import { Component } from 'react'
+import { Provider } from 'react-redux'
+
+import configStore from './store'
+
+import './app.less'
+import 'taro-ui/dist/style/index.scss'
+
+const store = configStore()
+
+class App extends Component {
+  componentDidMount () {}
+
+  componentDidShow () {}
+
+  componentDidHide () {}
+
+  componentDidCatchError () {}
+
+  // 在 App 类中的 render() 函数没有实际作用
+  // 请勿修改此函数
+  render () {
+    return (
+      <Provider store={store}>
+        {this.props.children}
+      </Provider>
+    )
+  }
+}
+
+export default App

+ 0 - 0
src/app.less


BIN
src/assets/images/background.png


File diff suppressed because it is too large
+ 8 - 0
src/components/common/mp-weixin/index.js


+ 1 - 0
src/components/common/mp-weixin/index.json

@@ -0,0 +1 @@
+{"component":true,"usingComponents":{"node":"./node/node"}}

+ 1 - 0
src/components/common/mp-weixin/index.wxml

@@ -0,0 +1 @@
+<view class="_root {{selectable?'_select':''}}" style="{{containerStyle}}"><slot wx:if="{{!nodes[0]}}"/><node id="_root" childs="{{nodes}}" opts="{{[lazyLoad,loadingImg,errorImg,showImgMenu]}}" catchadd="_add"/></view>

+ 1 - 0
src/components/common/mp-weixin/index.wxss

@@ -0,0 +1 @@
+._root{padding:1px 0;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}._select{-webkit-user-select:text;user-select:text}

File diff suppressed because it is too large
+ 1 - 0
src/components/common/mp-weixin/node/node.js


+ 1 - 0
src/components/common/mp-weixin/node/node.json

@@ -0,0 +1 @@
+{"component":true,"usingComponents":{"node":"./node"}}

File diff suppressed because it is too large
+ 1 - 0
src/components/common/mp-weixin/node/node.wxml


File diff suppressed because it is too large
+ 1 - 0
src/components/common/mp-weixin/node/node.wxss


File diff suppressed because it is too large
+ 1 - 0
src/components/common/mp-weixin/parser.js


+ 3 - 0
src/components/iconfont/alipay/alipay.acss

@@ -0,0 +1,3 @@
+.icon {
+  background-repeat: no-repeat;
+}

File diff suppressed because it is too large
+ 5 - 0
src/components/iconfont/alipay/alipay.axml


+ 44 - 0
src/components/iconfont/alipay/alipay.js

@@ -0,0 +1,44 @@
+Component({
+  props: {
+    // changyouhuashi | gift
+    name: null,
+    // string | string[]
+    color: '',
+    size: 18,
+  },
+  data: {
+    quot: '"',
+    svgSize: 18,
+    isStr: true,
+  },
+  didMount() {
+    const size = this.props.size;
+    const color = this.props.color;
+
+    this.setData({
+      isStr: typeof color === 'string',
+    });
+
+    if (size !== this.data.svgSize) {
+      this.setData({
+        svgSize: size / 750 * my.getSystemInfoSync().windowWidth,
+      });
+    }
+  },
+  disUpdate(prevProps) {
+    const size = this.props.size;
+    const color = this.props.color;
+
+    if (color !== prevProps.color) {
+      this.setData({
+        isStr: typeof color === 'string',
+      });
+    }
+
+    if (size !== prevProps.size) {
+      this.setData({
+        svgSize: size / 750 * my.getSystemInfoSync().windowWidth,
+      });
+    }
+  },
+});

+ 3 - 0
src/components/iconfont/alipay/alipay.json

@@ -0,0 +1,3 @@
+{
+  "component": true
+}

File diff suppressed because it is too large
+ 467 - 0
src/components/iconfont/h5/Changyouhuashi.js


File diff suppressed because it is too large
+ 27 - 0
src/components/iconfont/h5/Gift.js


+ 17 - 0
src/components/iconfont/h5/helper.js

@@ -0,0 +1,17 @@
+/* eslint-disable */
+
+/**
+ * @param {string | string[] | undefined} color
+ * @param {number} index
+ * @param {string} defaultColor
+ * @return {string}
+ */
+export const getIconColor = (color, index, defaultColor) => {
+  return color
+    ? (
+      typeof color === 'string'
+        ? color
+        : color[index] || defaultColor
+    )
+    : defaultColor;
+};

+ 19 - 0
src/components/iconfont/h5/index.js

@@ -0,0 +1,19 @@
+/* eslint-disable */
+
+import React from 'react';
+import Changyouhuashi from './Changyouhuashi';
+import Gift from './Gift';
+
+const IconFont = ({ name, ...rest }) => {
+  switch (name) {
+    case 'changyouhuashi':
+      return <Changyouhuashi {...rest} />;
+    case 'gift':
+      return <Gift {...rest} />;
+
+  }
+
+  return null;
+};
+
+export default IconFont;

+ 2 - 0
src/components/iconfont/helper.d.ts

@@ -0,0 +1,2 @@
+/* eslint-disable */
+export declare var useGlobalIconFont: () => { iconfont: string };

+ 9 - 0
src/components/iconfont/helper.js

@@ -0,0 +1,9 @@
+/* eslint-disable */
+const useGlobalIconFont = () => {
+  return {
+    iconfont: `components/iconfont/${process.env.TARO_ENV}/${process.env.TARO_ENV}`,
+  };
+};
+
+// es modules is unavaiable.
+module.exports.useGlobalIconFont = useGlobalIconFont;

+ 16 - 0
src/components/iconfont/index.alipay.js

@@ -0,0 +1,16 @@
+/* eslint-disable */
+
+import React from 'react';
+import Taro from '@tarojs/taro';
+
+const IconFont = (props) => {
+  const { name, size, color, style } = props;
+
+  return <iconfont name={name} size={parseFloat(Taro.pxTransform(size))} color={color} style={style} />;
+};
+
+IconFont.defaultProps = {
+  size: 18,
+};
+
+export default IconFont;

+ 13 - 0
src/components/iconfont/index.d.ts

@@ -0,0 +1,13 @@
+/* eslint-disable */
+import React, { FunctionComponent } from 'react';
+
+interface Props {
+  name: 'changyouhuashi' | 'gift';
+  size?: number;
+  color?: string | string[];
+  style?: React.CSSProperties;
+}
+
+declare const IconFont: FunctionComponent<Props>;
+
+export default IconFont;

+ 17 - 0
src/components/iconfont/index.h5.js

@@ -0,0 +1,17 @@
+/* eslint-disable */
+
+import React from 'react';
+import Taro from '@tarojs/taro';
+import Icon from './h5';
+
+const IconFont = (props) => {
+  const { name, size, color, style } = props;
+
+  return <Icon name={name} size={parseFloat(Taro.pxTransform(size, 750))} color={color} style={style} />;
+};
+
+IconFont.defaultProps = {
+  size: 18,
+};
+
+export default IconFont;

+ 7 - 0
src/components/iconfont/index.js

@@ -0,0 +1,7 @@
+/* eslint-disable */
+
+const IconFont = () => {
+  return null;
+};
+
+export default IconFont;

+ 16 - 0
src/components/iconfont/index.qq.js

@@ -0,0 +1,16 @@
+/* eslint-disable */
+
+import React from 'react';
+import Taro from '@tarojs/taro';
+
+const IconFont = (props) => {
+  const { name, size, color, style } = props;
+
+  return <iconfont name={name} size={parseFloat(Taro.pxTransform(size))} color={color} style={style} />;
+};
+
+IconFont.defaultProps = {
+  size: 18,
+};
+
+export default IconFont;

+ 17 - 0
src/components/iconfont/index.rn.js

@@ -0,0 +1,17 @@
+/* eslint-disable */
+
+import React from 'react';
+import Taro from '@tarojs/taro';
+import Icon from './rn';
+
+const IconFont = (props) => {
+  const { name, size, color, style } = props;
+
+  return <Icon name={name} size={parseFloat(Taro.pxTransform(size))} color={color} style={style} />;
+};
+
+IconFont.defaultProps = {
+  size: 18,
+};
+
+export default IconFont;

+ 16 - 0
src/components/iconfont/index.swan.js

@@ -0,0 +1,16 @@
+/* eslint-disable */
+
+import React from 'react';
+import Taro from '@tarojs/taro';
+
+const IconFont = (props) => {
+  const { name, size, color, style } = props;
+
+  return <iconfont name={name} size={parseFloat(Taro.pxTransform(size))} color={color} style={style} />;
+};
+
+IconFont.defaultProps = {
+  size: 18,
+};
+
+export default IconFont;

+ 16 - 0
src/components/iconfont/index.tt.js

@@ -0,0 +1,16 @@
+/* eslint-disable */
+
+import React from 'react';
+import Taro from '@tarojs/taro';
+
+const IconFont = (props) => {
+  const { name, size, color, style } = props;
+
+  return <iconfont name={name} size={parseFloat(Taro.pxTransform(size))} color={color} style={style} />;
+};
+
+IconFont.defaultProps = {
+  size: 18,
+};
+
+export default IconFont;

+ 16 - 0
src/components/iconfont/index.weapp.js

@@ -0,0 +1,16 @@
+/* eslint-disable */
+
+import React from 'react';
+import Taro from '@tarojs/taro';
+
+const IconFont = (props) => {
+  const { name, size, color, style } = props;
+
+  return <iconfont name={name} size={parseFloat(Taro.pxTransform(size))} color={color} style={style} />;
+};
+
+IconFont.defaultProps = {
+  size: 18,
+};
+
+export default IconFont;

+ 31 - 0
src/components/iconfont/qq/qq.js

@@ -0,0 +1,31 @@
+Component({
+  properties: {
+    // changyouhuashi | gift
+    name: {
+      type: String,
+    },
+    // string | string[]
+    color: {
+      type: null,
+      observer: function(color) {
+        this.setData({
+          isStr: typeof color === 'string',
+        });
+      }
+    },
+    size: {
+      type: Number,
+      value: 18,
+      observer: function(size) {
+        this.setData({
+          svgSize: size / 750 * qq.getSystemInfoSync().windowWidth,
+        });
+      },
+    },
+  },
+  data: {
+    svgSize: 18 / 750 * qq.getSystemInfoSync().windowWidth,
+    quot: '"',
+    isStr: true,
+  },
+});

+ 4 - 0
src/components/iconfont/qq/qq.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

File diff suppressed because it is too large
+ 5 - 0
src/components/iconfont/qq/qq.qml


+ 3 - 0
src/components/iconfont/qq/qq.qss

@@ -0,0 +1,3 @@
+.icon {
+  background-repeat: no-repeat;
+}

File diff suppressed because it is too large
+ 462 - 0
src/components/iconfont/rn/Changyouhuashi.js


File diff suppressed because it is too large
+ 22 - 0
src/components/iconfont/rn/Gift.js


+ 17 - 0
src/components/iconfont/rn/helper.js

@@ -0,0 +1,17 @@
+/* eslint-disable */
+
+/**
+ * @param {string | string[] | undefined} color
+ * @param {number} index
+ * @param {string} defaultColor
+ * @return {string}
+ */
+export const getIconColor = (color, index, defaultColor) => {
+  return color
+    ? (
+      typeof color === 'string'
+        ? color
+        : color[index] || defaultColor
+    )
+    : defaultColor;
+};

+ 19 - 0
src/components/iconfont/rn/index.js

@@ -0,0 +1,19 @@
+/* eslint-disable */
+
+import React from 'react';
+
+import Changyouhuashi from './Changyouhuashi';
+import Gift from './Gift';
+
+const IconFont = ({ name, ...rest }) => {
+  switch (name) {
+    case 'changyouhuashi':
+      return <Changyouhuashi {...rest} />;
+    case 'gift':
+      return <Gift {...rest} />;
+  }
+
+  return null;
+};
+
+export default IconFont;

+ 3 - 0
src/components/iconfont/swan/swan.css

@@ -0,0 +1,3 @@
+.icon {
+  background-repeat: no-repeat;
+}

+ 32 - 0
src/components/iconfont/swan/swan.js

@@ -0,0 +1,32 @@
+Component({
+  properties: {
+    // changyouhuashi | gift
+    name: {
+      type: String,
+    },
+    // string | string[]
+    color: {
+      type: null,
+      value: '',
+      observer: function(color) {
+        this.setData({
+          isStr: typeof color === 'string',
+        });
+      }
+    },
+    size: {
+      type: Number,
+      value: 18,
+      observer: function(size) {
+        this.setData({
+          svgSize: size / 750 * swan.getSystemInfoSync().windowWidth,
+        });
+      },
+    },
+  },
+  data: {
+    quot: '"',
+    svgSize: 18 / 750 * swan.getSystemInfoSync().windowWidth,
+    isStr: true,
+  },
+});

+ 4 - 0
src/components/iconfont/swan/swan.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

File diff suppressed because it is too large
+ 5 - 0
src/components/iconfont/swan/swan.swan


+ 32 - 0
src/components/iconfont/tt/tt.js

@@ -0,0 +1,32 @@
+Component({
+  properties: {
+    // changyouhuashi | gift
+    name: {
+      type: String,
+    },
+    // string | string[]
+    color: {
+      type: null,
+      value: '',
+      observer: function(color) {
+        this.setData({
+          isStr: typeof color === 'string',
+        });
+      }
+    },
+    size: {
+      type: Number,
+      value: 18,
+      observer: function(size) {
+        this.setData({
+          svgSize: size / 750 * tt.getSystemInfoSync().windowWidth,
+        });
+      },
+    },
+  },
+  data: {
+    svgSize: 18 / 750 * tt.getSystemInfoSync().windowWidth,
+    quot: '"',
+    isStr: true,
+  },
+});

+ 3 - 0
src/components/iconfont/tt/tt.json

@@ -0,0 +1,3 @@
+{
+  "component": true
+}

File diff suppressed because it is too large
+ 5 - 0
src/components/iconfont/tt/tt.ttml


+ 3 - 0
src/components/iconfont/tt/tt.ttss

@@ -0,0 +1,3 @@
+.icon {
+  background-repeat: no-repeat;
+}

+ 63 - 0
src/components/iconfont/weapp/weapp.js

@@ -0,0 +1,63 @@
+Component({
+  properties: {
+    // changyouhuashi | gift
+    name: {
+      type: String,
+    },
+    // string | string[]
+    color: {
+      type: null,
+      observer: function(color) {
+        this.setData({
+          colors: this.fixColor(),
+          isStr: typeof color === 'string',
+        });
+      }
+    },
+    size: {
+      type: Number,
+      value: 18,
+      observer: function(size) {
+        this.setData({
+          svgSize: size / 750 * wx.getSystemInfoSync().windowWidth,
+        });
+      },
+    },
+  },
+  data: {
+    colors: '',
+    svgSize: 18 / 750 * wx.getSystemInfoSync().windowWidth,
+    quot: '"',
+    isStr: true,
+  },
+  methods: {
+    fixColor: function() {
+      var color = this.data.color;
+      var hex2rgb = this.hex2rgb;
+
+      if (typeof color === 'string') {
+        return color.indexOf('#') === 0 ? hex2rgb(color) : color;
+      }
+
+      return color.map(function (item) {
+        return item.indexOf('#') === 0 ? hex2rgb(item) : item;
+      });
+    },
+    hex2rgb: function(hex) {
+      var rgb = [];
+
+      hex = hex.substr(1);
+
+      if (hex.length === 3) {
+        hex = hex.replace(/(.)/g, '$1$1');
+      }
+
+      hex.replace(/../g, function(color) {
+        rgb.push(parseInt(color, 0x10));
+        return color;
+      });
+
+      return 'rgb(' + rgb.join(',') + ')';
+    }
+  }
+});

+ 4 - 0
src/components/iconfont/weapp/weapp.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

File diff suppressed because it is too large
+ 5 - 0
src/components/iconfont/weapp/weapp.wxml


+ 3 - 0
src/components/iconfont/weapp/weapp.wxss

@@ -0,0 +1,3 @@
+.icon {
+  background-repeat: no-repeat;
+}

+ 3 - 0
src/constants/counter.js

@@ -0,0 +1,3 @@
+export const ADD = 'ADD'
+export const MINUS = 'MINUS'
+export const SET = 'SET'

BIN
src/custom-tab-bar/image/icon_API.png


BIN
src/custom-tab-bar/image/icon_API_HL.png


BIN
src/custom-tab-bar/image/icon_component.png


BIN
src/custom-tab-bar/image/icon_component_HL.png


+ 94 - 0
src/custom-tab-bar/index.jsx

@@ -0,0 +1,94 @@
+import React,{Component} from 'react';
+import Taro from '@tarojs/taro';
+import { View , CoverImage,CoverView } from '@tarojs/components'
+import './index.less'
+
+import icon_component from './image/icon_component.png';
+import icon_component_HL from './image/icon_component_HL.png';
+import icon_API from './image/icon_API.png';
+import icon_API_HL from './image/icon_API_HL.png';
+import {connect} from "react-redux";
+import {add, asyncAdd, minus} from "../actions/counter";
+
+@connect(({ counter }) => ({
+  counter
+}), (dispatch) => ({
+  add () {
+    dispatch(add())
+  },
+  dec () {
+    dispatch(minus())
+  },
+  asyncAdd () {
+    dispatch(asyncAdd())
+  }
+}))
+class CustomTabBar extends Component{
+  constructor(props) {
+    super(props);
+    this.state={
+      color: "#9C9ABB",
+      selectedColor: "#76D3FF",
+      list: [
+        {
+          pagePath: "/pages/index/index",
+          iconPath: icon_component,
+          selectedIconPath: icon_component_HL,
+          text: "组件"
+        },
+        {
+          pagePath: "/pages/user/index",
+          iconPath: icon_API,
+          selectedIconPath: icon_API_HL,
+          text: "接口"
+        },
+        {
+          pagePath: "/pages/user/index",
+          iconPath: icon_API,
+          selectedIconPath: icon_API_HL,
+          text: "接口"
+        },
+      ]
+    }
+    this.switchTab = this.switchTab.bind(this);
+  }
+
+  switchTab(value,key) {
+    Taro.switchTab({
+      url: value.pagePath
+    })
+  }
+
+  render() {
+    return(
+      <View className='tab-bar'>
+        <View className='ss'>
+          <View  className='tab-bar-border'/>
+          {
+            this.state.list.map((v,key)=>(
+              <View key={key} className='tab-bar-item' dataPath={v.pagePath} dataIndex={key} onClick={()=>{
+                this.switchTab(v,key);
+              }}>
+                {
+                  key !== 1 ?
+                    <>
+                      <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>
+                      <View className='View'  style={{color:this.props.counter.num === key ? this.state.selectedColor : this.state.color}}>
+                        {v.text}
+                      </View>
+                    </>:
+                    <View className='zhong' style={{background: '#393484'}}>
+                      <CoverImage className='coverImage' src={this.props.counter.num === key ? v.selectedIconPath : v.iconPath}/>
+                      <View className='View'  style={{color:this.props.counter.num === key ? this.state.selectedColor : this.state.color}}>{v.text}</View>
+                    </View>
+                }
+              </View >
+            ))
+          }
+        </View>
+      </View >
+    )
+  }
+}
+
+export default CustomTabBar;

+ 66 - 0
src/custom-tab-bar/index.less

@@ -0,0 +1,66 @@
+.tab-bar {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  height: 132px;
+  padding-top:23px;
+  display: flex;
+  padding-bottom: env(safe-area-inset-bottom);
+  z-index: 9999999;
+  .ss{
+    display: flex;
+    height: 100%;
+    width: 100%;
+    background: #393484;
+  }
+  .tab-bar-border {
+    background-color: rgba(0, 0, 0, 0.33);
+    position: absolute;
+    left: 0;
+    top: 23px;
+    width: 100%;
+    height: 1px;
+    transform: scaleY(0.5);
+  }
+
+  .tab-bar-item {
+    flex: 1;
+    text-align: center;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    flex-direction: column;
+  }
+
+  .tab-bar-item .coverImage {
+    width: 44px;
+    height: 44px;
+  }
+
+  .tab-bar-item .View {
+    font-size: 18px;
+    padding-top: 10px;
+  }
+
+  .zhong {
+    position: absolute;
+    bottom: 50px;
+    background: #393484;
+    width: 98px;
+    height: 98px;
+    padding: 23px;
+    border-radius: 98px;
+    display: flex;
+    flex-flow: column;
+    align-items: center;
+    .coverImage{
+      width: 75px;
+      height: 75px;
+      padding-top: 8px;
+    }
+    .View{
+      font-size: 18px;
+    }
+  }
+}

+ 20 - 0
src/index.html

@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+  <meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
+  <meta name="apple-mobile-web-app-capable" content="yes">
+  <meta name="apple-touch-fullscreen" content="yes">
+  <meta name="format-detection" content="telephone=no,address=no">
+  <meta name="apple-mobile-web-app-status-bar-style" content="white">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
+  <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js">
+  <title></title>
+  <script>
+    !function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
+  </script>
+</head>
+<body>
+  <div id="app"></div>
+</body>
+</html>

+ 8 - 0
src/pages/details/index.config.js

@@ -0,0 +1,8 @@
+export default {
+  navigationBarTitleText: '产品详情',
+  enablePullDownRefresh: true,
+  backgroundColor: '#000',
+  usingComponents: {
+    "mp-html": "../../components/common/mp-weixin/index",
+  }
+}

File diff suppressed because it is too large
+ 285 - 0
src/pages/details/index.jsx


+ 93 - 0
src/pages/details/index.less

@@ -0,0 +1,93 @@
+.indexPage{
+  .swiper{
+    height: 500px;
+    .swiperImage {
+      width: 100%;
+      height: inherit;
+    }
+  }
+  .content{
+    display: flex;
+    flex-flow: row nowrap;
+    align-items: center;
+    justify-content: space-between;
+    padding: 25px 25px 45px 25px;
+    border-bottom: 20px solid #eae5e5;
+    .contentIntroduce{
+     padding-right: 80px;
+      text-align: center;
+      .title{
+        font-size: 38px;
+        color: #777777;
+      }
+      .introduce{
+        padding-top: 15px;
+        text-align: left;
+        font-size: 25px;
+        color: #777777;
+      }
+      .time{
+        text-align: left;
+        font-size: 18px;
+        color: #666;
+        padding-top: 18px;
+      }
+    }
+    .giveContent{
+      text-align: center;
+      .giveImage{
+        width: 60px;
+        height: 60px;
+      }
+      .time{
+        font-size: 20px;
+        color: #666;
+        white-space: nowrap;
+      }
+    }
+  }
+  .shopInfo{
+    padding: 15px 25px 0px 25px;
+    margin-bottom: 53px;
+    image{
+      width: 100%;
+    }
+  }
+  .at-tabs__item-underline{
+    width: 56%;
+    margin-left: 88px;
+    border-radius: 10px;
+    background-color: #30ec0e;
+    padding-top: 4px;
+    padding-bottom: 4px;
+  }
+  .at-tabs__item {
+    font-size: 34px;
+    color: #777777;
+  }
+  .at-tabs__item--active{
+    color: #30ec0e;
+  }
+  .shop{
+    display: flex;
+    position: fixed;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    height: 120px;
+    color: #FFF;
+    font-size: 35px;
+    .member{
+      flex: 1;
+      text-align: center;
+      background: darkorange;
+      line-height: 120px;
+    }
+    .singlePurchase{
+      flex: 1;
+      text-align: center;
+      background: #30ec0e;
+      line-height: 120px;
+    }
+  }
+}

+ 11 - 0
src/pages/index/index.config.js

@@ -0,0 +1,11 @@
+export default {
+  navigationBarTitleText: '首页',
+  enablePullDownRefresh: true,
+  // navigationStyle: 'custom',
+  navigationBarBackgroundColor:'#77D4FF',
+  backgroundColor: '#FFF',
+  onReachBottomDistance: 310,
+  usingComponents: {
+    "mp-html": "../../components/common/mp-weixin/index",
+  }
+}

File diff suppressed because it is too large
+ 210 - 0
src/pages/index/index.jsx


+ 67 - 0
src/pages/index/index.less

@@ -0,0 +1,67 @@
+.indexPage{
+  position: relative;
+  min-height: 100vh;
+  background: #F5F5F5;
+  z-index: 1;
+  padding-bottom: 202px;
+  .background{
+    position: absolute;
+    top: 0;
+    z-index: -1;
+    width: 100%;
+    height: 300px;
+  }
+  .title{
+    font-size: 37px;
+    color: #393484;
+    font-weight: bolder;
+    padding: 35px 0 30px 25px;
+  }
+  .list{
+    padding: 30px 23px 0 23px;
+    .item{
+      border-radius: 6px;
+      padding: 21px 11px 31px 57px;
+      background: #FFFFFF;
+      display: flex;
+      flex-flow: row nowrap;
+      margin-bottom: 17px;
+      .infor{
+        padding-right: 26px;
+        .name{
+          font-size: 28px;
+          color: #2F3742;
+          font-weight: bolder;
+          line-height: 39px;
+        }
+        .createTimes{
+          display: inline;
+          background: #A1B1F0;
+          border-radius: 2px;
+          font-size: 16px;
+          margin-top: 19px;
+          margin-bottom: 15px;
+          padding: 5px;
+          color: #4564DC;
+        }
+        .amount{
+          display: flex;
+          flex-flow: row nowrap;
+          align-items: flex-end;
+          font-size: 28px;
+          font-weight: bolder;
+          color: #FE3371;
+          .money{
+            padding-left: 10px;
+            font-size: 20px;
+          }
+        }
+      }
+      .thumbnailUrl{
+        width: 200px;
+        height: auto;
+        margin-left: auto;
+      }
+    }
+  }
+}

+ 5 - 0
src/pages/user/index.config.js

@@ -0,0 +1,5 @@
+export default {
+  navigationBarTitleText: '我的',
+  enablePullDownRefresh: true,
+  backgroundColor: '#000',
+}

+ 141 - 0
src/pages/user/index.jsx

@@ -0,0 +1,141 @@
+import { Component } from 'react';
+import Taro,{getCurrentInstance} from '@tarojs/taro';
+import { connect } from 'react-redux'
+import { View, Image, Video,Button,OpenData } from '@tarojs/components'
+import {add, minus, asyncAdd, set} from '../../actions/counter'
+import { Swiper, SwiperItem } from '@tarojs/components'
+import { AtTabs, AtTabsPane } from 'taro-ui'
+import { login,pay,payClose } from '../../utils/servers/servers'
+import './index.less'
+import IconFont from '../../components/iconfont';
+import API from '../../utils/API';
+
+@connect(({ counter }) => ({
+  counter
+}), (dispatch) => ({
+  add () {
+    dispatch(add())
+  },
+  dec () {
+    dispatch(minus())
+  },
+  asyncAdd () {
+    dispatch(asyncAdd())
+  },
+  set (value) {
+    dispatch(set(value))
+  }
+}))
+class Index extends Component {
+
+  inst = Taro.getCurrentInstance()
+
+  constructor(props) {
+    super(props);
+    this.state={
+
+    }
+  }
+
+  componentWillReceiveProps (nextProps) {
+    console.log(this.props, nextProps)
+  }
+
+  componentWillUnmount () { }
+
+  componentDidShow() {
+    this.props.set(1);
+  }
+
+
+  componentWillMount () {
+
+  }
+
+  componentDidHide () { }
+
+  login(){
+    let token = Taro.getStorageSync('token');
+    if(!token){
+      Taro.login({
+        success: function (res) {
+          if (res.code) {
+            login({code:res.code}).then(v => {
+              if(v.error.length === 0){
+                Taro.setStorageSync('token', v.token)
+              }else{
+                Taro.showToast({title:v.error[0].message,icon:'none'})
+              }
+            }).catch(err => {
+              Taro.showToast({title:'系统错误,请稍后重试',icon:'none'});
+              console.log(err)
+            })
+          } else {
+            Taro.showToast({title:res.errMsg,icon:'none'})
+            console.log('登录失败!' + res.errMsg)
+          }
+        }
+      })
+    }
+  }
+
+  getUserInfor(){
+    // Taro.getUserProfile({
+    //   desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+    //   success: (res) => {
+    //     console.log(res)
+    //   }
+    // })
+    Taro.getSetting({
+      success: (res)=>{
+        if (res.authSetting['scope.userInfo']) {
+          // 已经授权,可以直接调用 getUserInfo 获取头像昵称
+          Taro.getUserInfo({
+            success: function(res) {
+              console.log(res)
+            }
+          })
+        }else{
+          Taro.authorize({
+            scope: 'scope.userInfo',
+            success: ()=> {
+              // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
+              Taro.getUserInfo({
+                success: function(res) {
+                  console.log(res)
+                }
+              })
+            }
+          })
+          console.log(11111)
+        }
+      },
+      fail: (err)=>{
+        console.log(err)
+      }
+    })
+  }
+
+  getCode(){
+    let params = getCurrentInstance().router.params
+    console.log(Object.keys(params).length,'this.$router.params')
+    if(Object.keys(params).length === 0){
+      let encodeURI = encodeURIComponent('http://172.16.0.253:10086/#/pages/index/index');
+      let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe99e0a402c1da6b0&redirect_uri=${encodeURI}&response_type=code&scope=snsapi_base&state=12580#wechat_redirect`;
+      window.location.href=url;
+    }else{0
+      console.log(params,'this.$router.params')
+    }
+  }
+
+  render () {
+    return (
+      <View className='userPage'>
+       1111
+      </View>
+    )
+  }
+}
+
+export default Index
+

+ 3 - 0
src/pages/user/index.less

@@ -0,0 +1,3 @@
+.userPage{
+
+}

+ 27 - 0
src/reducers/counter.js

@@ -0,0 +1,27 @@
+import { ADD, MINUS, SET } from '../constants/counter'
+
+const INITIAL_STATE = {
+  num: 0
+}
+
+export default function counter (state = INITIAL_STATE, action) {
+  switch (action.type) {
+    case ADD:
+      return {
+        ...state,
+        num: state.num + 1
+      }
+     case MINUS:
+       return {
+         ...state,
+         num: state.num - 1
+       }
+    case SET:
+      return {
+        ...state,
+        num: action.value
+      }
+     default:
+       return state
+  }
+}

+ 6 - 0
src/reducers/index.js

@@ -0,0 +1,6 @@
+import { combineReducers } from 'redux'
+import counter from './counter'
+
+export default combineReducers({
+  counter
+})

+ 28 - 0
src/store/index.js

@@ -0,0 +1,28 @@
+import { createStore, applyMiddleware, compose } from 'redux'
+import thunkMiddleware from 'redux-thunk'
+import rootReducer from '../reducers'
+
+const composeEnhancers =
+  typeof window === 'object' &&
+  window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?   
+    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
+      // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
+    }) : compose
+
+const middlewares = [
+  thunkMiddleware
+]
+
+if (process.env.NODE_ENV === 'development' && process.env.TARO_ENV !== 'quickapp') {
+  middlewares.push(require('redux-logger').createLogger())
+}
+
+const enhancer = composeEnhancers(
+  applyMiddleware(...middlewares),
+  // other store enhancers if any
+)
+
+export default function configStore () {
+  const store = createStore(rootReducer, enhancer)
+  return store
+}

+ 7 - 0
src/utils/API/h5.js

@@ -0,0 +1,7 @@
+const requestPayment = (data) => {
+  return wx.chooseWXPay(data);
+}
+
+export default {
+  requestPayment,
+}

+ 8 - 0
src/utils/API/index.js

@@ -0,0 +1,8 @@
+import Taro from "@tarojs/taro"
+import wx from './wx';
+import h5 from './h5';
+
+let ENV_TYPE = Taro.getEnv();
+const api = ENV_TYPE === 'WEAPP' ? wx : ENV_TYPE === 'WEB' ? h5 : {};
+
+export default api;

+ 9 - 0
src/utils/API/wx.js

@@ -0,0 +1,9 @@
+import Taro from "@tarojs/taro"
+
+const requestPayment = (data) => {
+  return Taro.requestPayment(data)
+}
+
+export default {
+  requestPayment
+}

+ 1 - 0
src/utils/config.js

@@ -0,0 +1 @@
+export const resourceAddress = 'http://172.16.0.188:3000/upload/'

+ 13 - 0
src/utils/servers/baseUrl.js

@@ -0,0 +1,13 @@
+const getBaseUrl = (url) => {
+  let BASE_URL = '';
+  if (process.env.NODE_ENV === 'development') {
+    //开发环境 - 根据请求不同返回不同的BASE_URL
+    BASE_URL = 'http://172.16.0.188:8088'
+  } else {
+    // 生产环境
+    BASE_URL = 'http://172.16.0.188:8088'
+  }
+  return BASE_URL
+}
+
+export default getBaseUrl;

+ 13 - 0
src/utils/servers/config.js

@@ -0,0 +1,13 @@
+export const HTTP_STATUS = {
+  SUCCESS: 200,
+  CREATED: 201,
+  ACCEPTED: 202,
+  CLIENT_ERROR: 400,
+  AUTHENTICATE: 401,
+  FORBIDDEN: 403,
+  NOT_FOUND: 404,
+  SERVER_ERROR: 500,
+  BAD_GATEWAY: 502,
+  SERVICE_UNAVAILABLE: 503,
+  GATEWAY_TIMEOUT: 504
+}

+ 49 - 0
src/utils/servers/http.js

@@ -0,0 +1,49 @@
+import Taro from '@tarojs/taro'
+import getBaseUrl from './baseUrl'
+import interceptors from './interceptors'
+
+interceptors.forEach(i => Taro.addInterceptor(i))
+
+class httpRequest {
+  baseOptions(params, method = "GET") {
+    let { url, data } = params;
+    const BASE_URL = getBaseUrl(url);
+    let contentType = "application/x-www-form-urlencoded; charset=UTF-8;";
+    contentType = params.contentType || contentType;
+    let token = Taro.getStorageSync('token');
+    data.token = token;
+    const option = {
+      url: BASE_URL + url,
+      data: data,
+      method: method,
+      header: {
+        'content-type': contentType,
+        'Authorization': Taro.getStorageSync('Authorization'),
+      }
+    };
+    return Taro.request(option);
+  }
+
+  get(url, data = "") {
+    let option = { url, data };
+    return this.baseOptions(option);
+  }
+
+  post(url, data, contentType) {
+    let params = { url, data, contentType };
+    return this.baseOptions(params, "POST");
+  }
+
+  put(url, data = "") {
+    let option = { url, data };
+    return this.baseOptions(option, "PUT");
+  }
+
+  delete(url, data = "") {
+    let option = { url, data };
+    return this.baseOptions(option, "DELETE");
+  }
+
+}
+
+export default new httpRequest()

+ 38 - 0
src/utils/servers/interceptors.js

@@ -0,0 +1,38 @@
+import Taro from "@tarojs/taro"
+import { pageToLogin } from "./utils"
+import { HTTP_STATUS } from './config'
+
+const customInterceptor = (chain) => {
+
+  const requestParams = chain.requestParams
+
+  return chain.proceed(requestParams).then(res => {
+    // console.log(res,'proceed')
+    // 只要请求成功,不管返回什么状态码,都走这个回调
+    if (res.statusCode === HTTP_STATUS.NOT_FOUND) {
+      return Promise.reject("请求资源不存在")
+
+    } else if (res.statusCode === HTTP_STATUS.BAD_GATEWAY) {
+      return Promise.reject("服务端出现了问题")
+
+    } else if (res.statusCode === HTTP_STATUS.FORBIDDEN) {
+      Taro.setStorageSync("token", "")
+      pageToLogin()
+      // TODO 根据自身业务修改
+      return Promise.reject("没有权限访问,请重新登录");
+
+    } else if (res.statusCode === HTTP_STATUS.AUTHENTICATE) {
+      Taro.setStorageSync("Authorization", "")
+      pageToLogin()
+      return Promise.reject("需要鉴权")
+
+    } else if (res.statusCode === HTTP_STATUS.SUCCESS) {
+      return res.data
+
+    }
+  })
+}
+
+const interceptors = [customInterceptor, Taro.interceptors.logInterceptor]
+
+export default interceptors

+ 27 - 0
src/utils/servers/servers.js

@@ -0,0 +1,27 @@
+/* eslint-disable import/prefer-default-export */
+import HTTPREQUEST from "./http"
+
+//登录
+export const login = (postData) => {
+  return HTTPREQUEST.post('/wxLogin', postData)
+}
+
+//产品支付
+export const pay = (postData) => {
+  return HTTPREQUEST.post('/wxPush', postData)
+}
+
+//撤销支付
+export const payClose = (postData) => {
+  return HTTPREQUEST.get('/wxClose', postData)
+}
+
+//产品列表
+export const getProjecList = (postData) => {
+  return HTTPREQUEST.get('/open/projectList', postData)
+}
+
+//测试
+export const test = (postData) => {
+  return HTTPREQUEST.get('/open/test', postData)
+}

+ 19 - 0
src/utils/servers/utils.js

@@ -0,0 +1,19 @@
+import Taro from "@tarojs/taro";
+/**
+ * @description 获取当前页url
+ */
+export const getCurrentPageUrl = () => {
+  let pages = Taro.getCurrentPages()
+  let currentPage = pages[pages.length - 1]
+  let url = currentPage.route
+  return url
+};
+
+export const pageToLogin = () => {
+  let path = getCurrentPageUrl()
+  if (!path.includes('login')) {
+    Taro.navigateTo({
+      url: "/pages/login/login"
+    });
+  }
+}

File diff suppressed because it is too large
+ 10814 - 0
yarn-error.log


File diff suppressed because it is too large
+ 10830 - 0
yarn.lock