README.md 17.3 KB
Newer Older
M
udate  
maguohua 已提交
1
# 前言
M
udpata  
maguohua 已提交
2

J
Junv Zhao 已提交
3
初学vue时曾在网上搜索vue的实战项目源码,无奈大部分都是简单的demo,对于深究vue没有太大的帮助,剩下的一些大部分都是像音乐播放器之类的展示型项目,交互没有预期那么复杂。但我们实际在工作中,经常会遇到有购物车的项目,这类项目因为涉及到money,所以对逻辑严谨度要求高,页面之间交互复杂,又会伴随着登录、注册、用户信息等等,常常会让我们很头疼。既然还没人用vue写过这样的项目,那不如我来写,开源出来对能看到的人也会有帮助。
C
cangdu 已提交
4

M
update  
maguohua 已提交
5
这种功能性的项目很实用但是往往也很枯燥,没有音乐播放器那么看起来绚丽,思来想去发现饿了么是一个不错的素材,一来它足够复杂,开放的外卖平台比一般的公司独有商店更加复杂。二来 见到那么多美食,大家也不会感觉到厌烦。
C
cangdu 已提交
6

M
update  
maguohua 已提交
7 8
为啥是饿了么,而不是百度,美团?原因很简单,三个外卖大佬里,饿了么的色调和布局是最漂亮的,看起来最舒服。

J
Junv Zhao 已提交
9
此项目大大小小共 45 个页面,涉及注册、登录、商品展示、购物车、下单等等,是一个完整的流程。一般公司即便是官网的单页面项目都没这么复杂,如果这个项目能驾驭的了,相信大部分公司的其他单页面应用也就不在话下,即便更复杂,也不会比这个高到哪里去。
C
cangdu 已提交
10

M
update  
maguohua 已提交
11
因为利用业余时间来做,年前就开始写,又跨个年,周期有点长,项目从零布局到完成共用了2个多月的时间,目前项目已经完成,正在进行一些性能的优化,增加详细的注释。
M
udpata  
maguohua 已提交
12

M
udpate  
maguohua 已提交
13 14
另外,这个项目和慕课网视频的那个饿了么没有任何关系,慕课网的项目只有一个页面,我在看完vue的官方文档后直接写了这个项目,没有参照任何人的代码,请大家不要混为一谈。

M
update  
maguohua 已提交
15

M
maguohua 已提交
16
## 项目运行
M
udpate  
maguohua 已提交
17

J
Junv Zhao 已提交
18
#### 注意:由于涉及大量的 ES6/7 等新属性,nodejs 必须是 6.0 以上版本 ,node 7 是先行版,有可能会出问题,建议使用 node 6 稳定版
M
update  
maguohua 已提交
19

M
udpate  
maguohua 已提交
20 21
```
git clone https://github.com/bailicangdu/vue2-elm.git  
M
udpate  
maguohua 已提交
22

M
udpate  
maguohua 已提交
23 24 25
cd vue2-elm

npm install
M
udate  
maguohua 已提交
26

M
udpate  
maguohua 已提交
27
npm run dev
M
udpate  
maguohua 已提交
28

M
udpate  
maguohua 已提交
29
```
M
udpate  
maguohua 已提交
30

M
udpate  
maguohua 已提交
31

M
maguohua 已提交
32
## 关于后台系统:
M
maguohua 已提交
33

M
maguohua 已提交
34 35 36
作为一名前端工程师,nodejs几乎是我们绕不过去的坎。于是专门用nodejs为此项目写一个后台系统,并尽量保持和官网一致的API接口,相信对大家会有帮助。

#### [后台项目地址戳这里](https://github.com/bailicangdu/node-elm)
M
maguohua 已提交
37 38 39



M
udate  
maguohua 已提交
40
# 说明
M
update  
maguohua 已提交
41

M
udpate  
maguohua 已提交
42
>  本项目主要用于熟悉如何用 vue2 架构一个大型项目
M
update  
maguohua 已提交
43

M
udpate  
maguohua 已提交
44
>  如果对您有帮助,您可以点右上角 "Star" 支持一下 谢谢! ^_^
M
update  
maguohua 已提交
45

M
update  
maguohua 已提交
46
>  或者您可以 "follow" 一下,我会不断开源更多的有趣的项目
M
update  
maguohua 已提交
47

C
cangdu 已提交
48
>  开发环境 macOS 10.12.3  Chrome 56  nodejs 6.10.0
M
update  
maguohua 已提交
49

M
update  
maguohua 已提交
50
>  特别感谢辰妹子,在百忙之中抽出时间和我一起完成了这个项目,辛苦了🌹
M
udpate  
maguohua 已提交
51

M
maguohua 已提交
52 53
>  此项目只用做vue的学习,请不要用于商业用途,正常下单请选择饿了么官方客户端。

M
update  
maguohua 已提交
54
>  如有问题请直接在 Issues 中提,或者您发现问题并有非常好的解决方案,欢迎 PR 👍
M
update  
maguohua 已提交
55

M
udpate  
maguohua 已提交
56 57
>  推荐一个 react + redux 开源项目,对react感兴趣的朋友赶紧去看看。[地址在这里](https://github.com/bailicangdu/react-pxq)

M
update  
maguohua 已提交
58
>  另外一个 vue2 + vuex 的入门项目,比当前的项目简单很多,非常适合入门练习。[地址在这里](https://github.com/bailicangdu/vue2-happyfri)
M
update  
maguohua 已提交
59 60 61



M
maguohua 已提交
62
# 关于 数据 的说明🤔
M
udate  
maguohua 已提交
63

M
maguohua 已提交
64
下载代码运行后,因为开启了反向代理,可以获取真实的官方数据,最终可以进行下单(真实的下单,而不是模拟,下单后可以在官方App中查看并付款,亲自试过,且成功付款点餐),但是为了安全起见,登录的帐号为固定的帐号,以免泄露个人信息,不过照样可以点餐。
M
udate  
maguohua 已提交
65

M
update  
maguohua 已提交
66

M
udpate  
maguohua 已提交
67 68
## 效果演示

M
update  
maguohua 已提交
69
#### (demo使用的是模拟数据,数据是固定的,只做为样式的演示,要获取真实的数据,请clone代码并运行);
M
udpate  
maguohua 已提交
70

M
update  
maguohua 已提交
71
[查看demo请戳这里](http://test.fe.ptdev.cn/elm/)(请用chrome手机模式预览)
J
Junv Zhao 已提交
72

M
udpate  
maguohua 已提交
73 74
### 移动端扫描下方二维码

M
maguohua 已提交
75
![](https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/elm_ewm.png)
M
udpate  
maguohua 已提交
76 77 78



M
update  
maguohua 已提交
79 80


M
udate  
maguohua 已提交
81
# 目标功能
C
cangdu 已提交
82 83 84
- [x] 定位功能 -- 完成
- [x] 选择城市 -- 完成
- [x] 搜索地址 -- 完成
M
maguohua 已提交
85
- [x] 展示所选地址附近商家列表 -- 完成
M
maguohua 已提交
86
- [x] 搜索美食,餐馆 -- 完成
M
updata  
maguohua 已提交
87
- [x] 根据距离、销量、评分、特色菜、配送方式等进行排序和筛选 -- 完成
M
updata  
maguohua 已提交
88
- [x] 餐馆食品列表页 -- 完成
M
maguohua 已提交
89
- [x] 购物车功能 -- 完成
M
upata  
maguohua 已提交
90
- [x] 店铺评价页面 -- 完成
M
upata  
maguohua 已提交
91
- [x] 单个食品详情页面 -- 完成
M
update  
maguohua 已提交
92
- [x] 商家详情页 -- 完成
J
Junv Zhao 已提交
93
- [x] 登录、注册 -- 完成
M
maguohua 已提交
94
- [x] 修改密码 -- 完成
M
maguohua 已提交
95
- [x] 个人中心 -- 完成
M
maguohua 已提交
96
- [x] 发送短信、语音验证 -- 完成
M
update  
maguohua 已提交
97 98
- [x] 下单功能 -- 完成 ✨✨🎉🎉
- [x] 订单列表 -- 完成
M
maguohua 已提交
99
- [x] 订单详情 -- 完成
M
update  
maguohua 已提交
100
- [x] 下载App -- 完成
M
udate  
maguohua 已提交
101
- [x] 添加、删除、修改收货地址 -- 完成
M
update  
maguohua 已提交
102 103
- [x] 帐户信息 -- 完成
- [x] 服务中心 -- 完成
M
update  
maguohua 已提交
104
- [x] 红包 -- 完成
M
update  
maguohua 已提交
105
- [x] 上传头像 -- 完成
J
Junv Zhao 已提交
106
- [ ] 付款 -- 臣妾做不到啊~~
M
udate  
maguohua 已提交
107 108 109 110 111 112 113 114 115 116 117



# 总结

1、因为并不是elm官方,而且因为要开代理,必须在pc端打开,最多只能做到下单这一步,下单成功后可以在手机客户端查看并付款。

2、一般涉及到money的网页逻辑都比较复杂,尤其像饿了么这样一个开放的平台,商家和食品种类繁多,页面与页面之间交互复杂,在写到 购物车 和 下单 功能时众多的数据和逻辑一度让人很头疼,又没有设计和接口api文档,只能一步步摸索。

3、vue因其轻量级的框架在中小型项目中表现亮眼,在大型单页面应用中因为vuex的存在,表现依然出色,在处理复杂交互逻辑的时候,vuex的存在是不可或缺的。所以说利用 vue + vuex 完全可以去做大型的单页面项目。

J
Junv Zhao 已提交
118
4、项目写到现在,从 登录注册到、首页、搜索、商家列表、购物车、下单、订单列表、个人中心 一个流程走完之后、不但对vue的理解更深一层,而且对以后掌控大型项目的时候也有非常多的帮助,做一个实际的项目才能对自己有很大的提升。
M
udate  
maguohua 已提交
119 120 121 122 123 124

5、曾一度怀疑,花几个月的时间做这样一个项目到底有没有意义,本来只是想做一个小项目练练手,没想到后来越写越多,不过坚持下来后我相信一切都是值得的。

6、项目已经完成,共45个页面。


M
udpate  
maguohua 已提交
125
# 最终目标
M
update  
maguohua 已提交
126

C
cangdu 已提交
127
1、用node.js构建一个模拟外卖平台的后台系统。[地址在这里](https://github.com/bailicangdu/node-elm)
M
udate  
maguohua 已提交
128

C
cangdu 已提交
129
2、利用 react-native 写出跨 Android 和 IOS 的原生APP版本。[地址在这里](https://github.com/bailicangdu/React-Native-elm)
M
udate  
maguohua 已提交
130 131 132

3、如果时间来的及,会出一个pc端的网页版。

M
update  
maguohua 已提交
133 134
所以我的目的是构建一个横跨前后端,移动IOS、Android的完整生态圈。

M
udate  
maguohua 已提交
135 136 137 138 139
。。。敬请期待




M
udpate  
maguohua 已提交
140
# 部分截图
M
udate  
maguohua 已提交
141

C
cangdu 已提交
142

M
udate  
maguohua 已提交
143
### 商铺列表页
C
cangdu 已提交
144

M
maguohua 已提交
145
<img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/msite.png" width="365" height="619"/> <img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/msite.gif" width="365" height="619"/>
M
udate  
maguohua 已提交
146 147 148 149


### 商铺筛选页

M
maguohua 已提交
150
<img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/food.png" width="365" height="619"/> <img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/food.gif" width="365" height="619"/>
M
udate  
maguohua 已提交
151 152 153 154 155



### 餐馆食品列表与购物车

M
maguohua 已提交
156
<img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/shop_cart.png" width="365" height="619"/> <img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/shop_cart.gif" width="365" height="619"/>
M
udate  
maguohua 已提交
157 158 159

### 确认订单页

M
maguohua 已提交
160
<img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/confirm1.png" width="365" height="619"/> <img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/confirmOrder.gif" width="365" height="619"/>
M
udate  
maguohua 已提交
161 162 163 164


### 搜索页

M
maguohua 已提交
165
<img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/search.png" width="365" height="619"/> <img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/search.gif" width="365" height="619"/>
M
udate  
maguohua 已提交
166 167


J
Junv Zhao 已提交
168
### 登录页
M
udate  
maguohua 已提交
169

M
maguohua 已提交
170
<img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/login1.png" width="365" height="619"/> <img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/login.gif" width="365" height="619"/>
M
udate  
maguohua 已提交
171 172 173 174


### 个人中心

M
maguohua 已提交
175
<img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/profile.png" width="365" height="619"/> <img src="https://github.com/bailicangdu/vue2-elm/blob/master/screenshots/profile.gif" width="365" height="619"/>
M
udate  
maguohua 已提交
176 177 178 179 180 181 182






# 项目布局
M
maguohua 已提交
183

M
maguohua 已提交
184
```
M
maguohua 已提交
185
.
M
maguohua 已提交
186 187 188 189 190
├── build                                       // webpack配置文件
├── config                                      // 项目打包路径
├── elm                                         // 上线项目文件,放在服务器即可正常访问
├── screenshots                                 // 项目截图
├── src                                         // 源码目录
M
maguohua 已提交
191 192 193 194 195 196 197 198 199
│   ├── components                              // 组件
│   │   ├── common                              // 公共组件
│   │   │   ├── alertTip.vue                    // 弹出框组件
│   │   │   ├── buyCart.vue                     // 购物车组件
│   │   │   ├── computeTime.vue                 // 倒计时组件
│   │   │   ├── loading.vue                     // 页面初始化加载数据的动画组件
│   │   │   ├── mixin.js                        // 组件混合(包括:指令-下拉加载更多,处理图片地址)
│   │   │   ├── ratingStar.vue                  // 评论的五颗星组件
│   │   │   └── shoplist.vue                    // msite和shop页面的餐馆列表公共组件
M
maguohua 已提交
200
│   │   ├── footer
M
maguohua 已提交
201
│   │   │   └── footGuide.vue                   // 底部公共组件
M
maguohua 已提交
202
│   │   └── header
M
maguohua 已提交
203
│   │       └── head.vue                        // 头部公共组件
M
maguohua 已提交
204 205 206 207 208 209
│   ├── config                                  // 基本配置
│   │   ├── env.js                              // 环境切换配置
│   │   ├── fetch.js                            // 获取数据
│   │   ├── mUtils.js                           // 常用的js方法
│   │   └── rem.js                              // px转换rem
│   ├── images                                  // 公共图片
M
maguohua 已提交
210 211
│   ├── page
│   │   ├── balance
M
maguohua 已提交
212
│   │   │   ├── balance.vue                     // 余额页
M
maguohua 已提交
213
│   │   │   └── children
M
maguohua 已提交
214
│   │   │       └── detail.vue                  // 余额说明
M
maguohua 已提交
215
│   │   ├── benefit
M
maguohua 已提交
216
│   │   │   ├── benefit.vue                     // 红包页
M
maguohua 已提交
217
│   │   │   └── children
M
maguohua 已提交
218 219 220 221 222 223 224
│   │   │       ├── commend.vue                 // 推荐有奖
│   │   │       ├── coupon.vue                  // 代金券说明
│   │   │       ├── exchange.vue                // 兑换红包
│   │   │       ├── hbDescription.vue           // 红包说明
│   │   │       └── hbHistory.vue               // 历史红包
│   │   ├── city                 
│   │   │   └── city.vue                        // 当前城市页
M
maguohua 已提交
225 226 227
│   │   ├── confirmOrder
│   │   │   ├── children
│   │   │   │   ├── children
M
maguohua 已提交
228
│   │   │   │   │   ├── addAddress.vue          // 添加地址页
M
maguohua 已提交
229
│   │   │   │   │   └── children
M
maguohua 已提交
230 231 232 233 234 235 236
│   │   │   │   │       └── searchAddress.vue   // 搜索地址页
│   │   │   │   ├── chooseAddress.vue           // 选择地址页
│   │   │   │   ├── invoice.vue                 // 选择发票页
│   │   │   │   ├── payment.vue                 // 付款页
│   │   │   │   ├── remark.vue                  // 订单备注页 
│   │   │   │   └── userValidation.vue          // 用户验证页
│   │   │   └── confirmOrder.vue                // 确认订单页
M
maguohua 已提交
237
│   │   ├── download
M
maguohua 已提交
238
│   │   │   └── download.vue                    // 下载App
M
maguohua 已提交
239
│   │   ├── find
M
maguohua 已提交
240
│   │   │   └── find.vue                        // 发现页
M
maguohua 已提交
241
│   │   ├── food
M
maguohua 已提交
242
│   │   │   └── food.vue                        // 食品筛选排序页
M
maguohua 已提交
243
│   │   ├── forget
M
maguohua 已提交
244
│   │   │   └── forget.vue                      // 忘记密码,修改密码页
M
maguohua 已提交
245
│   │   ├── home
M
maguohua 已提交
246
│   │   │   └── home.vue                        // 首页
M
maguohua 已提交
247
│   │   ├── login
M
maguohua 已提交
248
│   │   │   └── login.vue                       // 登录注册页
M
maguohua 已提交
249
│   │   ├── msite
M
maguohua 已提交
250
│   │   │   └── msite.vue                       // 商铺列表页
M
maguohua 已提交
251 252
│   │   ├── order
│   │   │   ├── children
M
maguohua 已提交
253 254
│   │   │   │   └── orderDetail.vue             // 订单详情页
│   │   │   └── order.vue                       // 订单列表页
M
maguohua 已提交
255 256
│   │   ├── points
│   │   │   ├── children
M
maguohua 已提交
257 258
│   │   │   │   └── detail.vue                  // 积分说明
│   │   │   └── points.vue                      // 积分页
M
maguohua 已提交
259 260 261
│   │   ├── profile
│   │   │   ├── children
│   │   │   │   ├── children
M
maguohua 已提交
262
│   │   │   │   │   ├── address.vue             // 添加地址
M
maguohua 已提交
263
│   │   │   │   │   └── children
M
maguohua 已提交
264
│   │   │   │   │       ├── add.vue             // 新增地址
M
maguohua 已提交
265
│   │   │   │   │       └── children
M
maguohua 已提交
266 267 268 269
│   │   │   │   │           └── addDetail.vue   // 搜索地址
│   │   │   │   ├── info.vue                    // 帐户信息
│   │   │   │   └── setusername.vue             // 重置用户名
│   │   │   └── profile.vue                     // 个人中心
M
maguohua 已提交
270
│   │   ├── search
M
maguohua 已提交
271
│   │   │   └── search.vue                      // 搜索页
M
maguohua 已提交
272 273
│   │   ├── service
│   │   │   ├── children
M
maguohua 已提交
274 275
│   │   │   │   └── questionDetail.vue          // 问题详情
│   │   │   └── service.vue                     // 服务中心
M
maguohua 已提交
276 277 278
│   │   ├── shop
│   │   │   ├── children
│   │   │   │   ├── children
M
maguohua 已提交
279 280 281 282
│   │   │   │   │   └── shopSafe.vue            // 商铺认证信息页
│   │   │   │   ├── foodDetail.vue              // 商铺信息页
│   │   │   │   └── shopDetail.vue              // 单个商铺信息页
│   │   │   └── shop.vue                        // 商铺筛选页
M
maguohua 已提交
283 284
│   │   └── vipcard
│   │       ├── children
M
maguohua 已提交
285 286 287 288 289
│   │       │   ├── invoiceRecord.vue           // 购买记录
│   │       │   ├── useCart.vue                 // 使用卡号购买
│   │       │   └── vipDescription.vue          // 会员说明
│   │       └── vipcard.vue                     // 会员卡办理页
│   ├── plugins                                 // 引用的插件
M
maguohua 已提交
290
│   ├── router
M
maguohua 已提交
291 292 293 294
│   │   └── router.js                           // 路由配置
│   ├── service                                 // 数据交互统一调配
│   │   ├── getData.js                          // 获取数据的统一调配文件,对接口进行统一管理
│   │   └── tempdata                            // 开发阶段的临时数据
M
maguohua 已提交
295 296 297 298 299 300 301
│   ├── store                                   // vuex的状态管理
│   │   ├── action.js                           // 配置actions
│   │   ├── getters.js                          // 配置getters
│   │   ├── index.js                            // 引用vuex,创建store
│   │   ├── modules                             // store模块
│   │   ├── mutation-types.js                   // 定义常量muations名
│   │   └── mutations.js                        // 配置mutations
M
maguohua 已提交
302
│   └── style
M
maguohua 已提交
303 304
│       ├── common.scss                         // 公共样式文件
│       ├── mixin.scss                          // 样式配置文件
M
maguohua 已提交
305
│       └── swiper.min.css
M
maguohua 已提交
306 307 308 309
│   ├── App.vue                                 // 页面入口文件
│   ├── main.js                                 // 程序入口文件,加载各种公共组件
├── favicon.ico                                 // 图标
├── index.html                                  // 入口html文件
M
maguohua 已提交
310
.
M
maguohua 已提交
311 312

56 directories, 203 files
C
cangdu 已提交
313
```
M
maguohua 已提交
314 315 316 317 318


### License

[MIT](https://github.com/bailicangdu/vue2-elm/blob/master/LICENSE)