Convert Figma logo to code with AI

hai-27 logovue-store

基于Vue+Vue-Router+Vuex+Element-ui+axios,参考小米商城,实现的电商项目。

1,137
274
1,137
52

Top Related Projects

🎉 A curated list of awesome things related to Vue.js

An exemplary real-world application built with Vue.js, Vuex, axios and different other technologies. This is a good example to discover Vue for beginners.

:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin

40,969

Large single page application with 45 pages built on vue2 + vuex. 基于 vue2 + vuex 构建一个具有 45 个页面的大型单页面应用

54,105

A Vue.js 2.0 UI Toolkit for Web

Quick Overview

Vue-store is a simple e-commerce web application built using Vue.js. It demonstrates the implementation of a basic online store with features such as product listing, shopping cart functionality, and user authentication.

Pros

  • Provides a clear example of building an e-commerce application with Vue.js
  • Includes both frontend and backend components for a complete application structure
  • Implements common e-commerce features like product browsing and cart management
  • Uses modern Vue.js practices and components

Cons

  • Limited documentation and comments in the code
  • Lacks advanced e-commerce features like payment processing or order management
  • May not be suitable for production use without significant enhancements
  • UI design is relatively basic and may require improvement for a professional look

Code Examples

Here are a few code examples from the project:

  1. Product listing component:
<template>
  <div class="goods-list">
    <div class="goods-item" v-for="item in goodsList" :key="item.id">
      <div class="goods-img">
        <img :src="item.img" alt="">
      </div>
      <div class="goods-info">
        <p>{{item.name}}</p>
        <p class="price">¥{{item.price}}</p>
      </div>
    </div>
  </div>
</template>
  1. Adding an item to the cart:
addShoppingCart() {
  if (!this.user.username) {
    Toast("Please login first");
    return;
  }
  this.$http
    .post("/api/user/shoppingCart/add", {
      productId: this.productID,
      num: this.num
    })
    .then(res => {
      if (res.data.code === "001") {
        Toast("Added to cart successfully");
      } else {
        Toast(res.data.msg);
      }
    })
    .catch(err => {
      console.log(err);
    });
}
  1. User login action:
login() {
  this.$http
    .post("/api/users/login", {
      username: this.username,
      password: this.password
    })
    .then(res => {
      if (res.data.code === "001") {
        this.$store.commit("setUser", res.data.user);
        this.$router.push({ path: "/" });
      } else {
        this.toast = this.$createToast({
          txt: res.data.msg,
          type: "error"
        });
        this.toast.show();
      }
    })
    .catch(err => {
      console.log(err);
    });
}

Getting Started

To run the vue-store project locally:

  1. Clone the repository:

    git clone https://github.com/hai-27/vue-store.git
    
  2. Install dependencies:

    cd vue-store
    npm install
    
  3. Start the development server:

    npm run serve
    
  4. Open your browser and navigate to http://localhost:8080 to view the application.

Competitor Comparisons

🎉 A curated list of awesome things related to Vue.js

Pros of awesome-vue

  • Comprehensive resource collection for Vue.js ecosystem
  • Regularly updated with community contributions
  • Covers a wide range of topics, from tutorials to components

Cons of awesome-vue

  • Not a functional application, primarily a curated list
  • May be overwhelming for beginners due to the sheer volume of resources
  • Requires external exploration of listed resources

Code comparison

vue-store:

<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'App'
}
</script>

awesome-vue:

## Official Resources

- [Official Guide](https://vuejs.org/v2/guide/)
- [API Reference](https://vuejs.org/v2/api/)
- [GitHub Repo](https://github.com/vuejs/vue)
- [Release Notes](https://github.com/vuejs/vue/releases)

Summary

vue-store is a practical e-commerce application built with Vue.js, providing a hands-on example of Vue implementation. It offers a complete, functional store with features like product listing and shopping cart.

awesome-vue, on the other hand, is a curated list of Vue.js resources, components, and tools. It serves as a comprehensive reference for developers looking to explore the Vue ecosystem but doesn't provide a working application itself.

While vue-store demonstrates practical Vue usage, awesome-vue offers a broader overview of available resources and tools in the Vue community. The choice between them depends on whether you need a practical example or a comprehensive resource guide.

An exemplary real-world application built with Vue.js, Vuex, axios and different other technologies. This is a good example to discover Vue for beginners.

Pros of vue-realworld-example-app

  • More comprehensive and feature-rich, implementing a full-fledged social blogging platform
  • Better organized codebase with clear separation of concerns and modular architecture
  • Follows Vue.js best practices and conventions more closely

Cons of vue-realworld-example-app

  • More complex and potentially overwhelming for beginners
  • Requires a deeper understanding of Vue.js ecosystem and advanced concepts
  • Less focused on e-commerce specific features compared to vue-store

Code Comparison

vue-realworld-example-app:

import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");

vue-store:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

Both projects use similar main.js files, demonstrating standard Vue.js application setup. However, vue-realworld-example-app generally has more structured and modular code throughout the project, while vue-store focuses more on e-commerce specific components and functionality.

:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin

Pros of vue-element-admin

  • More comprehensive and feature-rich admin panel solution
  • Extensive documentation and community support
  • Includes advanced features like permission control and i18n

Cons of vue-element-admin

  • Steeper learning curve due to its complexity
  • May be overkill for smaller projects or simple e-commerce sites
  • Requires more setup and configuration

Code Comparison

vue-element-admin:

import permission from './permission'
import element from './element'
import settings from './settings'

Vue.use(permission)
Vue.use(element, { size: settings.elementSize })

vue-store:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

vue-element-admin offers a more complex setup with additional modules for permissions and element UI configuration, while vue-store provides a simpler Vue.js initialization. The former is better suited for large-scale admin panels, while the latter is more appropriate for smaller e-commerce projects.

vue-element-admin includes more advanced features out of the box, but vue-store offers a lighter-weight solution that may be easier to customize for specific e-commerce needs. The choice between the two depends on the project's requirements and complexity.

40,969

Large single page application with 45 pages built on vue2 + vuex. 基于 vue2 + vuex 构建一个具有 45 个页面的大型单页面应用

Pros of vue2-elm

  • More comprehensive and feature-rich, simulating a real-world food delivery application
  • Includes advanced features like geolocation and complex state management
  • Larger community and more stars on GitHub, indicating wider adoption and potential support

Cons of vue2-elm

  • Older project with less frequent updates, potentially using outdated dependencies
  • More complex codebase, which may be harder for beginners to understand and navigate
  • Focuses on a specific use case (food delivery), which may limit its applicability as a general learning resource

Code Comparison

vue2-elm:

import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './router/router'
import store from './store/'
import {routerMode} from './config/env'
import './config/rem'

vue-store:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
import './assets/css/global.css'

Both projects use Vue.js and Vuex for state management, but vue2-elm appears to have more complex routing and configuration setup. vue-store has a simpler structure and includes Element UI as a UI framework, which may be more suitable for beginners or smaller projects.

54,105

A Vue.js 2.0 UI Toolkit for Web

Pros of element

  • Comprehensive UI component library with extensive documentation
  • Large community support and regular updates
  • Wide range of pre-built components for rapid development

Cons of element

  • Larger bundle size due to extensive component library
  • Steeper learning curve for beginners
  • Less flexibility for custom styling compared to a custom-built solution

Code Comparison

element:

<el-button type="primary" @click="handleClick">Click me</el-button>
<el-input v-model="inputValue" placeholder="Enter text"></el-input>
<el-table :data="tableData" style="width: 100%">
  <el-table-column prop="name" label="Name"></el-table-column>
  <el-table-column prop="address" label="Address"></el-table-column>
</el-table>

vue-store:

<button class="btn" @click="handleClick">Click me</button>
<input v-model="inputValue" placeholder="Enter text">
<table>
  <tr v-for="item in tableData" :key="item.id">
    <td>{{ item.name }}</td>
    <td>{{ item.address }}</td>
  </tr>
</table>

The code comparison shows that element provides pre-built components with specific props and styling, while vue-store uses more basic HTML elements that require custom styling and functionality. element offers a more standardized approach, while vue-store allows for greater customization but requires more manual implementation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Store(参考小米商城)

前言

2020年寒假尤其特殊,因为新型冠状病毒肺炎疫情,学校至今没有开学。想起上学期利用课余时间学习了Vue.js、Node.js,一直想做个完整的项目实战一下,但之前在学校并没有那么多的时间。现在恰好有时间,就想着做一个项目巩固之前学到的东西。

思来想去,最后决定模仿 小米商城 做一个电商项目。可能时间隔得有点久了,之前学的东西很多都差不多忘记了,做这个项目基本上都是看着官方的文档一点一点做的。在家里也免不了有各种各样的事情耽误了项目的进度。现在终于差不多做好了,分享出来,新手上路,如有错误,请多多指教。

说明

本项目前后端分离,前端参考 小米商城 实现,但与小米官方没有关系,纯属个人瞎搞,若需要购买小米产品请到小米官方商城。

这是本项目的前端,后端请移步到store-server 。

前端已经部署在阿里云,欢迎访问 http://101.132.181.9/ (没有兼容移动端,请使用电脑访问)。

后端也已经部署在阿里云,接口地址已经修改为线上地址,本地运行前端也可以正常访问后端。

本人在读本科大三,今年暑假即将开始实习,后面的时间可能没有那么的自由,但会不定期的更新完善该项目,如有问题请直接在 Issues 中提。

如果觉得这个项目还不错,您可以点右上角 Star支持一下, 谢谢! ^_^

项目简介

本项目前后端分离,前端基于Vue+Vue-router+Vuex+Element-ui+Axios,参考小米商城实现。后端基于Node.js(Koa框架)+Mysql实现。

前端包含了11个页面:首页、登录、注册、全部商品、商品详情页、关于我们、我的收藏、购物车、订单结算页面、我的订单以及错误处理页面。

实现了商品的展示、商品分类查询、关键字搜索商品、商品详细信息展示、登录、注册、用户购物车、订单结算、用户订单、用户收藏列表以及错误处理功能。

后端采取了MVC模式,根据前端需要的数据分模块设计了相应的接口、控制层、数据持久层。后端传送地址store-server 。

技术栈

  • 前端:Vue+Vue-router+Vuex+Element-ui+Axios

  • 后端:Node.js、Koa框架

  • 数据库:Mysql

功能模块

登录

页面使用了element-ui的Dialog实现弹出蒙版对话框的效果,登录按钮设置在App.vue根组件,通过vuex中的showLogin状态控制登录框是否显示。

这样设计是为了既可以通过点击页面中的按钮登录,也可以是用户访问需要登录验证的页面或后端返回需要验证登录的提示后自动弹出登录框,减少了页面的跳转,简化用户操作。

用户输入的数据往往是不可靠的,所以本项目前后端都对登录信息进行了校验,前端基于element-ui的表单校验方式,自定义了校验规则进行校验。

注册

页面同样使用了element-ui的Dialog实现弹出蒙版对话框的效果,注册按钮设置在App.vue根组件,通过父子组件传值控制注册框是否显示。

用户输入的数据往往是不可靠的,所以本项目前后端同样都对注册信息进行了校验,前端基于element-ui的表单校验方式,自定义了校验规则进行校验。

首页

首页主要是对商品的展示,有轮播图展示推荐的商品,分类别对热门商品进行展示。

全部商品

全部商品页面集成了全部商品展示、商品分类查询,以及根据关键字搜索商品结果展示。

商品详情页

商品详情页主要是对某个商品的详细信息进行展示,用户可以在这里把喜欢的商品加入购物车或收藏列表。

我的购物车

购物车采用vuex实现,页面效果参考了小米商城的购物车。

详细实现过程请看:基于Vuex实现小米商城购物车

订单结算

用户在购物车选择了准备购买的商品后,点击“去结算”按钮,会来到该页面。 用户在这里选择收货地址,确认订单的相关信息,然后确认购买。

我的收藏

用户在商品的详情页,可以通过点击加入 喜欢 按钮,把喜欢的商品加入到收藏列表。

我的订单

对用户的所有订单进行展示。

运行项目

注意:

  • 后端接口地址已经修改为线上的地址,本地运行会直接分为我部署在服务器的后端。
  • 为了方便测试,数据库数据没有加密,注册时切记不要使用自己的常用密码。
  • 如果需要自己运行后端,请移步到store-server clone后端项目,并修改前端的接口地址为您的服务器地址。
1. Clone project

git clone https://github.com/hai-27/vue-store.git

2. Project setup

cd vue-store
npm install

3. Compiles and hot-reloads for development

npm run serve

4. Compiles and minifies for production

npm run build

页面截图

首页

全部商品

购物车

我的收藏

我的订单

登录

注册

作者 hai-27

2020年3月8日