许成详 vor 6 Jahren
Ursprung
Commit
fd705ff057

+ 18
- 0
.babelrc Datei anzeigen

@@ -0,0 +1,18 @@
1
+{
2
+  "presets": [
3
+    ["env", {
4
+      "modules": false,
5
+      "targets": {
6
+        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7
+      }
8
+    }],
9
+    "stage-2"
10
+  ],
11
+  "plugins": ["transform-vue-jsx", "transform-runtime"],
12
+  "env": {
13
+    "test": {
14
+      "presets": ["env", "stage-2"],
15
+      "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
16
+    }
17
+  }
18
+}

+ 9
- 0
.editorconfig Datei anzeigen

@@ -0,0 +1,9 @@
1
+root = true
2
+
3
+[*]
4
+charset = utf-8
5
+indent_style = space
6
+indent_size = 2
7
+end_of_line = lf
8
+insert_final_newline = true
9
+trim_trailing_whitespace = true

+ 5
- 0
.eslintignore Datei anzeigen

@@ -0,0 +1,5 @@
1
+/build/
2
+/config/
3
+/dist/
4
+/*.js
5
+/test/unit/coverage/

+ 29
- 0
.eslintrc.js Datei anzeigen

@@ -0,0 +1,29 @@
1
+// https://eslint.org/docs/user-guide/configuring
2
+
3
+module.exports = {
4
+  root: true,
5
+  parserOptions: {
6
+    parser: 'babel-eslint'
7
+  },
8
+  env: {
9
+    browser: true,
10
+  },
11
+  extends: [
12
+    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
13
+    // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
14
+    'plugin:vue/essential', 
15
+    // https://github.com/standard/standard/blob/master/docs/RULES-en.md
16
+    'standard'
17
+  ],
18
+  // required to lint *.vue files
19
+  plugins: [
20
+    'vue'
21
+  ],
22
+  // add your custom rules here
23
+  rules: {
24
+    // allow async-await
25
+    'generator-star-spacing': 'off',
26
+    // allow debugger during development
27
+    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
28
+  }
29
+}

+ 17
- 0
.gitignore Datei anzeigen

@@ -0,0 +1,17 @@
1
+.DS_Store
2
+node_modules/
3
+/dist/
4
+npm-debug.log*
5
+yarn-debug.log*
6
+yarn-error.log*
7
+/test/unit/coverage/
8
+/test/e2e/reports/
9
+selenium-debug.log
10
+
11
+# Editor directories and files
12
+.idea
13
+.vscode
14
+*.suo
15
+*.ntvs*
16
+*.njsproj
17
+*.sln

+ 10
- 0
.postcssrc.js Datei anzeigen

@@ -0,0 +1,10 @@
1
+// https://github.com/michael-ciniawsky/postcss-load-config
2
+
3
+module.exports = {
4
+  "plugins": {
5
+    "postcss-import": {},
6
+    "postcss-url": {},
7
+    // to edit target browsers: use "browserslist" field in package.json
8
+    "autoprefixer": {}
9
+  }
10
+}

+ 41
- 0
build/build.js Datei anzeigen

@@ -0,0 +1,41 @@
1
+'use strict'
2
+require('./check-versions')()
3
+
4
+process.env.NODE_ENV = 'production'
5
+
6
+const ora = require('ora')
7
+const rm = require('rimraf')
8
+const path = require('path')
9
+const chalk = require('chalk')
10
+const webpack = require('webpack')
11
+const config = require('../config')
12
+const webpackConfig = require('./webpack.prod.conf')
13
+
14
+const spinner = ora('building for production...')
15
+spinner.start()
16
+
17
+rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18
+  if (err) throw err
19
+  webpack(webpackConfig, (err, stats) => {
20
+    spinner.stop()
21
+    if (err) throw err
22
+    process.stdout.write(stats.toString({
23
+      colors: true,
24
+      modules: false,
25
+      children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26
+      chunks: false,
27
+      chunkModules: false
28
+    }) + '\n\n')
29
+
30
+    if (stats.hasErrors()) {
31
+      console.log(chalk.red('  Build failed with errors.\n'))
32
+      process.exit(1)
33
+    }
34
+
35
+    console.log(chalk.cyan('  Build complete.\n'))
36
+    console.log(chalk.yellow(
37
+      '  Tip: built files are meant to be served over an HTTP server.\n' +
38
+      '  Opening index.html over file:// won\'t work.\n'
39
+    ))
40
+  })
41
+})

+ 54
- 0
build/check-versions.js Datei anzeigen

@@ -0,0 +1,54 @@
1
+'use strict'
2
+const chalk = require('chalk')
3
+const semver = require('semver')
4
+const packageConfig = require('../package.json')
5
+const shell = require('shelljs')
6
+
7
+function exec (cmd) {
8
+  return require('child_process').execSync(cmd).toString().trim()
9
+}
10
+
11
+const versionRequirements = [
12
+  {
13
+    name: 'node',
14
+    currentVersion: semver.clean(process.version),
15
+    versionRequirement: packageConfig.engines.node
16
+  }
17
+]
18
+
19
+if (shell.which('npm')) {
20
+  versionRequirements.push({
21
+    name: 'npm',
22
+    currentVersion: exec('npm --version'),
23
+    versionRequirement: packageConfig.engines.npm
24
+  })
25
+}
26
+
27
+module.exports = function () {
28
+  const warnings = []
29
+
30
+  for (let i = 0; i < versionRequirements.length; i++) {
31
+    const mod = versionRequirements[i]
32
+
33
+    if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
34
+      warnings.push(mod.name + ': ' +
35
+        chalk.red(mod.currentVersion) + ' should be ' +
36
+        chalk.green(mod.versionRequirement)
37
+      )
38
+    }
39
+  }
40
+
41
+  if (warnings.length) {
42
+    console.log('')
43
+    console.log(chalk.yellow('To use this template, you must update following to modules:'))
44
+    console.log()
45
+
46
+    for (let i = 0; i < warnings.length; i++) {
47
+      const warning = warnings[i]
48
+      console.log('  ' + warning)
49
+    }
50
+
51
+    console.log()
52
+    process.exit(1)
53
+  }
54
+}

+ 101
- 0
build/utils.js Datei anzeigen

@@ -0,0 +1,101 @@
1
+'use strict'
2
+const path = require('path')
3
+const config = require('../config')
4
+const ExtractTextPlugin = require('extract-text-webpack-plugin')
5
+const packageConfig = require('../package.json')
6
+
7
+exports.assetsPath = function (_path) {
8
+  const assetsSubDirectory = process.env.NODE_ENV === 'production'
9
+    ? config.build.assetsSubDirectory
10
+    : config.dev.assetsSubDirectory
11
+
12
+  return path.posix.join(assetsSubDirectory, _path)
13
+}
14
+
15
+exports.cssLoaders = function (options) {
16
+  options = options || {}
17
+
18
+  const cssLoader = {
19
+    loader: 'css-loader',
20
+    options: {
21
+      sourceMap: options.sourceMap
22
+    }
23
+  }
24
+
25
+  const postcssLoader = {
26
+    loader: 'postcss-loader',
27
+    options: {
28
+      sourceMap: options.sourceMap
29
+    }
30
+  }
31
+
32
+  // generate loader string to be used with extract text plugin
33
+  function generateLoaders (loader, loaderOptions) {
34
+    const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
35
+
36
+    if (loader) {
37
+      loaders.push({
38
+        loader: loader + '-loader',
39
+        options: Object.assign({}, loaderOptions, {
40
+          sourceMap: options.sourceMap
41
+        })
42
+      })
43
+    }
44
+
45
+    // Extract CSS when that option is specified
46
+    // (which is the case during production build)
47
+    if (options.extract) {
48
+      return ExtractTextPlugin.extract({
49
+        use: loaders,
50
+        fallback: 'vue-style-loader'
51
+      })
52
+    } else {
53
+      return ['vue-style-loader'].concat(loaders)
54
+    }
55
+  }
56
+
57
+  // https://vue-loader.vuejs.org/en/configurations/extract-css.html
58
+  return {
59
+    css: generateLoaders(),
60
+    postcss: generateLoaders(),
61
+    less: generateLoaders('less'),
62
+    sass: generateLoaders('sass', { indentedSyntax: true }),
63
+    scss: generateLoaders('sass'),
64
+    stylus: generateLoaders('stylus'),
65
+    styl: generateLoaders('stylus')
66
+  }
67
+}
68
+
69
+// Generate loaders for standalone style files (outside of .vue)
70
+exports.styleLoaders = function (options) {
71
+  const output = []
72
+  const loaders = exports.cssLoaders(options)
73
+
74
+  for (const extension in loaders) {
75
+    const loader = loaders[extension]
76
+    output.push({
77
+      test: new RegExp('\\.' + extension + '$'),
78
+      use: loader
79
+    })
80
+  }
81
+
82
+  return output
83
+}
84
+
85
+exports.createNotifierCallback = () => {
86
+  const notifier = require('node-notifier')
87
+
88
+  return (severity, errors) => {
89
+    if (severity !== 'error') return
90
+
91
+    const error = errors[0]
92
+    const filename = error.file && error.file.split('!').pop()
93
+
94
+    notifier.notify({
95
+      title: packageConfig.name,
96
+      message: severity + ': ' + error.name,
97
+      subtitle: filename || '',
98
+      icon: path.join(__dirname, 'logo.png')
99
+    })
100
+  }
101
+}

+ 22
- 0
build/vue-loader.conf.js Datei anzeigen

@@ -0,0 +1,22 @@
1
+'use strict'
2
+const utils = require('./utils')
3
+const config = require('../config')
4
+const isProduction = process.env.NODE_ENV === 'production'
5
+const sourceMapEnabled = isProduction
6
+  ? config.build.productionSourceMap
7
+  : config.dev.cssSourceMap
8
+
9
+module.exports = {
10
+  loaders: utils.cssLoaders({
11
+    sourceMap: sourceMapEnabled,
12
+    extract: isProduction
13
+  }),
14
+  cssSourceMap: sourceMapEnabled,
15
+  cacheBusting: config.dev.cacheBusting,
16
+  transformToRequire: {
17
+    video: ['src', 'poster'],
18
+    source: 'src',
19
+    img: 'src',
20
+    image: 'xlink:href'
21
+  }
22
+}

+ 92
- 0
build/webpack.base.conf.js Datei anzeigen

@@ -0,0 +1,92 @@
1
+'use strict'
2
+const path = require('path')
3
+const utils = require('./utils')
4
+const config = require('../config')
5
+const vueLoaderConfig = require('./vue-loader.conf')
6
+
7
+function resolve (dir) {
8
+  return path.join(__dirname, '..', dir)
9
+}
10
+
11
+const createLintingRule = () => ({
12
+  test: /\.(js|vue)$/,
13
+  loader: 'eslint-loader',
14
+  enforce: 'pre',
15
+  include: [resolve('src'), resolve('test')],
16
+  options: {
17
+    formatter: require('eslint-friendly-formatter'),
18
+    emitWarning: !config.dev.showEslintErrorsInOverlay
19
+  }
20
+})
21
+
22
+module.exports = {
23
+  context: path.resolve(__dirname, '../'),
24
+  entry: {
25
+    app: './src/main.js'
26
+  },
27
+  output: {
28
+    path: config.build.assetsRoot,
29
+    filename: '[name].js',
30
+    publicPath: process.env.NODE_ENV === 'production'
31
+      ? config.build.assetsPublicPath
32
+      : config.dev.assetsPublicPath
33
+  },
34
+  resolve: {
35
+    extensions: ['.js', '.vue', '.json'],
36
+    alias: {
37
+      'vue$': 'vue/dist/vue.esm.js',
38
+      '@': resolve('src'),
39
+    }
40
+  },
41
+  module: {
42
+    rules: [
43
+      ...(config.dev.useEslint ? [createLintingRule()] : []),
44
+      {
45
+        test: /\.vue$/,
46
+        loader: 'vue-loader',
47
+        options: vueLoaderConfig
48
+      },
49
+      {
50
+        test: /\.js$/,
51
+        loader: 'babel-loader',
52
+        include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
53
+      },
54
+      {
55
+        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
56
+        loader: 'url-loader',
57
+        options: {
58
+          limit: 10000,
59
+          name: utils.assetsPath('img/[name].[hash:7].[ext]')
60
+        }
61
+      },
62
+      {
63
+        test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
64
+        loader: 'url-loader',
65
+        options: {
66
+          limit: 10000,
67
+          name: utils.assetsPath('media/[name].[hash:7].[ext]')
68
+        }
69
+      },
70
+      {
71
+        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
72
+        loader: 'url-loader',
73
+        options: {
74
+          limit: 10000,
75
+          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
76
+        }
77
+      }
78
+    ]
79
+  },
80
+  node: {
81
+    // prevent webpack from injecting useless setImmediate polyfill because Vue
82
+    // source contains it (although only uses it if it's native).
83
+    setImmediate: false,
84
+    // prevent webpack from injecting mocks to Node native modules
85
+    // that does not make sense for the client
86
+    dgram: 'empty',
87
+    fs: 'empty',
88
+    net: 'empty',
89
+    tls: 'empty',
90
+    child_process: 'empty'
91
+  }
92
+}

+ 95
- 0
build/webpack.dev.conf.js Datei anzeigen

@@ -0,0 +1,95 @@
1
+'use strict'
2
+const utils = require('./utils')
3
+const webpack = require('webpack')
4
+const config = require('../config')
5
+const merge = require('webpack-merge')
6
+const path = require('path')
7
+const baseWebpackConfig = require('./webpack.base.conf')
8
+const CopyWebpackPlugin = require('copy-webpack-plugin')
9
+const HtmlWebpackPlugin = require('html-webpack-plugin')
10
+const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
11
+const portfinder = require('portfinder')
12
+
13
+const HOST = process.env.HOST
14
+const PORT = process.env.PORT && Number(process.env.PORT)
15
+
16
+const devWebpackConfig = merge(baseWebpackConfig, {
17
+  module: {
18
+    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
19
+  },
20
+  // cheap-module-eval-source-map is faster for development
21
+  devtool: config.dev.devtool,
22
+
23
+  // these devServer options should be customized in /config/index.js
24
+  devServer: {
25
+    clientLogLevel: 'warning',
26
+    historyApiFallback: {
27
+      rewrites: [
28
+        { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
29
+      ],
30
+    },
31
+    hot: true,
32
+    contentBase: false, // since we use CopyWebpackPlugin.
33
+    compress: true,
34
+    host: HOST || config.dev.host,
35
+    port: PORT || config.dev.port,
36
+    open: config.dev.autoOpenBrowser,
37
+    overlay: config.dev.errorOverlay
38
+      ? { warnings: false, errors: true }
39
+      : false,
40
+    publicPath: config.dev.assetsPublicPath,
41
+    proxy: config.dev.proxyTable,
42
+    quiet: true, // necessary for FriendlyErrorsPlugin
43
+    watchOptions: {
44
+      poll: config.dev.poll,
45
+    }
46
+  },
47
+  plugins: [
48
+    new webpack.DefinePlugin({
49
+      'process.env': require('../config/dev.env')
50
+    }),
51
+    new webpack.HotModuleReplacementPlugin(),
52
+    new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
53
+    new webpack.NoEmitOnErrorsPlugin(),
54
+    // https://github.com/ampedandwired/html-webpack-plugin
55
+    new HtmlWebpackPlugin({
56
+      filename: 'index.html',
57
+      template: 'index.html',
58
+      inject: true
59
+    }),
60
+    // copy custom static assets
61
+    new CopyWebpackPlugin([
62
+      {
63
+        from: path.resolve(__dirname, '../static'),
64
+        to: config.dev.assetsSubDirectory,
65
+        ignore: ['.*']
66
+      }
67
+    ])
68
+  ]
69
+})
70
+
71
+module.exports = new Promise((resolve, reject) => {
72
+  portfinder.basePort = process.env.PORT || config.dev.port
73
+  portfinder.getPort((err, port) => {
74
+    if (err) {
75
+      reject(err)
76
+    } else {
77
+      // publish the new Port, necessary for e2e tests
78
+      process.env.PORT = port
79
+      // add port to devServer config
80
+      devWebpackConfig.devServer.port = port
81
+
82
+      // Add FriendlyErrorsPlugin
83
+      devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
84
+        compilationSuccessInfo: {
85
+          messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
86
+        },
87
+        onErrors: config.dev.notifyOnErrors
88
+        ? utils.createNotifierCallback()
89
+        : undefined
90
+      }))
91
+
92
+      resolve(devWebpackConfig)
93
+    }
94
+  })
95
+})

+ 149
- 0
build/webpack.prod.conf.js Datei anzeigen

@@ -0,0 +1,149 @@
1
+'use strict'
2
+const path = require('path')
3
+const utils = require('./utils')
4
+const webpack = require('webpack')
5
+const config = require('../config')
6
+const merge = require('webpack-merge')
7
+const baseWebpackConfig = require('./webpack.base.conf')
8
+const CopyWebpackPlugin = require('copy-webpack-plugin')
9
+const HtmlWebpackPlugin = require('html-webpack-plugin')
10
+const ExtractTextPlugin = require('extract-text-webpack-plugin')
11
+const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
12
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
13
+
14
+const env = process.env.NODE_ENV === 'testing'
15
+  ? require('../config/test.env')
16
+  : require('../config/prod.env')
17
+
18
+const webpackConfig = merge(baseWebpackConfig, {
19
+  module: {
20
+    rules: utils.styleLoaders({
21
+      sourceMap: config.build.productionSourceMap,
22
+      extract: true,
23
+      usePostCSS: true
24
+    })
25
+  },
26
+  devtool: config.build.productionSourceMap ? config.build.devtool : false,
27
+  output: {
28
+    path: config.build.assetsRoot,
29
+    filename: utils.assetsPath('js/[name].[chunkhash].js'),
30
+    chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
31
+  },
32
+  plugins: [
33
+    // http://vuejs.github.io/vue-loader/en/workflow/production.html
34
+    new webpack.DefinePlugin({
35
+      'process.env': env
36
+    }),
37
+    new UglifyJsPlugin({
38
+      uglifyOptions: {
39
+        compress: {
40
+          warnings: false
41
+        }
42
+      },
43
+      sourceMap: config.build.productionSourceMap,
44
+      parallel: true
45
+    }),
46
+    // extract css into its own file
47
+    new ExtractTextPlugin({
48
+      filename: utils.assetsPath('css/[name].[contenthash].css'),
49
+      // Setting the following option to `false` will not extract CSS from codesplit chunks.
50
+      // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
51
+      // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, 
52
+      // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
53
+      allChunks: true,
54
+    }),
55
+    // Compress extracted CSS. We are using this plugin so that possible
56
+    // duplicated CSS from different components can be deduped.
57
+    new OptimizeCSSPlugin({
58
+      cssProcessorOptions: config.build.productionSourceMap
59
+        ? { safe: true, map: { inline: false } }
60
+        : { safe: true }
61
+    }),
62
+    // generate dist index.html with correct asset hash for caching.
63
+    // you can customize output by editing /index.html
64
+    // see https://github.com/ampedandwired/html-webpack-plugin
65
+    new HtmlWebpackPlugin({
66
+      filename: process.env.NODE_ENV === 'testing'
67
+        ? 'index.html'
68
+        : config.build.index,
69
+      template: 'index.html',
70
+      inject: true,
71
+      minify: {
72
+        removeComments: true,
73
+        collapseWhitespace: true,
74
+        removeAttributeQuotes: true
75
+        // more options:
76
+        // https://github.com/kangax/html-minifier#options-quick-reference
77
+      },
78
+      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
79
+      chunksSortMode: 'dependency'
80
+    }),
81
+    // keep module.id stable when vendor modules does not change
82
+    new webpack.HashedModuleIdsPlugin(),
83
+    // enable scope hoisting
84
+    new webpack.optimize.ModuleConcatenationPlugin(),
85
+    // split vendor js into its own file
86
+    new webpack.optimize.CommonsChunkPlugin({
87
+      name: 'vendor',
88
+      minChunks (module) {
89
+        // any required modules inside node_modules are extracted to vendor
90
+        return (
91
+          module.resource &&
92
+          /\.js$/.test(module.resource) &&
93
+          module.resource.indexOf(
94
+            path.join(__dirname, '../node_modules')
95
+          ) === 0
96
+        )
97
+      }
98
+    }),
99
+    // extract webpack runtime and module manifest to its own file in order to
100
+    // prevent vendor hash from being updated whenever app bundle is updated
101
+    new webpack.optimize.CommonsChunkPlugin({
102
+      name: 'manifest',
103
+      minChunks: Infinity
104
+    }),
105
+    // This instance extracts shared chunks from code splitted chunks and bundles them
106
+    // in a separate chunk, similar to the vendor chunk
107
+    // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
108
+    new webpack.optimize.CommonsChunkPlugin({
109
+      name: 'app',
110
+      async: 'vendor-async',
111
+      children: true,
112
+      minChunks: 3
113
+    }),
114
+
115
+    // copy custom static assets
116
+    new CopyWebpackPlugin([
117
+      {
118
+        from: path.resolve(__dirname, '../static'),
119
+        to: config.build.assetsSubDirectory,
120
+        ignore: ['.*']
121
+      }
122
+    ])
123
+  ]
124
+})
125
+
126
+if (config.build.productionGzip) {
127
+  const CompressionWebpackPlugin = require('compression-webpack-plugin')
128
+
129
+  webpackConfig.plugins.push(
130
+    new CompressionWebpackPlugin({
131
+      asset: '[path].gz[query]',
132
+      algorithm: 'gzip',
133
+      test: new RegExp(
134
+        '\\.(' +
135
+        config.build.productionGzipExtensions.join('|') +
136
+        ')$'
137
+      ),
138
+      threshold: 10240,
139
+      minRatio: 0.8
140
+    })
141
+  )
142
+}
143
+
144
+if (config.build.bundleAnalyzerReport) {
145
+  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
146
+  webpackConfig.plugins.push(new BundleAnalyzerPlugin())
147
+}
148
+
149
+module.exports = webpackConfig

+ 7
- 0
config/dev.env.js Datei anzeigen

@@ -0,0 +1,7 @@
1
+'use strict'
2
+const merge = require('webpack-merge')
3
+const prodEnv = require('./prod.env')
4
+
5
+module.exports = merge(prodEnv, {
6
+  NODE_ENV: '"development"'
7
+})

+ 81
- 0
config/index.js Datei anzeigen

@@ -0,0 +1,81 @@
1
+'use strict'
2
+// Template version: 1.3.1
3
+// see http://vuejs-templates.github.io/webpack for documentation.
4
+
5
+const path = require('path')
6
+
7
+module.exports = {
8
+  dev: {
9
+
10
+    // Paths
11
+    assetsSubDirectory: 'static',
12
+    assetsPublicPath: '/',
13
+    proxyTable: {
14
+      '/app-api': {
15
+        target: 'http://101.132.102.231:8085',
16
+        changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
17
+      },
18
+    },
19
+
20
+    // Various Dev Server settings
21
+    host: '0.0.0.0', // can be overwritten by process.env.HOST
22
+    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
23
+    autoOpenBrowser: false,
24
+    errorOverlay: true,
25
+    notifyOnErrors: true,
26
+    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
27
+
28
+    // Use Eslint Loader?
29
+    // If true, your code will be linted during bundling and
30
+    // linting errors and warnings will be shown in the console.
31
+    useEslint: true,
32
+    // If true, eslint errors and warnings will also be shown in the error overlay
33
+    // in the browser.
34
+    showEslintErrorsInOverlay: false,
35
+
36
+    /**
37
+     * Source Maps
38
+     */
39
+
40
+    // https://webpack.js.org/configuration/devtool/#development
41
+    devtool: 'cheap-module-eval-source-map',
42
+
43
+    // If you have problems debugging vue-files in devtools,
44
+    // set this to false - it *may* help
45
+    // https://vue-loader.vuejs.org/en/options.html#cachebusting
46
+    cacheBusting: true,
47
+
48
+    cssSourceMap: true
49
+  },
50
+
51
+  build: {
52
+    // Template for index.html
53
+    index: path.resolve(__dirname, '../dist/index.html'),
54
+
55
+    // Paths
56
+    assetsRoot: path.resolve(__dirname, '../dist'),
57
+    assetsSubDirectory: 'static',
58
+    assetsPublicPath: '/',
59
+
60
+    /**
61
+     * Source Maps
62
+     */
63
+
64
+    productionSourceMap: true,
65
+    // https://webpack.js.org/configuration/devtool/#production
66
+    devtool: '#source-map',
67
+
68
+    // Gzip off by default as many popular static hosts such as
69
+    // Surge or Netlify already gzip all static assets for you.
70
+    // Before setting to `true`, make sure to:
71
+    // npm install --save-dev compression-webpack-plugin
72
+    productionGzip: false,
73
+    productionGzipExtensions: ['js', 'css'],
74
+
75
+    // Run the build command with an extra argument to
76
+    // View the bundle analyzer report after build finishes:
77
+    // `npm run build --report`
78
+    // Set to `true` or `false` to always turn it on or off
79
+    bundleAnalyzerReport: process.env.npm_config_report
80
+  }
81
+}

+ 4
- 0
config/prod.env.js Datei anzeigen

@@ -0,0 +1,4 @@
1
+'use strict'
2
+module.exports = {
3
+  NODE_ENV: '"production"'
4
+}

+ 7
- 0
config/test.env.js Datei anzeigen

@@ -0,0 +1,7 @@
1
+'use strict'
2
+const merge = require('webpack-merge')
3
+const devEnv = require('./dev.env')
4
+
5
+module.exports = merge(devEnv, {
6
+  NODE_ENV: '"testing"'
7
+})

+ 13
- 0
index.html Datei anzeigen

@@ -0,0 +1,13 @@
1
+<!DOCTYPE html>
2
+<html>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
6
+    <link rel="stylesheet" href="//at.alicdn.com/t/font_948990_7dbjfb2d5yb.css">
7
+    <title>myvue</title>
8
+  </head>
9
+  <body>
10
+    <div id="app"></div>
11
+    <!-- built files will be auto injected -->
12
+  </body>
13
+</html>

+ 15650
- 0
package-lock.json
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 95
- 0
package.json Datei anzeigen

@@ -0,0 +1,95 @@
1
+{
2
+  "name": "myvue",
3
+  "version": "1.0.0",
4
+  "description": "A Vue.js project",
5
+  "author": "xuchengxiang <xcx18267901393@dingtalk.com>",
6
+  "private": true,
7
+  "scripts": {
8
+    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
9
+    "start": "npm run dev",
10
+    "unit": "jest --config test/unit/jest.conf.js --coverage",
11
+    "e2e": "node test/e2e/runner.js",
12
+    "test": "npm run unit && npm run e2e",
13
+    "lint": "eslint --ext .js,.vue src test/unit test/e2e/specs",
14
+    "build": "node build/build.js"
15
+  },
16
+  "dependencies": {
17
+    "axios": "^0.18.0",
18
+    "mescroll.js": "^1.3.8",
19
+    "solarlunar": "^2.0.7",
20
+    "vant": "^1.4.5",
21
+    "vue": "^2.5.2",
22
+    "vue-awesome-swiper": "^3.1.3",
23
+    "vue-router": "^3.0.1",
24
+    "vuex": "^3.0.1"
25
+  },
26
+  "devDependencies": {
27
+    "autoprefixer": "^7.1.2",
28
+    "babel-core": "^6.22.1",
29
+    "babel-eslint": "^8.2.1",
30
+    "babel-helper-vue-jsx-merge-props": "^2.0.3",
31
+    "babel-jest": "^21.0.2",
32
+    "babel-loader": "^7.1.1",
33
+    "babel-plugin-dynamic-import-node": "^1.2.0",
34
+    "babel-plugin-syntax-jsx": "^6.18.0",
35
+    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
36
+    "babel-plugin-transform-runtime": "^6.22.0",
37
+    "babel-plugin-transform-vue-jsx": "^3.5.0",
38
+    "babel-preset-env": "^1.3.2",
39
+    "babel-preset-stage-2": "^6.22.0",
40
+    "babel-register": "^6.22.0",
41
+    "chalk": "^2.0.1",
42
+    "chromedriver": "^2.46.0",
43
+    "copy-webpack-plugin": "^4.0.1",
44
+    "cross-spawn": "^5.0.1",
45
+    "css-loader": "^0.28.0",
46
+    "eslint": "^4.15.0",
47
+    "eslint-config-standard": "^10.2.1",
48
+    "eslint-friendly-formatter": "^3.0.0",
49
+    "eslint-loader": "^1.7.1",
50
+    "eslint-plugin-import": "^2.7.0",
51
+    "eslint-plugin-node": "^5.2.0",
52
+    "eslint-plugin-promise": "^3.4.0",
53
+    "eslint-plugin-standard": "^3.0.1",
54
+    "eslint-plugin-vue": "^4.0.0",
55
+    "extract-text-webpack-plugin": "^3.0.0",
56
+    "file-loader": "^1.1.4",
57
+    "friendly-errors-webpack-plugin": "^1.6.1",
58
+    "html-webpack-plugin": "^2.30.1",
59
+    "jest": "^22.0.4",
60
+    "jest-serializer-vue": "^0.3.0",
61
+    "nightwatch": "^0.9.12",
62
+    "node-notifier": "^5.1.2",
63
+    "node-sass": "^4.10.0",
64
+    "optimize-css-assets-webpack-plugin": "^3.2.0",
65
+    "ora": "^1.2.0",
66
+    "portfinder": "^1.0.13",
67
+    "postcss-import": "^11.0.0",
68
+    "postcss-loader": "^2.0.8",
69
+    "postcss-url": "^7.2.1",
70
+    "rimraf": "^2.6.0",
71
+    "sass-loader": "^7.1.0",
72
+    "selenium-server": "^3.0.1",
73
+    "semver": "^5.3.0",
74
+    "shelljs": "^0.7.6",
75
+    "uglifyjs-webpack-plugin": "^1.1.1",
76
+    "url-loader": "^0.5.8",
77
+    "vue-jest": "^1.0.2",
78
+    "vue-loader": "^13.3.0",
79
+    "vue-style-loader": "^3.1.2",
80
+    "vue-template-compiler": "^2.5.2",
81
+    "webpack": "^3.6.0",
82
+    "webpack-bundle-analyzer": "^2.9.0",
83
+    "webpack-dev-server": "^2.9.1",
84
+    "webpack-merge": "^4.1.0"
85
+  },
86
+  "engines": {
87
+    "node": ">= 6.0.0",
88
+    "npm": ">= 3.0.0"
89
+  },
90
+  "browserslist": [
91
+    "> 1%",
92
+    "last 2 versions",
93
+    "not ie <= 8"
94
+  ]
95
+}

+ 21
- 0
src/App.vue Datei anzeigen

@@ -0,0 +1,21 @@
1
+<template>
2
+  <div id="app">
3
+    <router-view/>
4
+  </div>
5
+</template>
6
+
7
+<script>
8
+import './assets/css/reset.css'
9
+export default {
10
+  name: 'App'
11
+}
12
+</script>
13
+
14
+<style>
15
+#app {
16
+  width: 100%;
17
+  height: 100%;
18
+  position: relative;
19
+  overflow: hidden;
20
+}
21
+</style>

+ 48
- 0
src/assets/css/reset.css Datei anzeigen

@@ -0,0 +1,48 @@
1
+@charset"utf-8";
2
+html,body{width:100%;height:100%;width:100vw;height:100vh;-webkit-text-size-adjust:100%;position:relative;overflow-x:hidden;font-size:100px;}
3
+
4
+@media screen and(max-width:320px){html,body{font-size:85px;}}
5
+@media screen and(min-width:375px){html,body{font-size:100px;}}
6
+@media screen and(min-width:414px){html,body{font-size:110px;}}
7
+
8
+*{margin:0;padding:0;font-family:"微软雅黑";-webkit-tap-highlight-color:rgba(255,0,0,0);-webkit-font-smoothing:antialiased;}
9
+body *{font-size:.15rem;}
10
+a{text-decoration:none;}
11
+a:hover{cursor:pointer;}
12
+em{font-style:normal;}
13
+li{list-style:none;}
14
+img{border:0;vertical-align:middle;}
15
+table{border-collapse:collapse;border-spacing:0;}
16
+p{word-wrap:break-word;}
17
+b{font-weight:normal;}
18
+input,textarea{border:0;-webkit-appearance:none;}
19
+input[type=input]{-webkit-appearance:none;}
20
+input[type=checkbox]{-webkit-appearance:checkbox;}
21
+input:focus,textarea:focus,select:focus{outline:none;}
22
+textarea{resize:none;}
23
+select{direction:rtl;}
24
+select option{direction:ltr;}
25
+::-webkit-scrollbar{display:none;}
26
+
27
+.text-overflow-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
28
+.centerLabel{display:block;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);}
29
+.flex-h{display:flex;display:-webkit-flex;}
30
+.flex-v{display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;}
31
+.flex-item{flex:1;-webkit-flex:1;position:relative;overflow:hidden;}
32
+*[class*="text-overflowEllipsis-line"]{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;}
33
+.text-overflowEllipsis-line2{-webkit-line-clamp:2;}
34
+.text-overflowEllipsis-line3{-webkit-line-clamp:3;}
35
+.text-overflowEllipsis-line4{-webkit-line-clamp:4;}
36
+*[class*="overflow-scroll-y"]{overflow-x:hidden;overflow-y:scroll;-webkit-overflow-scrolling:touch;}
37
+*[class*="overflow-scroll-x"]{overflow-y:hidden;overflow-x:scroll;-webkit-overflow-scrolling:touch;}
38
+.overflow-scroll-y-3d,.overflow-scroll-x-3d{transform:translateZ(0);-webkit-transform:translateZ(0);}
39
+.overflow-scroll-x::-webkit-scrollbar,.overflow-scroll-x-3d::-webkit-scrollbar{width:0;height:0;color:transparent;display:none;}
40
+*>img.cover{width:100%;height:100%;object-fit:cover;}
41
+*>img.contain{width:100%;height:100%;object-fit:contain;}
42
+
43
+.mainPage{width:100%;height:100%;position:relative;background:#fff;}
44
+
45
+.van-toast div{color:white;}
46
+.van-toast i{color:white;}
47
+.van-dialog__message{text-align:center;}
48
+.van-dialog__message.van-dialog__message--has-title{text-align:center;}

BIN
src/assets/images/bg.jpg Datei anzeigen


BIN
src/assets/images/icon-1.png Datei anzeigen


BIN
src/assets/images/icon-10.png Datei anzeigen


BIN
src/assets/images/icon-2.png Datei anzeigen


BIN
src/assets/images/icon-3.png Datei anzeigen


BIN
src/assets/images/icon-4.png Datei anzeigen


BIN
src/assets/images/icon-5.png Datei anzeigen


BIN
src/assets/images/icon-6.png Datei anzeigen


BIN
src/assets/images/icon-7.png Datei anzeigen


BIN
src/assets/images/icon-8.png Datei anzeigen


BIN
src/assets/images/icon-9.png Datei anzeigen


+ 178
- 0
src/components/slideTabH/index.vue Datei anzeigen

@@ -0,0 +1,178 @@
1
+<template>
2
+  <div class="components flex-v">
3
+    <div class="tabNav flex-h" :style="{backgroundColor: backgroundColor || '#fff'}">
4
+      <a
5
+        class="flex-item"
6
+        v-for="(item, index) in data"
7
+        :key="index"
8
+        @click="cutNav(index)"
9
+        :style="{fontSize: fontSize + 'px', color: index === activeIndex ? (activeColor || 'red') : (normalColor || '#333')}"
10
+      >{{item.value}}</a>
11
+      <div class="activeLine" id="activeLine"></div>
12
+    </div>
13
+    <div class="flex-item">
14
+      <div>
15
+        <swiper :options="swiperOption" ref="mySwiper">
16
+          <swiper-slide class="swiper-slide" v-for="(item, index) in data" :key="index">
17
+            <slot :name="'slideTabH-' + item.id"></slot>
18
+          </swiper-slide>
19
+        </swiper>
20
+      </div>
21
+    </div>
22
+  </div>
23
+</template>
24
+
25
+<script>
26
+import { swiper, swiperSlide } from 'vue-awesome-swiper'
27
+import 'swiper/dist/css/swiper.css'
28
+export default {
29
+  name: 'slideTabH',
30
+  props: ['data', 'fontSize', 'activeColor', 'normalColor', 'backgroundColor', 'initIndex'],
31
+  data () {
32
+    var _self = this
33
+    return {
34
+      leftArr: [],
35
+      widthArr: [],
36
+      activeWidth: 0,
37
+      activeIndex: 0,
38
+      stepNum: 120,
39
+      swiperOption: {
40
+        watchSlidesProgress: true,
41
+        initialSlide: _self.activeIndex,
42
+        on: {
43
+          init () {
44
+            document.getElementById('activeLine').style.width = _self.widthArr[_self.activeIndex * _self.stepNum] + 'px'
45
+            document.getElementById('activeLine').style.left = _self.leftArr[_self.activeIndex * _self.stepNum] + 'px'
46
+          },
47
+          setTranslate (translate) { // 滑动偏移量监听
48
+            var num = (-translate / document.body.clientWidth * _self.stepNum).toFixed(0)
49
+            if (num >= 0 && num <= (_self.data.length - 1) * _self.stepNum) {
50
+              document.getElementById('activeLine').style.width = _self.widthArr[num] + 'px'
51
+              document.getElementById('activeLine').style.left = _self.leftArr[num] + 'px'
52
+            }
53
+          },
54
+          touchStart () {
55
+            document.getElementById('activeLine').style.transition = ''
56
+            document.getElementById('activeLine').style.WebkitTransition = ''
57
+          },
58
+          touchEnd () {
59
+            document.getElementById('activeLine').style.transition = '300ms'
60
+            document.getElementById('activeLine').style.WebkitTransition = '300ms'
61
+            if (this.realIndex !== _self.activeIndex) {
62
+              document.getElementById('activeLine').style.width = (_self.widthArr[this.realIndex * _self.stepNum]) + 'px'
63
+              document.getElementById('activeLine').style.left = (_self.leftArr[this.realIndex * _self.stepNum]) + 'px'
64
+            }
65
+          },
66
+          setTransition (speed) {
67
+            if (this.realIndex !== _self.activeIndex) {
68
+              document.getElementById('activeLine').style.width = (_self.widthArr[this.realIndex * _self.stepNum]) + 'px'
69
+              document.getElementById('activeLine').style.left = (_self.leftArr[this.realIndex * _self.stepNum]) + 'px'
70
+            }
71
+          },
72
+          transitionEnd () {
73
+            _self.activeIndex = this.activeIndex
74
+            _self.$emit('slideChange', this.activeIndex)
75
+          }
76
+        }
77
+      }
78
+    }
79
+  },
80
+  computed: {
81
+    MySwiper () {
82
+      return this.$refs.mySwiper.swiper
83
+    }
84
+  },
85
+  components: {
86
+    swiper,
87
+    swiperSlide
88
+  },
89
+  created () {
90
+    this.activeIndex = this.initIndex || 0
91
+    var aLeft = (document.body.clientWidth / this.data.length).toFixed(0)
92
+    this.data.map((item, index) => {
93
+      this.widthArr.push(item.value.length * (this.fontSize || 15))
94
+      this.leftArr.push((aLeft * index - 0) + ((aLeft / 2).toFixed(0) - 0) - this.widthArr[index] / 2)
95
+    })
96
+    this.activeWidth = this.widthArr[this.activeIndex]
97
+    this.widthArr = this.calcArr(this.widthArr, this.stepNum)
98
+    this.leftArr = this.calcArr(this.leftArr, this.stepNum)
99
+  },
100
+  mounted () {
101
+    this.$nextTick(() => {
102
+    })
103
+  },
104
+  methods: {
105
+    cutNav (index) { // 切换nav
106
+      document.getElementById('activeLine').style.transition = '300ms'
107
+      document.getElementById('activeLine').style.WebkitTransition = '300ms'
108
+      this.MySwiper.slideTo(index, 0, false)
109
+    },
110
+    calcArr (arr, num) { // 构造间隔数组:arr-原数组;num-间隔数
111
+      arr = arr || []
112
+      num = num || 20
113
+      var aArr = []
114
+      arr.map((item, index) => {
115
+        if (index < arr.length - 1) {
116
+          aArr.push([])
117
+          for (var n = 0; n < num; n++) {
118
+            aArr[index].push(item + (arr[index + 1] - item) * (n + 1) / num)
119
+          }
120
+        }
121
+      })
122
+      return [arr[0]].concat(...aArr)
123
+    }
124
+  }
125
+}
126
+</script>
127
+
128
+<!-- Add "scoped" attribute to limit CSS to this component only -->
129
+<style lang="scss" scoped>
130
+.components {
131
+  width: 100%;
132
+  height: 100%;
133
+  position: relative;
134
+  overflow: hidden;
135
+  .tabNav {
136
+    background: #fff;
137
+    position: relative;
138
+    overflow: hidden;
139
+    box-shadow: 0 0 0.1rem 0.02rem rgba(0, 0, 0, 0.05);
140
+    z-index: 100;
141
+    > a {
142
+      line-height: 0.45rem;
143
+      text-align: center;
144
+      color: #333;
145
+      position: relative;
146
+      z-index: 1;
147
+    }
148
+    .activeLine {
149
+      height: 0.02rem;
150
+      background: #f9064b;
151
+      position: absolute;
152
+      left: 0;
153
+      bottom: 0;
154
+      z-index: 2;
155
+    }
156
+  }
157
+  > .flex-item {
158
+    position: relative;
159
+    > div {
160
+      width: 100%;
161
+      position: absolute;
162
+      left: 0;
163
+      bottom: 0;
164
+      top: 0;
165
+      overflow: hidden;
166
+      > div {
167
+        width: 100%;
168
+        height: 100%;
169
+      }
170
+    }
171
+  }
172
+  .swiper-slide {
173
+    background: #f8f8f8;
174
+    position: relative;
175
+    z-index: 1;
176
+  }
177
+}
178
+</style>

+ 74
- 0
src/components/swiperBanner/index.vue Datei anzeigen

@@ -0,0 +1,74 @@
1
+<template>
2
+  <div class="components">
3
+    <swiper :options="swiperOption" ref="myBannerSwiper">
4
+      <swiper-slide class="swiper-slide" v-for="(item,index) in data" :key="index">
5
+        <a @click="bannerLink(item)">
6
+          <img :src="item.img" class="cover" alt>
7
+        </a>
8
+      </swiper-slide>
9
+      <div class="swiper-pagination" slot="pagination"></div>
10
+    </swiper>
11
+  </div>
12
+</template>
13
+
14
+<script>
15
+import { swiper, swiperSlide } from 'vue-awesome-swiper'
16
+import 'swiper/dist/css/swiper.css'
17
+export default {
18
+  name: 'swiperBanner',
19
+  props: ['data'],
20
+  data () {
21
+    return {
22
+      swiperOption: {
23
+        observer: true,
24
+        pagination: {
25
+          el: '.swiper-pagination'
26
+        },
27
+        autoplay: {
28
+          disableOnInteraction: false
29
+        }
30
+      }
31
+    }
32
+  },
33
+  computed: {
34
+  },
35
+  components: {
36
+    swiper,
37
+    swiperSlide
38
+  },
39
+  created () {
40
+  },
41
+  mounted () {
42
+    this.$nextTick(() => {
43
+    })
44
+  },
45
+  methods: {
46
+    bannerLink (item) {
47
+      this.$emit('bannerLink', item)
48
+    }
49
+  }
50
+}
51
+</script>
52
+
53
+<!-- Add "scoped" attribute to limit CSS to this component only -->
54
+<style lang="scss" scoped>
55
+.components {
56
+  width: 100%;
57
+  height: 100%;
58
+  position: relative;
59
+  overflow: hidden;
60
+  >div{
61
+    width: 100%;
62
+    height: 100%;
63
+    .swiper-slide{
64
+      a{
65
+        width: 100%;
66
+        height: 100%;
67
+        display: block;
68
+        position: relative;
69
+        overflow: hidden;
70
+      }
71
+    }
72
+  }
73
+}
74
+</style>

+ 23
- 0
src/main.js Datei anzeigen

@@ -0,0 +1,23 @@
1
+// The Vue build version to load with the `import` command
2
+// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3
+import Vue from 'vue'
4
+import App from './App'
5
+import router from './router'
6
+import store from './store'
7
+import Vant from 'vant'
8
+import 'vant/lib/index.css'
9
+import toolClass from './util/util'
10
+
11
+Vue.use(Vant)
12
+
13
+Vue.config.productionTip = false
14
+Vue.prototype.toolClass = toolClass
15
+
16
+/* eslint-disable no-new */
17
+new Vue({
18
+  el: '#app',
19
+  router,
20
+  store,
21
+  components: { App },
22
+  template: '<App/>'
23
+})

+ 527
- 0
src/pages/index.vue Datei anzeigen

@@ -0,0 +1,527 @@
1
+<template>
2
+  <div class="projectIndex">
3
+    <img src="../assets/images/bg.jpg" class="centerLabel cover bg" alt>
4
+    <div class="content flex-h">
5
+      <div class="left flex-v">
6
+        <div class="weather">
7
+          <div class="date flex-h">
8
+            <span>{{currentDate}}</span>
9
+            <span class="flex-item">{{currentWeek}}</span>
10
+            <span>农历{{currentChineseDate}}</span>
11
+          </div>
12
+          <div class="weatherDetail flex-h">
13
+            <div class="imgData">
14
+              <img src="../assets/images/icon-1.png" width="100%" alt>
15
+              <span>3°C ~ 14°C</span>
16
+            </div>
17
+            <div class="flex-item">
18
+              <div>
19
+                <span>今日降雨概率60%,请做好防雨措施</span>
20
+                <ul>
21
+                  <li>
22
+                    <span>北风2级</span>
23
+                    <span>空气湿度: 96%</span>
24
+                  </li>
25
+                  <li>
26
+                    <span>北风2级</span>
27
+                    <span>空气湿度: 96%</span>
28
+                  </li>
29
+                  <li>
30
+                    <span>北风2级</span>
31
+                    <span>空气湿度: 96%</span>
32
+                  </li>
33
+                </ul>
34
+              </div>
35
+            </div>
36
+          </div>
37
+        </div>
38
+        <div class="flex-item">
39
+          <div>
40
+            <div class="centerLabel notice">
41
+              <h1>{{timeNum}}</h1>
42
+              <span>阿克苏娜LDNA索拉卡DNASDLK安山东济南加上大陆上的那家里电脑安静店里看到埃里克的加快了升级卡了多久啊啦拉开觉得苦辣加大了肯德基案例卡的昆仑决ad卡拉胶的拉客的加快了升级阿卡丽</span>
43
+              <div>
44
+                <span>通知人</span>
45
+                <span>2019年2月22日</span>
46
+              </div>
47
+            </div>
48
+          </div>
49
+        </div>
50
+      </div>
51
+      <div class="flex-item">
52
+        <div :hidden="!showSlide">
53
+          <swiper :options="swiperOption" ref="mySwiper">
54
+            <swiper-slide class="swiper-slide" v-for="(item, index) in 5" :key="index">
55
+              <img
56
+                class="centerLabel cover"
57
+                src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1550835899076&di=3f786b46cffb6956608e66421b2ec859&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2Fe4dde71190ef76c66c3378239716fdfaae5167d1.jpg"
58
+                alt
59
+              >
60
+            </swiper-slide>
61
+          </swiper>
62
+        </div>
63
+        <div :hidden="showSlide">
64
+          <ul class="centerLabel userList">
65
+            <li v-for="(item, index) in userList" :key="index" :class="{'active': item.show}">
66
+              <span>{{`${item.firstName}${item.gender - 0 === 1 ? '先生' : '女士'}`}}</span>
67
+              <span>欢迎光临 !</span>
68
+            </li>
69
+          </ul>
70
+        </div>
71
+      </div>
72
+    </div>
73
+  </div>
74
+</template>
75
+
76
+<script>
77
+import { createNamespacedHelpers } from 'vuex'
78
+import 'swiper/dist/css/swiper.css'
79
+import { swiper, swiperSlide } from 'vue-awesome-swiper'
80
+import solarLunar from 'solarLunar'
81
+const { mapState: mapUserState, mapActions: mapUserActions } = createNamespacedHelpers('user')
82
+export default {
83
+  name: 'projectIndex',
84
+  data () {
85
+    return {
86
+      userList: [],
87
+      currentWeek: '周',
88
+      currentTime: '00:00:00',
89
+      currentDate: 'xx年xx月xx日',
90
+      currentChineseDate: 'xx月xx日',
91
+      showSlide: true,
92
+      currentTimeTamp: Date.now(),
93
+      ChineseDate: null,
94
+      activeIndex: 0,
95
+      timer: null,
96
+      timeNum: 0,
97
+      swiperOption: {
98
+        loop: true,
99
+        speed: 1000,
100
+        autoplay: {
101
+          delay: 6000,
102
+          disableOnInteraction: false
103
+        }
104
+      }
105
+    }
106
+  },
107
+  computed: {
108
+    ...mapUserState({
109
+      weatherInfo: x => x.weatherInfo // 天气信息
110
+    }),
111
+    mySwiper () {
112
+      return this.$refs.mySwiper.swiper
113
+    },
114
+    isDay () {
115
+      return new Date(this.currentTimeTamp).getHours() <= 17 && new Date(this.currentTimeTamp).getHours() >= 6
116
+    }
117
+  },
118
+  components: {
119
+    swiper,
120
+    swiperSlide
121
+  },
122
+  created () {
123
+    this.init()
124
+    window.setInterval(() => {
125
+      this.init()
126
+    }, 1000)
127
+    // this.getWeatherInfo({
128
+    //   city: '110101',
129
+    //   key: '1c57a8a9ba3fd1a2afcac167dec97be1'
130
+    // })
131
+    window.setTimeout(() => {
132
+      this.returnUserList({
133
+        firstName: '111',
134
+        gender: '0',
135
+        show: false
136
+      })
137
+    }, 1000)
138
+    window.setTimeout(() => {
139
+      this.returnUserList({
140
+        firstName: '222',
141
+        gender: '1',
142
+        show: false
143
+      })
144
+    }, 4000)
145
+    window.setTimeout(() => {
146
+      this.returnUserList({
147
+        firstName: '333',
148
+        gender: '1',
149
+        show: false
150
+      })
151
+    }, 8000)
152
+    window.setTimeout(() => {
153
+      this.returnUserList({
154
+        firstName: '444',
155
+        gender: '1',
156
+        show: false
157
+      })
158
+    }, 12000)
159
+    window.setTimeout(() => {
160
+      this.returnUserList({
161
+        firstName: '555',
162
+        gender: '1',
163
+        show: false
164
+      })
165
+    }, 14000)
166
+    window.setTimeout(() => {
167
+      this.returnUserList({
168
+        firstName: '666',
169
+        gender: '1',
170
+        show: false
171
+      })
172
+    }, 16000)
173
+    window.setTimeout(() => {
174
+      this.returnUserList({
175
+        firstName: '777',
176
+        gender: '1',
177
+        show: false
178
+      })
179
+    }, 19000)
180
+    window.setTimeout(() => {
181
+      this.returnUserList({
182
+        firstName: '888',
183
+        gender: '1',
184
+        show: false
185
+      })
186
+    }, 21000)
187
+    window.setTimeout(() => {
188
+      this.returnUserList({
189
+        firstName: '999',
190
+        gender: '1',
191
+        show: false
192
+      })
193
+    }, 24000)
194
+  },
195
+  mounted () {
196
+    this.$nextTick(() => {
197
+    })
198
+  },
199
+  methods: {
200
+    ...mapUserActions([
201
+      'getWeatherInfo'
202
+    ]),
203
+    returnUserList (item) { // 返回用户信息
204
+      this.showSlide = false
205
+      window.clearInterval(this.timer)
206
+      this.timeNum = 0
207
+      window.setTimeout(() => {
208
+        item.show = true
209
+      }, 100)
210
+      if (this.userList.length > 2) {
211
+        this.userList.splice(0, 1)
212
+        this.userList.push(item)
213
+      } else {
214
+        this.userList.push(item)
215
+      }
216
+      this.timer = window.setInterval(() => {
217
+        if (this.timeNum - 0 >= 5000) {
218
+          this.timeNum = 0
219
+          window.clearInterval(this.timer)
220
+          this.showSlide = true
221
+        } else {
222
+          this.timeNum += 100
223
+        }
224
+      }, 100)
225
+    },
226
+    init () { // 初始化
227
+      this.getDate()
228
+      if (!new Date().getMinutes()) { // 整点更新时间
229
+        this.currentTimeTamp = Date.now()
230
+      }
231
+    },
232
+    getDate () { // 获取当前时间
233
+      let currentTime = Date.now()
234
+      let weekday = ['日', '一', '二', '三', '四', '五', '六']
235
+      let ChineseDate = solarLunar.lunar2solar(new Date(currentTime).getFullYear(), new Date(currentTime).getMonth(), new Date(currentTime).getDate())
236
+      this.currentWeek = `星期${weekday[new Date(currentTime).getDay()]}`
237
+      this.currentTime = `${new Date(currentTime).getHours().toString().padStart(2, '0')} : ${new Date(currentTime).getMinutes().toString().padStart(2, '0')} : ${new Date(currentTime).getSeconds().toString().padStart(2, '0')}`
238
+      this.currentDate = `${new Date(currentTime).getFullYear()}年${(new Date(currentTime).getMonth() + 1).toString().padStart(2, '0')}月${new Date(currentTime).getDate().toString().padStart(2, '0')}日`
239
+      this.currentChineseDate = `${ChineseDate.monthCn}${ChineseDate.dayCn}`
240
+    }
241
+    // weatherIcon (target) { // 返回天气图标
242
+    //   switch (target) {
243
+    //     case '晴':
244
+    //       return require('../assets/images/icon-2.png')
245
+    //     case '少云':
246
+    //     case '晴间多云':
247
+    //     case '多云':
248
+    //       return require('../assets/images/icon-1.png')
249
+    //     case '阴':
250
+    //     case '平静':
251
+    //       return require('../assets/images/icon-3.png')
252
+    //     case '有风':
253
+    //     case '微风':
254
+    //     case '和风':
255
+    //     case '清风':
256
+    //     case '强风/劲风':
257
+    //     case '疾风':
258
+    //     case '大风':
259
+    //     case '烈风':
260
+    //     case '风暴':
261
+    //     case '狂爆风':
262
+    //     case '飓风':
263
+    //     case '热带风暴':
264
+    //     case '浮尘':
265
+    //     case '扬沙':
266
+    //       return require('../assets/images/icon-19.png')
267
+    //     case '阵雨':
268
+    //     case '大雨':
269
+    //     case '中雨-大雨':
270
+    //     case '大雨-暴雨':
271
+    //     case '暴雨-大暴雨':
272
+    //     case '大暴雨-特大暴雨':
273
+    //     case '暴雨':
274
+    //     case '大暴雨':
275
+    //     case '特大暴雨':
276
+    //     case '强阵雨':
277
+    //     case '极端降雨':
278
+    //       return require('../assets/images/icon-6.png')
279
+    //     case '雷阵雨':
280
+    //     case '雷阵雨并伴有冰雹':
281
+    //       return require('../assets/images/icon-7.png')
282
+    //     case '毛毛雨/细雨':
283
+    //     case '小雨':
284
+    //       return require('../assets/images/icon-4.png')
285
+    //     case '雨':
286
+    //     case '中雨':
287
+    //     case '小雨-中雨':
288
+    //       return require('../assets/images/icon-5.png')
289
+    //     case '雨夹雪':
290
+    //     case '阵雨夹雪':
291
+    //     case '雨雪天气':
292
+    //     case '冻雨':
293
+    //       return require('../assets/images/icon-21.png')
294
+    //     case '阵雪':
295
+    //     case '小雪':
296
+    //     case '中雪':
297
+    //     case '大雪':
298
+    //     case '暴雪':
299
+    //     case '小雪-中雪':
300
+    //     case '中雪-大雪':
301
+    //     case '大雪-暴雪':
302
+    //     case '雪':
303
+    //       return require('../assets/images/icon-14.png')
304
+    //     case '沙尘暴':
305
+    //     case '强沙尘暴':
306
+    //     case '龙卷风':
307
+    //       return require('../assets/images/icon-20.png')
308
+    //     case '雾':
309
+    //     case '浓雾':
310
+    //     case '强浓雾':
311
+    //     case '轻雾':
312
+    //     case '大雾':
313
+    //     case '特强浓雾':
314
+    //       return require('../assets/images/icon-22.png')
315
+    //     case '霾':
316
+    //     case '中度霾':
317
+    //     case '重度霾':
318
+    //     case '严重霾':
319
+    //       return require('../assets/images/icon-23.png')
320
+    //     default:
321
+    //       return require('../assets/images/icon-24.png')
322
+    //   }
323
+    // }
324
+  }
325
+}
326
+</script>
327
+
328
+<!-- Add "scoped" attribute to limit CSS to this component only -->
329
+<style lang="scss" scoped>
330
+.projectIndex {
331
+  width: 100%;
332
+  height: 100%;
333
+  position: relative;
334
+  overflow: hidden;
335
+  .bg {
336
+    z-index: 1;
337
+  }
338
+  > div {
339
+    width: 100%;
340
+    height: 100%;
341
+    box-sizing: border-box;
342
+    border: 20px solid transparent;
343
+    z-index: 2;
344
+    position: relative;
345
+    overflow: hidden;
346
+    .left {
347
+      width: 35.5%;
348
+      position: relative;
349
+      overflow: hidden;
350
+      > div {
351
+        background: rgba(255, 255, 255, 0.15);
352
+        border-radius: 6px;
353
+      }
354
+      .weather {
355
+        width: 100%;
356
+        position: relative;
357
+        overflow: hidden;
358
+        margin-bottom: 20px;
359
+        padding: 60px 0;
360
+        .date {
361
+          align-items: center;
362
+          span {
363
+            line-height: 1.6;
364
+            font-size: 1.7vw;
365
+            color: #fff;
366
+            text-align: center;
367
+            &:first-child {
368
+              margin-left: 2.4vw;
369
+            }
370
+            &:last-child {
371
+              margin-right: 2.4vw;
372
+            }
373
+          }
374
+        }
375
+        .weatherDetail {
376
+          padding: 0 20px;
377
+          position: relative;
378
+          overflow: hidden;
379
+          margin-top: 18px;
380
+          .imgData {
381
+            width: 12.6vw;
382
+            position: relative;
383
+            overflow: hidden;
384
+            span {
385
+              width: 100%;
386
+              color: #fff;
387
+              font-size: 2vw;
388
+              line-height: 1.5;
389
+              margin-top: 20px;
390
+              display: block;
391
+            }
392
+          }
393
+          > .flex-item {
394
+            > div {
395
+              width: 100%;
396
+              position: relative;
397
+              overflow: hidden;
398
+              > span {
399
+                width: 100%;
400
+                color: #fff;
401
+                font-size: 1.2vw;
402
+                line-height: 1.8;
403
+                white-space: nowrap;
404
+                overflow: hidden;
405
+                text-overflow: ellipsis;
406
+              }
407
+              ul {
408
+                li {
409
+                  border-bottom: 1px solid #b3bcc3;
410
+                  font-size: 0;
411
+                  white-space: nowrap;
412
+                  padding: 6px 0;
413
+                  span {
414
+                    display: inline-block;
415
+                    width: 50%;
416
+                    color: #fff;
417
+                    font-size: 1.3vw;
418
+                    white-space: nowrap;
419
+                    line-height: 1.7;
420
+                  }
421
+                }
422
+              }
423
+            }
424
+          }
425
+        }
426
+      }
427
+      > .flex-item {
428
+        > div {
429
+          width: 100%;
430
+          height: 100%;
431
+          position: relative;
432
+          > .notice {
433
+            width: 100%;
434
+            box-sizing: border-box;
435
+            border-left: 2.4vw solid transparent;
436
+            border-right: 2.4vw solid transparent;
437
+            overflow: hidden;
438
+            h1 {
439
+              text-align: center;
440
+              color: #fff;
441
+              font-size: 1.9vw;
442
+              line-height: 1.6;
443
+              white-space: nowrap;
444
+              overflow: hidden;
445
+              text-overflow: ellipsis;
446
+              font-weight: normal;
447
+            }
448
+            > span {
449
+              width: 100%;
450
+              display: block;
451
+              color: #fff;
452
+              font-size: 1.2vw;
453
+              line-height: 1.6;
454
+              text-align: justify;
455
+              margin-top: 30px;
456
+            }
457
+            div {
458
+              margin-top: 30px;
459
+              span {
460
+                width: 100%;
461
+                display: block;
462
+                text-align: right;
463
+                color: #fff;
464
+                font-size: 1.2vw;
465
+                line-height: 1.6;
466
+              }
467
+            }
468
+          }
469
+        }
470
+      }
471
+    }
472
+    > .flex-item {
473
+      margin-left: 20px;
474
+      position: relative;
475
+      > div {
476
+        width: 100%;
477
+        height: 100%;
478
+        position: relative;
479
+        overflow: hidden;
480
+        border-radius: 6px;
481
+        .swiper-container {
482
+          width: 100%;
483
+          height: 100%;
484
+          position: relative;
485
+        }
486
+        .userList {
487
+          width: 35vw;
488
+          overflow: hidden;
489
+          transition: all 0.3s linear;
490
+          -webkit-transition: all 0.3s linear;
491
+          > li {
492
+            width: 100%;
493
+            position: relative;
494
+            overflow: hidden;
495
+            background: rgba(255, 255, 255, 0.15);
496
+            margin: 1.8vh auto 0;
497
+            padding: 9vh 0;
498
+            transform: translateY(100vh);
499
+            -webkit-transform: translateY(100vh);
500
+            transition: all 0.3s linear;
501
+            -webkit-transition: all 0.3s linear;
502
+            &:first-child {
503
+              margin-top: 0;
504
+            }
505
+            &.active {
506
+              transform: translateY(0);
507
+              -webkit-transform: translateY(0);
508
+            }
509
+            span {
510
+              width: 100%;
511
+              display: block;
512
+              color: #fff;
513
+              text-align: center;
514
+              line-height: 1.45;
515
+              font-size: 2.3vw;
516
+              &:first-child {
517
+                font-size: 2.8vw;
518
+                line-height: 1.3;
519
+              }
520
+            }
521
+          }
522
+        }
523
+      }
524
+    }
525
+  }
526
+}
527
+</style>

+ 21
- 0
src/router/index.js Datei anzeigen

@@ -0,0 +1,21 @@
1
+/* eslint-disable */
2
+import Vue from 'vue'
3
+import Router from 'vue-router'
4
+import index from '../pages/index'
5
+
6
+Vue.use(Router)
7
+
8
+let router = new Router({
9
+  routes: [{
10
+    path: '/',
11
+    name: 'index',
12
+    component: index,
13
+    children: []
14
+  }]
15
+})
16
+
17
+router.beforeEach((to, from, next) => {
18
+  next()
19
+})
20
+
21
+export default router

+ 44
- 0
src/store/index.js Datei anzeigen

@@ -0,0 +1,44 @@
1
+/* eslint-disable */
2
+import Vue from 'vue'
3
+import Vuex from 'vuex'
4
+
5
+Vue.use(Vuex)
6
+
7
+const store = new Vuex.Store({
8
+  state: {
9
+    projectHeaderData: { // 顶部数据
10
+      hidden: true, // 是否隐藏框架
11
+      title: '', // 标题
12
+      btns: [] // 按钮数据:{value: 'icon-shezhi',type: 'icon',response: ()=>{}},{value: '按钮',type: 'word',response: ()=>{}}
13
+    },
14
+    systemType: null // 系统类型判断:IOS/Android/Other
15
+  },
16
+  mutations: {
17
+    setProjectHeader (state, data) { // 设置顶部数据
18
+      data = data || {}
19
+      state.projectHeaderData = {
20
+        hidden: true,
21
+        title: '',
22
+        btns: [],
23
+        ...data
24
+      }
25
+    },
26
+    setSystemType (state) { // 获取系统类型
27
+      var u = navigator.userAgent
28
+      var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 // android终端
29
+      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) // ios终端
30
+      state.systemType = isIOS ? 'IOS' : isAndroid ? 'Android' : 'Other'
31
+    }
32
+  }
33
+})
34
+export const modules = {
35
+  user: () => require('./user/index').default
36
+}
37
+
38
+Object.keys(modules).forEach((modKey) => {
39
+  const modNS = modKey.split('/')
40
+  const getMod = modules[modKey]
41
+  store.registerModule(...modNS, getMod())
42
+})
43
+
44
+export default store

+ 85
- 0
src/store/user/index.js Datei anzeigen

@@ -0,0 +1,85 @@
1
+import Ajax from '../../util/ajax'
2
+import api from '../../util/api'
3
+
4
+export default {
5
+  namespaced: true,
6
+  state: {
7
+    weatherInfo: {
8
+      'status': '1',
9
+      'count': '1',
10
+      'info': 'OK',
11
+      'infocode': '10000',
12
+      'forecasts': [{
13
+        'city': '南京市',
14
+        'adcode': '320100',
15
+        'province': '江苏',
16
+        'reporttime': '2019-02-21 13:48:01',
17
+        'casts': [{
18
+          'date': '2019-02-21',
19
+          'week': '4',
20
+          'dayweather': '晴间多云',
21
+          'nightweather': '雨夹雪',
22
+          'daytemp': '7',
23
+          'nighttemp': '2',
24
+          'daywind': '东',
25
+          'nightwind': '东',
26
+          'daypower': '≤3',
27
+          'nightpower': '≤3'
28
+        }, {
29
+          'date': '2019-02-22',
30
+          'week': '5',
31
+          'dayweather': '小雨',
32
+          'nightweather': '多云',
33
+          'daytemp': '6',
34
+          'nighttemp': '0',
35
+          'daywind': '北',
36
+          'nightwind': '北',
37
+          'daypower': '≤3',
38
+          'nightpower': '≤3'
39
+        }, {
40
+          'date': '2019-02-23',
41
+          'week': '6',
42
+          'dayweather': '多云',
43
+          'nightweather': '多云',
44
+          'daytemp': '11',
45
+          'nighttemp': '1',
46
+          'daywind': '东北',
47
+          'nightwind': '东北',
48
+          'daypower': '≤3',
49
+          'nightpower': '≤3'
50
+        }, {
51
+          'date': '2019-02-24',
52
+          'week': '7',
53
+          'dayweather': '多云',
54
+          'nightweather': '多云',
55
+          'daytemp': '10',
56
+          'nighttemp': '4',
57
+          'daywind': '东',
58
+          'nightwind': '东',
59
+          'daypower': '≤3',
60
+          'nightpower': '≤3'
61
+        }]
62
+      }]
63
+    }
64
+  },
65
+  mutations: {
66
+    setWeatherInfo (state, data) {
67
+      state.weatherInfo = data
68
+    }
69
+  },
70
+  actions: {
71
+    getWeatherInfo (context, payload) { // 获取天气信息
72
+      return new Promise((resolve, reject) => {
73
+        Ajax(api.getWeatherInfo.url, {
74
+          method: api.getWeatherInfo.method,
75
+          queryData: { ...payload }
76
+        }).then(res => {
77
+          context.commit('setWeatherInfo', res)
78
+          resolve(res)
79
+        }).catch((res) => {
80
+          reject(res)
81
+        })
82
+      })
83
+    }
84
+  }
85
+}

+ 53
- 0
src/util/ajax.js Datei anzeigen

@@ -0,0 +1,53 @@
1
+import axios from 'axios'
2
+import qs from 'qs'
3
+
4
+const Axios = axios.create({
5
+  timeout: 60000,
6
+  responseType: 'json',
7
+  withCredentials: true,
8
+  queryData: {},
9
+  urlData: {},
10
+  headers: {
11
+    'Content-Type': 'application/json',
12
+    'X-Auth-Token': ''
13
+  }
14
+})
15
+
16
+Axios.interceptors.request.use((config) => {
17
+  let aName = 'X-Auth-Token'
18
+  config.headers[aName] = config.token || ''
19
+  let urlData = qs.stringify(config.urlData)
20
+  let queryData = qs.stringify(config.queryData)
21
+  if (config.url.indexOf(':') > -1) {
22
+    if (typeof config.urlData === 'object') {
23
+      config.url = replaceURLParams(config.url, config.urlData)
24
+    } else {
25
+      config.url = config.url.slice(0, config.url.indexOf(':')) + urlData
26
+    }
27
+  }
28
+  if (queryData) {
29
+    config.url += '?' + queryData
30
+  }
31
+  return config
32
+}, (error) => {
33
+  console.log(error)
34
+})
35
+
36
+const ajax = (...args) => {
37
+  return new Promise((resolve, reject) => {
38
+    Axios(...args).then(({ data, headers }) => {
39
+      resolve(data)
40
+    }).catch(reject)
41
+  })
42
+}
43
+
44
+export default ajax
45
+
46
+export function replaceURLParams (url, params) {
47
+  const args = { ...(params || {}), org: 'MQ' }
48
+
49
+  return Object.keys(args).reduce((acc, k) => { // 此方法对每个元素进行处理
50
+    const re = new RegExp(`:${k}(?!w)`, 'i')
51
+    return acc.replace(re, args[k])
52
+  }, url)
53
+}

+ 9
- 0
src/util/api.js Datei anzeigen

@@ -0,0 +1,9 @@
1
+
2
+const $api = {
3
+  getWeatherInfo: { // 获取天气信息
4
+    method: 'get',
5
+    url: `https://restapi.amap.com/v3/weather/weatherInfo?parameters`
6
+  }
7
+}
8
+
9
+export default $api

+ 96
- 0
src/util/util.js Datei anzeigen

@@ -0,0 +1,96 @@
1
+/* eslint-disable */
2
+const toolClass = {
3
+  dateFormat: (timestamp, fmt) => { // 时间格式转换
4
+    if (timestamp) {
5
+      if (!fmt) {
6
+        fmt = 'yyyy-MM-dd hh:mm'
7
+      }
8
+      let date = new Date(timestamp)
9
+      var o = {
10
+        'M+': date.getMonth() + 1,
11
+        'd+': date.getDate(),
12
+        'h+': date.getHours(),
13
+        'm+': date.getMinutes(),
14
+        's+': date.getSeconds(),
15
+        'q+': Math.floor((date.getMonth() + 3) / 3),
16
+        'S': date.getMilliseconds()
17
+      }
18
+      if (/(y+)/.test(fmt)) {
19
+        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
20
+      }
21
+      for (var k in o) {
22
+        if (new RegExp('(' + k + ')').test(fmt)) {
23
+          fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
24
+        }
25
+      }
26
+      return fmt
27
+    } else {
28
+      return ''
29
+    }
30
+  },
31
+  JsBridge: { // IOS/Android原生交互
32
+    init: function (callback) { // 初始化
33
+      var u = navigator.userAgent
34
+      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
35
+      if (!isiOS) {
36
+        if (window.WebViewJavascriptBridge) {
37
+          callback(WebViewJavascriptBridge)
38
+        } else {
39
+          document.addEventListener(
40
+            'WebViewJavascriptBridgeReady',
41
+            function () {
42
+              callback(WebViewJavascriptBridge)
43
+            },
44
+            false
45
+          )
46
+        }
47
+      } else {
48
+        if (window.WebViewJavascriptBridge) return callback(WebViewJavascriptBridge)
49
+        if (window.WVJBCallbacks) return window.WVJBCallbacks.push(callback)
50
+        window.WVJBCallbacks = [callback]
51
+        var WVJBIframe = document.createElement('iframe')
52
+        WVJBIframe.style.display = 'none'
53
+        WVJBIframe.src = 'https://__bridge_loaded__'
54
+        document.documentElement.appendChild(WVJBIframe)
55
+        setTimeout(function () { document.documentElement.removeChild(WVJBIframe) }, 0)
56
+      }
57
+    },
58
+    first: function () { // 建立第一次链接
59
+      var u = navigator.userAgent
60
+      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
61
+      if (!isiOS) {
62
+        var _this = this
63
+        _this.init(function (bridge) {
64
+          bridge.init(function (message, responseCallback) {
65
+            responseCallback(data)
66
+          })
67
+        })
68
+      }
69
+    },
70
+    registerHandler: function (name, fun) { // app通知h5方法
71
+      var _this = this
72
+      _this.init(function (bridge) {
73
+        bridge.registerHandler(name, fun)
74
+      })
75
+    },
76
+    callHandler: function (name, data, fun) { // h5通知app方法
77
+      var _this = this
78
+      _this.init(function (bridge) {
79
+        bridge.callHandler(name, data, fun)
80
+      })
81
+    }
82
+  },
83
+  returnDoubleNum (num) { // 转化双位数
84
+    return num > 9 ? num : ('0' + num)
85
+  },
86
+  checkPhoneNum (num) { // 校验手机号
87
+    var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
88
+    return !!myreg.test(num)
89
+  },
90
+  checkEmail (num) { // 校验邮箱
91
+    var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/
92
+    return !!myreg.test(num)
93
+  }
94
+}
95
+
96
+export default toolClass

+ 0
- 0
static/.gitkeep Datei anzeigen