├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── README.md ├── build ├── build.js ├── check-versions.js ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── index.html ├── package-lock.json ├── package.json ├── src ├── App.vue ├── common │ ├── imgs │ │ └── footer-icons.png │ ├── js │ │ ├── axiosConfig.js │ │ ├── config.js │ │ ├── dom.js │ │ ├── globalVueConfig.js │ │ ├── mixins.js │ │ └── vector.js │ └── sass │ │ ├── element-ui.sass │ │ ├── index.sass │ │ ├── mixins.sass │ │ ├── scaffolding.sass │ │ ├── utilities.sass │ │ └── variables.sass ├── components │ ├── Affix.vue │ ├── GoodsCard.vue │ ├── TheFooter.vue │ └── TheHeader.vue ├── main.js ├── router │ └── index.js └── views │ ├── entry │ └── login.vue │ ├── home │ ├── banner.vue │ ├── goods-hot.vue │ ├── goods-special.vue │ ├── goods-swiper.vue │ ├── index.vue │ └── menu.vue │ └── index.vue └── static └── .gitkeep /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 9"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": [ 12 | "transform-vue-jsx", 13 | "transform-runtime", 14 | "babel-plugin-transform-async-to-generator", 15 | "babel-plugin-external-helpers", 16 | "babel-plugin-transform-decorators-legacy", 17 | "babel-plugin-transform-class-properties", 18 | ["component", [ 19 | { 20 | "libraryName": "element-ui", 21 | "styleLibraryName": "theme-chalk" 22 | } 23 | ]] 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 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 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 13 | extends: 'standard', 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'html' 17 | ], 18 | // add your custom rules here 19 | 'rules': { 20 | // allow paren-less arrow functions 21 | 'arrow-parens': 0, 22 | // allow async-await 23 | 'generator-star-spacing': 0, 24 | // allow debugger during development 25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 26 | 'eol-last': 0, 27 | 'space-before-function-paren': 0, 28 | 'comma-dangle': 0, // 多行模式必须带逗号 29 | 'no-return-assign': 0, 30 | 'camelcase': 0, 31 | 'no-useless-computed-key': 0, 32 | 'no-unused-vars': 0, // 变量声明了是否必须使用 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Editor directories and files 9 | .idea 10 | .vscode 11 | *.suo 12 | *.ntvs* 13 | *.njsproj 14 | *.sln 15 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | // to edit target browsers: use "browserslist" field in package.json 6 | "postcss-import": {}, 7 | "autoprefixer": {} 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-shop 2 | 3 | > 使用 vue + sass + pug + vue-component-class 模仿[DOKODEMO](https://dokodemo.world/zh-Hans/) 首页的项目。 4 | 5 | ## Build Setup 6 | **node 版本需要大于 8.0** 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:3000 12 | npm start 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | ``` 20 | > 请特别注意,直接使用 cnpm 可能会导致依赖不正确。强烈建议给 npm 设置 taobao 的 registry。 21 | ```bash 22 | npm install --registry=https://registry.npm.taobao.org 23 | ``` 24 | 25 | 或者使用 nrm 26 | ```bash 27 | npm install nrm -g 28 | nrm use taobao 29 | ``` 30 | 31 | 如果你已经用上了 yarn,建议这样 32 | ```bash 33 | yarn config set registry https://registry.npm.taobao.org 34 | yarn 35 | ``` 36 | 37 | ## 第三方库 38 | - vue 2.5+ 39 | - vue-router 40 | - vuex 41 | - axios 42 | - [vue-class-component](https://github.com/vuejs/vue-class-component) 43 | - [element-ui 2.x](http://element-cn.eleme.io/#/zh-CN) 44 | - babel-polyfill 45 | 46 | ## 模板 47 | - sass 48 | - pug 49 | 50 | ## 代码规范 51 | - 两个空格为一个 Tab 52 | 53 | ### JS 54 | - Standard Style 55 | - 不写分号 56 | - 一行开头是括号或者方括号的时候加上分号就可以了,其他时候全部不需要 57 | - 用单引号 58 | - template 里用双引号 59 | - 请设置编辑器,保存的时候自动删除多余空格 60 | - 优先使用 ES6/ES7 语法 61 | 62 | ### HTML 63 | - 属性用双引号 64 | - 请使用 pug 65 | 66 | ### CSS 67 | - 请使用 sass 68 | - 元素选择器应该避免在 scoped 中出现 69 | 70 | ### [Vue 风格指南](https://cn.vuejs.org/v2/style-guide/) 71 | - 组件命名:MyComponent.vue 72 | - 只应该拥有单个活跃实例的组件应该以 The 前缀命名,以示其唯一性 73 | - 应该优先通过 prop 和事件进行父子组件之间的通信,而不是 this.$parent 或改变 prop 74 | 75 | ### 文件模板 76 | ```vue 77 | 80 | 81 | 90 | 91 | 94 | ``` 95 | 96 | ## 全局公用函数 97 | 如果你需要让一个工具函数在每个组件可用,可以把方法挂载到 Vue.prototype上。 98 | 99 | main.js 中 100 | ```javascript 101 | Vue.prototype.method = function () {} 102 | ``` 103 | 那么组件代码里 104 | ```javascript 105 | this.method() 106 | ``` 107 | 108 | ## autoprefix 设置 109 | vue官方模板的设置是last 2 versions,相对来说支持浏览器版本过少,会导致你在某些Android机子上出现问题。 110 | PC 端建议使用 last 7 versions(会生成-ms前缀代码) 111 | 移动端建议使用配置 ['iOS >= 7', 'Android >= 4.1'] 112 | 113 | ## 禁用 eslint 114 | 并不推荐禁用eslint, 编码规范可以一定程序上保证代码质量。但是如果你确实想禁用,可以删除build/webpack.base.conf.js里的相关代码。 115 | ```javascript 116 | preLoaders: [ 117 | { 118 | test: /\.vue$/, 119 | loader: 'eslint', 120 | include: [ 121 | path.join(projectRoot, 'src') 122 | ], 123 | exclude: /node_modules/ 124 | }, 125 | { 126 | test: /\.js$/, 127 | loader: 'eslint', 128 | include: [ 129 | path.join(projectRoot, 'src') 130 | ], 131 | exclude: /node_modules/ 132 | } 133 | ] 134 | ``` 135 | 如果你只是想禁用对某一文件的检测,那么可以在.eslintignore里添加规则。 136 | 如果你是想禁止某一行的检测,那么可以使用// eslint-disable-line。 137 | 更加灵活的使用参考 [eslint文档](https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments)。 138 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 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 tyescript 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 | }) 42 | -------------------------------------------------------------------------------- /build/check-versions.js: -------------------------------------------------------------------------------- 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 | } 55 | -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 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 | } 102 | -------------------------------------------------------------------------------- /build/vue-loader.conf.js: -------------------------------------------------------------------------------- 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 | } 23 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 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 | '@': resolve('src'), 38 | 'common': resolve('src/common'), 39 | 'views': resolve('src/views'), 40 | 'store': resolve('src/store'), 41 | 'components': resolve('src/components'), 42 | } 43 | }, 44 | module: { 45 | rules: [ 46 | ...(config.dev.useEslint ? [createLintingRule()] : []), 47 | { 48 | test: /\.vue$/, 49 | loader: 'vue-loader', 50 | options: vueLoaderConfig 51 | }, 52 | { 53 | test: /\.js$/, 54 | loader: 'babel-loader', 55 | include: [resolve('src'), resolve('test')] 56 | }, 57 | { 58 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 59 | loader: 'url-loader', 60 | options: { 61 | limit: 10000, 62 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 63 | } 64 | }, 65 | { 66 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 67 | loader: 'url-loader', 68 | options: { 69 | limit: 10000, 70 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 71 | } 72 | }, 73 | { 74 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 75 | loader: 'url-loader', 76 | options: { 77 | limit: 10000, 78 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 79 | } 80 | } 81 | ] 82 | }, 83 | node: { 84 | // prevent webpack from injecting useless setImmediate polyfill because Vue 85 | // source contains it (although only uses it if it's native). 86 | setImmediate: false, 87 | // prevent webpack from injecting mocks to Node native modules 88 | // that does not make sense for the client 89 | dgram: 'empty', 90 | fs: 'empty', 91 | net: 'empty', 92 | tls: 'empty', 93 | child_process: 'empty' 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 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 baseWebpackConfig = require('./webpack.base.conf') 7 | const HtmlWebpackPlugin = require('html-webpack-plugin') 8 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 9 | const portfinder = require('portfinder') 10 | 11 | const HOST = process.env.HOST 12 | const PORT = process.env.PORT && Number(process.env.PORT) 13 | 14 | const devWebpackConfig = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: config.dev.devtool, 20 | 21 | // these devServer options should be customized in /config/index.js 22 | devServer: { 23 | clientLogLevel: 'warning', 24 | historyApiFallback: true, 25 | hot: true, 26 | compress: true, 27 | host: HOST || config.dev.host, 28 | port: PORT || config.dev.port, 29 | open: config.dev.autoOpenBrowser, 30 | overlay: config.dev.errorOverlay 31 | ? { warnings: false, errors: true } 32 | : false, 33 | publicPath: config.dev.assetsPublicPath, 34 | proxy: config.dev.proxyTable, 35 | quiet: true, // necessary for FriendlyErrorsPlugin 36 | watchOptions: { 37 | poll: config.dev.poll, 38 | } 39 | }, 40 | plugins: [ 41 | new webpack.DefinePlugin({ 42 | 'process.env': require('../config/dev.env') 43 | }), 44 | new webpack.HotModuleReplacementPlugin(), 45 | new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. 46 | new webpack.NoEmitOnErrorsPlugin(), 47 | // https://github.com/ampedandwired/html-webpack-plugin 48 | new HtmlWebpackPlugin({ 49 | filename: 'index.html', 50 | template: 'index.html', 51 | inject: true 52 | }), 53 | ] 54 | }) 55 | 56 | module.exports = new Promise((resolve, reject) => { 57 | portfinder.basePort = process.env.PORT || config.dev.port 58 | portfinder.getPort((err, port) => { 59 | if (err) { 60 | reject(err) 61 | } else { 62 | // publish the new Port, necessary for e2e tests 63 | process.env.PORT = port 64 | // add port to devServer config 65 | devWebpackConfig.devServer.port = port 66 | 67 | // Add FriendlyErrorsPlugin 68 | devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ 69 | compilationSuccessInfo: { 70 | messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], 71 | }, 72 | onErrors: config.dev.notifyOnErrors 73 | ? utils.createNotifierCallback() 74 | : undefined 75 | })) 76 | 77 | resolve(devWebpackConfig) 78 | } 79 | }) 80 | }) 81 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 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 = require('../config/prod.env') 15 | 16 | const webpackConfig = merge(baseWebpackConfig, { 17 | module: { 18 | rules: utils.styleLoaders({ 19 | sourceMap: config.build.productionSourceMap, 20 | extract: true, 21 | usePostCSS: true 22 | }) 23 | }, 24 | devtool: config.build.productionSourceMap ? config.build.devtool : false, 25 | output: { 26 | path: config.build.assetsRoot, 27 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 28 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 29 | }, 30 | plugins: [ 31 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 32 | new webpack.DefinePlugin({ 33 | 'process.env': env 34 | }), 35 | new UglifyJsPlugin({ 36 | uglifyOptions: { 37 | compress: { 38 | warnings: false 39 | } 40 | }, 41 | sourceMap: config.build.productionSourceMap, 42 | parallel: true 43 | }), 44 | // extract css into its own file 45 | new ExtractTextPlugin({ 46 | filename: utils.assetsPath('css/[name].[contenthash].css'), 47 | // Setting the following option to `false` will not extract CSS from codesplit chunks. 48 | // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. 49 | // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, 50 | // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 51 | allChunks: true, 52 | }), 53 | // Compress extracted CSS. We are using this plugin so that possible 54 | // duplicated CSS from different components can be deduped. 55 | new OptimizeCSSPlugin({ 56 | cssProcessorOptions: config.build.productionSourceMap 57 | ? { safe: true, map: { inline: false } } 58 | : { safe: true } 59 | }), 60 | // generate dist index.html with correct asset hash for caching. 61 | // you can customize output by editing /index.html 62 | // see https://github.com/ampedandwired/html-webpack-plugin 63 | new HtmlWebpackPlugin({ 64 | filename: config.build.index, 65 | template: 'index.html', 66 | inject: true, 67 | minify: { 68 | removeComments: true, 69 | collapseWhitespace: true, 70 | removeAttributeQuotes: true 71 | // more options: 72 | // https://github.com/kangax/html-minifier#options-quick-reference 73 | }, 74 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 75 | chunksSortMode: 'dependency' 76 | }), 77 | // keep module.id stable when vender modules does not change 78 | new webpack.HashedModuleIdsPlugin(), 79 | // enable scope hoisting 80 | new webpack.optimize.ModuleConcatenationPlugin(), 81 | // split vendor js into its own file 82 | new webpack.optimize.CommonsChunkPlugin({ 83 | name: 'vendor', 84 | minChunks (module) { 85 | // any required modules inside node_modules are extracted to vendor 86 | return ( 87 | module.resource && 88 | /\.js$/.test(module.resource) && 89 | module.resource.indexOf( 90 | path.join(__dirname, '../node_modules') 91 | ) === 0 92 | ) 93 | } 94 | }), 95 | // extract webpack runtime and module manifest to its own file in order to 96 | // prevent vendor hash from being updated whenever app bundle is updated 97 | new webpack.optimize.CommonsChunkPlugin({ 98 | name: 'manifest', 99 | minChunks: Infinity 100 | }), 101 | // This instance extracts shared chunks from code splitted chunks and bundles them 102 | // in a separate chunk, similar to the vendor chunk 103 | // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk 104 | new webpack.optimize.CommonsChunkPlugin({ 105 | name: 'app', 106 | async: 'vendor-async', 107 | children: true, 108 | minChunks: 3 109 | }), 110 | 111 | // copy custom static assets 112 | new CopyWebpackPlugin([ 113 | { 114 | from: path.resolve(__dirname, '../static'), 115 | to: config.build.assetsSubDirectory, 116 | ignore: ['.*'] 117 | } 118 | ]) 119 | ] 120 | }) 121 | 122 | if (config.build.productionGzip) { 123 | const CompressionWebpackPlugin = require('compression-webpack-plugin') 124 | 125 | webpackConfig.plugins.push( 126 | new CompressionWebpackPlugin({ 127 | asset: '[path].gz[query]', 128 | algorithm: 'gzip', 129 | test: new RegExp( 130 | '\\.(' + 131 | config.build.productionGzipExtensions.join('|') + 132 | ')$' 133 | ), 134 | threshold: 10240, 135 | minRatio: 0.8 136 | }) 137 | ) 138 | } 139 | 140 | if (config.build.bundleAnalyzerReport) { 141 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 142 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 143 | } 144 | 145 | module.exports = webpackConfig 146 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 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 | }) 8 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.2.7 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 | 15 | // Various Dev Server settings 16 | host: 'localhost', // can be overwritten by process.env.HOST 17 | port: 3000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 18 | autoOpenBrowser: false, 19 | errorOverlay: true, 20 | notifyOnErrors: true, 21 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 22 | 23 | // Use Eslint Loader? 24 | // If true, your code will be linted during bundling and 25 | // linting errors and warnings will be shown in the console. 26 | useEslint: true, 27 | // If true, eslint errors and warnings will also be shown in the error overlay 28 | // in the browser. 29 | showEslintErrorsInOverlay: false, 30 | 31 | /** 32 | * Source Maps 33 | */ 34 | 35 | // https://webpack.js.org/configuration/devtool/#development 36 | devtool: 'eval-source-map', 37 | 38 | // If you have problems debugging vue-files in devtools, 39 | // set this to false - it *may* help 40 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 41 | cacheBusting: true, 42 | 43 | // CSS Sourcemaps off by default because relative paths are "buggy" 44 | // with this option, according to the CSS-Loader README 45 | // (https://github.com/webpack/css-loader#sourcemaps) 46 | // In our experience, they generally work as expected, 47 | // just be aware of this issue when enabling this option. 48 | cssSourceMap: false, 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: false, 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 | } 82 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | huofanr 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "huofanr", 3 | "version": "1.0.0", 4 | "description": "huofanr pc", 5 | "author": "zaxlct ", 6 | "private": true, 7 | "scripts": { 8 | "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", 9 | "start": "npm run dev", 10 | "lint": "eslint --ext .js,.vue src", 11 | "build": "node build/build.js" 12 | }, 13 | "dependencies": { 14 | "axios": "^0.17.1", 15 | "babel-runtime": "^6.26.0", 16 | "element-ui": "^2.0.8", 17 | "nprogress": "^0.2.0", 18 | "vue": "^2.5.2", 19 | "vue-awesome-swiper": "^3.0.6", 20 | "vue-class-component": "^6.1.1", 21 | "vue-router": "^3.0.1", 22 | "vuex": "^3.0.1" 23 | }, 24 | "devDependencies": { 25 | "autoprefixer": "^7.1.2", 26 | "babel-core": "^6.22.1", 27 | "babel-eslint": "^7.1.1", 28 | "babel-helper-vue-jsx-merge-props": "^2.0.3", 29 | "babel-loader": "^7.1.1", 30 | "babel-plugin-component": "^0.10.1", 31 | "babel-plugin-external-helpers": "^6.22.0", 32 | "babel-plugin-syntax-jsx": "^6.18.0", 33 | "babel-plugin-transform-async-to-generator": "^6.24.1", 34 | "babel-plugin-transform-class-properties": "^6.24.1", 35 | "babel-plugin-transform-decorators-legacy": "^1.3.4", 36 | "babel-plugin-transform-runtime": "^6.22.0", 37 | "babel-plugin-transform-vue-jsx": "^3.5.0", 38 | "babel-polyfill": "^6.26.0", 39 | "babel-preset-env": "^1.3.2", 40 | "babel-preset-stage-2": "^6.22.0", 41 | "chalk": "^2.0.1", 42 | "copy-webpack-plugin": "^4.0.1", 43 | "css-loader": "^0.28.0", 44 | "eslint": "^3.19.0", 45 | "eslint-config-standard": "^10.2.1", 46 | "eslint-friendly-formatter": "^3.0.0", 47 | "eslint-loader": "^1.7.1", 48 | "eslint-plugin-html": "^3.0.0", 49 | "eslint-plugin-import": "^2.7.0", 50 | "eslint-plugin-node": "^5.2.0", 51 | "eslint-plugin-promise": "^3.4.0", 52 | "eslint-plugin-standard": "^3.0.1", 53 | "extract-text-webpack-plugin": "^3.0.0", 54 | "file-loader": "^1.1.4", 55 | "friendly-errors-webpack-plugin": "^1.6.1", 56 | "html-webpack-plugin": "^2.30.1", 57 | "node-notifier": "^5.1.2", 58 | "node-sass": "^4.7.2", 59 | "optimize-css-assets-webpack-plugin": "^3.2.0", 60 | "ora": "^1.2.0", 61 | "portfinder": "^1.0.13", 62 | "postcss-import": "^11.0.0", 63 | "postcss-loader": "^2.0.8", 64 | "pug": "^2.0.0-rc.4", 65 | "pug-loader": "^2.3.0", 66 | "rimraf": "^2.6.0", 67 | "sass-loader": "^6.0.6", 68 | "semver": "^5.3.0", 69 | "shelljs": "^0.7.6", 70 | "uglifyjs-webpack-plugin": "^1.1.1", 71 | "url-loader": "^0.5.8", 72 | "vue-loader": "^13.3.0", 73 | "vue-style-loader": "^3.0.1", 74 | "vue-template-compiler": "^2.5.2", 75 | "webpack": "^3.6.0", 76 | "webpack-bundle-analyzer": "^2.9.0", 77 | "webpack-dev-server": "^2.9.1", 78 | "webpack-merge": "^4.1.0" 79 | }, 80 | "engines": { 81 | "node": ">= 4.0.0", 82 | "npm": ">= 3.0.0" 83 | }, 84 | "browserslist": [ 85 | "> 1%", 86 | "last 7 versions", 87 | "not ie <= 9" 88 | ] 89 | } 90 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 21 | 22 | 33 | -------------------------------------------------------------------------------- /src/common/imgs/footer-icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kele59/vue-shop/37af36a48e0c334d8a92b20b745001fc1c4af3f4/src/common/imgs/footer-icons.png -------------------------------------------------------------------------------- /src/common/js/axiosConfig.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import store from 'store' 3 | import * as types from 'store/types' 4 | import router from '../../router' 5 | import { Message } from 'element-ui' 6 | 7 | export const Axios = axios.create({ 8 | baseURL: process.env.BASE_API, 9 | timeout: 5000 10 | }) 11 | 12 | Axios.interceptors.request.use(config => { 13 | if (store.state.token) { 14 | config.headers.token = store.state.token 15 | } 16 | return config 17 | }, error => { 18 | console.error('错误的传参', 'fail') 19 | return Promise.reject(error) 20 | }) 21 | 22 | Axios.interceptors.response.use( 23 | res => { 24 | const { data } = res 25 | if (data.code !== 200) { 26 | Message.error(data.msg) 27 | return Promise.reject(data.msg) 28 | } 29 | return data 30 | }, 31 | error => { 32 | if (!error.response) { 33 | Message.error('网络错误') 34 | return Promise.reject(error) 35 | } 36 | switch (error.response.status) { 37 | case 401: 38 | // 清除token信息并跳转到登录页面 39 | store.commit(types.LOGOUT) 40 | router.replace({ 41 | path: '/login', 42 | query: {redirect: router.currentRoute.fullPath} 43 | }) 44 | break 45 | 46 | case 400: 47 | Message.error('参数错误') 48 | break 49 | 50 | default: 51 | Message.error('网络错误') 52 | } 53 | return Promise.reject(error.response.data) 54 | } 55 | ) 56 | 57 | export default { 58 | install(Vue) { 59 | Object.defineProperty(Vue.prototype, '$http', { value: Axios }) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/common/js/config.js: -------------------------------------------------------------------------------- 1 | export const PAT_TYPE = { 2 | alipay: '支付宝', 3 | wxpay: '微信', 4 | unpa: '银联', 5 | } 6 | 7 | export const ORDER_STATUS = [ 8 | { 9 | name: '0', 10 | label: '全部', 11 | }, 12 | { 13 | name: '1', 14 | label: '待付款', 15 | }, 16 | { 17 | name: '2', 18 | label: '待发货', 19 | }, 20 | { 21 | name: '3', 22 | label: '已发货', 23 | }, 24 | { 25 | name: '4', 26 | label: '已关闭', 27 | }, 28 | { 29 | name: '5', 30 | label: '退款中', 31 | }, 32 | { 33 | name: '6', 34 | label: '已完成', 35 | }, 36 | { 37 | name: '7', 38 | label: '已退款', 39 | }, 40 | ] 41 | 42 | export let ORDER_STATUS_DICT = {} 43 | ORDER_STATUS.forEach(order => { 44 | ORDER_STATUS_DICT[order.name] = order.label 45 | }) 46 | 47 | export const GOODS_STATUS = [ 48 | { 49 | text: '全部商品', 50 | value: 0, 51 | }, 52 | { 53 | text: '出售中', 54 | value: 1, 55 | }, 56 | { 57 | text: '已售罄', 58 | value: 2, 59 | }, 60 | { 61 | text: '未上架', 62 | value: 3, 63 | }, 64 | ] 65 | 66 | export const COUPON_STATUS = [ 67 | { 68 | name: '0', 69 | label: '全部', 70 | }, 71 | { 72 | name: '1', 73 | label: '未领取', 74 | }, 75 | { 76 | name: '2', 77 | label: '已领取', 78 | }, 79 | { 80 | name: '3', 81 | label: '未使用', 82 | }, 83 | { 84 | name: '4', 85 | label: '已使用', 86 | }, 87 | ] 88 | -------------------------------------------------------------------------------- /src/common/js/dom.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | const isServer = Vue.prototype.$isServer 3 | 4 | const isDOM = (typeof HTMLElement === 'object') 5 | ? obj => obj instanceof HTMLElement 6 | : obj => obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string' 7 | 8 | export function hasClass(el, className) { 9 | let reg = new RegExp('(^|\\s)' + className + '(\\s|$)') 10 | return reg.test(el.className) 11 | } 12 | 13 | export function addClass(el, className) { 14 | if (!isDOM(el)) { 15 | console.error('请传入 Dom 对象') 16 | return 17 | } 18 | if (hasClass(el, className)) { 19 | return 20 | } 21 | 22 | let newClass = el.className.split(' ') 23 | newClass.push(className) 24 | el.className = newClass.join(' ') 25 | return el 26 | } 27 | 28 | export function removeClass(el, cls) { 29 | if (!isDOM(el)) { 30 | console.error('请传入 Dom 对象') 31 | return 32 | } 33 | if (hasClass(el, cls)) { 34 | let newClass = ' ' + el.className.replace(/[\t\r\n]/g, '') + ' ' 35 | while (newClass.indexOf(' ' + cls + ' ') >= 0) { 36 | newClass = newClass.replace(' ' + cls + ' ', ' ') 37 | } 38 | el.className = newClass.replace(/^\s+|\s+$/g, '') 39 | } 40 | return el 41 | } 42 | 43 | export function getData(el, name, val) { 44 | if (!isDOM(el)) { 45 | console.error('请传入 Dom 对象') 46 | return 47 | } 48 | const prefix = 'data-' 49 | if (val) { 50 | return el.setAttribute(prefix + name, val) 51 | } 52 | return el.getAttribute(prefix + name) 53 | } 54 | 55 | // jquery offset原生实现 56 | export function getOffset(el) { 57 | let docElem = document.documentElement 58 | let box = el.getBoundingClientRect() 59 | return { 60 | top: box.top + docElem.scrollTop, 61 | left: box.left + docElem.scrollLeft 62 | } 63 | } 64 | 65 | // https://github.com/iview/iview/blob/2.0/src/utils/dom.js 66 | /* istanbul ignore next */ 67 | export const on = (function() { 68 | if (!isServer && document.addEventListener) { 69 | return function(element, event, handler) { 70 | if (element && event && handler) { 71 | element.addEventListener(event, handler, false) 72 | } 73 | } 74 | } else { 75 | return function(element, event, handler) { 76 | if (element && event && handler) { 77 | element.attachEvent('on' + event, handler) 78 | } 79 | } 80 | } 81 | })() 82 | 83 | /* istanbul ignore next */ 84 | export const off = (function() { 85 | if (!isServer && document.removeEventListener) { 86 | return function(element, event, handler) { 87 | if (element && event) { 88 | element.removeEventListener(event, handler, false) 89 | } 90 | } 91 | } else { 92 | return function(element, event, handler) { 93 | if (element && event) { 94 | element.detachEvent('on' + event, handler) 95 | } 96 | } 97 | } 98 | })() 99 | -------------------------------------------------------------------------------- /src/common/js/globalVueConfig.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | /* 4 | * directive 5 | */ 6 | Vue.directive('bg-cover', function (el, binding) { 7 | el.style.cssText += ` 8 | ; 9 | background: url('${binding.value}') center center no-repeat; 10 | -webkit-background-size: cover; 11 | background-size: cover; 12 | font-size: 19px; 13 | ` 14 | }) 15 | 16 | /* 17 | * Mixins Global 18 | */ 19 | // Vue.mixin({ 20 | // destroyed() { 21 | // if(Indicator) Indicator.close() 22 | // }, 23 | // }) 24 | -------------------------------------------------------------------------------- /src/common/js/mixins.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Component from 'vue-class-component' 3 | 4 | @Component 5 | export class Mixins extends Vue { 6 | } 7 | -------------------------------------------------------------------------------- /src/common/js/vector.js: -------------------------------------------------------------------------------- 1 | // document: https://www.cnblogs.com/6kou/p/jd.html 2 | 3 | import { getOffset } from './dom' 4 | 5 | export default class Vector { 6 | sameSign(a, b) { 7 | return (a ^ b) >= 0 8 | } 9 | 10 | vector(a, b) { 11 | return { 12 | x: b.x - a.x, 13 | y: b.y - a.y, 14 | } 15 | } 16 | 17 | vectorProduct(v1, v2) { 18 | return v1.x * v2.y - v2.x * v1.y 19 | } 20 | 21 | isPointInTrangle(p, a, b, c) { 22 | const pa = this.vector(p, a) 23 | const pb = this.vector(p, b) 24 | const pc = this.vector(p, c) 25 | 26 | const t1 = this.vectorProduct(pa, pb) 27 | const t2 = this.vectorProduct(pb, pc) 28 | const t3 = this.vectorProduct(pc, pa) 29 | 30 | return this.sameSign(t1, t2) && this.sameSign(t2, t3) 31 | } 32 | 33 | needDelay(elem, leftCorner, currMousePos) { 34 | const offset = getOffset(elem) 35 | 36 | const topLeft = { 37 | x: offset.left, 38 | y: offset.top 39 | } 40 | 41 | const bottomLeft = { 42 | x: offset.left, 43 | y: offset.top + elem.offsetHeight 44 | } 45 | 46 | return this.isPointInTrangle(currMousePos, leftCorner, topLeft, bottomLeft) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/common/sass/element-ui.sass: -------------------------------------------------------------------------------- 1 | /* 改变主题色变量 */ 2 | $--color-primary: $color 3 | 4 | /* 改变 icon 字体路径变量,必需 */ 5 | $--font-path: '~element-ui/lib/theme-chalk/fonts' 6 | 7 | @import "~element-ui/packages/theme-chalk/src/index" 8 | 9 | 10 | // ======= TheHeader ============ 11 | // 搜索商品的输入框 hack 12 | .TheHeader .header_search 13 | .input .el-input__inner 14 | border-top-right-radius: 0 15 | border-bottom-right-radius: 0 16 | 17 | .select .el-input .el-input__inner 18 | border-left: none 19 | background: #f2f2f2 20 | border-radius: 0 21 | 22 | &:focus 23 | border-color: #dcdfe6 24 | 25 | .header_right-popover_content 26 | text-align: center 27 | 28 | .button 29 | width: 180px 30 | margin: auto 31 | margin-bottom: 10px 32 | display: block 33 | // ↑↑↑↑↑↑↑↑↑ 34 | -------------------------------------------------------------------------------- /src/common/sass/index.sass: -------------------------------------------------------------------------------- 1 | @import "variables" 2 | @import "mixins" 3 | @import "element-ui" 4 | @import "utilities" 5 | @import "scaffolding" 6 | 7 | -------------------------------------------------------------------------------- /src/common/sass/mixins.sass: -------------------------------------------------------------------------------- 1 | %text-ellipsis 2 | overflow: hidden 3 | white-space: nowrap 4 | text-overflow: ellipsis 5 | -o-text-overflow: ellipsis 6 | word-break:break-all 7 | word-wrap: normal 8 | 9 | =text-multiLine-ellipsis($line: 2, $lineHeight: 20px) 10 | line-height: $lineHeight 11 | overflow: hidden 12 | height: $lineHeight * $line 13 | display: -webkit-box 14 | display: -moz-box 15 | display: box 16 | text-overflow: ellipsis 17 | -webkit-line-clamp: $line 18 | -moz-line-clamp: $line 19 | line-clamp: $line 20 | -webkit-box-orient: vertical 21 | -moz-box-orient: vertical 22 | box-orient: vertical 23 | 24 | %text-breakWord 25 | word-wrap: break-word 26 | white-space: normal 27 | 28 | =x-scroll 29 | overflow-y: hidden 30 | overflow-x: scroll 31 | -webkit-overflow-scrolling: touch 32 | white-space: nowrap 33 | 34 | =y-scroll 35 | overflow-x: hidden 36 | overflow-y: scroll 37 | -webkit-overflow-scrolling: touch 38 | -------------------------------------------------------------------------------- /src/common/sass/scaffolding.sass: -------------------------------------------------------------------------------- 1 | * 2 | box-sizing: border-box 3 | margin: 0 4 | padding: 0 5 | 6 | body 7 | width: 100% 8 | height: 100vh 9 | text-rendering: optimizeLegibility 10 | // -webkit-font-smoothing: antialiased 11 | // -moz-osx-font-smoothing: grayscale 12 | font-family: tahoma, arial, "MS YaHei", "Hiragino Sans GB", sans-serif 13 | color: #000 14 | background: #f6f6f6 15 | 16 | /* icon-font */ 17 | i[class*='i-'] 18 | font-family: "iconfont" !important 19 | font-size: 16px 20 | font-style: normal 21 | -webkit-font-smoothing: antialiased 22 | -moz-osx-font-smoothing: grayscale 23 | 24 | input, 25 | textarea 26 | outline: none 27 | border: none 28 | background: none 29 | 30 | li 31 | list-style: none 32 | 33 | a 34 | text-decoration: none 35 | color: #000 36 | 37 | p, 38 | div 39 | word-wrap: break-word 40 | white-space: normal 41 | 42 | h2 43 | font-size: 19.2px 44 | font-weight: 400 -------------------------------------------------------------------------------- /src/common/sass/utilities.sass: -------------------------------------------------------------------------------- 1 | //----- container 2 | .container 3 | margin: 0 auto 4 | width: 1600px 5 | 6 | @media (max-width: 1600px) 7 | width: 100% 8 | 9 | @media (max-width: 1100px) 10 | width: 1010px 11 | 12 | 13 | // ----- flex---- 14 | .flex 15 | display: flex 16 | 17 | .flex1 18 | flex: 1 19 | 20 | .flex2 21 | flex: 2 22 | 23 | 24 | // --- float ---- 25 | .fr 26 | float: right !important 27 | .fl 28 | float: left !important 29 | 30 | 31 | // ------ display ----- 32 | .block 33 | display: block 34 | .in-block 35 | display: inline-block 36 | 37 | // ---- hover ------ 38 | .underline_hover:hover 39 | text-decoration: underline 40 | 41 | .op_opacity:hover 42 | opacity: .8 43 | 44 | // ----- text------ 45 | .pointer 46 | cursor: pointer 47 | .underline 48 | text-decoration: underline 49 | .tc 50 | text-align: center !important 51 | .tl 52 | text-align: left !important 53 | .tr 54 | text-align: right !important 55 | 56 | .over_hide 57 | overflow: hidden 58 | height: 100px 59 | word-break: break-all 60 | text-align: left 61 | 62 | .text_ellipsis 63 | @extend %text-ellipsis 64 | 65 | .text_breakWord 66 | @extend %text-breakWord 67 | 68 | .small 69 | font-size: 12px !important 70 | 71 | 72 | // ----color------ 73 | .main_color 74 | color: $color !important 75 | .main_bg 76 | color: $color !important 77 | 78 | .black 79 | color: #000 !important 80 | .bg_white 81 | background: #fff !important 82 | 83 | 84 | //----- font-size 85 | @for $i from 0 through 40 86 | .fz#{12 + $i} 87 | font-size: 12px + $i !important 88 | 89 | 90 | //--- margin & padding 91 | @for $i from 1 through 6 92 | .ml#{$i}0 93 | margin-left: 10px * $i !important 94 | 95 | @for $i from 1 through 6 96 | .mt#{$i}0 97 | margin-top: 10px * $i !important 98 | 99 | @for $i from 1 through 6 100 | .mr#{$i}0 101 | margin-right: 10px * $i !important 102 | 103 | @for $i from 1 through 6 104 | .mb#{$i}0 105 | margin-bottom: 10px * $i !important 106 | 107 | @for $i from 1 through 6 108 | .pl#{$i}0 109 | padding-left: 10px * $i !important 110 | 111 | @for $i from 1 through 6 112 | .pt#{$i}0 113 | padding-top: 10px * $i !important 114 | 115 | @for $i from 1 through 6 116 | .pr#{$i}0 117 | padding-right: 10px * $i !important 118 | 119 | @for $i from 1 through 6 120 | .pb#{$i}0 121 | padding-bottom: 10px * $i !important 122 | -------------------------------------------------------------------------------- /src/common/sass/variables.sass: -------------------------------------------------------------------------------- 1 | $color: #fc534c 2 | $z-tabbbar: 100 -------------------------------------------------------------------------------- /src/components/Affix.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 18 | 19 | -------------------------------------------------------------------------------- /src/components/GoodsCard.vue: -------------------------------------------------------------------------------- 1 | 38 | 39 | 46 | -------------------------------------------------------------------------------- /src/components/TheFooter.vue: -------------------------------------------------------------------------------- 1 | 127 | 128 | 225 | 226 | 235 | -------------------------------------------------------------------------------- /src/components/TheHeader.vue: -------------------------------------------------------------------------------- 1 | 98 | 99 | 147 | 148 | 163 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import Vue from 'vue' 3 | 4 | import VueAwesomeSwiper from 'vue-awesome-swiper' 5 | import 'swiper/dist/css/swiper.css' 6 | 7 | import App from './App' 8 | import router from './router' 9 | // import store from './store' 10 | // import axiosConfig from 'common/js/axiosConfig' 11 | import 'common/js/globalVueConfig' 12 | 13 | // Vue.use(axiosConfig) 14 | import { 15 | Pagination, 16 | Dialog, 17 | Autocomplete, 18 | Dropdown, 19 | DropdownMenu, 20 | DropdownItem, 21 | Menu, 22 | Submenu, 23 | MenuItem, 24 | MenuItemGroup, 25 | Input, 26 | InputNumber, 27 | Radio, 28 | RadioGroup, 29 | RadioButton, 30 | Checkbox, 31 | CheckboxButton, 32 | CheckboxGroup, 33 | Switch, 34 | Select, 35 | Option, 36 | OptionGroup, 37 | Button, 38 | ButtonGroup, 39 | Table, 40 | TableColumn, 41 | DatePicker, 42 | TimeSelect, 43 | TimePicker, 44 | Popover, 45 | Tooltip, 46 | Breadcrumb, 47 | BreadcrumbItem, 48 | Form, 49 | FormItem, 50 | Tabs, 51 | TabPane, 52 | Tag, 53 | Tree, 54 | Alert, 55 | Slider, 56 | Icon, 57 | Row, 58 | Col, 59 | Upload, 60 | Progress, 61 | Badge, 62 | Card, 63 | Rate, 64 | Steps, 65 | Step, 66 | Carousel, 67 | CarouselItem, 68 | Collapse, 69 | CollapseItem, 70 | Cascader, 71 | ColorPicker, 72 | Container, 73 | Header, 74 | Aside, 75 | Main, 76 | Footer, 77 | Loading, 78 | MessageBox, 79 | Message, 80 | Notification 81 | } from 'element-ui' 82 | 83 | Vue.use(Pagination) 84 | Vue.use(Dialog) 85 | Vue.use(Autocomplete) 86 | Vue.use(Dropdown) 87 | Vue.use(DropdownMenu) 88 | Vue.use(DropdownItem) 89 | Vue.use(Menu) 90 | Vue.use(Submenu) 91 | Vue.use(MenuItem) 92 | Vue.use(MenuItemGroup) 93 | Vue.use(Input) 94 | Vue.use(InputNumber) 95 | Vue.use(Radio) 96 | Vue.use(RadioGroup) 97 | Vue.use(RadioButton) 98 | Vue.use(Checkbox) 99 | Vue.use(CheckboxButton) 100 | Vue.use(CheckboxGroup) 101 | Vue.use(Switch) 102 | Vue.use(Select) 103 | Vue.use(Option) 104 | Vue.use(OptionGroup) 105 | Vue.use(Button) 106 | Vue.use(ButtonGroup) 107 | Vue.use(Table) 108 | Vue.use(TableColumn) 109 | Vue.use(DatePicker) 110 | Vue.use(TimeSelect) 111 | Vue.use(TimePicker) 112 | Vue.use(Popover) 113 | Vue.use(Tooltip) 114 | Vue.use(Breadcrumb) 115 | Vue.use(BreadcrumbItem) 116 | Vue.use(Form) 117 | Vue.use(FormItem) 118 | Vue.use(Tabs) 119 | Vue.use(TabPane) 120 | Vue.use(Tag) 121 | Vue.use(Tree) 122 | Vue.use(Alert) 123 | Vue.use(Slider) 124 | Vue.use(Icon) 125 | Vue.use(Row) 126 | Vue.use(Col) 127 | Vue.use(Upload) 128 | Vue.use(Progress) 129 | Vue.use(Badge) 130 | Vue.use(Card) 131 | Vue.use(Rate) 132 | Vue.use(Steps) 133 | Vue.use(Step) 134 | Vue.use(Carousel) 135 | Vue.use(CarouselItem) 136 | Vue.use(Collapse) 137 | Vue.use(CollapseItem) 138 | Vue.use(Cascader) 139 | Vue.use(ColorPicker) 140 | Vue.use(Container) 141 | Vue.use(Header) 142 | Vue.use(Aside) 143 | Vue.use(Main) 144 | Vue.use(Footer) 145 | 146 | Vue.use(Loading.directive) 147 | 148 | Vue.prototype.$loading = Loading.service 149 | Vue.prototype.$msgbox = MessageBox 150 | Vue.prototype.$alert = MessageBox.alert 151 | Vue.prototype.$confirm = MessageBox.confirm 152 | Vue.prototype.$prompt = MessageBox.prompt 153 | Vue.prototype.$notify = Notification 154 | Vue.prototype.$message = Message 155 | Vue.prototype.$ELEMENT = { size: 'medium' } 156 | 157 | Vue.use(VueAwesomeSwiper) 158 | 159 | Vue.config.productionTip = false 160 | 161 | /* eslint-disable no-new */ 162 | new Vue({ 163 | el: '#app', 164 | router, 165 | render: h => h(App) 166 | }) 167 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import NProgress from 'nprogress' // Progress 进度条 4 | import 'nprogress/nprogress.css'// Progress 进度条样式 5 | Vue.use(Router) 6 | 7 | const Index = () => import('views/index') 8 | const Home = () => import('views/home/index') 9 | const Login = () => import('views/entry/login') 10 | 11 | const routes = [ 12 | { 13 | path: '/', 14 | name: 'Index', 15 | component: Index, 16 | children: [ 17 | { 18 | path: '/home', 19 | name: 'Home', 20 | component: Home, 21 | alias: '/', 22 | }, 23 | ], 24 | }, 25 | { 26 | path: '/login', 27 | name: 'Login', 28 | component: Login, 29 | }, 30 | // 404 跳转到首页 31 | // { path: '*', component: Home } 32 | ] 33 | 34 | const router = new Router({ 35 | mode: 'history', 36 | routes, 37 | scrollBehavior (to, from, savedPosition) { 38 | if (savedPosition) { 39 | return savedPosition 40 | } 41 | return { x: 0, y: 0 } 42 | }, 43 | }) 44 | 45 | const setTitle = title => { 46 | title = title ? title + '' : '活范儿' 47 | window.document.title = title 48 | } 49 | 50 | router.beforeEach((to, from, next) => { 51 | setTitle(to.meta.title) // 设置document标题 52 | NProgress.start() 53 | next() 54 | }) 55 | 56 | router.afterEach(() => { 57 | NProgress.done() // 结束Progress 58 | }) 59 | 60 | export default router 61 | -------------------------------------------------------------------------------- /src/views/entry/login.vue: -------------------------------------------------------------------------------- 1 | 54 | 55 | 83 | 84 | 115 | 116 | -------------------------------------------------------------------------------- /src/views/home/banner.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 41 | 42 | 51 | -------------------------------------------------------------------------------- /src/views/home/goods-hot.vue: -------------------------------------------------------------------------------- 1 | 66 | 67 | 87 | 88 | 97 | -------------------------------------------------------------------------------- /src/views/home/goods-special.vue: -------------------------------------------------------------------------------- 1 | 94 | 95 | 130 | 131 | 145 | -------------------------------------------------------------------------------- /src/views/home/goods-swiper.vue: -------------------------------------------------------------------------------- 1 | 82 | 83 | 99 | 100 | 129 | -------------------------------------------------------------------------------- /src/views/home/index.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 23 | 24 | 46 | -------------------------------------------------------------------------------- /src/views/home/menu.vue: -------------------------------------------------------------------------------- 1 | 79 | 80 | 234 | 235 | 338 | -------------------------------------------------------------------------------- /src/views/index.vue: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 24 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kele59/vue-shop/37af36a48e0c334d8a92b20b745001fc1c4af3f4/static/.gitkeep --------------------------------------------------------------------------------