├── static ├── .gitkeep └── css │ └── reset.css ├── .eslintignore ├── config ├── prod.env.js ├── dev.env.js └── index.js ├── src ├── common │ ├── imgs │ │ └── loading.gif │ └── stylus │ │ └── mixins.styl ├── pages │ ├── Order │ │ ├── images │ │ │ └── person.png │ │ └── Order.vue │ ├── Shop │ │ ├── Shop.vue │ │ ├── ShopInfo │ │ │ └── ShopInfo.vue │ │ ├── ShopGoods │ │ │ └── ShopGoods.vue │ │ └── ShopRatings │ │ │ └── ShopRatings.vue │ ├── Msite │ │ ├── images │ │ │ └── msite_back.svg │ │ └── MSite.vue │ ├── Search │ │ └── Search.vue │ ├── Profile │ │ └── Profile.vue │ └── Login │ │ ├── images │ │ └── captcha.svg │ │ └── Login.vue ├── components │ ├── Star │ │ ├── images │ │ │ ├── star24_on@2x.png │ │ │ ├── star24_on@3x.png │ │ │ ├── star36_on@2x.png │ │ │ ├── star36_on@3x.png │ │ │ ├── star48_on@2x.png │ │ │ ├── star48_on@3x.png │ │ │ ├── star24_half@2x.png │ │ │ ├── star24_half@3x.png │ │ │ ├── star24_off@2x.png │ │ │ ├── star24_off@3x.png │ │ │ ├── star36_half@2x.png │ │ │ ├── star36_half@3x.png │ │ │ ├── star36_off@2x.png │ │ │ ├── star36_off@3x.png │ │ │ ├── star48_half@2x.png │ │ │ ├── star48_half@3x.png │ │ │ ├── star48_off@2x.png │ │ │ └── star48_off@3x.png │ │ └── Star.vue │ ├── ShopList │ │ ├── images │ │ │ └── shop_back.svg │ │ └── ShopList.vue │ ├── HeaderTop │ │ └── HeaderTop.vue │ ├── CartControl │ │ └── CartControl.vue │ ├── FooterGuide │ │ └── FooterGuide.vue │ ├── AlertTip │ │ └── AlertTip.vue │ ├── Food │ │ └── Food.vue │ ├── ShopCart │ │ └── ShopCart.vue │ └── ShopHeader │ │ └── ShopHeader.vue ├── filters │ └── index.js ├── store │ ├── index.js │ ├── state.js │ ├── getters.js │ ├── mutation-types.js │ ├── mutations.js │ └── actions.js ├── mock │ └── mockServer.js ├── main.js ├── App.vue ├── api │ ├── ajax.js │ └── index.js └── router │ └── index.js ├── server ├── views │ ├── error.ejs │ └── index.ejs ├── public │ └── stylesheets │ │ └── style.css ├── routes │ ├── users.js │ └── index.js ├── package.json ├── api │ └── ajax.js ├── db │ └── models.js ├── bin │ └── www ├── app.js ├── util │ └── sms_util.js ├── data │ └── index_category.json └── API文档.md ├── .editorconfig ├── .gitignore ├── .postcssrc.js ├── .babelrc ├── .eslintrc.js ├── index.html ├── README.md └── package.json /static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | *.vue 6 | *.js 7 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /src/common/imgs/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/common/imgs/loading.gif -------------------------------------------------------------------------------- /server/views/error.ejs: -------------------------------------------------------------------------------- 1 |

<%= message %>

2 |

<%= error.status %>

3 |
<%= error.stack %>
4 | -------------------------------------------------------------------------------- /src/pages/Order/images/person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/pages/Order/images/person.png -------------------------------------------------------------------------------- /src/components/Star/images/star24_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star24_on@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star24_on@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star24_on@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star36_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star36_on@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star36_on@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star36_on@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star48_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star48_on@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star48_on@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star48_on@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star24_half@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star24_half@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star24_half@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star24_half@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star24_off@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star24_off@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star24_off@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star24_off@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star36_half@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star36_half@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star36_half@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star36_half@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star36_off@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star36_off@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star36_off@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star36_off@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star48_half@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star48_half@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star48_half@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star48_half@3x.png -------------------------------------------------------------------------------- /src/components/Star/images/star48_off@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star48_off@2x.png -------------------------------------------------------------------------------- /src/components/Star/images/star48_off@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zionuke/vue2-takeaway/HEAD/src/components/Star/images/star48_off@3x.png -------------------------------------------------------------------------------- /server/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /server/routes/users.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET users listing. */ 5 | router.get('/', function(req, res, next) { 6 | res.send('respond with a resource'); 7 | }); 8 | 9 | module.exports = router; 10 | -------------------------------------------------------------------------------- /server/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | 8 |

<%= title %>

9 |

Welcome to <%= title %>

10 | 11 | 12 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /src/filters/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | // import moment from 'moment' 3 | import format from 'date-fns/format' 4 | 5 | // 自定义过滤器 6 | Vue.filter('date-format', function (value, formatStr='yyyy-MM-dd HH:mm:ss') { 7 | 8 | // return moment(value).format(formatStr) 9 | return format(value, formatStr) 10 | }) -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | vuex最核心的管理对象store 3 | */ 4 | import Vue from "vue" 5 | import Vuex from 'vuex' 6 | import state from './state' 7 | import actions from './actions' 8 | import mutations from './mutations' 9 | import getters from './getters' 10 | 11 | Vue.use(Vuex) 12 | 13 | export default new Vuex.Store({ 14 | state, 15 | actions, 16 | mutations, 17 | getters 18 | }) 19 | -------------------------------------------------------------------------------- /src/mock/mockServer.js: -------------------------------------------------------------------------------- 1 | /* 2 | 使用mockjs提供mock数据接口 3 | */ 4 | import Mock from 'mockjs' 5 | import data from './data.json' 6 | 7 | // 返回goods的接口 8 | Mock.mock('/goods', {code:0, data: data.goods}) 9 | // 返回ratings的接口 10 | Mock.mock('/ratings', {code:0, data: data.ratings}) 11 | // 返回info的接口 12 | Mock.mock('/info', {code:0, data: data.info}) 13 | 14 | // export default ??? 不需要向外暴露任何数据, 只需要保存能执行即可 -------------------------------------------------------------------------------- /.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", ["component", [ 12 | { 13 | "libraryName": "mint-ui", 14 | "style": true 15 | } 16 | ]]] 17 | } 18 | -------------------------------------------------------------------------------- /src/store/state.js: -------------------------------------------------------------------------------- 1 | /* 2 | 状态对象 3 | */ 4 | export default { 5 | latitude: 30.513216871440488, // 纬度 6 | longitude: 114.4202863269456, // 经度 7 | address: {}, //地址相关信息对象 8 | categorys: [], // 食品分类数组 9 | shops: [], // 商家数组 10 | userInfo: {}, // 用户信息 11 | goods: [], // 商品列表 12 | ratings: [], // 商家评价列表 13 | info: {}, // 商家信息 14 | cartFoods: [], // 购物车中食物的列表 15 | searchShops: [], // 搜索得到的商家列表 16 | } -------------------------------------------------------------------------------- /src/store/getters.js: -------------------------------------------------------------------------------- 1 | /* 2 | 包含多个基于state的getter计算属性的对象 3 | */ 4 | export default { 5 | totalCount(state) { 6 | return state.cartFoods.reduce((prev, food) => prev + food.count, 0) 7 | }, 8 | 9 | totalPrice(state) { 10 | return state.cartFoods.reduce((prev, food) => prev + food.count*food.price, 0) 11 | }, 12 | 13 | positiveSize(state) { 14 | return state.ratings.reduce((prev, rating) => prev + (rating.rateType===0?1:0), 0) 15 | } 16 | } -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | 入口JS 3 | */ 4 | import Vue from 'vue' 5 | import { Button } from 'mint-ui' 6 | import VueLazyload from 'vue-lazyload' 7 | import App from './App' 8 | import router from './router' 9 | import store from './store' 10 | 11 | import './mock/mockServer' // 加载mockServer即可 12 | import loading from './common/imgs/loading.gif' 13 | import './filters' // 加载过滤器 14 | 15 | // 注册全局组件标签 16 | Vue.component(Button.name, Button) // 全局可使用标签 17 | Vue.use(VueLazyload, { // 内部自定义一个指令lazy 18 | loading 19 | }) 20 | 21 | new Vue({ 22 | el: '#app', 23 | render: h => h(App), 24 | router, // 使用vue-router 25 | store // 使用vuex 26 | }) 27 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gshop_server", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "nodemon ./bin/www" 7 | }, 8 | "dependencies": { 9 | "axios": "^0.18.0", 10 | "blueimp-md5": "^2.10.0", 11 | "body-parser": "~1.18.2", 12 | "cookie-parser": "~1.4.3", 13 | "debug": "~2.6.9", 14 | "ejs": "~2.5.7", 15 | "express": "~4.15.5", 16 | "express-session": "^1.15.6", 17 | "js-base64": "^2.4.3", 18 | "moment": "^2.21.0", 19 | "mongoose": "^5.0.8", 20 | "morgan": "~1.9.0", 21 | "nodemon": "^1.17.1", 22 | "request": "^2.83.0", 23 | "serve-favicon": "~2.4.5", 24 | "svg-captcha": "^1.3.11" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 31 | 32 | 38 | -------------------------------------------------------------------------------- /src/store/mutation-types.js: -------------------------------------------------------------------------------- 1 | /* 2 | 包含n个mutation的type名称常量 3 | */ 4 | export const RECEIVE_ADDRESS = 'receive_address' // 接收地址 5 | export const RECEIVE_CATEGORYS = 'receive_categorys' // 接收食品分类数组 6 | export const RECEIVE_SHOPS = 'receive_shops' // 接收商家数组 7 | export const RECEIVE_USER_INFO = 'receive_user_info' // 接收用户信息 8 | export const RESET_USER_INFO = 'reset_user_info' // 重置用户信息 9 | 10 | export const RECEIVE_GOODS = 'receive_goods' // 接收商品数组 11 | export const RECEIVE_RATINGS = 'receive_ratings' // 接收商家评价数组 12 | export const RECEIVE_INFO = 'receive_info' // 接收商家信息 13 | 14 | export const INCREMENT_FOOD_COUNT = 'increment_food_count' // 增加food中的count 15 | export const DECREMENT_FOOD_COUNT = 'decrement_food_count' // 减少food中的count 16 | export const CLEAR_CART = 'clear_cart' // 清空购物车 17 | 18 | export const RECEIVE_SEARCH_SHOPS = 'receive_search_shops' // 接收搜索的商家数组 -------------------------------------------------------------------------------- /server/api/ajax.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios') 2 | 3 | module.exports = function ajax(url = '', data = {}, type = 'GET') { 4 | return new Promise(function (resolve, reject) { 5 | 6 | let promise 7 | 8 | if (type === 'GET') { 9 | // 准备url query参数数据 10 | let dataStr = '' //数据拼接字符串 11 | Object.keys(data).forEach(key => { 12 | dataStr += key + '=' + data[key] + '&' 13 | }) 14 | if (dataStr !== '') { 15 | dataStr = dataStr.substr(0, dataStr.lastIndexOf('&')) 16 | url = url + '?' + dataStr 17 | } 18 | // 发送get请求 19 | promise = axios.get(url) 20 | } else { 21 | // 发送post请求 22 | promise = axios.post(url, data) 23 | } 24 | 25 | promise.then(response => { 26 | resolve(response.data) 27 | }) 28 | .catch(error => { 29 | reject(error) 30 | }) 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parserOptions: { 6 | parser: 'babel-eslint' 7 | }, 8 | env: { 9 | browser: true, 10 | }, 11 | extends: [ 12 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention 13 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 14 | 'plugin:vue/essential', 15 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 16 | 'standard' 17 | ], 18 | // required to lint *.vue files 19 | plugins: [ 20 | 'vue' 21 | ], 22 | // add your custom rules here 23 | rules: { 24 | // allow async-await 25 | 'generator-star-spacing': 'off', 26 | // allow debugger during development 27 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /server/db/models.js: -------------------------------------------------------------------------------- 1 | /* 2 | 包含n个能操作mongodb数据库集合的model的模块 3 | 1. 连接数据库 4 | 1.1. 引入mongoose 5 | 1.2. 连接指定数据库(URL只有数据库是变化的) 6 | 1.3. 获取连接对象 7 | 1.4. 绑定连接完成的监听(用来提示连接成功) 8 | 2. 定义对应特定集合的Model 9 | 2.1. 字义Schema(描述文档结构) 10 | 2.2. 定义Model(与集合对应, 可以操作集合) 11 | 3. 向外暴露获取Model的方法 12 | */ 13 | // 1. 连接数据库 14 | const mongoose = require('mongoose') 15 | mongoose.connect('mongodb://localhost:27017/guigu_zhipin') 16 | const conn = mongoose.connection 17 | conn.on('connected', function () { 18 | console.log('数据库连接成功!') 19 | }) 20 | 21 | // 2. 得到对应特定集合的Model: UserModel 22 | const userSchema = mongoose.Schema({ 23 | // 用户名 24 | 'name': {type: String}, 25 | // 密码 26 | 'pwd': {type: String}, 27 | // 类型 28 | 'phone': {'type': String} 29 | }) 30 | UserModel = mongoose.model('user', userSchema) 31 | 32 | // 3. 向外暴露 33 | module.exports = { 34 | getModel(name) { 35 | return mongoose.model(name) 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/components/ShopList/images/shop_back.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | gshop 8 | 9 | 10 | 11 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/pages/Order/Order.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 25 | 26 | 53 | -------------------------------------------------------------------------------- /src/api/ajax.js: -------------------------------------------------------------------------------- 1 | /* 2 | ajax 请求函数模块 3 | */ 4 | import axios from 'axios' 5 | /** 6 | * 向外部暴露一个函数 ajax 7 | * @param {*} url 请求路径,默认为空 8 | * @param {*} data 请求参数,默认为空对象 9 | * @param {*} type 请求方法,默认为GET 10 | */ 11 | export default function ajax (url = '', data = {}, type = 'GET') { 12 | // 返回值 Promise对象 (异步返回的数据是response.data,而不是response) 13 | return new Promise(function (resolve, reject) { 14 | // (利用axios)异步执行ajax请求 15 | let promise // 这个内部的promise用来保存axios的返回值(promise对象) 16 | if (type === 'GET') { 17 | // 准备 url query 参数数据 18 | let dataStr = '' // 数据拼接字符串,将data连接到url 19 | Object.keys(data).forEach(key => { 20 | dataStr += key + '=' + data[key] + '&' 21 | }) 22 | if (dataStr !== '') { 23 | dataStr = dataStr.substring(0, dataStr.lastIndexOf('&')) 24 | url = url + '?' + dataStr 25 | } 26 | // 发送 get 请求 27 | promise = axios.get(url) 28 | } else { 29 | // 发送 post 请求 30 | promise = axios.post(url, data) 31 | } 32 | promise.then(response => { 33 | // 成功回调resolve() 34 | resolve(response.data) 35 | }) 36 | .catch(error => { 37 | // 失败回调reject() 38 | reject(error) 39 | }) 40 | }) 41 | } -------------------------------------------------------------------------------- /src/common/stylus/mixins.styl: -------------------------------------------------------------------------------- 1 | $green = #02a774; 2 | $yellow = #F5A100; 3 | $bc = #e4e4e4; 4 | 5 | // 一像素下边框 6 | bottom-border-1px($color) 7 | position relative 8 | border none 9 | &:after 10 | content '' 11 | position absolute 12 | left 0 13 | bottom 0 14 | width 100% 15 | height 1px 16 | background-color $color 17 | transform scaleY(0.5) 18 | 19 | // 一像素上边框 20 | top-border-1px($color) 21 | position relative 22 | &::before 23 | content '' 24 | position absolute 25 | z-index 200 26 | left 0 27 | top 0 28 | width 100% 29 | height 1px 30 | background-color $color 31 | 32 | //根据像素比缩放1px像素边框 33 | @media only screen and (-webkit-device-pixel-ratio: 2 ) 34 | .border-1px 35 | &::before 36 | transform scaleY(.5) 37 | 38 | @media only screen and (-webkit-device-pixel-ratio: 3 ) 39 | .border-1px 40 | &::before 41 | transform scaleY(.333333) 42 | 43 | //根据像素比来使用 2x图 3x图 44 | bg-image($url) 45 | background-image: url($url + "@2x.png") 46 | @media (-webkit-min-device-pixel-ratio: 3),(min-device-pixel-ratio: 3) 47 | background-image: url($url + "@3x.png") 48 | 49 | //清除浮动 50 | clearFix() 51 | *zoom 1 52 | &::after 53 | content '' 54 | display block 55 | clear both -------------------------------------------------------------------------------- /src/components/HeaderTop/HeaderTop.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 19 | 20 | 61 | -------------------------------------------------------------------------------- /src/api/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | 与后台交互模块 (依赖已封装的ajax函数) 3 | 包含n个接口请求函数的模块,函数的返回值是promise对象 4 | */ 5 | import ajax from './ajax' 6 | // const BASE_URL = 'http://localhost:4000' 7 | const BASE_URL = '/api' 8 | 9 | // 1.获取地址信息(根据经纬度串) 10 | // 这个接口的经纬度参数是在url路径里的param参数,没有query参数 11 | export const reqAddress = (geohash) => ajax(`${BASE_URL}/position/${geohash}`) 12 | 13 | // 2.获取 msite 页面食品分类列表 14 | export const reqCategorys = () => ajax(BASE_URL + '/index_category') 15 | 16 | // 3.获取 msite 商铺列表(根据query参数:经纬度) 17 | // 将经纬度两个数据作为一个参数对象传入 18 | // 也可以两个数据分别传入ajax, 然后再放入一个对象参数内, 如下面的手机号接口 19 | export const reqShops = ({latitude, longitude}) => ajax(BASE_URL + '/shops', {latitude, longitude}) 20 | 21 | // 4.根据经纬度和关键字搜索商铺列表 22 | export const reqSearchShop = (geohash, keyword) => ajax(BASE_URL + '/search_shops', {geohash, keyword}) 23 | 24 | // 5.获取一次性验证码 25 | // 不是ajax请求,src可通过methods改变 26 | 27 | // 6.账号密码登录 28 | export const reqPwdLogin = ({name, pwd, captcha}) => ajax(BASE_URL + '/login_pwd', {name, pwd, captcha}, 'POST') 29 | 30 | // 7.获取短信验证码 31 | export const reqSendCode = (phone) => ajax(BASE_URL + '/sendcode', {phone}) 32 | 33 | // 8.手机号验证码登录 34 | export const reqSmsLogin = (phone, code) => ajax(BASE_URL + '/login_sms', {phone, code}, 'POST') 35 | 36 | // 9.获取用户信息(根据会话) 37 | export const reqUserInfo = () => ajax(BASE_URL + '/userinfo') 38 | 39 | // 10.请求登出 40 | export const reqLogout = () => ajax(BASE_URL + '/logout') 41 | 42 | 43 | /** 44 | * 下列请求由mock拦截并返回 不需要代理 45 | */ 46 | // 获取商家信息 47 | export const reqShopInfo = () => ajax('/info') 48 | 49 | // 获取商家评价数组 50 | export const reqShopRatings = () => ajax('/ratings') 51 | 52 | // 获取商家商品数组 53 | export const reqShopGoods = () => ajax('/goods') 54 | -------------------------------------------------------------------------------- /src/pages/Shop/Shop.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 42 | 43 | 71 | -------------------------------------------------------------------------------- /src/components/CartControl/CartControl.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 24 | 25 | 63 | 64 | -------------------------------------------------------------------------------- /server/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var app = require('../app'); 8 | var debug = require('debug')('gweimai-server:server'); 9 | var http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | var port = normalizePort(process.env.PORT || '4000'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | var server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /src/store/mutations.js: -------------------------------------------------------------------------------- 1 | /* 2 | 直接更新state的多个方法的对象 3 | */ 4 | import Vue from 'vue' 5 | import { 6 | RECEIVE_ADDRESS, 7 | RECEIVE_CATEGORYS, 8 | RECEIVE_SHOPS, 9 | RECEIVE_USER_INFO, 10 | RESET_USER_INFO, 11 | RECEIVE_INFO, 12 | RECEIVE_RATINGS, 13 | RECEIVE_GOODS, 14 | INCREMENT_FOOD_COUNT, 15 | DECREMENT_FOOD_COUNT, 16 | CLEAR_CART, 17 | RECEIVE_SEARCH_SHOPS 18 | } from './mutation-types' 19 | 20 | export default { 21 | [RECEIVE_ADDRESS] (state, {address}) { 22 | state.address = address 23 | }, 24 | [RECEIVE_CATEGORYS] (state, {categorys}) { 25 | state.categorys = categorys 26 | }, 27 | [RECEIVE_SHOPS] (state, {shops}) { 28 | state.shops = shops 29 | }, 30 | [RECEIVE_USER_INFO] (state, {userInfo}) { 31 | state.userInfo = userInfo 32 | }, 33 | [RESET_USER_INFO] (state) { 34 | state.userInfo = {} 35 | }, 36 | 37 | [RECEIVE_INFO](state, {info}) { 38 | state.info = info 39 | }, 40 | [RECEIVE_RATINGS](state, {ratings}) { 41 | state.ratings = ratings 42 | }, 43 | [RECEIVE_GOODS](state, {goods}) { 44 | state.goods = goods 45 | }, 46 | 47 | [INCREMENT_FOOD_COUNT](state, {food}) { 48 | if(!food.count) { // 第一次增加 49 | // food.count = 1 // 新增属性(没有数据绑定) 50 | /* 51 | 对象 52 | 属性名 53 | 属性值 54 | */ 55 | Vue.set(food, 'count', 1) // 让新增的属性也有数据绑定 56 | // 将food添加到cartFoods中 57 | state.cartFoods.push(food) 58 | } else { 59 | food.count++ 60 | 61 | } 62 | }, 63 | [DECREMENT_FOOD_COUNT](state, {food}) { 64 | if(food.count) {// 只有有值才去减 65 | food.count-- 66 | if(food.count===0) { 67 | // 将food从cartFoods中移除 68 | state.cartFoods.splice(state.cartFoods.indexOf(food), 1) 69 | } 70 | } 71 | }, 72 | 73 | [CLEAR_CART](state) { 74 | 75 | // 清除food中的count 76 | state.cartFoods.forEach(food => food.count = 0) 77 | // 移除购物车中所有购物项 78 | state.cartFoods = [] 79 | }, 80 | 81 | [RECEIVE_SEARCH_SHOPS](state, {searchShops}) { 82 | state.searchShops = searchShops 83 | }, 84 | } -------------------------------------------------------------------------------- /src/components/FooterGuide/FooterGuide.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 40 | 41 | 71 | -------------------------------------------------------------------------------- /src/pages/Msite/images/msite_back.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /server/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var path = require('path'); 3 | var favicon = require('serve-favicon'); 4 | var logger = require('morgan'); 5 | var cookieParser = require('cookie-parser'); 6 | var bodyParser = require('body-parser'); 7 | var session = require('express-session'); 8 | 9 | var index = require('./routes/index'); 10 | var users = require('./routes/users'); 11 | 12 | var app = express(); 13 | /* 14 | app.all("*", function(req, res, next) { 15 | if (!req.get("Origin")) return next(); 16 | // use "*" here to accept any origin 17 | res.set("Access-Control-Allow-Origin", "*"); 18 | res.set("Access-Control-Allow-Methods", "GET"); 19 | res.set("Access-Control-Allow-Headers", "X-Requested-With, Content-Type"); 20 | // res.set('Access-Control-Allow-Max-Age', 3600); 21 | if ("OPTIONS" === req.method) return res.send(200); 22 | next(); 23 | }); 24 | */ 25 | 26 | // view engine setup 27 | app.set('views', path.join(__dirname, 'views')); 28 | app.set('view engine', 'ejs'); 29 | 30 | // uncomment after placing your favicon in /public 31 | //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 32 | app.use(logger('dev')); 33 | app.use(bodyParser.json()); 34 | app.use(bodyParser.urlencoded({ extended: false })); 35 | app.use(cookieParser()); 36 | app.use(express.static(path.join(__dirname, 'public'))); 37 | 38 | app.use(session({ 39 | secret: '12345', 40 | cookie: {maxAge: 1000*60*60*24 }, //设置maxAge是1天,即1天后session和相应的cookie失效过期 41 | resave: false, 42 | saveUninitialized: true, 43 | })); 44 | 45 | 46 | app.use('/', index); 47 | app.use('/users', users); 48 | 49 | // catch 404 and forward to error handler 50 | app.use(function(req, res, next) { 51 | var err = new Error('Not Found'); 52 | err.status = 404; 53 | next(err); 54 | }); 55 | 56 | // error handler 57 | app.use(function(err, req, res, next) { 58 | // set locals, only providing error in development 59 | res.locals.message = err.message; 60 | res.locals.error = req.app.get('env') === 'development' ? err : {}; 61 | 62 | // render the error page 63 | res.status(err.status || 500); 64 | res.render('error'); 65 | }); 66 | 67 | module.exports = app; 68 | -------------------------------------------------------------------------------- /static/css/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) 3 | * http://cssreset.com 4 | */ 5 | html, body, div, span, applet, object, iframe, 6 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 7 | a, abbr, acronym, address, big, cite, code, 8 | del, dfn, em, img, ins, kbd, q, s, samp, 9 | small, strike, strong, sub, sup, tt, var, 10 | b, u, i, center, 11 | dl, dt, dd, ol, ul, li, 12 | fieldset, form, label, legend, 13 | table, caption, tbody, tfoot, thead, tr, th, td, 14 | article, aside, canvas, details, embed, 15 | figure, figcaption, footer, header, 16 | menu, nav, output, ruby, section, summary, 17 | time, mark, audio, video, input { 18 | margin: 0; 19 | padding: 0; 20 | border: 0; 21 | font-size: 100%; 22 | font-weight: normal; 23 | vertical-align: baseline; 24 | } 25 | 26 | /* HTML5 display-role reset for older browsers */ 27 | article, aside, details, figcaption, figure, 28 | footer, header, menu, nav, section { 29 | display: block; 30 | } 31 | 32 | body { 33 | line-height: 1; 34 | } 35 | 36 | blockquote, q { 37 | quotes: none; 38 | } 39 | 40 | blockquote:before, blockquote:after, 41 | q:before, q:after { 42 | content: none; 43 | } 44 | 45 | table { 46 | border-collapse: collapse; 47 | border-spacing: 0; 48 | } 49 | 50 | /* custom */ 51 | a { 52 | color: #7e8c8d; 53 | text-decoration: none; 54 | -webkit-backface-visibility: hidden; 55 | } 56 | 57 | li { 58 | list-style: none; 59 | } 60 | 61 | ::-webkit-scrollbar { 62 | width: 5px; 63 | height: 5px; 64 | } 65 | 66 | ::-webkit-scrollbar-track-piece { 67 | background-color: rgba(0, 0, 0, 0.2); 68 | -webkit-border-radius: 6px; 69 | } 70 | 71 | ::-webkit-scrollbar-thumb:vertical { 72 | height: 5px; 73 | background-color: rgba(125, 125, 125, 0.7); 74 | -webkit-border-radius: 6px; 75 | } 76 | 77 | ::-webkit-scrollbar-thumb:horizontal { 78 | width: 5px; 79 | background-color: rgba(125, 125, 125, 0.7); 80 | -webkit-border-radius: 6px; 81 | } 82 | 83 | html, body { 84 | width: 100%; 85 | height: 100%; 86 | } 87 | 88 | body { 89 | -webkit-text-size-adjust: none; 90 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 91 | } 92 | 93 | /*显示省略号*/ 94 | .ellipsis{ 95 | overflow: hidden; 96 | text-overflow: ellipsis; 97 | white-space: nowrap; 98 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 简介 2 | 3 | ## 1. 项目描述 4 | 5 | 1. 此项目为一个前后端分离的外卖 Web App (SPA) 项目 6 | 2. 使用了 Vue 全家桶+ES6+Webpack 等前端技术 7 | 3. 包括商家, 商品, 购物车, 用户等多个功能子模块 8 | 4. 采用模块化、组件化、工程化的模式开发 9 | 10 | ## 2. 能从此项目中学到什么? 11 | 12 | ### 2.1 项目开发流程及开发方法 13 | 14 | 1. 熟悉一个项目的开发流程 15 | 2. 学会组件化、模块化、工程化的开发模式 16 | 3. 掌握使用 vue-cli 脚手架初始化 Vue.js 项目 17 | 4. 学会模拟 json 后端数据,实现前后端分离开发 18 | 5. 学会 ES6+eslint 的开发方式 19 | 6. 掌握一些项目优化技巧 20 | 21 | ### 2.2 Vue 插件或第三方库 22 | 23 | 1. 学会使用 vue-router 开发SPA单页应用 24 | 2. 学会使用 axios/vue-resource 与后端进行数据交互 25 | 3. 学会使用 vuex 管理应用组件状态 26 | 4. 学会使用 better-scroll/vue-scroller 实现页面滑动效果 27 | 5. 学会使用 mint-ui 组件库构建界面 28 | 6. 学会使用 vue-lazyload 实现图片惰加载 29 | 7. 学会使用 mockjs 模拟后台数据接口 30 | 31 | ### 2.3 样式/布局/效果相关 32 | 33 | 1. 学会使用 stylus 编写模块化的 CSS 34 | 2. 学会使用 Vue.js 的过渡编写酷炫的交互动画 35 | 3. 学会制作并使用图标字体 36 | 4. 学会解决移动端 1px 边框问题 37 | 5. 学会移动端经典的 css sticky footer 布局 38 | 6. 学会 flex 弹性布局 39 | 40 | ## 3. API接口文档 41 | 42 | [项目API接口文档](https://github.com/dragon-liu/vue2-takeaway/blob/main/server/API%E6%96%87%E6%A1%A3.md) 43 | 44 | ## 4. 运行项目 45 | 46 | **先运行服务器,再打开项目** 47 | 48 | 开启服务端程序之前要先安装mongdb,并且成功打开数据库连接 49 | 50 | **server文件夹下cmd命令:** 51 | 52 | 1. `npm install` 53 | 2. `npm start` 54 | 55 | **工程根目录下cmd命令:** 56 | 57 | 1. `npm install` 58 | 2. `npm start` 59 | 60 | **登陆** 61 | 62 | 1. 手机号登陆,需要自己注册容联云通讯后先添加一个测试账号,然后在server\util\sms_util.js中修改相应个人配置,之后输入符合格式的手机号即可 63 | 2. 密码登陆,默认用户名abc,密码123 64 | 65 | ## 5. 项目截图 66 | 67 | 1. 首页 68 | 69 | ![首页](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/QQ%E5%9B%BE%E7%89%8720211102110806.png?token=AJJYY5S4HG4VEOL4HCZ4AGDBQCW3M) 70 | 71 | 2. 订单 72 | 73 | ![订单](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/202111021133379.png) 74 | 75 | 3. 搜索 76 | 77 | ![搜索](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/202111021134670.png) 78 | 79 | 4. 个人 80 | 81 | ![个人](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/202111021135769.png) 82 | 83 | 5. 登陆 84 | 85 | ![登陆](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/202111021136950.png) 86 | 87 | 6. 商家信息 88 | 89 | ![商家信息](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/202111021137629.png) 90 | 91 | 7. 商家评价 92 | 93 | ![商家评价](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/202111021137465.png) 94 | 95 | 8. 商家详情 96 | 97 | ![商家详情](https://raw.githubusercontent.com/dragon-liu/picBed/master/img/202111021138618.png) 98 | -------------------------------------------------------------------------------- /src/components/Star/Star.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 47 | 48 | 99 | -------------------------------------------------------------------------------- /server/util/sms_util.js: -------------------------------------------------------------------------------- 1 | var md5 = require('blueimp-md5') 2 | var moment = require('moment') 3 | var Base64 = require('js-base64').Base64; 4 | var request = require('request'); 5 | 6 | /* 7 | 生成指定长度的随机数 8 | */ 9 | function randomCode(length) { 10 | var chars = ['0','1','2','3','4','5','6','7','8','9']; 11 | var result = ""; //统一改名: alt + shift + R 12 | for(var i = 0; i < length ; i ++) { 13 | var index = Math.ceil(Math.random()*9); 14 | result += chars[index]; 15 | } 16 | return result; 17 | } 18 | // console.log(randomCode(6)); 19 | exports.randomCode = randomCode; 20 | 21 | /* 22 | 向指定号码发送指定验证码 23 | */ 24 | function sendCode(phone, code, callback) { 25 | // ACCOUNT_SID,AUTH_TOKEN,AppID要填个人容联云通讯开发者主账号相应信息 26 | var ACCOUNT_SID = ''; 27 | var AUTH_TOKEN = ''; 28 | var Rest_URL = 'https://app.cloopen.com:8883'; 29 | var AppID = ''; 30 | //1. 准备请求url 31 | /* 32 | 1.使用MD5加密(账户Id + 账户授权令牌 + 时间戳)。其中账户Id和账户授权令牌根据url的验证级别对应主账户。 33 | 时间戳是当前系统时间,格式"yyyyMMddHHmmss"。时间戳有效时间为24小时,如:20140416142030 34 | 2.SigParameter参数需要大写,如不能写成sig=abcdefg而应该写成sig=ABCDEFG 35 | */ 36 | var sigParameter = ''; 37 | var time = moment().format('YYYYMMDDHHmmss'); 38 | sigParameter = md5(ACCOUNT_SID+AUTH_TOKEN+time); 39 | var url = Rest_URL+'/2013-12-26/Accounts/'+ACCOUNT_SID+'/SMS/TemplateSMS?sig='+sigParameter; 40 | 41 | //2. 准备请求体 42 | var body = { 43 | to : phone, 44 | appId : AppID, 45 | templateId : '1', 46 | "datas":[code,"1"] 47 | } 48 | //body = JSON.stringify(body); 49 | 50 | //3. 准备请求头 51 | /* 52 | 1.使用Base64编码(账户Id + 冒号 + 时间戳)其中账户Id根据url的验证级别对应主账户 53 | 2.冒号为英文冒号 54 | 3.时间戳是当前系统时间,格式"yyyyMMddHHmmss",需与SigParameter中时间戳相同。 55 | */ 56 | var authorization = ACCOUNT_SID + ':' + time; 57 | authorization = Base64.encode(authorization); 58 | var headers = { 59 | 'Accept' :'application/json', 60 | 'Content-Type' :'application/json;charset=utf-8', 61 | 'Content-Length': JSON.stringify(body).length+'', 62 | 'Authorization' : authorization 63 | } 64 | 65 | //4. 发送请求, 并得到返回的结果, 调用callback 66 | // callback(true); 67 | request({ 68 | method : 'POST', 69 | url : url, 70 | headers : headers, 71 | body : body, 72 | json : true 73 | }, function (error, response, body) { 74 | console.log(error, response, body); 75 | callback(body.statusCode==='000000'); 76 | // callback(true); 77 | }); 78 | } 79 | exports.sendCode = sendCode; 80 | 81 | /* 82 | sendCode('13716962779', randomCode(6), function (success) { 83 | console.log(success); 84 | })*/ 85 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | 路由器对象模块 3 | */ 4 | import Vue from 'vue' 5 | import VueRouter from 'vue-router' 6 | 7 | // import MSite from '@/pages/MSite/MSite' 8 | // import Search from '@/pages/Search/Search' 9 | // import Order from '@/pages/Order/Order' 10 | // import Profile from '@/pages/Profile/Profile' 11 | // import Login from '@/pages/Login/Login' 12 | // import Shop from '@/pages/Shop/Shop' 13 | 14 | const MSite = () => import('../pages/MSite/MSite.vue') 15 | const Search = () => import('../pages/Search/Search.vue') 16 | const Order = () => import('../pages/Order/Order.vue') 17 | const Profile = () => import('../pages/Profile/Profile.vue') 18 | const Login = () => import('@/pages/Login/Login') 19 | const Shop = () => import('@/pages/Shop/Shop') 20 | 21 | import ShopGoods from '@/pages/Shop/ShopGoods/ShopGoods' 22 | import ShopRatings from '@/pages/Shop/ShopRatings/ShopRatings' 23 | import ShopInfo from '@/pages/Shop/ShopInfo/ShopInfo' 24 | 25 | // 声明使用插件 26 | Vue.use(VueRouter) 27 | 28 | export default new VueRouter({ 29 | // 所有路由 30 | routes: [ 31 | { // 默认重定向至/msite 32 | path: '/', 33 | redirect: '/msite' 34 | }, 35 | { 36 | path: '/msite', 37 | component: MSite, 38 | // 元数据,用于控制是否显示底部导航栏 39 | meta: { 40 | showFooter: true 41 | } 42 | }, 43 | { 44 | path: '/search', 45 | component: Search, 46 | meta: { 47 | showFooter: true 48 | } 49 | }, 50 | { 51 | path: '/order', 52 | component: Order, 53 | meta: { 54 | showFooter: true 55 | } 56 | }, 57 | { 58 | path: '/profile', 59 | component: Profile, 60 | meta: { 61 | showFooter: true 62 | } 63 | }, 64 | { 65 | path: '/login', 66 | component: Login 67 | }, 68 | { 69 | path: '/shop', 70 | component: Shop, 71 | children: [ 72 | { 73 | path: 'goods', 74 | component: ShopGoods 75 | }, 76 | { 77 | path: 'ratings', 78 | component: ShopRatings 79 | }, 80 | { 81 | path: 'info', 82 | component: ShopInfo 83 | }, 84 | { // 默认重定向至/shop/goods 85 | path: '', 86 | redirect: 'goods' 87 | } 88 | ] 89 | } 90 | ] 91 | }) 92 | 93 | /*解决重复点击同一个标签实现路由跳转报错问题:下面三行语句解决报错问题 94 | * Uncaught (in promise) NavigationDuplicated 95 | * {_name: “NavigationDuplicated”, name: "NavigationDuplic}的报错问*/ 96 | const VueRouterReplace = VueRouter.prototype.replace; 97 | VueRouter.prototype.replace = function replace (to) { 98 | return VueRouterReplace.call(this, to).catch(err => err); 99 | } 100 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gshop-client", 3 | "version": "1.0.0", 4 | "description": "A Vue.js project", 5 | "author": "zxfjd3g <258147149@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 | "lint": "eslint --ext .js,.vue src", 11 | "build": "node build/build.js" 12 | }, 13 | "dependencies": { 14 | "axios": "^0.18.0", 15 | "better-scroll": "^2.4.2", 16 | "date-fns": "^2.25.0", 17 | "mint-ui": "^2.2.13", 18 | "mockjs": "^1.1.0", 19 | "moment": "^2.29.1", 20 | "swiper": "^4.2.6", 21 | "vue": "^2.5.2", 22 | "vue-lazyload": "^1.3.3", 23 | "vue-router": "^3.5.2", 24 | "vuex": "^3.6.2" 25 | }, 26 | "devDependencies": { 27 | "autoprefixer": "^7.1.2", 28 | "babel-core": "^6.22.1", 29 | "babel-eslint": "^8.2.1", 30 | "babel-helper-vue-jsx-merge-props": "^2.0.3", 31 | "babel-loader": "^7.1.1", 32 | "babel-plugin-component": "^1.1.1", 33 | "babel-plugin-syntax-jsx": "^6.18.0", 34 | "babel-plugin-transform-runtime": "^6.22.0", 35 | "babel-plugin-transform-vue-jsx": "^3.5.0", 36 | "babel-preset-env": "^1.3.2", 37 | "babel-preset-stage-2": "^6.22.0", 38 | "chalk": "^2.0.1", 39 | "copy-webpack-plugin": "^4.0.1", 40 | "css-loader": "^0.28.0", 41 | "eslint": "^4.15.0", 42 | "eslint-config-standard": "^10.2.1", 43 | "eslint-friendly-formatter": "^3.0.0", 44 | "eslint-loader": "^1.7.1", 45 | "eslint-plugin-import": "^2.7.0", 46 | "eslint-plugin-node": "^5.2.0", 47 | "eslint-plugin-promise": "^3.4.0", 48 | "eslint-plugin-standard": "^3.0.1", 49 | "eslint-plugin-vue": "^4.0.0", 50 | "extract-text-webpack-plugin": "^3.0.0", 51 | "file-loader": "^1.1.4", 52 | "friendly-errors-webpack-plugin": "^1.6.1", 53 | "html-webpack-plugin": "^2.30.1", 54 | "node-notifier": "^5.1.2", 55 | "optimize-css-assets-webpack-plugin": "^3.2.0", 56 | "ora": "^1.2.0", 57 | "portfinder": "^1.0.13", 58 | "postcss-import": "^11.0.0", 59 | "postcss-loader": "^2.0.8", 60 | "postcss-url": "^7.2.1", 61 | "rimraf": "^2.6.0", 62 | "semver": "^5.3.0", 63 | "shelljs": "^0.7.6", 64 | "stylus": "^0.54.5", 65 | "stylus-loader": "^3.0.2", 66 | "uglifyjs-webpack-plugin": "^1.1.1", 67 | "url-loader": "^0.5.8", 68 | "vue-loader": "^13.3.0", 69 | "vue-style-loader": "^3.0.1", 70 | "vue-template-compiler": "^2.5.2", 71 | "webpack": "^3.6.0", 72 | "webpack-bundle-analyzer": "^2.9.0", 73 | "webpack-dev-server": "^2.9.1", 74 | "webpack-merge": "^4.1.0" 75 | }, 76 | "engines": { 77 | "node": ">= 6.0.0", 78 | "npm": ">= 3.0.0" 79 | }, 80 | "browserslist": [ 81 | "> 1%", 82 | "last 2 versions", 83 | "not ie <= 8" 84 | ] 85 | } 86 | -------------------------------------------------------------------------------- /src/components/AlertTip/AlertTip.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 29 | 30 | 108 | -------------------------------------------------------------------------------- /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 | // 静态资源文件夹 12 | assetsSubDirectory: 'static', 13 | // 发布路径 14 | assetsPublicPath: '/', 15 | 16 | // 代理配置表,在这里可以配置特定的请求代理到对应的API接口 17 | // 例如将'localhost:8080/api/xxx'代理到'www.example.com/api/xxx' 18 | proxyTable: { 19 | '/api': { // 匹配所有以 '/api'开头的请求路径 20 | target: 'http://localhost:4000', // 代理目标的基础路径 21 | // secure: false, // 如果是https接口,需要配置这个参数 22 | changeOrigin: true, // changeOrigin设置为true时,服务器收到的请求头中的host为:localhost:4000;设置为false则为localhost:8080 23 | pathRewrite: { // 重写路径: 去掉路径中开头的'/api' 24 | '^/api': '' 25 | } 26 | } 27 | }, 28 | 29 | // Various Dev Server settings 30 | host: 'localhost', // can be overwritten by process.env.HOST 31 | port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 32 | autoOpenBrowser: true, 33 | errorOverlay: true, 34 | notifyOnErrors: true, 35 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 36 | 37 | // Use Eslint Loader? 38 | // If true, your code will be linted during bundling and 39 | // linting errors and warnings will be shown in the console. 40 | useEslint: true, 41 | // If true, eslint errors and warnings will also be shown in the error overlay 42 | // in the browser. 43 | showEslintErrorsInOverlay: false, 44 | 45 | /** 46 | * Source Maps 47 | */ 48 | 49 | // https://webpack.js.org/configuration/devtool/#development 50 | devtool: 'cheap-module-eval-source-map', 51 | 52 | // If you have problems debugging vue-files in devtools, 53 | // set this to false - it *may* help 54 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 55 | cacheBusting: true, 56 | 57 | cssSourceMap: true 58 | }, 59 | 60 | build: { 61 | // Template for index.html 62 | index: path.resolve(__dirname, '../dist/index.html'), 63 | 64 | // Paths 65 | assetsRoot: path.resolve(__dirname, '../dist'), 66 | assetsSubDirectory: 'static', 67 | assetsPublicPath: '/', 68 | 69 | /** 70 | * Source Maps 71 | */ 72 | 73 | productionSourceMap: true, 74 | // https://webpack.js.org/configuration/devtool/#production 75 | devtool: '#source-map', 76 | 77 | // Gzip off by default as many popular static hosts such as 78 | // Surge or Netlify already gzip all static assets for you. 79 | // Before setting to `true`, make sure to: 80 | // npm install --save-dev compression-webpack-plugin 81 | productionGzip: false, 82 | productionGzipExtensions: ['js', 'css'], 83 | 84 | // Run the build command with an extra argument to 85 | // View the bundle analyzer report after build finishes: 86 | // `npm run build --report` 87 | // Set to `true` or `false` to always turn it on or off 88 | bundleAnalyzerReport: process.env.npm_config_report 89 | } 90 | } -------------------------------------------------------------------------------- /src/store/actions.js: -------------------------------------------------------------------------------- 1 | /* 2 | 通过mutation间接更新state的多个方法的对象 3 | */ 4 | import { 5 | RECEIVE_ADDRESS, 6 | RECEIVE_CATEGORYS, 7 | RECEIVE_SHOPS, 8 | RECEIVE_USER_INFO, 9 | RESET_USER_INFO, 10 | RECEIVE_GOODS, 11 | RECEIVE_RATINGS, 12 | RECEIVE_INFO, 13 | INCREMENT_FOOD_COUNT, 14 | DECREMENT_FOOD_COUNT, 15 | CLEAR_CART, 16 | RECEIVE_SEARCH_SHOPS 17 | } from './mutation-types' 18 | import { 19 | reqAddress, 20 | reqCategorys, 21 | reqShops, 22 | reqUserInfo, 23 | reqLogout, 24 | reqShopRatings, 25 | reqShopGoods, 26 | reqShopInfo, 27 | reqSearchShop 28 | } from '../api' 29 | 30 | export default { 31 | // 异步获取地址 32 | async getAddress({commit, state}) { 33 | // 发送异步ajax请求 34 | const geohash = state.latitude + ',' + state.longitude 35 | const result = await reqAddress(geohash) 36 | // 提交一个mutation 37 | if (result.code === 0) { 38 | const address = result.data 39 | commit(RECEIVE_ADDRESS, {address}) 40 | } 41 | }, 42 | 43 | // 异步获取食品分类列表 44 | async getCategorys({commit}) { 45 | // 发送异步ajax请求 46 | const result = await reqCategorys() 47 | // 提交一个mutation 48 | if (result.code === 0) { 49 | const categorys = result.data 50 | commit(RECEIVE_CATEGORYS, {categorys}) 51 | } 52 | }, 53 | 54 | // 异步获取商家列表 55 | async getShops({commit, state}) { 56 | // 发送异步ajax请求 57 | const result = await reqShops(state) 58 | // 提交一个mutation 59 | if (result.code === 0) { 60 | const shops = result.data 61 | commit(RECEIVE_SHOPS, {shops}) 62 | } 63 | }, 64 | 65 | // 同步记录用户信息 66 | recordUser({commit}, userInfo) { 67 | commit(RECEIVE_USER_INFO, {userInfo}) 68 | }, 69 | 70 | // 异步获取用户信息 71 | async getUserInfo({commit}) { 72 | const result = await reqUserInfo() 73 | if (result.code === 0) { 74 | const userInfo = result.data 75 | commit(RECEIVE_USER_INFO, {userInfo}) 76 | } 77 | }, 78 | 79 | // 异步登出 80 | async logout({commit}) { 81 | const result = await reqLogout() 82 | if (result.code === 0) { 83 | commit(RESET_USER_INFO) 84 | } 85 | }, 86 | 87 | // 异步获取商家信息 88 | async getShopInfo({commit}) { 89 | const result = await reqShopInfo() 90 | if (result.code === 0) { 91 | const info = result.data 92 | commit(RECEIVE_INFO, {info}) 93 | } 94 | }, 95 | 96 | // 异步获取商家评价列表 97 | async getShopRatings({commit}, callback) { 98 | const result = await reqShopRatings() 99 | if (result.code === 0) { 100 | const ratings = result.data 101 | commit(RECEIVE_RATINGS, {ratings}) 102 | // 数据更新了, 通知一下组件 103 | callback && callback() 104 | } 105 | }, 106 | 107 | // 异步获取商家商品列表 108 | async getShopGoods({commit}, callback) { 109 | const result = await reqShopGoods() 110 | if (result.code === 0) { 111 | const goods = result.data 112 | commit(RECEIVE_GOODS, {goods}) 113 | // 数据更新了, 通知一下组件 114 | callback && callback() 115 | } 116 | }, 117 | 118 | // 同步更新food中的count值 119 | updateFoodCount({commit}, {isAdd, food}) { 120 | if (isAdd) { 121 | commit(INCREMENT_FOOD_COUNT, {food}) 122 | } else { 123 | commit(DECREMENT_FOOD_COUNT, {food}) 124 | } 125 | }, 126 | 127 | // 同步清空购物车 128 | clearCart({commit}) { 129 | commit(CLEAR_CART) 130 | }, 131 | 132 | // 异步获取附近商家商品列表 133 | async searchShops({commit, state}, keyword) { 134 | 135 | const geohash = state.latitude + ',' + state.longitude 136 | const result = await reqSearchShop(geohash, keyword) 137 | if (result.code === 0) { 138 | const searchShops = result.data 139 | commit(RECEIVE_SEARCH_SHOPS, {searchShops}) 140 | } 141 | }, 142 | } 143 | 144 | -------------------------------------------------------------------------------- /src/pages/Search/Search.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 78 | 79 | -------------------------------------------------------------------------------- /src/components/Food/Food.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 53 | 54 | -------------------------------------------------------------------------------- /server/routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | const md5 = require('blueimp-md5') 4 | const models = require('../db/models') 5 | const UserModel = models.getModel('user') 6 | const _filter = {'pwd': 0, '__v': 0} // 查询时过滤掉 7 | const sms_util = require('../util/sms_util') 8 | const users = {} 9 | const ajax = require('../api/ajax') 10 | var svgCaptcha = require('svg-captcha') 11 | 12 | /* 13 | 密码登陆 14 | */ 15 | router.post('/login_pwd', function (req, res) { 16 | const name = req.body.name 17 | const pwd = md5(req.body.pwd) 18 | const captcha = req.body.captcha.toLowerCase() 19 | console.log('/login_pwd', name, pwd, captcha, req.session) 20 | 21 | // 可以对用户名/密码格式进行检查, 如果非法, 返回提示信息 22 | if(captcha!==req.session.captcha) { 23 | return res.send({code: 1, msg: '验证码不正确'}) 24 | } 25 | // 删除保存的验证码 26 | delete req.session.captcha 27 | 28 | UserModel.findOne({name}, function (err, user) { 29 | if (user) { 30 | console.log('findUser', user) 31 | if (user.pwd !== pwd) { 32 | res.send({code: 1, msg: '用户名或密码不正确!'}) 33 | } else { 34 | req.session.userid = user._id 35 | res.send({code: 0, data: {_id: user._id, name: user.name, phone: user.phone}}) 36 | } 37 | } else { 38 | const userModel = new UserModel({name, pwd}) 39 | userModel.save(function (err, user) { 40 | // 向浏览器端返回cookie(key=value) 41 | // res.cookie('userid', user._id, {maxAge: 1000*60*60*24*7}) 42 | req.session.userid = user._id 43 | const data = {_id: user._id, name: user.name} 44 | // 3.2. 返回数据(新的user) 45 | res.send({code: 0, data}) 46 | }) 47 | } 48 | }) 49 | }) 50 | 51 | /* 52 | 一次性图形验证码 53 | */ 54 | router.get('/captcha', function (req, res) { 55 | var captcha = svgCaptcha.create({ 56 | ignoreChars: '0o1l', 57 | noise: 2, 58 | color: true 59 | }); 60 | req.session.captcha = captcha.text.toLowerCase(); 61 | console.log(req.session.captcha) 62 | /*res.type('svg'); 63 | res.status(200).send(captcha.data);*/ 64 | res.type('svg'); 65 | res.send(captcha.data) 66 | }); 67 | 68 | /* 69 | 发送验证码短信 70 | */ 71 | router.get('/sendcode', function (req, res, next) { 72 | //1. 获取请求参数数据 73 | var phone = req.query.phone; 74 | //2. 处理数据 75 | //生成验证码(6位随机数) 76 | var code = sms_util.randomCode(6); 77 | //发送给指定的手机号 78 | console.log(`向${phone}发送验证码短信: ${code}`); 79 | sms_util.sendCode(phone, code, function (success) {//success表示是否成功 80 | if (success) { 81 | users[phone] = code 82 | console.log('保存验证码: ', phone, code) 83 | res.send({"code": 0}) 84 | } else { 85 | //3. 返回响应数据 86 | res.send({"code": 1, msg: '短信验证码发送失败'}) 87 | } 88 | }) 89 | }) 90 | 91 | /* 92 | 短信登陆 93 | */ 94 | router.post('/login_sms', function (req, res, next) { 95 | var phone = req.body.phone; 96 | var code = req.body.code; 97 | console.log('/login_sms', phone, code); 98 | if (users[phone] != code) { 99 | res.send({code: 1, msg: '手机号或验证码不正确'}); 100 | return; 101 | } 102 | //删除保存的code 103 | delete users[phone]; 104 | 105 | 106 | UserModel.findOne({phone}, function (err, user) { 107 | if (user) { 108 | req.session.userid = user._id 109 | res.send({code: 0, data: user}) 110 | } else { 111 | //存储数据 112 | const userModel = new UserModel({phone}) 113 | userModel.save(function (err, user) { 114 | req.session.userid = user._id 115 | res.send({code: 0, data: user}) 116 | }) 117 | } 118 | }) 119 | 120 | }) 121 | 122 | /* 123 | 根据sesion中的userid, 查询对应的user 124 | */ 125 | router.get('/userinfo', function (req, res) { 126 | // 取出userid 127 | const userid = req.session.userid 128 | // 查询 129 | UserModel.findOne({_id: userid}, _filter, function (err, user) { 130 | // 如果没有, 返回错误提示 131 | if (!user) { 132 | // 清除浏览器保存的userid的cookie 133 | delete req.session.userid 134 | 135 | res.send({code: 1, msg: '请先登陆'}) 136 | } else { 137 | // 如果有, 返回user 138 | res.send({code: 0, data: user}) 139 | } 140 | }) 141 | }) 142 | 143 | 144 | router.get('/logout', function (req, res) { 145 | // 清除浏览器保存的userid的cookie 146 | delete req.session.userid 147 | // 返回数据 148 | res.send({code: 0}) 149 | }) 150 | 151 | /* 152 | 根据经纬度获取位置详情 153 | */ 154 | router.get('/position/:geohash', function (req, res) { 155 | const {geohash} = req.params 156 | ajax(`http://cangdu.org:8001/v2/pois/${geohash}`) 157 | .then(data => { 158 | res.send({code: 0, data}) 159 | }) 160 | }) 161 | 162 | /* 163 | 获取首页分类列表 164 | */ 165 | router.get('/index_category', function (req, res) { 166 | setTimeout(function () { 167 | const data = require('../data/index_category.json') 168 | res.send({code: 0, data}) 169 | }, 300) 170 | }) 171 | 172 | /* 173 | 根据经纬度获取商铺列表 174 | ?latitude=40.10038&longitude=116.36867 175 | */ 176 | router.get('/shops', function (req, res) { 177 | const latitude = req.query.latitude 178 | const longitude = req.query.longitude 179 | 180 | setTimeout(function () { 181 | const data = require('../data/shops.json') 182 | res.send({code: 0, data}) 183 | }, 300) 184 | }) 185 | 186 | router.get('/search_shops', function (req, res) { 187 | const {geohash, keyword} = req.query 188 | ajax('http://cangdu.org:8001/v4/restaurants', { 189 | 'extras[]': 'restaurant_activity', 190 | geohash, 191 | keyword, 192 | type: 'search' 193 | }).then(data => { 194 | res.send({code: 0, data}) 195 | }) 196 | }) 197 | 198 | module.exports = router; -------------------------------------------------------------------------------- /src/pages/Msite/MSite.vue: -------------------------------------------------------------------------------- 1 | 45 | 46 | 136 | 137 | 192 | -------------------------------------------------------------------------------- /src/components/ShopList/ShopList.vue: -------------------------------------------------------------------------------- 1 | 49 | 50 | 72 | 73 | 178 | -------------------------------------------------------------------------------- /src/pages/Shop/ShopInfo/ShopInfo.vue: -------------------------------------------------------------------------------- 1 | 57 | 58 | 105 | 106 | 224 | 225 | -------------------------------------------------------------------------------- /src/pages/Profile/Profile.vue: -------------------------------------------------------------------------------- 1 | 96 | 97 | 126 | 127 | 261 | -------------------------------------------------------------------------------- /src/pages/Shop/ShopGoods/ShopGoods.vue: -------------------------------------------------------------------------------- 1 | 70 | 71 | 177 | 178 | 281 | -------------------------------------------------------------------------------- /src/components/ShopCart/ShopCart.vue: -------------------------------------------------------------------------------- 1 | 48 | 49 | 121 | 122 | 294 | -------------------------------------------------------------------------------- /src/pages/Login/images/captcha.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 12 | -------------------------------------------------------------------------------- /src/pages/Shop/ShopRatings/ShopRatings.vue: -------------------------------------------------------------------------------- 1 | 74 | 75 | 137 | 138 | 318 | 319 | 320 | 321 | -------------------------------------------------------------------------------- /src/pages/Login/Login.vue: -------------------------------------------------------------------------------- 1 | 70 | 71 | 206 | 207 | 346 | -------------------------------------------------------------------------------- /server/data/index_category.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 20, 4 | "is_in_serving": true, 5 | "description": "苦了累了,来点甜的", 6 | "title": "甜品饮品", 7 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu751c%5Cu54c1%5Cu996e%5Cu54c1%22%2C%22complex_category_ids%22%3A%5B240%2C241%2C242%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A239%2C%22name%22%3A%22%5Cu751c%5Cu54c1%5Cu996e%5Cu54c1%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E7%94%9C%E5%93%81%E9%A5%AE%E5%93%81&animation_type=1&is_need_mark=0&banner_type=", 8 | "image_url": "/2/35/696aa5cf9820adada9b11a3d14bf5jpeg.jpeg", 9 | "icon_url": "", 10 | "title_color": "", 11 | "__v": 0 12 | }, 13 | { 14 | "id": 10, 15 | "is_in_serving": true, 16 | "description": "足不出户,便利回家", 17 | "title": "商超便利", 18 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu5546%5Cu8d85%5Cu4fbf%5Cu5229%22%2C%22complex_category_ids%22%3A%5B254%2C255%2C256%2C257%2C258%2C271%2C272%2C273%2C274%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A252%2C%22name%22%3A%22%5Cu5546%5Cu5e97%5Cu8d85%5Cu5e02%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E5%95%86%E8%B6%85%E4%BE%BF%E5%88%A9&animation_type=1&is_need_mark=0&banner_type=", 19 | "image_url": "/0/da/f42235e6929a5cb0e7013115ce78djpeg.jpeg", 20 | "icon_url": "", 21 | "title_color": "", 22 | "__v": 0 23 | }, 24 | { 25 | "id": 15, 26 | "is_in_serving": true, 27 | "description": "附近美食一网打尽", 28 | "title": "美食", 29 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu7f8e%5Cu98df%22%2C%22complex_category_ids%22%3A%5B207%2C220%2C233%2C260%5D%2C%22is_show_all_category%22%3Afalse%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A207%2C%22name%22%3A%22%5Cu5feb%5Cu9910%5Cu4fbf%5Cu5f53%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E7%BE%8E%E9%A3%9F&animation_type=1&is_need_mark=0&banner_type=", 30 | "image_url": "/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg", 31 | "icon_url": "", 32 | "title_color": "", 33 | "__v": 0 34 | }, 35 | { 36 | "id": 225, 37 | "is_in_serving": true, 38 | "description": "有菜有肉,营养均衡", 39 | "title": "简餐", 40 | "link": "eleme://restaurants?filter_key=%7B%22activity_types%22%3A%5B3%5D%2C%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu7b80%5Cu9910%22%2C%22complex_category_ids%22%3A%5B209%2C212%2C215%2C265%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A207%2C%22name%22%3A%22%5Cu5feb%5Cu9910%5Cu4fbf%5Cu5f53%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%7B%22id%22%3A3%2C%22name%22%3A%22%5Cu4e0b%5Cu5355%5Cu7acb%5Cu51cf%22%2C%22icon_name%22%3A%22%5Cu51cf%22%2C%22icon_color%22%3A%22f07373%22%2C%22is_need_filling%22%3A1%2C%22is_multi_choice%22%3A0%2C%22filter_value%22%3A3%2C%22filter_key%22%3A%22activity_types%22%7D%5D%7D&target_name=%E7%AE%80%E9%A4%90&animation_type=1&is_need_mark=0&banner_type=", 41 | "image_url": "/d/38/7bddb07503aea4b711236348e2632jpeg.jpeg", 42 | "icon_url": "", 43 | "title_color": "", 44 | "__v": 0 45 | }, 46 | { 47 | "id": 403297, 48 | "is_in_serving": true, 49 | "description": "大胆尝鲜,遇见惊喜", 50 | "title": "新店特惠", 51 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu65b0%5Cu5e97%5Cu7279%5Cu60e0%22%2C%22complex_category_ids%22%3A%5B207%2C220%2C233%2C239%2C244%2C248%2C252%2C260%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A207%2C%22name%22%3A%22%5Cu5feb%5Cu9910%5Cu4fbf%5Cu5f53%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22support_ids%22%3A%5B-1%5D%2C%22activities%22%3A%5B%5D%7D&target_name=%E6%96%B0%E5%BA%97%E7%89%B9%E6%83%A0&animation_type=1&is_need_mark=0&banner_type=", 52 | "image_url": "/a/fa/d41b04d520d445dc5de42dae9a384jpeg.jpeg", 53 | "icon_url": "", 54 | "title_color": "", 55 | "__v": 0 56 | }, 57 | { 58 | "id": 92, 59 | "is_in_serving": true, 60 | "description": "准时必达,超时赔付", 61 | "title": "准时达", 62 | "link": "eleme://restaurants?filter_key=%7B%22support_ids%22%3A%5B9%5D%2C%22activities%22%3A%5B%7B%22id%22%3A9%2C%22name%22%3A%22%5Cu51c6%5Cu65f6%5Cu8fbe%22%2C%22icon_name%22%3A%22%5Cu51c6%22%2C%22icon_color%22%3A%22E8842D%22%2C%22is_need_filling%22%3A0%2C%22is_multi_choice%22%3A1%2C%22filter_value%22%3A9%2C%22filter_key%22%3A%22support_ids%22%2C%22description%22%3A%22%5Cu51c6%5Cu65f6%5Cu8fbe%22%7D%5D%7D&target_name=%E5%87%86%E6%97%B6%E8%BE%BE&animation_type=1&is_need_mark=0&banner_type=", 63 | "image_url": "/3/84/8e031bf7b3c036b4ec19edff16e46jpeg.jpeg", 64 | "icon_url": "", 65 | "title_color": "", 66 | "__v": 0 67 | }, 68 | { 69 | "id": 1, 70 | "is_in_serving": true, 71 | "description": "0元早餐0起送,每天都有新花样。", 72 | "title": "预订早餐", 73 | "link": "eleme://web?url=https%3A%2F%2Fzaocan.ele.me&target_name=%E9%A2%84%E8%AE%A2%E6%97%A9%E9%A4%90&animation_type=1&is_need_mark=&banner_type=", 74 | "image_url": "/d/49/7757ff22e8ab28e7dfa5f7e2c2692jpeg.jpeg", 75 | "icon_url": "", 76 | "title_color": "", 77 | "__v": 0 78 | }, 79 | { 80 | "id": 65, 81 | "is_in_serving": true, 82 | "description": "", 83 | "title": "土豪推荐", 84 | "link": "eleme://restaurants?filter_key=%7B%22activities%22%3A%5B%7B%22filter_key%22%3A%22tags%22%2C%22filter_value%22%3A0%7D%5D%7D&target_name=%E5%9C%9F%E8%B1%AA%E6%8E%A8%E8%8D%90&animation_type=1&is_need_mark=0&banner_type=", 85 | "image_url": "/e/7e/02b72b5e63c127d5bfae57b8e4ab1jpeg.jpeg", 86 | "icon_url": "", 87 | "title_color": "", 88 | "__v": 0 89 | }, 90 | { 91 | "id": 288, 92 | "is_in_serving": true, 93 | "description": "无辣不欢", 94 | "title": "川湘菜", 95 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu5ddd%5Cu6e58%5Cu83dc%22%2C%22complex_category_ids%22%3A%5B221%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A220%2C%22name%22%3A%22%5Cu7279%5Cu8272%5Cu83dc%5Cu7cfb%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E5%B7%9D%E6%B9%98%E8%8F%9C&animation_type=1&is_need_mark=0&banner_type=", 96 | "image_url": "/9/7c/9700836a33e05c2410bda8da59117jpeg.jpeg", 97 | "icon_url": "", 98 | "title_color": "", 99 | "__v": 0 100 | }, 101 | { 102 | "id": 286, 103 | "is_in_serving": true, 104 | "description": "", 105 | "title": "麻辣烫", 106 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu9ebb%5Cu8fa3%5Cu70eb%22%2C%22complex_category_ids%22%3A%5B214%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A207%2C%22name%22%3A%22%5Cu5feb%5Cu9910%5Cu4fbf%5Cu5f53%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E9%BA%BB%E8%BE%A3%E7%83%AB&animation_type=1&is_need_mark=0&banner_type=", 107 | "image_url": "/3/c7/a9ef469a12e7a596b559145b87f09jpeg.jpeg", 108 | "icon_url": "", 109 | "title_color": "", 110 | "__v": 0 111 | }, 112 | { 113 | "id": 289, 114 | "is_in_serving": true, 115 | "description": "老字号,好味道", 116 | "title": "包子粥店", 117 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu5305%5Cu5b50%5Cu7ca5%5Cu5e97%22%2C%22complex_category_ids%22%3A%5B215%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A207%2C%22name%22%3A%22%5Cu5feb%5Cu9910%5Cu4fbf%5Cu5f53%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E5%8C%85%E5%AD%90%E7%B2%A5%E5%BA%97&animation_type=1&is_need_mark=0&banner_type=", 118 | "image_url": "/2/17/244241b514affc0f12f4168cf6628jpeg.jpeg", 119 | "icon_url": "", 120 | "title_color": "", 121 | "__v": 0 122 | }, 123 | { 124 | "id": 9, 125 | "is_in_serving": true, 126 | "description": "内心小公举,一直被宠爱", 127 | "title": "鲜花蛋糕", 128 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu9c9c%5Cu82b1%5Cu86cb%5Cu7cd5%22%2C%22complex_category_ids%22%3A%5B249%2C250%2C251%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A248%2C%22name%22%3A%22%5Cu9c9c%5Cu82b1%5Cu86cb%5Cu7cd5%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E9%B2%9C%E8%8A%B1%E8%9B%8B%E7%B3%95&animation_type=1&is_need_mark=0&banner_type=", 129 | "image_url": "/8/83/171fd98b85dee3b3f4243b7459b48jpeg.jpeg", 130 | "icon_url": "", 131 | "title_color": "", 132 | "__v": 0 133 | }, 134 | { 135 | "id": 285, 136 | "is_in_serving": true, 137 | "description": "寿司定食,泡菜烤肉", 138 | "title": "日韩料理", 139 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu65e5%5Cu97e9%5Cu6599%5Cu7406%22%2C%22complex_category_ids%22%3A%5B229%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A260%2C%22name%22%3A%22%5Cu5f02%5Cu56fd%5Cu6599%5Cu7406%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E6%97%A5%E9%9F%A9%E6%96%99%E7%90%86&animation_type=1&is_need_mark=0&banner_type=", 140 | "image_url": "/6/1a/1e0f448be0624c62db416e864d2afjpeg.jpeg", 141 | "icon_url": "", 142 | "title_color": "", 143 | "__v": 0 144 | }, 145 | { 146 | "id": 8, 147 | "is_in_serving": true, 148 | "description": "一天变女神", 149 | "title": "果蔬生鲜", 150 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu679c%5Cu852c%5Cu751f%5Cu9c9c%22%2C%22complex_category_ids%22%3A%5B245%2C246%2C247%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A244%2C%22name%22%3A%22%5Cu679c%5Cu852c%5Cu751f%5Cu9c9c%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E6%9E%9C%E8%94%AC%E7%94%9F%E9%B2%9C&animation_type=1&is_need_mark=0&banner_type=", 151 | "image_url": "/4/34/ea0d51c9608310cf41faa5de6b8efjpeg.jpeg", 152 | "icon_url": "", 153 | "title_color": "", 154 | "__v": 0 155 | }, 156 | { 157 | "id": 236, 158 | "is_in_serving": true, 159 | "description": "大口大口把你吃掉", 160 | "title": "汉堡薯条", 161 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu6c49%5Cu5821%22%2C%22complex_category_ids%22%3A%5B212%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A207%2C%22name%22%3A%22%5Cu5feb%5Cu9910%5Cu4fbf%5Cu5f53%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E6%B1%89%E5%A0%A1%E8%96%AF%E6%9D%A1&animation_type=1&is_need_mark=0&banner_type=", 162 | "image_url": "/b/7f/432619fb21a40b05cd25d11eca02djpeg.jpeg", 163 | "icon_url": "", 164 | "title_color": "", 165 | "__v": 0 166 | }, 167 | { 168 | "id": 287, 169 | "is_in_serving": true, 170 | "description": "西餐始祖,欧洲的味道", 171 | "title": "披萨意面", 172 | "link": "eleme://restaurants?filter_key=%7B%22category_schema%22%3A%7B%22category_name%22%3A%22%5Cu62ab%5Cu8428%5Cu610f%5Cu9762%22%2C%22complex_category_ids%22%3A%5B211%5D%2C%22is_show_all_category%22%3Atrue%7D%2C%22restaurant_category_id%22%3A%7B%22id%22%3A260%2C%22name%22%3A%22%5Cu5f02%5Cu56fd%5Cu6599%5Cu7406%22%2C%22sub_categories%22%3A%5B%5D%2C%22image_url%22%3A%22%22%7D%2C%22activities%22%3A%5B%5D%7D&target_name=%E6%8A%AB%E8%90%A8%E6%84%8F%E9%9D%A2&animation_type=1&is_need_mark=0&banner_type=", 173 | "image_url": "/7/b6/235761e50d391445f021922b71789jpeg.jpeg", 174 | "icon_url": "", 175 | "title_color": "", 176 | "__v": 0 177 | } 178 | ] -------------------------------------------------------------------------------- /src/components/ShopHeader/ShopHeader.vue: -------------------------------------------------------------------------------- 1 | 115 | 116 | 141 | 142 | -------------------------------------------------------------------------------- /server/API文档.md: -------------------------------------------------------------------------------- 1 | # 接口文档 2 | 3 | ## 目录: 4 | [1、根据经纬度获取位置详情](#1根据经纬度获取位置详情)
5 | [2、获取食品分类列表](#2获取食品分类列表)
6 | [3、根据经纬度获取商铺列表](#3根据经纬度获取商铺列表)
7 | [4、根据经纬度和关键字搜索商铺列表](#4根据经纬度和关键字搜索商铺列表)
8 | [5、获取一次性验证码](#5获取一次性验证码)
9 | [6、用户名密码登陆](#6用户名密码登陆)
10 | [7、发送短信验证码](#7发送短信验证码)
11 | [8、手机号验证码登陆](#8手机号验证码登陆)
12 | [9、根据会话获取用户信息](#9根据会话获取用户信息)
13 | [10、用户登出](#10用户登出)
14 | 15 | ## 1、根据经纬度获取位置详情 16 | 17 | ### 请求URL: 18 | http://localhost:4000/position/:geohash 19 | 20 | ### 示例: 21 | [http://localhost:4000/position/40.10038,116.36867](http://localhost:4000/position/40.10038,116.36867) 22 | 23 | ### 请求方式: 24 | GET 25 | 26 | ### 参数类型:param 27 | 28 | |参数 |是否必选 |类型 |说明 29 | |geohash    |Y       |string   |经纬度 30 | 31 | ### 返回示例: 32 | 33 | { 34 | "code": 0, 35 | "data": { 36 | "address": "北京市昌平区337省道", 37 | "city": "北京市", 38 | "geohash": "40.10038,116.36867", 39 | "latitude": "40.10038", 40 | "longitude": "116.36867", 41 | "name": "昌平区北七家宏福科技园(337省道北)" 42 | } 43 | } 44 | 45 | ## 2、获取食品分类列表 46 | 47 | ### 请求URL: 48 | http://localhost:4000/index_category 49 | 50 | ### 请求方式: 51 | GET 52 | 53 | ### 参数类型: 54 | 无 55 | 56 | ### 返回示例: 57 | { 58 | "code": 0, 59 | data: [ 60 | { 61 | id: 1, 62 | is_in_serving: true, 63 | description: "0元早餐0起送,每天都有新花样。", 64 | title: "预订早餐", 65 | link: "", 66 | image_url: "/d/49/7757ff22e8ab28e7dfa5f7e2c2692jpeg.jpeg", 67 | icon_url: "", 68 | title_color: "", 69 | __v: 0 70 | }, 71 | { 72 | id: 65, 73 | is_in_serving: true, 74 | description: "", 75 | title: "土豪推荐", 76 | image_url: "/d/49/7757ff22e8ab28e7dfa5f7e2c2692jpeg.jpeg", 77 | link: "", 78 | icon_url: "", 79 | title_color: "", 80 | __v: 0 81 | }, 82 | ... 共n条数据 83 | ] 84 | } 85 | 86 | 87 | ## 3、根据经纬度获取商铺列表 88 | 89 | ### 请求URL: 90 | http://localhost:4000/shops 91 | 92 | ### 示例: 93 | [http://localhost:4000/shops?latitude=40.10038&longitude=116.36867](http://localhost:4000/shops?latitude=40.10038&longitude=116.36867) 94 | 95 | ### 请求方式: 96 | GET 97 | 98 | ### 参数类型:query 99 | |参数 |是否必选 |类型 |说明| 100 | |latitude     |Y       |string  |纬度| 101 | |longitude     |Y       |string  |经度| 102 | 103 | ### 返回示例: 104 | { 105 | "code": 0, 106 | data: [ 107 | { 108 | name: "肯德基", 109 | address: "上海市宝山区淞宝路155弄18号星月国际商务广场1层", 110 | id: 1, 111 | latitude: 31.38098, 112 | longitude: 121.50146, 113 | location: [ 114 | 121.50146, 115 | 31.38098 116 | ], 117 | phone: "1232313124324", 118 | category: "快餐便当/简餐", 119 | supports: [ 120 | { 121 | description: "已加入“外卖保”计划,食品安全有保障", 122 | icon_color: "999999", 123 | icon_name: "保", 124 | id: 7, 125 | name: "外卖保", 126 | _id: "591bec73c2bbc84a6328a1e5" 127 | } 128 | ], 129 | status: 0, 130 | recent_order_num: 615, 131 | rating_count: 389, 132 | rating: 1.6, 133 | promotion_info: "他依然有人有人有人有人有人", 134 | piecewise_agent_fee: { 135 | tips: "配送费约¥5" 136 | }, 137 | opening_hours: [ 138 | "8:30/20:30" 139 | ], 140 | license: { 141 | catering_service_license_image: "", 142 | business_license_image: "" 143 | }, 144 | is_new: true, 145 | is_premium: true, 146 | image_path: "/img/shop/15c1513a00615.jpg", 147 | identification: { 148 | registered_number: "", 149 | registered_address: "", 150 | operation_period: "", 151 | licenses_scope: "", 152 | licenses_number: "", 153 | licenses_date: "", 154 | legal_person: "", 155 | identificate_date: null, 156 | identificate_agency: "", 157 | company_name: "" 158 | }, 159 | float_minimum_order_amount: 20, 160 | float_delivery_fee: 5, 161 | distance: "19.5公里", 162 | order_lead_time: "40分钟", 163 | description: "好吃的", 164 | delivery_mode: { 165 | color: "57A9FF", 166 | id: 1, 167 | is_solid: true, 168 | text: "蜂鸟专送" 169 | }, 170 | activities: [ 171 | { 172 | icon_name: "减", 173 | name: "满减优惠", 174 | description: "满30减5,满60减8", 175 | icon_color: "f07373", 176 | id: 1, 177 | _id: "591bec73c2bbc84a6328a1e7" 178 | } 179 | ], 180 | } 181 | ] 182 | } 183 | 184 | 185 | ## 4、根据经纬度和关键字搜索商铺列表 186 | 187 | ### 请求URL: 188 | http://localhost:4000/search_shops 189 | 例子: http://localhost:4000/search_shops?keyword=test&geohash=40.10038,116.36867 190 | 191 | ### 请求方式: 192 | GET 193 | 194 | ### 参数类型:query 195 | |参数 |是否必选 |类型 |说明| 196 | |geohash     |Y       |string   |经纬度 197 | |keyword     |Y       |string  |关键字 198 | 199 | ### 返回示例: 200 | { 201 | "code": 0, 202 | "data": [ 203 | { 204 | "name": "test_shop", 205 | "address": "广东省广州市海珠区马涌直街20号", 206 | "id": 1196, 207 | "latitude": 23.09499, 208 | "longitude": 113.26166, 209 | "location": [ 210 | 113.26166, 211 | 23.09499 212 | ], 213 | "phone": "18320326523", 214 | "category": "鲜花蛋糕/面包", 215 | "supports": [ 216 | { 217 | "description": "准时必达,超时秒赔", 218 | "icon_color": "57A9FF", 219 | "icon_name": "准", 220 | "id": 9, 221 | "name": "准时达", 222 | "_id": "5ad00b4febf543051ea2e5f6" 223 | }, 224 | { 225 | "description": "该商家支持开发票,请在下单时填写好发票抬头", 226 | "icon_color": "999999", 227 | "icon_name": "票", 228 | "id": 4, 229 | "name": "开发票", 230 | "_id": "5ad00b4febf543051ea2e5f5" 231 | } 232 | ], 233 | "status": 1, 234 | "recent_order_num": 444, 235 | "rating_count": 246, 236 | "rating": 4, 237 | "promotion_info": "便靓正", 238 | "piecewise_agent_fee": { 239 | "tips": "配送费约¥5" 240 | }, 241 | "opening_hours": [ 242 | "09:00/21:30" 243 | ], 244 | "license": { 245 | "catering_service_license_image": "162bcabb96f9264.jpg", 246 | "business_license_image": "162bcabb9869263.jpg" 247 | }, 248 | "is_new": true, 249 | "is_premium": true, 250 | "image_path": "162bcab6f889262.jpg", 251 | "identification": { 252 | "registered_number": "", 253 | "registered_address": "", 254 | "operation_period": "", 255 | "licenses_scope": "", 256 | "licenses_number": "", 257 | "licenses_date": "", 258 | "legal_person": "", 259 | "identificate_date": null, 260 | "identificate_agency": "", 261 | "company_name": "" 262 | }, 263 | "float_minimum_order_amount": 20, 264 | "float_delivery_fee": 5, 265 | "distance": "2124.6公里", 266 | "order_lead_time": "31小时27分钟", 267 | "description": "普通商店", 268 | "delivery_mode": { 269 | "color": "57A9FF", 270 | "id": 1, 271 | "is_solid": true, 272 | "text": "蜂鸟专送" 273 | }, 274 | "activities": [ 275 | { 276 | "icon_name": "减", 277 | "name": "满减优惠", 278 | "description": "参加活动满减优惠", 279 | "icon_color": "f07373", 280 | "id": 1, 281 | "_id": "5ad00b4febf543051ea2e5f7" 282 | } 283 | ], 284 | "__v": 0 285 | }, 286 | { 287 | "name": "test", 288 | "address": "浙江省杭州市余杭区高教路阿里巴巴西溪园区2号楼", 289 | "id": 1271, 290 | "latitude": 30.27817, 291 | "longitude": 120.022003, 292 | "location": [ 293 | 120.022003, 294 | 30.27817 295 | ], 296 | "phone": "111", 297 | "category": "快餐便当/简餐", 298 | "supports": [ 299 | { 300 | "description": "已加入“外卖保”计划,食品安全有保障", 301 | "icon_color": "999999", 302 | "icon_name": "保", 303 | "id": 7, 304 | "name": "外卖保", 305 | "_id": "5ad7101aebf543051ea30192" 306 | }, 307 | { 308 | "description": "准时必达,超时秒赔", 309 | "icon_color": "57A9FF", 310 | "icon_name": "准", 311 | "id": 9, 312 | "name": "准时达", 313 | "_id": "5ad7101aebf543051ea30191" 314 | }, 315 | { 316 | "description": "该商家支持开发票,请在下单时填写好发票抬头", 317 | "icon_color": "999999", 318 | "icon_name": "票", 319 | "id": 4, 320 | "name": "开发票", 321 | "_id": "5ad7101aebf543051ea30190" 322 | } 323 | ], 324 | "status": 1, 325 | "recent_order_num": 820, 326 | "rating_count": 305, 327 | "rating": 4.2, 328 | "promotion_info": "111", 329 | "piecewise_agent_fee": { 330 | "tips": "配送费约¥5" 331 | }, 332 | "opening_hours": [ 333 | "05:30/05:45" 334 | ], 335 | "license": { 336 | "catering_service_license_image": "162d816cf909817.png", 337 | "business_license_image": "162d816c82e9816.png" 338 | }, 339 | "is_new": true, 340 | "is_premium": true, 341 | "image_path": "162d81696a79815.png", 342 | "identification": { 343 | "registered_number": "", 344 | "registered_address": "", 345 | "operation_period": "", 346 | "licenses_scope": "", 347 | "licenses_number": "", 348 | "licenses_date": "", 349 | "legal_person": "", 350 | "identificate_date": null, 351 | "identificate_agency": "", 352 | "company_name": "" 353 | }, 354 | "float_minimum_order_amount": 20, 355 | "float_delivery_fee": 5, 356 | "distance": "1265.1公里", 357 | "order_lead_time": "18小时13分钟", 358 | "description": "111", 359 | "delivery_mode": { 360 | "color": "57A9FF", 361 | "id": 1, 362 | "is_solid": true, 363 | "text": "蜂鸟专送" 364 | }, 365 | "activities": [], 366 | "__v": 0 367 | } 368 | ] 369 | } 370 | 371 | ## 5、获取一次性验证码 372 | 373 | ### 请求URL: 374 | http://localhost:4000/captcha 375 | 376 | ### 请求方式: 377 | GET 378 | 379 | ### 返回示例: 380 | 381 | 382 | 384 | 385 | 387 | 389 | 391 | 392 | 393 | 394 | ## 6、用户名密码登陆 395 | 396 | ### 请求URL: 397 | http://localhost:4000/login_pwd 398 | 399 | ### 请求方式: 400 | POST 401 | 402 | ### 参数类型: 请求体 403 | 404 | |参数 |是否必选 |类型 |说明 405 | |name     |Y       |string   |用户名 406 | |pwd     |Y      |string   |密码 407 | |captcha  |Y      |string   |验证码 408 | 409 | ### 返回示例: 410 | * 登陆成功 411 | { 412 | "code": 0, 413 | "data": { 414 | "_id": "5a9cd9c6ad5b2d34d42b385d", 415 | "name": "aaa" 416 | } 417 | } 418 | * 登陆失败 419 | { 420 | "code": 1, 421 | "msg": "用户名或密码不正确!" 422 | } 423 | 424 | 425 | ## 7、发送短信验证码 426 | 427 | ### 请求URL: 428 | http://localhost:4000/sendcode 429 | 430 | ### 示例: 431 | [http://localhost:4000/sendcode?phone=13716962779](http://localhost:4000/sendcode?phone=13716962779) 432 | 433 | ### 请求方式: 434 | GET 435 | 436 | ### 参数类型: query 437 | 438 | |参数 |是否必选 |类型 |说明 439 | |phone     |Y       |string   |手机号 440 | 441 | ### 返回示例: 442 | * 成功: 443 | { 444 | "code": 0, 445 | } 446 | * 失败: 447 | { 448 | "code": 1, 449 | "msg": "短信验证码发送失败" 450 | } 451 | 452 | 453 | ​ 454 | ## 8、手机号验证码登陆 455 | 456 | ### 请求URL: 457 | http://localhost:4000/login_sms 458 | 459 | ### 请求方式: 460 | POST 461 | 462 | ### 参数类型: 请求体 463 | 464 | |参数 |是否必选 |类型 |说明 465 | |phone     |Y       |string   |手机号 466 | |code     |Y      |string   |验证码 467 | 468 | ### 返回示例: 469 | * 登陆成功 470 | { 471 | "code": 0, 472 | "data": { 473 | "_id": "5a9cd9c6ad5b2d34d42b385d", 474 | "phone": "13716962779" 475 | } 476 | } 477 | * 登陆失败 478 | { 479 | "code": 1, 480 | "msg": "手机号或验证码不正确" 481 | } 482 | 483 | ### 9、根据会话获取用户信息 484 | 485 | #### 请求URL: 486 | http://localhost:4000/userinfo 487 | 488 | #### 请求方式: 489 | GET 490 | 491 | #### 返回示例: 492 | * 获取成功 493 | { 494 | "code": 0, 495 | "data": { 496 | "_id": "5a9cd9c6ad5b2d34d42b385d", 497 | "phone": "13716962779" 498 | } 499 | } 500 | * 获取失败 501 | { 502 | "code": 1, 503 | "msg": "请先登陆" 504 | } 505 | 506 | 507 | ### 10、用户登出 508 | 509 | #### 请求URL: 510 | http://localhost:4000/logout 511 | 512 | #### 请求方式: 513 | GET 514 | 515 | #### 返回示例: 516 | {code: 0} --------------------------------------------------------------------------------