好的生活,聚集美丽,成人之美!从现在做起!http://www.tuicool.com/articles/EBbmAjr

效果预览

:point_right:预览地址: 请点我!在线预览,手机浏览或切换浏览器移动调试

PS:google浏览器在切换不同的手机测试,需要重新刷新页面;安卓手机可能不适应

:point_right:源码地址: Github在这里

项目描述

技术栈

Vue2.0全家桶 + axios + Vuex + Mint-Ui + Mock.js + Stylus

前端部分

  • Vue2.0 前端页面的展示
  • SPA单页应用,前端后分离
  • Stylus css预编译
  • Axios 异步数据的请求
  • localStorage 个人信息以及购物车信息的存储
  • ES6 Js语言的标准
  • Mint_UI 实现图片轮播,图片懒加载等等
  • Better-Scroll 实现移动端滚动,让滚动更加协调
  • flexible.js和rem,解决移动端设备兼容

后端部分

  • Mock.js 实现后端数据的托管

待更新的功能

  • 后端平台搭建,利用新一代的Koa服务器框架
  • 订单页面的展示
  • 商家页面的请求
  • 下拉,加载更多的商品数据

实现功能

首页

个人

  • 1、账户的登录
  • 2、注册账户
  • 3、设置页面

总结

  • 1、熟悉使用Vue2.0
  • 2、在项目中,将组件进行分离,编写可以复用的组件,提高效率
  • 3、Vuex的状态管理模块,统一的状态的管理,让我们更好的去对数据操作
  • 4、util的工具,倒计时js
  • 5、对axios有更进一步的理解,利用cros进行跨域处理
  • 6、进行路由的懒加载,优化页面加载

具体功能实现

路由结构

export default new Router({routes: [{ //这里要设置一个默认的主页面 后面才起作用 /代表根目录path: '/',name: 'index',component: resolve => require(['@/pages/index/index'], resolve),redirect: '/index/page1'},{ path: '/index',component: resolve => require(['@/pages/index/index'], resolve),meta: {keepAlive: true},children: [{path: '',component: resolve => require(['@/pages/index/index'], resolve)},{path: 'page1', name: 'page1',component: resolve => require(['@/pages/index/page1'], resolve)},{path: 'page2',name: 'page2',component: resolve => require(['@/pages/index/page2'], resolve)},{path: 'page3',name: 'page3',component: resolve => require(['@/pages/index/page3'], resolve)},{path: 'page4',name: 'page4',component: resolve => require(['@/pages/index/page4'], resolve)},{path: 'page5',name: 'page5',component: resolve => require(['@/pages/index/page5'], resolve)},{path: 'page6',name: 'page6',component: resolve => require(['@/pages/index/page6'], resolve)},{path: 'page7',component: resolve => require(['@/pages/index/page7'], resolve)},]},{path: '/brandsale',name: 'brandSale', component: resolve => require(['@/pages/brandsale/index'], resolve)},{path: '/livecommunity',name: 'liveCommunity',component:  resolve => require(['@/pages/livecommunity/index'], resolve)},{path: '/shopcart',name: 'shopCart',component:  resolve => require(['@/pages/shopCart/index'], resolve)},{path: '/myself',name: 'mySelf',component: resolve => require(['@/pages/mySelf/index'], resolve)},{path: "/setter",name: 'setter',component:  resolve => require(['@/pages/mySelf/setter'], resolve)},{path: '/login',name: 'login',component:  resolve => require(['@/pages/mySelf/login'], resolve)},{path: '/product',name: 'product',component:  resolve => require(['@/pages/product/index'], resolve),redirect: '/product/info', children: [{path: 'info',name: 'productInfo',component: resolve => require(['@/pages/product/info'], resolve)},{path: 'detail',name: 'productDetail',component: resolve => require(['@/pages/product/detail'], resolve)},{path: 'comment',name: 'productComment',component: resolve => require(['@/pages/product/comment'], resolve)}]},]
})

Vuex状态管理

这里我贴出购物车模块。它的使用场景:添加商品到购物车,更新商品的信息、进行增删,并且在操作过程中,将数据保存到

localStorage,持久存储,由于后台服务器尚未搭建,利用这样来保持数据的存储。

import * as types from '../mutation-types.js'
const storage = window.localStorage
const state = {added: [],checkoutStatus: null
}
const getters = {checkoutStatus: state => state.checkoutStatus,cartLists: state => state.added
}
const mutations = {[types.ADD_TO_CART] (state, product) {let id = product.idconst record = state.added.find(p => p.id === id && p.type === product.type)// 解决方法一 找到数据遍历一次// 方法二 是获取到父级的数据if (!record) {state.added.push(product)} else {record.quantity += product.quantity}storage.setItem('cart', JSON.stringify(state.added))},//传入商品的信息 product  id和类型判断当前存储的商品       要修改的数量// 更新产品的数据[types.UPDATE_THIS_PRODUCT] (state, product) {let {id,type,quantity} = product //对象的解构const record = state.added.find(p => p.id===id &&p.type===type)if (quantity>0) {record?record.quantity = quantity : ''} else {// 传入的商品数量为0 就删除这个商品 删除指定的序号的商品let index = state.added.indexOf(record)state.added.splice(index,1)}storage.setItem('cart', JSON.stringify(state.added))   },
}
export default {state,getters,mutations
}

来个广告,拍卖自己!!!

  • :point_right:jerrylee: 感兴趣请点我,这是我的简历
  • :point_right:微信号:JerryLeelisa
  • :point_right:电 话:15279106115
  • :point_right:邮 箱:958171512@qq.com

Build Setup

# install dependencies
npm install# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report

For detailed explanation on how things work, checkout theguide anddocs for vue-loader.

Vue全家桶实现一个购物Web App相关推荐

  1. Vue 全家桶实现一个移动端酷狗音乐

    Vue 已经用了不少时间,最近抽空把以前的未完成的酷狗音乐做完了,过来分享下,也可以直接点这里预览,注意切换成手机模式. 技术栈: vue-router.eventBus.vuex.vue-aweso ...

  2. Vue全家桶仿网易优选商城APP源码

    介绍: Vue全家桶仿优选商城APP源码,只写了前端,用到的技术栈是Vue全家桶.mintUI.axios,没有实现后端接口,全部是抓包至商城App接口. 实现了挺多的功能的,比如首页.商品列表.商品 ...

  3. vue音乐笔记_基于vue全家桶的移动端音乐web app

    项目描述 这是一个基于 Vue2.x 和网易云音乐 API制作的移动端 web app 项目:由于是出于练习和实验的目的,因此并非是网易云音乐 app 的替代品,目前也没有涵盖全部的功能: 该项目主要 ...

  4. Vue 全家桶 + Electron 开发的一个跨三端的应用

    GitHub Repo:vue-objccn Follow: halfrost · GitHub 项目地址:https://github.com/halfrost/vue-objccn 利用 Vue. ...

  5. Vue 全家桶 + Electron 开发的一个跨三端的应用 1

    代码地址如下: http://www.demodashi.com/demo/11738.html GitHub Repo:vue-objccn Follow: halfrost · GitHub 利用 ...

  6. 基于Vue全家桶制作的的高仿美团APP

    美团外卖APP ? 项目演示地址:http://39.108.232.27:9000 ? GitHub:github.com/bxm0927/vue- 基于 Vue 全家桶 (2.x) 制作的美团外卖 ...

  7. 从头到尾创建一个vue全家桶项目

    一.vue全家桶有哪些 全家桶:vue, vue-router, vuex, axios, elementui vue-router: 路由 vuex: vue状态机 axios: 网络请求工具 el ...

  8. [在线+源码]vue全家桶+Typescript开发一款习惯养成APP

    vue-ts-daily 基于Vue.js的2.5.13版本和TypeScript编写的模仿原生应用的WebApp. 源码地址 欢迎star 项目演示地址 建议直接添加到主屏幕(ios端体验差一些). ...

  9. Vue全家桶+Socket.io+Koa2打造一个智能聊天室 接口已开放

    Vue.js+Socket.io+Koa2打造一个智能聊天室 Vue.js全家桶+Socket.io+Express/Koa2 打造的一个智能聊天室. 已经开源啦!为了方便大家学习,智能机器人.IP定 ...

最新文章

  1. 16 级高代 II 思考题十的多种证明
  2. 解决Eclipse狂吃内存的解决方法(转)
  3. java 反序列化 ysoserial exploit/JRMPClient 原理剖析
  4. ABBYY PDF Transformer+支持的格式
  5. 两台笔记本如何不走路由而是通过无线网卡互联
  6. linux 原子整数操作详解 及 volatile (二)
  7. 《C++ Primer 第五版》第二章(第5小节)——using和typedef,auto和decltype总结
  8. perl 循环删除指定文件夹下所有满足条件的文件,不包含文件夹
  9. OpenCV-计算自然对数cv::log
  10. 中虚数怎么表示_虚数是负数的平方根,为什么在三次方程中才出现的呢?|高中篇3...
  11. 华为模拟器eNSP练习题 - VLAN综合实验
  12. 【Django】Django视图views详解
  13. 华硕主板装系统蓝屏_装xp系统蓝屏,电脑安装xp系统蓝屏怎么办
  14. 【自由探索】决策树归纳
  15. 《太阳照常升起》观后感
  16. iOS学习重要知识点整理02-进程和线程的一个简单解释
  17. java中的枚举与注解
  18. 用户openId 和 unionId 的区别
  19. Django dWebScoket 实时消息推送
  20. android计时器秒,倒数计时器android秒不准确

热门文章

  1. UG8.0 IGS补烂面与修复视频教程 改产品拔模教程
  2. 小白学习一eNSP华为模拟器(18) IPV6基本配置
  3. java jlabel 对齐_java-将JLabel中的文本右对齐
  4. ebs oracle pl sql开发_Oracle EBS Form个性化开发
  5. SWUSTOJ #1178 密码翻译
  6. echarts中当横轴的数据过多的时候,可以在横轴加一个滚动条,还可以设置横轴一次显示多少个数据
  7. QT生成XML(QXmlStreamWriter或DOM)
  8. 前端怎么做接口签名验证 -baijiahao_微信H5介绍:Razor+Mvc+盛派微信接口
  9. [AHK]为Word增加求和热键,审计求和助手
  10. vue 父子间通信 总结