├── .babelrc ├── .editorconfig ├── .gitignore ├── .postcssrc.js ├── README.md ├── build ├── build.js ├── check-versions.js ├── logo.png ├── 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.json ├── src ├── App.vue ├── components │ ├── detail.vue │ ├── index.vue │ ├── login.vue │ ├── order.vue │ ├── orderDetail.vue │ ├── orderList.vue │ ├── pay.vue │ ├── paySuccess.vue │ ├── shoppingCart.vue │ └── vipCenter.vue ├── main.js ├── router │ └── index.js └── vuex │ └── store.js └── static ├── .gitkeep ├── css └── style.css ├── images ├── bodyBg.jpg ├── bodyBg2.jpg ├── bodyBg3.jpg ├── loading.gif ├── lst.JPG ├── s_03.jpg └── w_03.jpg └── site └── css ├── icon ├── demo.css ├── demo_fontclass.html ├── demo_symbol.html ├── demo_unicode.html ├── iconfont.css ├── iconfont.eot ├── iconfont.js ├── iconfont.svg ├── iconfont.ttf └── iconfont.woff └── style.css /.babelrc: -------------------------------------------------------------------------------- 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 | } 13 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # shop 2 | 3 | > A Vue.js project 4 | 5 | ## 构建步骤 6 | 7 | ``` bash 8 | # install dependencies 9 | git clone git@github.com:ShoutongLiu/shop.git 10 | cd shop 11 | npm install 12 | 13 | # serve with hot reload at localhost:8080 14 | npm run dev 15 | 16 | # build for production with minification 17 | npm run build 18 | 19 | # build for production and view the bundle analyzer report 20 | npm run build --report 21 | ``` 22 | 23 | 24 | 25 | ## 项目结构 26 | 27 | ``` 28 | 29 | │ index.html 30 | │ package.json 31 | │ README.md 32 | │ 33 | ├─build //webpack构建文件 34 | │ 35 | ├─config //webpack配置文件 36 | │ 37 | ├─src 38 | │ │ App.vue //入口文件 39 | │ │ main.js 40 | │ │ 41 | │ ├─components //组件文件 42 | │ │ 43 | │ ├─router //路由文件 44 | │ │ 45 | │ └─vuex //全局状态管理文件 46 | │ 47 | └─static //静态文件 48 | ``` 49 | 50 | ## 实现功能 51 | 52 | 1. 商品详情展示 53 | 2. 发表评论 54 | 3. 分页功能 55 | 4. 懒加载 56 | 5. 加入购物车 57 | 6. 购物车删除 58 | 7. 价格结算 59 | 8. 收货人信息校验 60 | 9. 订单提交 61 | 10. 订单列表 62 | 11. 订单支付 63 | 12. 订单签收 64 | 13. 登录,退出 65 | 66 | 67 | 68 | ## 后续优化 69 | 70 | 1. 界面美观 71 | 72 | 2. 代码优化 73 | 74 | 3. 新增其他模块 75 | 76 | ------ 77 | 78 | 顺手给个start激励一下! 79 | -------------------------------------------------------------------------------- /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 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 | }) 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/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/build/logo.png -------------------------------------------------------------------------------- /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 | 12 | 13 | module.exports = { 14 | context: path.resolve(__dirname, '../'), 15 | entry: { 16 | app: './src/main.js' 17 | }, 18 | output: { 19 | path: config.build.assetsRoot, 20 | filename: '[name].js', 21 | publicPath: process.env.NODE_ENV === 'production' 22 | ? config.build.assetsPublicPath 23 | : config.dev.assetsPublicPath 24 | }, 25 | resolve: { 26 | extensions: ['.js', '.vue', '.json'], 27 | alias: { 28 | 'vue$': 'vue/dist/vue.esm.js', 29 | '@': resolve('src'), 30 | } 31 | }, 32 | module: { 33 | rules: [ 34 | { 35 | test: /\.vue$/, 36 | loader: 'vue-loader', 37 | options: vueLoaderConfig 38 | }, 39 | { 40 | test: /\.js$/, 41 | loader: 'babel-loader', 42 | include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] 43 | }, 44 | { 45 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 46 | loader: 'url-loader', 47 | options: { 48 | limit: 10000, 49 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 50 | } 51 | }, 52 | { 53 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 54 | loader: 'url-loader', 55 | options: { 56 | limit: 10000, 57 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 58 | } 59 | }, 60 | { 61 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 62 | loader: 'url-loader', 63 | options: { 64 | limit: 10000, 65 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 66 | } 67 | } 68 | ] 69 | }, 70 | node: { 71 | // prevent webpack from injecting useless setImmediate polyfill because Vue 72 | // source contains it (although only uses it if it's native). 73 | setImmediate: false, 74 | // prevent webpack from injecting mocks to Node native modules 75 | // that does not make sense for the client 76 | dgram: 'empty', 77 | fs: 'empty', 78 | net: 'empty', 79 | tls: 'empty', 80 | child_process: 'empty' 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /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 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 | }) 96 | -------------------------------------------------------------------------------- /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 vendor 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.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 | 15 | // Various Dev Server settings 16 | host: 'localhost', // can be overwritten by process.env.HOST 17 | port: 8080, // 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 | 24 | /** 25 | * Source Maps 26 | */ 27 | 28 | // https://webpack.js.org/configuration/devtool/#development 29 | devtool: 'cheap-module-eval-source-map', 30 | 31 | // If you have problems debugging vue-files in devtools, 32 | // set this to false - it *may* help 33 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 34 | cacheBusting: true, 35 | 36 | cssSourceMap: true 37 | }, 38 | 39 | build: { 40 | // Template for index.html 41 | index: path.resolve(__dirname, '../dist/index.html'), 42 | 43 | // Paths 44 | assetsRoot: path.resolve(__dirname, '../dist'), 45 | assetsSubDirectory: 'static', 46 | assetsPublicPath: './', 47 | 48 | /** 49 | * Source Maps 50 | */ 51 | 52 | productionSourceMap: true, 53 | // https://webpack.js.org/configuration/devtool/#production 54 | devtool: '#source-map', 55 | 56 | // Gzip off by default as many popular static hosts such as 57 | // Surge or Netlify already gzip all static assets for you. 58 | // Before setting to `true`, make sure to: 59 | // npm install --save-dev compression-webpack-plugin 60 | productionGzip: false, 61 | productionGzipExtensions: ['js', 'css'], 62 | 63 | // Run the build command with an extra argument to 64 | // View the bundle analyzer report after build finishes: 65 | // `npm run build --report` 66 | // Set to `true` or `false` to always turn it on or off 67 | bundleAnalyzerReport: process.env.npm_config_report 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | shop 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shop", 3 | "version": "1.0.0", 4 | "description": "A Vue.js project", 5 | "author": "liushouotng <1183063367@qq.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 | "build": "node build/build.js" 11 | }, 12 | "dependencies": { 13 | "@xkeshi/vue-qrcode": "^1.0.0", 14 | "axios": "^0.18.0", 15 | "element-ui": "^2.4.6", 16 | "iview": "^3.0.1", 17 | "jquery": "^3.3.1", 18 | "moment": "^2.22.2", 19 | "v-distpicker": "^1.0.17", 20 | "vue": "^2.5.17", 21 | "vue-concise-slider": "^2.5.1", 22 | "vue-lazyload": "^1.2.6", 23 | "vue-product-zoomer": "^2.0.11", 24 | "vue-router": "^3.0.1", 25 | "vuex": "^3.0.1" 26 | }, 27 | "devDependencies": { 28 | "autoprefixer": "^7.1.2", 29 | "babel-core": "^6.22.1", 30 | "babel-helper-vue-jsx-merge-props": "^2.0.3", 31 | "babel-loader": "^7.1.1", 32 | "babel-plugin-syntax-jsx": "^6.18.0", 33 | "babel-plugin-transform-runtime": "^6.22.0", 34 | "babel-plugin-transform-vue-jsx": "^3.5.0", 35 | "babel-preset-env": "^1.3.2", 36 | "babel-preset-stage-2": "^6.22.0", 37 | "chalk": "^2.0.1", 38 | "copy-webpack-plugin": "^4.0.1", 39 | "css-loader": "^0.28.0", 40 | "extract-text-webpack-plugin": "^3.0.0", 41 | "file-loader": "^1.1.4", 42 | "friendly-errors-webpack-plugin": "^1.6.1", 43 | "html-webpack-plugin": "^2.30.1", 44 | "less": "^3.8.1", 45 | "less-loader": "^4.1.0", 46 | "node-notifier": "^5.1.2", 47 | "optimize-css-assets-webpack-plugin": "^3.2.0", 48 | "ora": "^1.2.0", 49 | "portfinder": "^1.0.13", 50 | "postcss-import": "^11.0.0", 51 | "postcss-loader": "^2.0.8", 52 | "postcss-url": "^7.2.1", 53 | "rimraf": "^2.6.0", 54 | "semver": "^5.3.0", 55 | "shelljs": "^0.7.6", 56 | "uglifyjs-webpack-plugin": "^1.1.1", 57 | "url-loader": "^0.5.8", 58 | "vue-loader": "^13.3.0", 59 | "vue-style-loader": "^3.0.1", 60 | "vue-template-compiler": "^2.5.2", 61 | "webpack": "^3.6.0", 62 | "webpack-bundle-analyzer": "^2.9.0", 63 | "webpack-dev-server": "^2.9.1", 64 | "webpack-merge": "^4.1.0" 65 | }, 66 | "engines": { 67 | "node": ">= 6.0.0", 68 | "npm": ">= 3.0.0" 69 | }, 70 | "browserslist": [ 71 | "> 1%", 72 | "last 2 versions", 73 | "not ie <= 8" 74 | ] 75 | } 76 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 123 | 171 | -------------------------------------------------------------------------------- /src/components/detail.vue: -------------------------------------------------------------------------------- 1 | 150 | 294 | -------------------------------------------------------------------------------- /src/components/index.vue: -------------------------------------------------------------------------------- 1 | 108 | 151 | -------------------------------------------------------------------------------- /src/components/login.vue: -------------------------------------------------------------------------------- 1 | 36 | -------------------------------------------------------------------------------- /src/components/order.vue: -------------------------------------------------------------------------------- 1 | 175 | 341 | 343 | 344 | -------------------------------------------------------------------------------- /src/components/orderDetail.vue: -------------------------------------------------------------------------------- 1 | 199 | 233 | 246 | -------------------------------------------------------------------------------- /src/components/orderList.vue: -------------------------------------------------------------------------------- 1 | 125 | 162 | 168 | -------------------------------------------------------------------------------- /src/components/pay.vue: -------------------------------------------------------------------------------- 1 | 87 | 131 | 135 | -------------------------------------------------------------------------------- /src/components/paySuccess.vue: -------------------------------------------------------------------------------- 1 | 40 | 65 | -------------------------------------------------------------------------------- /src/components/shoppingCart.vue: -------------------------------------------------------------------------------- 1 | 110 | 204 | 205 | -------------------------------------------------------------------------------- /src/components/vipCenter.vue: -------------------------------------------------------------------------------- 1 | 115 | 116 | 119 | 120 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | import ElementUI from 'element-ui'; 5 | import 'element-ui/lib/theme-chalk/index.css'; 6 | 7 | //导入放大镜的包 8 | import ProductZoomer from 'vue-product-zoomer'; 9 | //导入iview 10 | import iView from 'iview'; 11 | import 'iview/dist/styles/iview.css'; 12 | //导入moment.js 13 | import moment from 'moment'; 14 | 15 | // 导入 懒加载 vue插件 16 | import VueLazyload from 'vue-lazyload'; 17 | Vue.use(VueLazyload,{ 18 | preLoad:1.3, 19 | loading:require('../static/images/loading.gif'), 20 | attempt: 1 21 | }) 22 | 23 | //转换时间 24 | Vue.filter('filterDate', function(val) { 25 | return moment(val).format('YYYY年MM月DD日'); 26 | }) 27 | 28 | //注册element 29 | Vue.use(ElementUI); 30 | 31 | Vue.use(iView); 32 | //注册productZoomer 33 | Vue.use(ProductZoomer); 34 | Vue.config.productionTip = false 35 | 36 | //导入vuex文件 37 | import { store } from './vuex/store'; 38 | import router from './router' 39 | 40 | 41 | new Vue({ 42 | render: h => h(App), 43 | router, 44 | store, 45 | beforeCreate(){ 46 | this.$axios.get('/site/account/islogin').then(response=>{ 47 | if (response.data.code == 'logined') { 48 | store.state.isLogin = true; 49 | } 50 | }) 51 | } 52 | }).$mount('#app') -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | //导入路由 3 | import Router from 'vue-router' 4 | //注册VueRouter 5 | Vue.use(Router); 6 | //导入单页面组件 7 | import Index from '../components/index'; 8 | //导入详情页面 9 | import Detail from '../components/detail' 10 | 11 | import Cart from '../components/shoppingCart' 12 | 13 | import Login from '../components/login' 14 | 15 | import Order from '../components/order' 16 | 17 | import Pay from '../components/pay' 18 | 19 | import paySuccess from '../components/paySuccess' 20 | 21 | import VipCenter from '../components/vipCenter' 22 | 23 | import OrderList from '../components/orderList' 24 | 25 | import OrderDetail from '../components/orderDetail' 26 | 27 | import axios from 'axios'; 28 | //基础地址 29 | axios.defaults.baseURL = 'http://47.106.148.205:8899'; 30 | //让ajax携带cookie 31 | // 跨域请求时 是否会携带 凭证(cookie) 32 | axios.defaults.withCredentials = true; 33 | //Vue原型对象存储axios 34 | Vue.prototype.$axios = axios; 35 | 36 | //定义路由规则 37 | let routes = [{ 38 | //首页 39 | path: '/', 40 | // component: Index, 41 | redirect: '/index' 42 | }, 43 | { 44 | //首页 45 | path: '/index', 46 | component: Index 47 | }, 48 | { 49 | //详情页 50 | path: '/detail/:id', 51 | component: Detail 52 | }, 53 | { 54 | //购物车 55 | path: '/cart', 56 | component: Cart 57 | }, 58 | { 59 | //登录 60 | path: '/login', 61 | component: Login 62 | }, 63 | { 64 | //订单 65 | path: '/order/:id', 66 | component: Order, 67 | meta: { 68 | checkLogin: true 69 | } 70 | }, 71 | { 72 | //订单详情 73 | path: '/pay/:id', 74 | component: Pay, 75 | meta: { 76 | checkLogin: true 77 | } 78 | }, 79 | { 80 | //订单成功 81 | path: '/paySuccess/:id', 82 | component: paySuccess, 83 | meta: { 84 | checkLogin: true 85 | } 86 | }, 87 | { 88 | //会员中心 89 | path: '/vipCenter', 90 | component: VipCenter, 91 | meta: { 92 | checkLogin: true 93 | } 94 | }, 95 | { 96 | //订单列表 97 | path: '/orderlist', 98 | component: OrderList, 99 | meta: { 100 | checkLogin: true 101 | } 102 | }, 103 | { 104 | //订单详情 105 | path: '/orderDetail/:id', 106 | component: OrderDetail, 107 | meta: { 108 | checkLogin: true 109 | } 110 | }, 111 | ] 112 | 113 | //实例化路由对象 114 | let router = new Router({ 115 | routes: routes 116 | }) 117 | 118 | // 增加 导航守卫(路由守卫),判断是否是登录状态,不是打回到登录 119 | router.beforeEach((to, from, next) => { 120 | if (to.meta.checkLogin == true) { 121 | axios.get("site/account/islogin") 122 | .then(response => { 123 | if (response.data.code != 'nologin') { 124 | next(); 125 | } else { 126 | next('/login'); 127 | } 128 | }) 129 | } else { 130 | next(); 131 | } 132 | }) 133 | export default new Router({ 134 | routes, 135 | }) 136 | -------------------------------------------------------------------------------- /src/vuex/store.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuex from 'vuex'; 3 | Vue.use(Vuex) 4 | //创建一个 stores 5 | const stores = new Vuex.Store({ 6 | state: { 7 | cartDate: JSON.parse(window.localStorage.getItem('goodkey')) || {}, 8 | isLogin: false, 9 | pathFrom: '' 10 | }, 11 | mutations: { 12 | // 传入的数据是一个对象 格式{goodId:商品id,goodNum:数量} 13 | addGoods(state, goodsInfo) { 14 | if (state.cartDate[goodsInfo.goodId] == undefined) { 15 | // state.cartDate[goodInfo.goodId] = goodInfo.goodNum; 16 | // 为了要让Vue检测到数据的改变同步修改页面显示 需要调用Vue.set方法 17 | Vue.set(state.cartDate, goodsInfo.goodId, goodsInfo.goodNum); 18 | } else { 19 | //传过来的id已存在则累加 20 | state.cartDate[goodsInfo.goodId] += goodsInfo.goodNum; 21 | } 22 | }, 23 | //更新数量时同步购物车的数量 24 | updateGoodsNum(state, goodsInfo) { 25 | state.cartDate[goodsInfo.goodId] = goodsInfo.goodNum; 26 | }, 27 | deleteGood(state, goodId) { 28 | //要调用Vue.delete方法 29 | Vue.delete(state.cartDate, goodId); 30 | }, 31 | changeLoginStatus(state, isLogin) { 32 | state.isLogin = isLogin; 33 | } 34 | }, 35 | getters: { 36 | goodsCount: state => { 37 | //临时num 38 | let num = 0; 39 | //遍历对象 40 | for (const key in state.cartDate) { 41 | num += state.cartDate[key]; 42 | } 43 | return num; 44 | } 45 | } 46 | }) 47 | 48 | window.onbeforeunload = function() { 49 | window.localStorage.setItem('goodkey', JSON.stringify(store.state.cartDate)); 50 | } 51 | //暴露出去 52 | export const store = stores; 53 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/.gitkeep -------------------------------------------------------------------------------- /static/css/style.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | body, ul, dl, dd, dt, ol, li, p, h1, h2, h3, h4, h5, h6, textarea, form, select, fieldset, table, td, div, input {margin:0;padding:0;-webkit-text-size-adjust: none} 3 | h1, h2, h3, h4, h5, h6{font-size:12px;font-weight:normal} 4 | body>div{margin:0 auto} 5 | div {text-align:left} 6 | a img {border:0} 7 | body { color: #333; text-align: center; font: 12px "微软雅黑"; background-color: #2B2B2B; } 8 | ul, ol, li {list-style-type:none;vertical-align:0} 9 | 10 | .menu{height:48px;display:block;padding:0px;width:999px;margin:0px auto 0 auto;} 11 | .menu ul{list-style:none;padding:0;margin:0;} 12 | .menu ul li{float:left;overflow:hidden;position:relative;line-height:48px;text-align:center;} 13 | .menu ul li a{position:relative;display:block;width:111px;height:48px;font-family:"微软雅黑", "宋体";font-size:14px;text-decoration:none;cursor:pointer;font-weight:bold;line-height:48px;} 14 | .menu ul li a span{position:absolute;left:0;width:111px;} 15 | .menu ul li a span.out{top:0px;} 16 | .menu ul li a span.over, .menu ul li a span.bg{top:-48px;} 17 | #menu2{background-image:url(../images/s_03.jpg);background-repeat:repeat;} 18 | #menu2 ul li a{color:#FFFFFF;} 19 | #menu2 ul li a span.over{color:#FFF;height:48px;width:111px;background-image:url(../images/w_03.jpg);background-repeat:repeat;} -------------------------------------------------------------------------------- /static/images/bodyBg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/images/bodyBg.jpg -------------------------------------------------------------------------------- /static/images/bodyBg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/images/bodyBg2.jpg -------------------------------------------------------------------------------- /static/images/bodyBg3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/images/bodyBg3.jpg -------------------------------------------------------------------------------- /static/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/images/loading.gif -------------------------------------------------------------------------------- /static/images/lst.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/images/lst.JPG -------------------------------------------------------------------------------- /static/images/s_03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/images/s_03.jpg -------------------------------------------------------------------------------- /static/images/w_03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/images/w_03.jpg -------------------------------------------------------------------------------- /static/site/css/icon/demo.css: -------------------------------------------------------------------------------- 1 | *{margin: 0;padding: 0;list-style: none;} 2 | /* 3 | KISSY CSS Reset 4 | 理念:1. reset 的目的不是清除浏览器的默认样式,这仅是部分工作。清除和重置是紧密不可分的。 5 | 2. reset 的目的不是让默认样式在所有浏览器下一致,而是减少默认样式有可能带来的问题。 6 | 3. reset 期望提供一套普适通用的基础样式。但没有银弹,推荐根据具体需求,裁剪和修改后再使用。 7 | 特色:1. 适应中文;2. 基于最新主流浏览器。 8 | 维护:玉伯, 正淳 9 | */ 10 | 11 | /** 清除内外边距 **/ 12 | body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, /* structural elements 结构元素 */ 13 | dl, dt, dd, ul, ol, li, /* list elements 列表元素 */ 14 | pre, /* text formatting elements 文本格式元素 */ 15 | form, fieldset, legend, button, input, textarea, /* form elements 表单元素 */ 16 | th, td /* table elements 表格元素 */ { 17 | margin: 0; 18 | padding: 0; 19 | } 20 | 21 | /** 设置默认字体 **/ 22 | body, 23 | button, input, select, textarea /* for ie */ { 24 | font: 12px/1.5 tahoma, arial, \5b8b\4f53, sans-serif; 25 | } 26 | h1, h2, h3, h4, h5, h6 { font-size: 100%; } 27 | address, cite, dfn, em, var { font-style: normal; } /* 将斜体扶正 */ 28 | code, kbd, pre, samp { font-family: courier new, courier, monospace; } /* 统一等宽字体 */ 29 | small { font-size: 12px; } /* 小于 12px 的中文很难阅读,让 small 正常化 */ 30 | 31 | /** 重置列表元素 **/ 32 | ul, ol { list-style: none; } 33 | 34 | /** 重置文本格式元素 **/ 35 | a { text-decoration: none; } 36 | a:hover { text-decoration: underline; } 37 | 38 | 39 | /** 重置表单元素 **/ 40 | legend { color: #000; } /* for ie6 */ 41 | fieldset, img { border: 0; } /* img 搭车:让链接里的 img 无边框 */ 42 | button, input, select, textarea { font-size: 100%; } /* 使得表单元素在 ie 下能继承字体大小 */ 43 | /* 注:optgroup 无法扶正 */ 44 | 45 | /** 重置表格元素 **/ 46 | table { border-collapse: collapse; border-spacing: 0; } 47 | 48 | /* 清除浮动 */ 49 | .ks-clear:after, .clear:after { 50 | content: '\20'; 51 | display: block; 52 | height: 0; 53 | clear: both; 54 | } 55 | .ks-clear, .clear { 56 | *zoom: 1; 57 | } 58 | 59 | .main { 60 | padding: 30px 100px; 61 | width: 960px; 62 | margin: 0 auto; 63 | } 64 | .main h1{font-size:36px; color:#333; text-align:left;margin-bottom:30px; border-bottom: 1px solid #eee;} 65 | 66 | .helps{margin-top:40px;} 67 | .helps pre{ 68 | padding:20px; 69 | margin:10px 0; 70 | border:solid 1px #e7e1cd; 71 | background-color: #fffdef; 72 | overflow: auto; 73 | } 74 | 75 | .icon_lists{ 76 | width: 100% !important; 77 | 78 | } 79 | 80 | .icon_lists li{ 81 | float:left; 82 | width: 100px; 83 | height:180px; 84 | text-align: center; 85 | list-style: none !important; 86 | } 87 | .icon_lists .icon{ 88 | font-size: 42px; 89 | line-height: 100px; 90 | margin: 10px 0; 91 | color:#333; 92 | -webkit-transition: font-size 0.25s ease-out 0s; 93 | -moz-transition: font-size 0.25s ease-out 0s; 94 | transition: font-size 0.25s ease-out 0s; 95 | 96 | } 97 | .icon_lists .icon:hover{ 98 | font-size: 100px; 99 | } 100 | 101 | 102 | 103 | .markdown { 104 | color: #666; 105 | font-size: 14px; 106 | line-height: 1.8; 107 | } 108 | 109 | .highlight { 110 | line-height: 1.5; 111 | } 112 | 113 | .markdown img { 114 | vertical-align: middle; 115 | max-width: 100%; 116 | } 117 | 118 | .markdown h1 { 119 | color: #404040; 120 | font-weight: 500; 121 | line-height: 40px; 122 | margin-bottom: 24px; 123 | } 124 | 125 | .markdown h2, 126 | .markdown h3, 127 | .markdown h4, 128 | .markdown h5, 129 | .markdown h6 { 130 | color: #404040; 131 | margin: 1.6em 0 0.6em 0; 132 | font-weight: 500; 133 | clear: both; 134 | } 135 | 136 | .markdown h1 { 137 | font-size: 28px; 138 | } 139 | 140 | .markdown h2 { 141 | font-size: 22px; 142 | } 143 | 144 | .markdown h3 { 145 | font-size: 16px; 146 | } 147 | 148 | .markdown h4 { 149 | font-size: 14px; 150 | } 151 | 152 | .markdown h5 { 153 | font-size: 12px; 154 | } 155 | 156 | .markdown h6 { 157 | font-size: 12px; 158 | } 159 | 160 | .markdown hr { 161 | height: 1px; 162 | border: 0; 163 | background: #e9e9e9; 164 | margin: 16px 0; 165 | clear: both; 166 | } 167 | 168 | .markdown p, 169 | .markdown pre { 170 | margin: 1em 0; 171 | } 172 | 173 | .markdown > p, 174 | .markdown > blockquote, 175 | .markdown > .highlight, 176 | .markdown > ol, 177 | .markdown > ul { 178 | width: 80%; 179 | } 180 | 181 | .markdown ul > li { 182 | list-style: circle; 183 | } 184 | 185 | .markdown > ul li, 186 | .markdown blockquote ul > li { 187 | margin-left: 20px; 188 | padding-left: 4px; 189 | } 190 | 191 | .markdown > ul li p, 192 | .markdown > ol li p { 193 | margin: 0.6em 0; 194 | } 195 | 196 | .markdown ol > li { 197 | list-style: decimal; 198 | } 199 | 200 | .markdown > ol li, 201 | .markdown blockquote ol > li { 202 | margin-left: 20px; 203 | padding-left: 4px; 204 | } 205 | 206 | .markdown code { 207 | margin: 0 3px; 208 | padding: 0 5px; 209 | background: #eee; 210 | border-radius: 3px; 211 | } 212 | 213 | .markdown pre { 214 | border-radius: 6px; 215 | background: #f7f7f7; 216 | padding: 20px; 217 | } 218 | 219 | .markdown pre code { 220 | border: none; 221 | background: #f7f7f7; 222 | margin: 0; 223 | } 224 | 225 | .markdown strong, 226 | .markdown b { 227 | font-weight: 600; 228 | } 229 | 230 | .markdown > table { 231 | border-collapse: collapse; 232 | border-spacing: 0px; 233 | empty-cells: show; 234 | border: 1px solid #e9e9e9; 235 | width: 95%; 236 | margin-bottom: 24px; 237 | } 238 | 239 | .markdown > table th { 240 | white-space: nowrap; 241 | color: #333; 242 | font-weight: 600; 243 | 244 | } 245 | 246 | .markdown > table th, 247 | .markdown > table td { 248 | border: 1px solid #e9e9e9; 249 | padding: 8px 16px; 250 | text-align: left; 251 | } 252 | 253 | .markdown > table th { 254 | background: #F7F7F7; 255 | } 256 | 257 | .markdown blockquote { 258 | font-size: 90%; 259 | color: #999; 260 | border-left: 4px solid #e9e9e9; 261 | padding-left: 0.8em; 262 | margin: 1em 0; 263 | font-style: italic; 264 | } 265 | 266 | .markdown blockquote p { 267 | margin: 0; 268 | } 269 | 270 | .markdown .anchor { 271 | opacity: 0; 272 | transition: opacity 0.3s ease; 273 | margin-left: 8px; 274 | } 275 | 276 | .markdown .waiting { 277 | color: #ccc; 278 | } 279 | 280 | .markdown h1:hover .anchor, 281 | .markdown h2:hover .anchor, 282 | .markdown h3:hover .anchor, 283 | .markdown h4:hover .anchor, 284 | .markdown h5:hover .anchor, 285 | .markdown h6:hover .anchor { 286 | opacity: 1; 287 | display: inline-block; 288 | } 289 | 290 | .markdown > br, 291 | .markdown > p > br { 292 | clear: both; 293 | } 294 | 295 | 296 | .hljs { 297 | display: block; 298 | background: white; 299 | padding: 0.5em; 300 | color: #333333; 301 | overflow-x: auto; 302 | } 303 | 304 | .hljs-comment, 305 | .hljs-meta { 306 | color: #969896; 307 | } 308 | 309 | .hljs-string, 310 | .hljs-variable, 311 | .hljs-template-variable, 312 | .hljs-strong, 313 | .hljs-emphasis, 314 | .hljs-quote { 315 | color: #df5000; 316 | } 317 | 318 | .hljs-keyword, 319 | .hljs-selector-tag, 320 | .hljs-type { 321 | color: #a71d5d; 322 | } 323 | 324 | .hljs-literal, 325 | .hljs-symbol, 326 | .hljs-bullet, 327 | .hljs-attribute { 328 | color: #0086b3; 329 | } 330 | 331 | .hljs-section, 332 | .hljs-name { 333 | color: #63a35c; 334 | } 335 | 336 | .hljs-tag { 337 | color: #333333; 338 | } 339 | 340 | .hljs-title, 341 | .hljs-attr, 342 | .hljs-selector-id, 343 | .hljs-selector-class, 344 | .hljs-selector-attr, 345 | .hljs-selector-pseudo { 346 | color: #795da3; 347 | } 348 | 349 | .hljs-addition { 350 | color: #55a532; 351 | background-color: #eaffea; 352 | } 353 | 354 | .hljs-deletion { 355 | color: #bd2c00; 356 | background-color: #ffecec; 357 | } 358 | 359 | .hljs-link { 360 | text-decoration: underline; 361 | } 362 | 363 | pre{ 364 | background: #fff; 365 | } 366 | 367 | 368 | 369 | 370 | 371 | -------------------------------------------------------------------------------- /static/site/css/icon/demo_fontclass.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | IconFont 7 | 8 | 9 | 10 | 11 |
12 |

IconFont 图标

13 |
    14 | 15 |
  • 16 | 17 |
    Error
    18 |
    .icon-error
    19 |
  • 20 | 21 |
  • 22 | 23 |
    返回
    24 |
    .icon-reply
    25 |
  • 26 | 27 |
  • 28 | 29 |
    购物车
    30 |
    .icon-cart
    31 |
  • 32 | 33 |
  • 34 | 35 |
    加号
    36 |
    .icon-plus
    37 |
  • 38 | 39 |
  • 40 | 41 |
    播放
    42 |
    .icon-play
    43 |
  • 44 | 45 |
  • 46 | 47 |
    电话
    48 |
    .icon-phone
    49 |
  • 50 | 51 |
  • 52 | 53 |
    用户
    54 |
    .icon-user-full
    55 |
  • 56 | 57 |
  • 58 | 59 |
    User
    60 |
    .icon-user
    61 |
  • 62 | 63 |
  • 64 | 65 |
    close
    66 |
    .icon-close
    67 |
  • 68 | 69 |
  • 70 | 71 |
    正确
    72 |
    .icon-check
    73 |
  • 74 | 75 |
  • 76 | 77 |
    查看
    78 |
    .icon-view
    79 |
  • 80 | 81 |
  • 82 | 83 |
    日期
    84 |
    .icon-date
    85 |
  • 86 | 87 |
  • 88 | 89 |
    标签
    90 |
    .icon-top-label
    91 |
  • 92 | 93 |
  • 94 | 95 |
    购物
    96 |
    .icon-order
    97 |
  • 98 | 99 |
  • 100 | 101 |
    评论
    102 |
    .icon-comment
    103 |
  • 104 | 105 |
  • 106 | 107 |
    放大镜
    108 |
    .icon-search
    109 |
  • 110 | 111 |
  • 112 | 113 |
    标签
    114 |
    .icon-right-label
    115 |
  • 116 | 117 |
  • 118 | 119 |
    积分
    120 |
    .icon-point
    121 |
  • 122 | 123 |
  • 124 | 125 |
    arrow
    126 |
    .icon-arrow-left
    127 |
  • 128 | 129 |
  • 130 | 131 |
    09附件
    132 |
    .icon-attach
    133 |
  • 134 | 135 |
  • 136 | 137 |
    下载
    138 |
    .icon-down
    139 |
  • 140 | 141 |
  • 142 | 143 |
    tip
    144 |
    .icon-tip
    145 |
  • 146 | 147 |
  • 148 | 149 |
    余额
    150 |
    .icon-amount
    151 |
  • 152 | 153 |
  • 154 | 155 |
    arrow
    156 |
    .icon-arrow-right
    157 |
  • 158 | 159 |
160 | 161 |

font-class引用

162 |
163 | 164 |

font-class是unicode使用方式的一种变种,主要是解决unicode书写不直观,语意不明确的问题。

165 |

与unicode使用方式相比,具有如下特点:

166 |
    167 |
  • 兼容性良好,支持ie8+,及所有现代浏览器。
  • 168 |
  • 相比于unicode语意明确,书写更直观。可以很容易分辨这个icon是什么。
  • 169 |
  • 因为使用class来定义图标,所以当要替换图标时,只需要修改class里面的unicode引用。
  • 170 |
  • 不过因为本质上还是使用的字体,所以多色图标还是不支持的。
  • 171 |
172 |

使用步骤如下:

173 |

第一步:引入项目下面生成的fontclass代码:

174 | 175 | 176 |
<link rel="stylesheet" type="text/css" href="./iconfont.css">
177 |

第二步:挑选相应图标并获取类名,应用于页面:

178 |
<i class="iconfont icon-xxx"></i>
179 |
180 |

"iconfont"是你项目下的font-family。可以通过编辑项目查看,默认是"iconfont"。

181 |
182 |
183 | 184 | 185 | -------------------------------------------------------------------------------- /static/site/css/icon/demo_symbol.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | IconFont 7 | 8 | 9 | 10 | 24 | 25 | 26 |
27 |

IconFont 图标

28 |
    29 | 30 |
  • 31 | 34 |
    Error
    35 |
    #icon-error
    36 |
  • 37 | 38 |
  • 39 | 42 |
    返回
    43 |
    #icon-reply
    44 |
  • 45 | 46 |
  • 47 | 50 |
    购物车
    51 |
    #icon-cart
    52 |
  • 53 | 54 |
  • 55 | 58 |
    加号
    59 |
    #icon-plus
    60 |
  • 61 | 62 |
  • 63 | 66 |
    播放
    67 |
    #icon-play
    68 |
  • 69 | 70 |
  • 71 | 74 |
    电话
    75 |
    #icon-phone
    76 |
  • 77 | 78 |
  • 79 | 82 |
    用户
    83 |
    #icon-user-full
    84 |
  • 85 | 86 |
  • 87 | 90 |
    User
    91 |
    #icon-user
    92 |
  • 93 | 94 |
  • 95 | 98 |
    close
    99 |
    #icon-close
    100 |
  • 101 | 102 |
  • 103 | 106 |
    正确
    107 |
    #icon-check
    108 |
  • 109 | 110 |
  • 111 | 114 |
    查看
    115 |
    #icon-view
    116 |
  • 117 | 118 |
  • 119 | 122 |
    日期
    123 |
    #icon-date
    124 |
  • 125 | 126 |
  • 127 | 130 |
    标签
    131 |
    #icon-top-label
    132 |
  • 133 | 134 |
  • 135 | 138 |
    购物
    139 |
    #icon-order
    140 |
  • 141 | 142 |
  • 143 | 146 |
    评论
    147 |
    #icon-comment
    148 |
  • 149 | 150 |
  • 151 | 154 |
    放大镜
    155 |
    #icon-search
    156 |
  • 157 | 158 |
  • 159 | 162 |
    标签
    163 |
    #icon-right-label
    164 |
  • 165 | 166 |
  • 167 | 170 |
    积分
    171 |
    #icon-point
    172 |
  • 173 | 174 |
  • 175 | 178 |
    arrow
    179 |
    #icon-arrow-left
    180 |
  • 181 | 182 |
  • 183 | 186 |
    09附件
    187 |
    #icon-attach
    188 |
  • 189 | 190 |
  • 191 | 194 |
    下载
    195 |
    #icon-down
    196 |
  • 197 | 198 |
  • 199 | 202 |
    tip
    203 |
    #icon-tip
    204 |
  • 205 | 206 |
  • 207 | 210 |
    余额
    211 |
    #icon-amount
    212 |
  • 213 | 214 |
  • 215 | 218 |
    arrow
    219 |
    #icon-arrow-right
    220 |
  • 221 | 222 |
223 | 224 | 225 |

symbol引用

226 |
227 | 228 |

这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇文章 229 | 这种用法其实是做了一个svg的集合,与另外两种相比具有如下特点:

230 |
    231 |
  • 支持多色图标了,不再受单色限制。
  • 232 |
  • 通过一些技巧,支持像字体那样,通过font-size,color来调整样式。
  • 233 |
  • 兼容性较差,支持 ie9+,及现代浏览器。
  • 234 |
  • 浏览器渲染svg的性能一般,还不如png。
  • 235 |
236 |

使用步骤如下:

237 |

第一步:引入项目下面生成的symbol代码:

238 |
<script src="./iconfont.js"></script>
239 |

第二步:加入通用css代码(引入一次就行):

240 |
<style type="text/css">
241 | .icon {
242 |    width: 1em; height: 1em;
243 |    vertical-align: -0.15em;
244 |    fill: currentColor;
245 |    overflow: hidden;
246 | }
247 | </style>
248 |

第三步:挑选相应图标并获取类名,应用于页面:

249 |
<svg class="icon" aria-hidden="true">
250 |   <use xlink:href="#icon-xxx"></use>
251 | </svg>
252 |         
253 |
254 | 255 | 256 | -------------------------------------------------------------------------------- /static/site/css/icon/demo_unicode.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | IconFont 7 | 8 | 9 | 29 | 30 | 31 |
32 |

IconFont 图标

33 |
    34 | 35 |
  • 36 | 37 |
    Error
    38 |
    &#xe600;
    39 |
  • 40 | 41 |
  • 42 | 43 |
    返回
    44 |
    &#xe607;
    45 |
  • 46 | 47 |
  • 48 | 49 |
    购物车
    50 |
    &#xe601;
    51 |
  • 52 | 53 |
  • 54 | 55 |
    加号
    56 |
    &#xe676;
    57 |
  • 58 | 59 |
  • 60 | 61 |
    播放
    62 |
    &#xe602;
    63 |
  • 64 | 65 |
  • 66 | 67 |
    电话
    68 |
    &#xe603;
    69 |
  • 70 | 71 |
  • 72 | 73 |
    用户
    74 |
    &#xe6ce;
    75 |
  • 76 | 77 |
  • 78 | 79 |
    User
    80 |
    &#xe6f5;
    81 |
  • 82 | 83 |
  • 84 | 85 |
    close
    86 |
    &#xe659;
    87 |
  • 88 | 89 |
  • 90 | 91 |
    正确
    92 |
    &#xe61f;
    93 |
  • 94 | 95 |
  • 96 | 97 |
    查看
    98 |
    &#xe61b;
    99 |
  • 100 | 101 |
  • 102 | 103 |
    日期
    104 |
    &#xe721;
    105 |
  • 106 | 107 |
  • 108 | 109 |
    标签
    110 |
    &#xe60d;
    111 |
  • 112 | 113 |
  • 114 | 115 |
    购物
    116 |
    &#xe62a;
    117 |
  • 118 | 119 |
  • 120 | 121 |
    评论
    122 |
    &#xe7e9;
    123 |
  • 124 | 125 |
  • 126 | 127 |
    放大镜
    128 |
    &#xe629;
    129 |
  • 130 | 131 |
  • 132 | 133 |
    标签
    134 |
    &#xe628;
    135 |
  • 136 | 137 |
  • 138 | 139 |
    积分
    140 |
    &#xe606;
    141 |
  • 142 | 143 |
  • 144 | 145 |
    arrow
    146 |
    &#xe604;
    147 |
  • 148 | 149 |
  • 150 | 151 |
    09附件
    152 |
    &#xe644;
    153 |
  • 154 | 155 |
  • 156 | 157 |
    下载
    158 |
    &#xe87a;
    159 |
  • 160 | 161 |
  • 162 | 163 |
    tip
    164 |
    &#xe605;
    165 |
  • 166 | 167 |
  • 168 | 169 |
    余额
    170 |
    &#xe6a0;
    171 |
  • 172 | 173 |
  • 174 | 175 |
    arrow
    176 |
    &#xe87b;
    177 |
  • 178 | 179 |
180 |

unicode引用

181 |
182 | 183 |

unicode是字体在网页端最原始的应用方式,特点是:

184 |
    185 |
  • 兼容性最好,支持ie6+,及所有现代浏览器。
  • 186 |
  • 支持按字体的方式去动态调整图标大小,颜色等等。
  • 187 |
  • 但是因为是字体,所以不支持多色。只能使用平台里单色的图标,就算项目里有多色图标也会自动去色。
  • 188 |
189 |
190 |

注意:新版iconfont支持多色图标,这些多色图标在unicode模式下将不能使用,如果有需求建议使用symbol的引用方式

191 |
192 |

unicode使用步骤如下:

193 |

第一步:拷贝项目下面生成的font-face

194 |
@font-face {
195 |   font-family: 'iconfont';
196 |   src: url('iconfont.eot');
197 |   src: url('iconfont.eot?#iefix') format('embedded-opentype'),
198 |   url('iconfont.woff') format('woff'),
199 |   url('iconfont.ttf') format('truetype'),
200 |   url('iconfont.svg#iconfont') format('svg');
201 | }
202 | 
203 |

第二步:定义使用iconfont的样式

204 |
.iconfont{
205 |   font-family:"iconfont" !important;
206 |   font-size:16px;font-style:normal;
207 |   -webkit-font-smoothing: antialiased;
208 |   -webkit-text-stroke-width: 0.2px;
209 |   -moz-osx-font-smoothing: grayscale;
210 | }
211 | 
212 |

第三步:挑选相应图标并获取字体编码,应用于页面

213 |
<i class="iconfont">&#x33;</i>
214 | 215 |
216 |

"iconfont"是你项目下的font-family。可以通过编辑项目查看,默认是"iconfont"。

217 |
218 |
219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /static/site/css/icon/iconfont.css: -------------------------------------------------------------------------------- 1 | 2 | @font-face {font-family: "iconfont"; 3 | src: url('iconfont.eot?t=1496954256369'); /* IE9*/ 4 | src: url('iconfont.eot?t=1496954256369#iefix') format('embedded-opentype'), /* IE6-IE8 */ 5 | url('iconfont.woff?t=1496954256369') format('woff'), /* chrome, firefox */ 6 | url('iconfont.ttf?t=1496954256369') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/ 7 | url('iconfont.svg?t=1496954256369#iconfont') format('svg'); /* iOS 4.1- */ 8 | } 9 | 10 | .iconfont { 11 | font-family:"iconfont" !important; 12 | font-size:16px; 13 | font-style:normal; 14 | -webkit-font-smoothing: antialiased; 15 | -moz-osx-font-smoothing: grayscale; 16 | } 17 | 18 | .icon-error:before { content: "\e600"; } 19 | 20 | .icon-reply:before { content: "\e607"; } 21 | 22 | .icon-cart:before { content: "\e601"; } 23 | 24 | .icon-plus:before { content: "\e676"; } 25 | 26 | .icon-play:before { content: "\e602"; } 27 | 28 | .icon-phone:before { content: "\e603"; } 29 | 30 | .icon-user-full:before { content: "\e6ce"; } 31 | 32 | .icon-user:before { content: "\e6f5"; } 33 | 34 | .icon-close:before { content: "\e659"; } 35 | 36 | .icon-check:before { content: "\e61f"; } 37 | 38 | .icon-view:before { content: "\e61b"; } 39 | 40 | .icon-date:before { content: "\e721"; } 41 | 42 | .icon-top-label:before { content: "\e60d"; } 43 | 44 | .icon-order:before { content: "\e62a"; } 45 | 46 | .icon-comment:before { content: "\e7e9"; } 47 | 48 | .icon-search:before { content: "\e629"; } 49 | 50 | .icon-right-label:before { content: "\e628"; } 51 | 52 | .icon-point:before { content: "\e606"; } 53 | 54 | .icon-arrow-left:before { content: "\e604"; } 55 | 56 | .icon-attach:before { content: "\e644"; } 57 | 58 | .icon-down:before { content: "\e87a"; } 59 | 60 | .icon-tip:before { content: "\e605"; } 61 | 62 | .icon-amount:before { content: "\e6a0"; } 63 | 64 | .icon-arrow-right:before { content: "\e87b"; } 65 | 66 | -------------------------------------------------------------------------------- /static/site/css/icon/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/site/css/icon/iconfont.eot -------------------------------------------------------------------------------- /static/site/css/icon/iconfont.js: -------------------------------------------------------------------------------- 1 | (function(window){var svgSprite=""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+"";var script=function(){var scripts=document.getElementsByTagName("script");return scripts[scripts.length-1]}();var shouldInjectCss=script.getAttribute("data-injectcss");var ready=function(fn){if(document.addEventListener){if(~["complete","loaded","interactive"].indexOf(document.readyState)){setTimeout(fn,0)}else{var loadFn=function(){document.removeEventListener("DOMContentLoaded",loadFn,false);fn()};document.addEventListener("DOMContentLoaded",loadFn,false)}}else if(document.attachEvent){IEContentLoaded(window,fn)}function IEContentLoaded(w,fn){var d=w.document,done=false,init=function(){if(!done){done=true;fn()}};var polling=function(){try{d.documentElement.doScroll("left")}catch(e){setTimeout(polling,50);return}init()};polling();d.onreadystatechange=function(){if(d.readyState=="complete"){d.onreadystatechange=null;init()}}}};var before=function(el,target){target.parentNode.insertBefore(el,target)};var prepend=function(el,target){if(target.firstChild){before(el,target.firstChild)}else{target.appendChild(el)}};function appendSvg(){var div,svg;div=document.createElement("div");div.innerHTML=svgSprite;svgSprite=null;svg=div.getElementsByTagName("svg")[0];if(svg){svg.setAttribute("aria-hidden","true");svg.style.position="absolute";svg.style.width=0;svg.style.height=0;svg.style.overflow="hidden";prepend(svg,document.body)}}if(shouldInjectCss&&!window.__iconfont__svg__cssinject__){window.__iconfont__svg__cssinject__=true;try{document.write("")}catch(e){console&&console.log(e)}}ready(appendSvg)})(window) -------------------------------------------------------------------------------- /static/site/css/icon/iconfont.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Created by FontForge 20120731 at Fri Jun 9 04:37:36 2017 6 | By admin 7 | 8 | 9 | 10 | 24 | 26 | 28 | 30 | 32 | 34 | 38 | 41 | 44 | 48 | 50 | 53 | 56 | 59 | 64 | 67 | 71 | 75 | 78 | 80 | 84 | 88 | 91 | 93 | 99 | 101 | 111 | 113 | 116 | 122 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /static/site/css/icon/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/site/css/icon/iconfont.ttf -------------------------------------------------------------------------------- /static/site/css/icon/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShoutongLiu/shop/79e5a788bfc098dddb7a192b79de70d2c45441c9/static/site/css/icon/iconfont.woff --------------------------------------------------------------------------------