Convert Figma logo to code with AI

canfoo logovue2.0-taopiaopiao

vue2.0+router+vuex+express 构建淘票票的全栈demo

1,234
380
1,234
3

Top Related Projects

209,052

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

54,239

A Vue.js 2.0 UI Toolkit for Web

23,922

A high quality UI Toolkit built on Vue.js 2.0

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

Vue3、Element Plus、typescript后台管理系统

41,144

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

Quick Overview

Vue2.0-taopiaopiao is a Vue.js-based project that replicates the functionality of the Taobao movie ticket booking system. It serves as a practical example of building a complex web application using Vue.js 2.0, demonstrating various features and best practices in Vue development.

Pros

  • Provides a comprehensive example of a real-world Vue.js application
  • Implements various Vue.js features, including components, routing, and state management
  • Offers insights into building responsive and interactive user interfaces
  • Serves as a valuable learning resource for Vue.js developers

Cons

  • Based on an older version of Vue.js (2.0), which may not include the latest features and best practices
  • Limited documentation and comments in English, which may pose challenges for non-Chinese speakers
  • May require updates to work with the latest dependencies and Vue.js ecosystem
  • Lacks comprehensive test coverage

Code Examples

  1. Vue component example:
<template>
  <div class="movie-list">
    <movie-item v-for="movie in movies" :key="movie.id" :movie="movie" />
  </div>
</template>

<script>
import MovieItem from './MovieItem.vue'

export default {
  components: {
    MovieItem
  },
  data() {
    return {
      movies: []
    }
  },
  created() {
    // Fetch movies data
  }
}
</script>

This code demonstrates a Vue component that renders a list of movies using a child component.

  1. Vue router configuration:
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from './views/Home.vue'
import MovieDetail from './views/MovieDetail.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', component: Home },
  { path: '/movie/:id', component: MovieDetail }
]

const router = new VueRouter({
  routes
})

export default router

This code sets up the Vue router with two routes: home and movie detail.

  1. Vuex store example:
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    selectedSeats: []
  },
  mutations: {
    addSeat(state, seat) {
      state.selectedSeats.push(seat)
    },
    removeSeat(state, seat) {
      const index = state.selectedSeats.indexOf(seat)
      if (index > -1) {
        state.selectedSeats.splice(index, 1)
      }
    }
  }
})

This code creates a Vuex store to manage the state of selected seats in the ticket booking process.

Getting Started

To run the project locally:

  1. Clone the repository:

    git clone https://github.com/canfoo/vue2.0-taopiaopiao.git
    
  2. Install dependencies:

    cd vue2.0-taopiaopiao
    npm install
    
  3. Start the development server:

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

Competitor Comparisons

209,052

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

Pros of Vue

  • Core Vue framework with extensive documentation and community support
  • Flexible and scalable for large applications
  • Regularly updated with new features and improvements

Cons of Vue

  • Steeper learning curve for beginners
  • More complex setup for advanced features
  • Larger file size compared to minimal implementations

Code Comparison

Vue (core framework):

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

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

vue2.0-taopiaopiao (specific implementation):

import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

Vue.use(VueRouter)
const router = new VueRouter({routes})

Summary

Vue is a comprehensive framework suitable for various project sizes, offering extensive features and community support. vue2.0-taopiaopiao is a specific implementation of a movie ticket booking system using Vue 2.0, demonstrating a practical application of the framework.

While Vue provides more flexibility and scalability, it may be overkill for simpler projects. vue2.0-taopiaopiao offers a focused solution for a particular use case but may lack the broader applicability of the core Vue framework.

The code comparison shows that Vue's core setup is simpler, while vue2.0-taopiaopiao includes additional routing configuration, reflecting its more specific purpose.

54,239

A Vue.js 2.0 UI Toolkit for Web

Pros of element

  • Comprehensive UI component library with extensive documentation
  • Active development and large community support
  • Designed for building complex enterprise-level applications

Cons of element

  • Larger bundle size due to its extensive feature set
  • Steeper learning curve for beginners
  • Less flexibility for custom designs compared to building from scratch

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">
  <el-table-column prop="name" label="Name"></el-table-column>
  <el-table-column prop="age" label="Age"></el-table-column>
</el-table>

vue2.0-taopiaopiao:

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

The element code showcases pre-built components with built-in functionality, while vue2.0-taopiaopiao uses more basic HTML elements with custom styling and logic. element provides a more standardized and feature-rich approach, while vue2.0-taopiaopiao offers more flexibility for custom implementations.

23,922

A high quality UI Toolkit built on Vue.js 2.0

Pros of iview

  • Comprehensive UI component library with a wide range of ready-to-use components
  • Well-documented and actively maintained, with regular updates and bug fixes
  • Supports both Vue 2 and Vue 3, providing flexibility for different project requirements

Cons of iview

  • Larger bundle size due to the extensive component library, which may impact initial load times
  • Steeper learning curve for developers unfamiliar with the iview ecosystem
  • Less customizable compared to building components from scratch

Code Comparison

iview:

<template>
  <Button type="primary" @click="handleClick">Click me</Button>
</template>

<script>
export default {
  methods: {
    handleClick() {
      this.$Message.info('Button clicked');
    }
  }
}
</script>

vue2.0-taopiaopiao:

<template>
  <div class="button" @click="handleClick">Click me</div>
</template>

<script>
export default {
  methods: {
    handleClick() {
      console.log('Button clicked');
    }
  }
}
</script>

The iview example showcases the use of pre-built components and integrated messaging system, while vue2.0-taopiaopiao demonstrates a more custom approach to building UI elements.

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

Pros of vue-element-admin

  • More comprehensive and feature-rich, offering a complete admin panel solution
  • Actively maintained with regular updates and a large community
  • Extensive documentation and examples for easier implementation

Cons of vue-element-admin

  • Steeper learning curve due to its complexity and extensive features
  • Potentially overkill for smaller projects or simple admin interfaces
  • Heavier bundle size, which may impact initial load times

Code Comparison

vue-element-admin:

import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  }
]

vue2.0-taopiaopiao:

import Vue from 'vue'
import Router from 'vue-router'
import Movie from '../views/movie/movie.vue'
import Cinema from '../views/cinema/cinema.vue'

Vue.use(Router)

export default new Router({
  routes: [
    { path: '/movie', component: Movie },
    { path: '/cinema', component: Cinema }
  ]
})

The code comparison shows that vue-element-admin uses a more modular approach with lazy-loading components, while vue2.0-taopiaopiao has a simpler router configuration. This reflects the overall complexity difference between the two projects.

Vue3、Element Plus、typescript后台管理系统

Pros of vue-manage-system

  • More comprehensive and feature-rich admin template
  • Regularly updated with newer Vue.js versions and dependencies
  • Includes a variety of pre-built components and layouts

Cons of vue-manage-system

  • Potentially more complex for beginners due to its extensive features
  • May require more customization to fit specific project needs
  • Larger codebase and potentially higher learning curve

Code Comparison

vue-manage-system:

<template>
    <div class="header">
        <div class="collapse-btn" @click="collapseChage">
            <i v-if="!collapse" class="el-icon-s-fold"></i>
            <i v-else class="el-icon-s-unfold"></i>
        </div>
        <div class="logo">后台管理系统</div>
        <div class="header-right">
            <div class="header-user-con">
                <!-- User-related components -->
            </div>
        </div>
    </div>
</template>

vue2.0-taopiaopiao:

<template>
  <div id="app">
    <v-header></v-header>
    <router-view></router-view>
    <v-footer></v-footer>
    <v-loading v-show="loading"></v-loading>
    <v-mask v-show="mask"></v-mask>
  </div>
</template>

The code comparison shows that vue-manage-system has a more detailed and feature-rich header component, while vue2.0-taopiaopiao has a simpler overall app structure. This reflects the differences in complexity and focus between the two projects.

41,144

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

Pros of vue2-elm

  • More comprehensive and feature-rich, covering a wider range of functionalities
  • Better documentation and code organization, making it easier for developers to understand and contribute
  • Includes a backend implementation, providing a full-stack solution

Cons of vue2-elm

  • Larger codebase, which may be overwhelming for beginners or smaller projects
  • More complex setup and configuration required
  • Potentially slower initial load times due to the increased number of components and features

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'
import FastClick from 'fastclick'

vue2.0-taopiaopiao:

import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import store from './vuex/store'
import VueResource from 'vue-resource'

The code comparison shows that vue2-elm includes additional imports for configuration and performance optimization (FastClick), while vue2.0-taopiaopiao has a simpler setup with fewer dependencies.

Both projects use Vue.js 2.0 and implement routing and state management. However, vue2-elm appears to have a more extensive configuration and setup process, which aligns with its more comprehensive feature set.

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

vue2.0与express构建淘票票页面

react构建淘票票,请点击这里

react-native构建淘票票,请点击这里

描述

写这个项目的目的一是为了学习vue2.0相关的知识点,二是为了给他想要了解vue2.0的童鞋提供一个学习demo。所以为了使这个项目更加完整,项目中加入一个server服务,模拟服务器环境,为前端提供数据来源,当用npm run deploy命令运行前端环境时,就可以直接将前端资源部署到server服务里。因此本项目有两个环境,一个是前端开发环境(端口是8080),一个是server服务环境(端口是9090)。

主要技术栈:

  • vue2.0
  • vue-router
  • vuex
  • mint-ui
  • nodejs
  • express

如何运行

下载项目

 git clone https://github.com/canfoo/vue2.0-taopiaopiao.git

打开一个终端(称这个终端为A终端)进入到vue2.0-taopiaopiao目录安装依赖包

 npm install

打开另一个一个终端(称这个终端为B终端)进入到server目录安装依赖包

 npm install

启动server服务(得先启动后台服务,否则前端页面没有数据),在server目录下执行以下命令,成功执行会终端会提示服务端口号为9090

 npm run start

启动前端开发服务,在vue2.0-taopiaopiao目录里执行以下命令,成功执行后,会自动打开浏览器访问前端开发环境,浏览地址是http://localhost:8080

 npm run dev

前端资源部署到server里,开发完成后,在vue2.0-taopiaopiao目录里执行以下命令,成功执行后,可以通过访问server提供的路径访问到页面了,访问路径为http://localhost:9090/app

 npm run deploy

备注:因为本项目有提供后台服务,所以当前端部署到服务器后,只要后台服务启动,就可以直接通过http://localhost:9090/app路径访问到前端页面,无须再启动前端的开发服务。

项目预览

Mou icon ---------- Mou icon Mou icon ---------- Mou icon

主要目录结构

build
config
src //前端主要开发目录
--assets //存放前端静态资源
--components //存放组件
--store //vuex数据流管理
--views //页面试图,由vue-router引入
--App.vue
--main.js //前端入口文件
server //后台服务
--bin //启动后台服务配置
--database //存放页面所需要的json数据
--public //前端部署时存放在后台服务的位置
--routes //路由于请求接口管理
--views //前端模板存放位置
--app.js //后台服务入口

后台接口

本项目是手动抓取淘票票部分数据,数据是16年12月份的,城市数据只有北上广有数据,其它城市都是随机从北上广数据抽取过来的,电影数据也是部分有数据。抓取的数据存放在server目录里的database里,供前端调用。

  1. 访问淘票票首页路径: http://localhost:9090/app

  2. 部分数据接口

    • 获取热映数据
    method: GET
    url: http://localhost:9090/movie/hot/?city=bj
    参数说明: city可以为bj、sh、gz
    
    • 获取即将上映数据
    method: GET
    url: http://localhost:9090/movie/coming/?limit=20&offset=0
    参数说明: limit为每次请求的数据数量,offset为所有数据的偏移量
    
    • 获取城市数据
    method: GET
    url: http://localhost:9090/movie/city
    
    • 获取电影院数据
    method: GET
    url: http://localhost:9090/movie/cinema/?city=bj
    参数说明:  city可以为bj、sh、gz
    

项目博客地址

如果对项目有疑惑的地方,请到http://www.cnblogs.com/canfoo/p/6214406.html里留言。如果觉得这个项目对你有帮助的话,请Star一下本项目,这是对作者最大的支持。