WuJunFeng %!s(int64=4) %!d(string=hai) anos
achega
673bf9a5f3

+ 16 - 0
.editorconfig

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

+ 1 - 0
.env

@@ -0,0 +1 @@
+

+ 3 - 0
.eslintrc

@@ -0,0 +1,3 @@
+{
+  "extends": "eslint-config-umi"
+}

+ 18 - 0
.gitignore

@@ -0,0 +1,18 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/npm-debug.log*
+/yarn-error.log
+/yarn.lock
+/package-lock.json
+
+# production
+/pay-pc
+
+# misc
+.DS_Store
+
+# umi
+.umi
+.umi-production

+ 7 - 0
.prettierignore

@@ -0,0 +1,7 @@
+**/*.md
+**/*.svg
+**/*.ejs
+**/*.html
+package.json
+.umi
+.umi-production

+ 11 - 0
.prettierrc

@@ -0,0 +1,11 @@
+{
+  "singleQuote": true,
+  "trailingComma": "es5",
+  "printWidth": 100,
+  "overrides": [
+    {
+      "files": ".prettierrc",
+      "options": { "parser": "json" }
+    }
+  ]
+}

+ 78 - 0
.umirc.js

@@ -0,0 +1,78 @@
+
+// ref: https://umijs.org/config/
+export default {
+  treeShaking: true,
+  hash: true,
+  routes: [
+    { 
+      path: '/recharge', 
+      component: '../layouts/BlankLayout',
+      name: '支付',
+      routes: [
+        {
+          path: '/recharge/callback', 
+          name: '回调页面',
+          routes: [
+            {
+              path: '/recharge/callback/alipay', 
+              name: '支付宝回调页面',
+              component: '../pages/AlipayCallback/AlipayCallback'
+            }
+          ]
+        }
+      ]
+    },
+    {
+      path: '/',
+      component: '../layouts/BlankLayout',
+      routes: [
+        { path: '/', component: '../pages/Home' },
+      ]
+    },
+  ],
+  plugins: [
+    // ref: https://umijs.org/plugin/umi-plugin-react.html
+    ['umi-plugin-react', {
+      antd: false,
+      dva: false,
+      dynamicImport: false, // { webpackChunkName: true },
+      title: 'xk-umi',
+      dll: true,
+      
+      routes: {
+        exclude: [
+          /models\//,
+          /services\//,
+          /model\.(t|j)sx?$/,
+          /service\.(t|j)sx?$/,
+          /components\//,
+        ],
+      },
+      lessLoaderOptions: {
+        javascriptEnabled: true,
+      }
+    }],
+  ],
+  outputPath: './pay-pc',
+
+  proxy: {
+    '/api-manage': {
+      target: 'http://api.starbuds.laylib.com',
+      changeOrigin: true,
+      //pathRewrite: { '^/server': '' },
+    },
+    '/api-common': {
+      target: 'http://api.starbuds.laylib.com',
+      changeOrigin: true,
+      //pathRewrite: { '^/server': '' },
+    },
+    '/api-app': {
+      target: 'http://api.starbuds.laylib.com',
+      changeOrigin: true,
+      //pathRewrite: { '^/server': '' },
+    }
+  },
+  targets: {
+    ie: 9,
+  }
+}

+ 0 - 0
mock/.gitkeep


+ 43 - 0
package.json

@@ -0,0 +1,43 @@
+{
+  "private": true,
+  "scripts": {
+    "start": "umi dev",
+    "build": "umi build",
+    "test": "umi test",
+    "lint": "eslint --ext .js src mock tests"
+  },
+  "dependencies": {
+    "antd": "^3.15.0",
+    "dva": "^2.5.0-beta.2",
+    "enquire-js": "^0.2.1",
+    "js-base64": "^2.5.2",
+    "rc-tween-one": "^2.4.1",
+    "react": "^16.7.0",
+    "react-dom": "^16.7.0",
+    "react-transition-group": "^4.2.1",
+    "umi-request": "^1.2.19"
+  },
+  "devDependencies": {
+    "babel-eslint": "^9.0.0",
+    "eslint": "^5.4.0",
+    "eslint-config-umi": "^1.4.0",
+    "eslint-plugin-flowtype": "^2.50.0",
+    "eslint-plugin-import": "^2.14.0",
+    "eslint-plugin-jsx-a11y": "^5.1.1",
+    "eslint-plugin-react": "^7.11.1",
+    "husky": "^0.14.3",
+    "lint-staged": "^7.2.2",
+    "react-test-renderer": "^16.7.0",
+    "umi": "^2.6.3",
+    "umi-plugin-react": "^1.6.0"
+  },
+  "lint-staged": {
+    "*.{js,jsx}": [
+      "eslint --fix",
+      "git add"
+    ]
+  },
+  "engines": {
+    "node": ">=8.0.0"
+  }
+}

BIN=BIN
public/favicon.png


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
public/qiniu-web.js


+ 9 - 0
src/app.js

@@ -0,0 +1,9 @@
+
+// export const dva = {
+//   config: {
+//     onError(err) {
+//       err.preventDefault();
+//       console.error(err.message);
+//     },
+//   },
+// };

+ 0 - 0
src/components/index.js


+ 18 - 0
src/global.css

@@ -0,0 +1,18 @@
+p, h1, h2, h3, h4, h5, h6, ul, ol, li, dl, dd, dt {
+  margin: 0; padding: 0;
+}
+html, body, #root {
+  height: 100%;
+}
+ul, li, ol {
+  list-style: none;
+}
+
+body {
+  margin: 0;
+  font-family: PingFangSC-Regular,PingFangSC-Medium,Helvetica,HelveticaNeue,Arial,Verdana,Sans-serif;
+  word-break: break-all;
+}
+a {
+  text-decoration: none;
+}

+ 23 - 0
src/layouts/BlankLayout.js

@@ -0,0 +1,23 @@
+import styles from './BlankLayout.less'
+import React from 'react'
+
+class BlankLayout extends React.Component {
+  constructor(props) {
+    super(props)
+    this.state = {}
+  }
+
+  componentDidMount () {}
+  
+
+  render() {
+    const props = this.props
+    return (
+      <div className={styles.normal}>
+        {props.children}
+      </div>
+    );
+  }
+}
+
+export default BlankLayout

+ 3 - 0
src/layouts/BlankLayout.less

@@ -0,0 +1,3 @@
+.normal {
+  height: 100%;
+}

+ 14 - 0
src/layouts/__tests__/index.test.js

@@ -0,0 +1,14 @@
+import BasicLayout from '..';
+import renderer from 'react-test-renderer';
+
+describe('Layout: BasicLayout', () => {
+  it('Render correctly', () => {
+    const wrapper = renderer.create(<BasicLayout />);
+    expect(wrapper.root.children.length).toBe(1);
+    const outerLayer = wrapper.root.children[0];
+    expect(outerLayer.type).toBe('div');
+    const title = outerLayer.children[0];
+    expect(title.type).toBe('h1');
+    expect(title.children[0]).toBe('Yay! Welcome to umi!');
+  });
+});

+ 0 - 0
src/models/.gitkeep


+ 15 - 0
src/pages/AlipayCallback/AlipayCallback.jsx

@@ -0,0 +1,15 @@
+/**
+ * 
+ * 支付宝支付成功回调页面
+ */
+import React, { Component } from 'react'
+class AlipayCallback extends Component {
+  render () {
+    return (
+      <div>
+        kdleels
+      </div>
+    )
+  }
+}
+export default AlipayCallback

+ 11 - 0
src/pages/Home.jsx

@@ -0,0 +1,11 @@
+import React, { Component } from 'react'
+class Home extends Component {
+  render () {
+    return (
+      <div>
+        kdleels
+      </div>
+    )
+  }
+}
+export default Home

+ 14 - 0
src/pages/__tests__/index.test.js

@@ -0,0 +1,14 @@
+import Index from '..';
+import renderer from 'react-test-renderer';
+
+
+describe('Page: index', () => {
+  it('Render correctly', () => {
+    const wrapper = renderer.create(<Index />);
+    expect(wrapper.root.children.length).toBe(1);
+    const outerLayer = wrapper.root.children[0];
+    expect(outerLayer.type).toBe('div');
+    expect(outerLayer.children.length).toBe(2);
+    
+  });
+});

+ 34 - 0
src/pages/document.ejs

@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
+  <link rel="icon" href="/favicon.png" type="image/x-icon" />
+  <title>星芽</title>
+  
+  <script>
+    var url = '//h5.paqukeji.com/download';
+    var isPc = () => { 
+      var userAgentInfo = navigator.userAgent; 
+      var Agents = new Array("Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"); 
+      var flag = true; 
+      for(var v = 0; v < Agents.length; v++) { 
+        if(userAgentInfo.indexOf(Agents[v]) > 0) { 
+          flag = false; 
+          break; 
+        } 
+      } 
+      // pc true phone false
+      return flag; 
+    }
+    if (!isPc()) {
+      window.location.href = url;
+    }
+  </script>
+</head>
+<body>
+  <noscript>Sorry, we need js to run correctly!</noscript>
+  <div id="root"></div>
+</body>
+</html>

+ 7 - 0
src/services/common.js

@@ -0,0 +1,7 @@
+import { stringify } from 'qs';
+import request from '@/utils/request';
+
+// 获取服务器时间
+export async function getCurrentTime() {
+  return request('/api-common/v1/data/getCurrentTime')
+}

+ 175 - 0
src/utils/Cookie.js

@@ -0,0 +1,175 @@
+// Cookie
+// -------------
+// Thanks to:
+//  - http://www.nczonline.net/blog/2009/05/05/http-cookies-explained/
+//  - http://developer.yahoo.com/yui/3/cookie/
+
+class Cookie {}
+
+var decode = decodeURIComponent;
+var encode = encodeURIComponent;
+
+/**
+ * Returns the cookie value for the given name.
+ *
+ * @param {String} name The name of the cookie to retrieve.
+ *
+ * @param {Function|Object} options (Optional) An object containing one or
+ *     more cookie options: raw (true/false) and converter (a function).
+ *     The converter function is run on the value before returning it. The
+ *     function is not used if the cookie doesn't exist. The function can be
+ *     passed instead of the options object for conveniently. When raw is
+ *     set to true, the cookie value is not URI decoded.
+ *
+ * @return {*} If no converter is specified, returns a string or undefined
+ *     if the cookie doesn't exist. If the converter is specified, returns
+ *     the value returned from the converter.
+ */
+Cookie.get = function(name, options) {
+  validateCookieName(name);
+
+  if (typeof options === 'function') {
+    options = { converter: options };
+  } else {
+    options = options || {};
+  }
+
+  var cookies = parseCookieString(document.cookie, !options['raw']);
+  return (options.converter || same)(cookies[name]);
+};
+
+/**
+ * Sets a cookie with a given name and value.
+ *
+ * @param {string} name The name of the cookie to set.
+ *
+ * @param {*} value The value to set for the cookie.
+ *
+ * @param {Object} options (Optional) An object containing one or more
+ *     cookie options: path (a string), domain (a string),
+ *     expires (number or a Date object), secure (true/false),
+ *     and raw (true/false). Setting raw to true indicates that the cookie
+ *     should not be URI encoded before being set.
+ *
+ * @return {string} The created cookie string.
+ */
+Cookie.set = function(name, value, options) {
+  validateCookieName(name);
+
+  options = options || {};
+  var expires = options['expires'];
+  var domain = options['domain'];
+  var path = options['path'];
+
+  if (!options['raw']) {
+    value = encode(String(value));
+  }
+
+  var text = name + '=' + value;
+
+  // expires
+  var date = expires;
+  if (typeof date === 'number') {
+    date = new Date();
+    date.setDate(date.getDate() + expires);
+  }
+  if (date instanceof Date) {
+    text += '; expires=' + date.toUTCString();
+  }
+
+  // domain
+  if (isNonEmptyString(domain)) {
+    text += '; domain=' + domain;
+  }
+
+  // path
+  if (isNonEmptyString(path)) {
+    text += '; path=' + path;
+  }
+
+  // secure
+  if (options['secure']) {
+    text += '; secure';
+  }
+
+  document.cookie = text;
+  return text;
+};
+
+/**
+ * Removes a cookie from the machine by setting its expiration date to
+ * sometime in the past.
+ *
+ * @param {string} name The name of the cookie to remove.
+ *
+ * @param {Object} options (Optional) An object containing one or more
+ *     cookie options: path (a string), domain (a string),
+ *     and secure (true/false). The expires option will be overwritten
+ *     by the method.
+ *
+ * @return {string} The created cookie string.
+ */
+Cookie.remove = function(name, options) {
+  options = options || {};
+  options['expires'] = new Date(0);
+  return this.set(name, '', options);
+};
+
+function parseCookieString(text, shouldDecode) {
+  var cookies = {};
+
+  if (isString(text) && text.length > 0) {
+    var decodeValue = shouldDecode ? decode : same;
+    var cookieParts = text.split(/;\s/g);
+    var cookieName;
+    var cookieValue;
+    var cookieNameValue;
+
+    for (var i = 0, len = cookieParts.length; i < len; i++) {
+      // Check for normally-formatted cookie (name-value)
+      cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
+      if (cookieNameValue instanceof Array) {
+        try {
+          cookieName = decode(cookieNameValue[1]);
+          cookieValue = decodeValue(cookieParts[i].substring(cookieNameValue[1].length + 1));
+        } catch (ex) {
+          // Intentionally ignore the cookie -
+          // the encoding is wrong
+        }
+      } else {
+        // Means the cookie does not have an "=", so treat it as
+        // a boolean flag
+        cookieName = decode(cookieParts[i]);
+        cookieValue = '';
+      }
+
+      if (cookieName) {
+        cookies[cookieName] = cookieValue;
+      }
+    }
+  }
+
+  return cookies;
+}
+
+// Helpers
+
+function isString(o) {
+  return typeof o === 'string';
+}
+
+function isNonEmptyString(s) {
+  return isString(s) && s !== '';
+}
+
+function validateCookieName(name) {
+  if (!isNonEmptyString(name)) {
+    throw new TypeError('Cookie name must be a non-empty string');
+  }
+}
+
+function same(s) {
+  return s;
+}
+
+export default Cookie;

+ 51 - 0
src/utils/MyDate.js

@@ -0,0 +1,51 @@
+import moment from 'moment'
+// 补 0
+function fixedZero(val) {
+  return val * 1 < 10 ? `0${val}` : val;
+}
+// 获取本日、本周、本月、本年
+function getTimeDistance (type) {
+  const now = new Date();
+  const oneDay = 1000 * 60 * 60 * 24;
+
+  if (type === 'today') {
+    now.setHours(0);
+    now.setMinutes(0);
+    now.setSeconds(0);
+    return [moment(now), moment(now.getTime() + (oneDay - 1000))];
+  }
+
+  if (type === 'week') {
+    let day = now.getDay();
+    now.setHours(0);
+    now.setMinutes(0);
+    now.setSeconds(0);
+
+    if (day === 0) {
+      day = 6;
+    } else {
+      day -= 1;
+    }
+    const beginTime = now.getTime() - day * oneDay;
+    return [moment(beginTime), moment(beginTime + (7 * oneDay - 1000))];
+  }
+
+  if (type === 'month') {
+    const year = now.getFullYear();
+    const month = now.getMonth();
+    const nextDate = moment(now).add(1, 'months');
+    const nextYear = nextDate.year();
+    const nextMonth = nextDate.month();
+
+    return [
+      moment(`${year}-${fixedZero(month + 1)}-01 00:00:00`),
+      moment(moment(`${nextYear}-${fixedZero(nextMonth + 1)}-01 00:00:00`).valueOf() - 1000),
+    ];
+  }
+
+  const year = now.getFullYear();
+  return [moment(`${year}`)]// [moment(`${year}-01-01 00:00:00`), moment(`${year}-12-31 23:59:59`)];
+}
+export default {
+  getTimeDistance
+}

+ 229 - 0
src/utils/Security.js

@@ -0,0 +1,229 @@
+function Md5(string) {
+  function RotateLeft(lValue, iShiftBits) {
+    return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
+  }
+  function AddUnsigned(lX, lY) {
+    var lX4, lY4, lX8, lY8, lResult;
+    lX8 = lX & 0x80000000;
+    lY8 = lY & 0x80000000;
+    lX4 = lX & 0x40000000;
+    lY4 = lY & 0x40000000;
+    lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
+    if (lX4 & lY4) {
+      return lResult ^ 0x80000000 ^ lX8 ^ lY8;
+    }
+    if (lX4 | lY4) {
+      if (lResult & 0x40000000) {
+        return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
+      } else {
+        return lResult ^ 0x40000000 ^ lX8 ^ lY8;
+      }
+    } else {
+      return lResult ^ lX8 ^ lY8;
+    }
+  }
+
+  function F(x, y, z) {
+    return (x & y) | (~x & z);
+  }
+  function G(x, y, z) {
+    return (x & z) | (y & ~z);
+  }
+  function H(x, y, z) {
+    return x ^ y ^ z;
+  }
+  function I(x, y, z) {
+    return y ^ (x | ~z);
+  }
+
+  function FF(a, b, c, d, x, s, ac) {
+    a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
+    return AddUnsigned(RotateLeft(a, s), b);
+  }
+
+  function GG(a, b, c, d, x, s, ac) {
+    a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
+    return AddUnsigned(RotateLeft(a, s), b);
+  }
+
+  function HH(a, b, c, d, x, s, ac) {
+    a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
+    return AddUnsigned(RotateLeft(a, s), b);
+  }
+
+  function II(a, b, c, d, x, s, ac) {
+    a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
+    return AddUnsigned(RotateLeft(a, s), b);
+  }
+
+  function ConvertToWordArray(string) {
+    var lWordCount;
+    var lMessageLength = string.length;
+    var lNumberOfWords_temp1 = lMessageLength + 8;
+    var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
+    var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
+    var lWordArray = Array(lNumberOfWords - 1);
+    var lBytePosition = 0;
+    var lByteCount = 0;
+    while (lByteCount < lMessageLength) {
+      lWordCount = (lByteCount - (lByteCount % 4)) / 4;
+      lBytePosition = (lByteCount % 4) * 8;
+      lWordArray[lWordCount] =
+        lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition);
+      lByteCount++;
+    }
+    lWordCount = (lByteCount - (lByteCount % 4)) / 4;
+    lBytePosition = (lByteCount % 4) * 8;
+    lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
+    lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
+    lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
+    return lWordArray;
+  }
+
+  function WordToHex(lValue) {
+    var WordToHexValue = '',
+      WordToHexValue_temp = '',
+      lByte,
+      lCount;
+    for (lCount = 0; lCount <= 3; lCount++) {
+      lByte = (lValue >>> (lCount * 8)) & 255;
+      WordToHexValue_temp = '0' + lByte.toString(16);
+      WordToHexValue =
+        WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
+    }
+    return WordToHexValue;
+  }
+
+  function Utf8Encode(string) {
+    string = string.replace(/\r\n/g, '\n');
+    var utftext = '';
+
+    for (var n = 0; n < string.length; n++) {
+      var c = string.charCodeAt(n);
+
+      if (c < 128) {
+        utftext += String.fromCharCode(c);
+      } else if (c > 127 && c < 2048) {
+        utftext += String.fromCharCode((c >> 6) | 192);
+        utftext += String.fromCharCode((c & 63) | 128);
+      } else {
+        utftext += String.fromCharCode((c >> 12) | 224);
+        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
+        utftext += String.fromCharCode((c & 63) | 128);
+      }
+    }
+
+    return utftext;
+  }
+
+  var x = Array();
+  var k, AA, BB, CC, DD, a, b, c, d;
+  var S11 = 7,
+    S12 = 12,
+    S13 = 17,
+    S14 = 22;
+  var S21 = 5,
+    S22 = 9,
+    S23 = 14,
+    S24 = 20;
+  var S31 = 4,
+    S32 = 11,
+    S33 = 16,
+    S34 = 23;
+  var S41 = 6,
+    S42 = 10,
+    S43 = 15,
+    S44 = 21;
+
+  string = Utf8Encode(string);
+
+  x = ConvertToWordArray(string);
+
+  a = 0x67452301;
+  b = 0xefcdab89;
+  c = 0x98badcfe;
+  d = 0x10325476;
+
+  for (k = 0; k < x.length; k += 16) {
+    AA = a;
+    BB = b;
+    CC = c;
+    DD = d;
+    a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
+    d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
+    c = FF(c, d, a, b, x[k + 2], S13, 0x242070db);
+    b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
+    a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
+    d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
+    c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
+    b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
+    a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
+    d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
+    c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
+    b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
+    a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
+    d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
+    c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
+    b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
+    a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
+    d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
+    c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
+    b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
+    a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
+    d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
+    c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
+    b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
+    a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
+    d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
+    c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
+    b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
+    a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
+    d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
+    c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
+    b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
+    a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
+    d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
+    c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
+    b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
+    a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
+    d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
+    c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
+    b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
+    a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
+    d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
+    c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
+    b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
+    a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
+    d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
+    c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
+    b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
+    a = II(a, b, c, d, x[k + 0], S41, 0xf4292244);
+    d = II(d, a, b, c, x[k + 7], S42, 0x432aff97);
+    c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
+    b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
+    a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
+    d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
+    c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
+    b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
+    a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
+    d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
+    c = II(c, d, a, b, x[k + 6], S43, 0xa3014314);
+    b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
+    a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
+    d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
+    c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
+    b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
+    a = AddUnsigned(a, AA);
+    b = AddUnsigned(b, BB);
+    c = AddUnsigned(c, CC);
+    d = AddUnsigned(d, DD);
+  }
+
+  var temp = WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d);
+
+  return temp.toLowerCase();
+}
+
+export default {
+  encryptMd5: Md5,
+};

+ 9 - 0
src/utils/Sign.js

@@ -0,0 +1,9 @@
+import Security from './Security';
+
+function signMd5() {
+  const time = new Date().getTime();
+  return { time: time, sign: Security.encryptMd5(time + 'security.marto.com') };
+}
+export default {
+  signMd5: signMd5,
+};

+ 37 - 0
src/utils/Url.js

@@ -0,0 +1,37 @@
+const Format = require('./Format');
+
+function getQueryString(name) {
+  const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
+  const r = window.location.search.substr(1).match(reg);
+  if (r != null) return unescape(r[2]);
+  return null;
+}
+
+//导出文档-数据流jsonp
+function parseBlob(res) {
+  const blob = new Blob([res], {
+    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+  });
+  const objectUrl = URL.createObjectURL(blob);
+  const filename =
+    Format.date(new Date().getTime(), 'yyyy_MM_dd_HH_mm_ss') +
+    '_' +
+    Math.floor(Math.random() * 20) +
+    '.xls';
+  //window.open(objectUrl);
+  const a = document.createElement('a');
+  // safari doesn't support this yet
+  if (typeof a.download === 'undefined') {
+    window.location = objectUrl;
+  } else {
+    a.href = objectUrl;
+    a.download = filename;
+    document.body.appendChild(a);
+    a.click();
+  }
+}
+
+module.exports = {
+  getQueryString,
+  parseBlob,
+};

+ 32 - 0
src/utils/base.js

@@ -0,0 +1,32 @@
+import { Base64 as Base64Npm } from 'js-base64'
+export const Base64 = Base64Npm
+export { default as MyDate } from './MyDate'
+
+// 获取时间
+export const getDate = (nDate = (new Date()), fmt = 'yyyy-MM-dd hh:mm:ss') => {
+  const sDate = new Date(nDate)
+  const dateObj = {
+    'M+': sDate.getMonth() + 1,
+    'd+': sDate.getDate(),
+    'h+': sDate.getHours(),
+    'm+': sDate.getMinutes(),
+    's+': sDate.getSeconds(),
+    'q+': Math.floor((sDate.getMonth() + 3) / 3),
+    'S': sDate.getMilliseconds()
+  }
+  if (/(y+)/.test(fmt)) {
+    fmt = fmt.replace(RegExp.$1, (sDate.getFullYear() + '')
+      .substr(4 - RegExp.$1.length))
+  }
+  for (const s in dateObj) {
+    if (new RegExp('(' + s + ')').test(fmt)) {
+      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1)
+        ? (dateObj[s])
+        : (('00' + dateObj[s]).substr(('' + dateObj[s]).length)))
+    }
+  }
+  return fmt
+}
+
+export const regIntNumber = /^[1-9]\d*$/
+export const regNumber = /^[1-9]\d*(\.?\d{1,})?$/

+ 1 - 0
src/utils/enums.js

@@ -0,0 +1 @@
+

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
src/utils/qiniu-web.js


+ 146 - 0
src/utils/request.js

@@ -0,0 +1,146 @@
+/**
+ * request 网络请求工具
+ * 更详细的 api 文档: https://github.com/umijs/umi-request
+ */
+import { extend } from 'umi-request';
+import { stringify } from 'querystring';
+import Cookie from './Cookie';
+import Security from './Security'
+import { Base64 } from './base'
+
+const codeMessage = {
+  200: '服务器成功返回请求的数据。',
+  201: '新建或修改数据成功。',
+  202: '一个请求已经进入后台排队(异步任务)。',
+  204: '删除数据成功。',
+  400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
+  401: '用户没有权限(令牌、用户名、密码错误)。',
+  403: '用户得到授权,但是访问是被禁止的。',
+  404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
+  406: '请求的格式不可得。',
+  410: '请求的资源被永久删除,且不会再得到的。',
+  422: '当创建一个对象时,发生一个验证错误。',
+  500: '服务器发生错误,请检查服务器。',
+  502: '网关错误。',
+  503: '服务不可用,服务器暂时过载或维护。',
+  504: '网关超时。',
+};
+
+/**
+ * 异常处理程序
+ */
+const errorHandler = error => {
+  const { response } = error;
+
+  if (response && response.status) {
+    const errorText = codeMessage[response.status] || response.statusText;
+    const { status, url } = response;
+    // notification.error({
+    //   message: `请求错误 ${status}: ${url}`,
+    //   description: errorText,
+    // });
+  } else if (!response) {
+    // notification.error({
+    //   description: '您的网络发生异常,无法连接服务器',
+    //   message: '网络异常',
+    // });
+  }
+
+  return response;
+};
+
+/**
+ * 配置request请求时的默认参数
+ */
+const request = extend({
+  errorHandler,
+  // 默认错误处理
+  credentials: 'include', // 默认请求是否带上cookie
+});
+
+/**
+ * 请求头处理
+ */
+const getHeader = () => {
+
+  // 通用参数
+  const commonParams = {
+    a: 11,
+    av: '1.0.0',
+    c: 4,
+    ci: '0',
+    di: '1a00bf0e978c458f7620b390714b26cc',
+    lat: '',
+    lng: '',
+    pm: '',
+    pn: 'com.starbuds.h5',
+    st: 1,
+    sv: '',
+    t: Cookie.get('_xy_tk_h5', { path: '/' }) || '',
+    ts: new Date().getTime()
+  };
+
+  let toSign = '';
+  Object.keys(commonParams).map((key)=> {
+    toSign += '&' + key + '=' + commonParams[key];
+  });
+  toSign = toSign.substr(1) + commonParams.pn;
+  var sign = Security.encryptMd5(toSign + ".security");
+  commonParams.s = sign;
+  var pkg = Base64.encode(JSON.stringify(commonParams));
+
+  return { pkg };
+};
+
+/**
+ * 请求拦截器 处理请求头
+ */
+request.interceptors.request.use(async (url, options) => {
+  let headers = getHeader();
+  const method = options.method.toUpperCase();
+  if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
+    if (!(options.body instanceof FormData)) {
+      headers = {
+        Accept: 'application/json',
+        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
+        ...headers,
+      };
+      options.body = stringify(options.body);
+    } else {
+      headers = {
+        Accept: 'application/json',
+        ...headers,
+      };
+    }
+  }
+
+  return {
+    url,
+    options: { ...options, headers },
+  };
+});
+
+/**
+ * 请求结果拦截器
+ */
+request.interceptors.response.use(async (response, options) => {
+  const res = await response.json();
+  if (!res.success) {
+    // notification.error({
+    //   message: '请求错误',
+    //   description: res.msg,
+    // });
+
+    // 令牌登录失败
+    if (res.code === 'TOKEN_INVALID') {
+      Cookie.remove('_xy_tk_h5', { path: '/' });
+      window.g_app._store.dispatch({
+        type: 'login/logout',
+      });
+      return res;
+    }
+  }
+  return res;
+});
+
+export default request;

+ 12 - 0
webpack.config.js

@@ -0,0 +1,12 @@
+/**
+ * 不是真实的 webpack 配置,仅为兼容 webstorm 和 intellij idea 代码跳转
+ * ref: https://github.com/umijs/umi/issues/1109#issuecomment-423380125
+ */
+
+module.exports = {
+  resolve: {
+    alias: {
+      '@': require('path').resolve(__dirname, 'src'),
+    },
+  },
+};

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio