36 注册

1,创建 views/login/Register.vue 文件为注册页面
复制代码
<template>
	<div>
		1111
	</div>
</template>

<script>
</script>

<style>
</style>
2,去 src/router/index.js 文件添加路由如下:
复制代码
{
    path: "/register",
    name: "Register",
    component: () =>
        import("../views/login/Register.vue"),
},
3,去 views/login/Login.vue和views/login/UserLogin.vue 添加点击事件,当从以上两个页面点击'快速注册',都可以跳转到注册页面
复制代码
template:
<span @click="goRegister">快速注册</span>

script:
// 点击'快速注册'跳转到注册页面
goRegister() {
    this.$router.push('/register')
},
4, 去 访问 http://localhost:8080/register看到1111,表示注册页面已经成功创建。

注册实现代码

复制代码
1, views/login/Header.vue
<template>
	<header>
		<!-- 左 -->
		<div @click="goBack">
			<i class="iconfont icon-a-huaban1fuben44"></i>
		</div>
		<!-- 中 -->
		<div>
			<slot>
				<span>登录</span>
			</slot>
		</div>
		<!-- 右 -->
		<div>
			<i class="iconfont icon-kefu"></i>
		</div>
	</header>
</template>

<script>
	export default {
		data() {
			return {
				//
			}
		},
		methods: {
			goBack() {
				// 返回上一页
				this.$router.back();
			},
		}
	}
</script>

<style scoped lang="scss">
	header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		height: 44px;
		color: #fff;
		background-color: #b0352f;

		i {
			padding: 0 18px;
			font-size: 24px;
		}

		span {
			font-size: 16px;
			font-weight: 500;
		}
	}
</style>






2, views/login/Login.vue

<template>
	<div class="login container">
		<Header></Header>
		<section>
			<div class="login-tel">
				<input type="text" v-model="userTel" placeholder="请输入手机号" pattern="[0-9]*" />
			</div>
			<div class="login-code">
				<input type="text" v-model="userCode" placeholder="请输入验证码" pattern="[0-9]*" />
				<button :disabled="disabled" @click="sendCode">{{codeMsg}}</button>
			</div>
			<div class="login-btn" @click="login">登录</div>
			<div class="login_tab">
				<span @click="goUserLogin">密码登录</span>
				<span @click="goRegister">快速注册</span>
			</div>
		</section>
		<Tabbar></Tabbar>
	</div>
</template>

<script>
	import Tabbar from '@/components/common/Tabbar.vue'
	import Header from '@/views/login/Header.vue'
	import {
		Toast
	} from 'mint-ui';
	import http from '@/common/api/request.js';
	export default {
		// 绑定数据和验证规则
		data() {
			return {
				disabled: false,
				userTel: '',
				userCode: '',
				// 验证规则
				rules: {
					// 验证手机号
					userTel: {
						rule: /^1[23456789]\d{9}$/,
						msg: '手机号不能为空,并且是11位数字'
					}
				},
				// 验证倒计时
				codeNum: 6,
				codeMsg: '获取短信验证码',
				code: '' // 将短信验证码存储起来 默认为空
			}
		},
		components: {
			Header,
			Tabbar
		},
		methods: {


			// 点击获取短信验证码按钮
			sendCode() {
				// 前端先验证
				if (!this.validate('userTel')) return;

				// 只要判断手机号正确就要发送一个请求
				// 请求短信验证码接口
				// 验证通过以后前端再发送请求,给后端验证
				http.$axios({
					url: '/api/code',
					method: 'POST',
					data: { // 前端向后端传递用户输入的数据-> 手机号
						// 前端给后端传递手机号
						phone: this.userTel
					}
				}).then(res => {
					// 后端返回给前端的数据
					if (!res.success) return;
					console.log(res);

					// 后端返回给前端的数据
					// console.log(res);
					// if (res.success) {
					// 	// 将短信验证码存储起来
					// 	this.code = res.data
					// }
				})


				// 禁用按钮
				this.disabled = true;

				// 倒计时 定时器
				let timer = setInterval(() => {
					--this.codeNum;
					this.codeMsg = `重新发送 ${this.codeNum}`;
				}, 1000);

				// 判断什么时候停止定时器 6秒时间
				setTimeout(() => {
					// 停止定时器
					clearInterval(timer);
					// 让倒计时恢复到6秒时间
					this.codeNum = 6;
					// 让按钮可用
					this.disabled = false;
					// 让文本还是显示 '获取短信验证码'
					this.codeMsg = '获取短信验证码';
				}, 6000)
			},
			// 注册 点击'快速注册'跳转到注册页面
			goRegister() {
				this.$router.push('/register')
			},
			// 密码登录 点击'密码登录'跳转到密码登录页面
			goUserLogin() {
				this.$router.push('/userLogin');
			},
			// 验证信息提示
			validate(key) {
				// key为 'userTel' 或者 'userPwd'
				let bool = true;
				if (!this.rules[key].rule.test(this[key])) {
					// 提示信息 this.rules[key]=res
					Toast(this.rules[key].msg);
					bool = false;
					return false;
				}
				return bool;
			},
			// 当用户点击 '登录'
			login() {
				alret(1);
				// 接收到的验证码 和 用户输入的验证码相等,表示登录成功
				if (this.code == this.userTel) {
					// 证明用户输入的短信验证码是正确的==>发送请求,把用户存储到数据库中
					// 请求短信验证码接口
					// 验证通过以后前端再发送请求,给后端验证
					http.$axios({
						url: '/api/addUser',
						method: 'POST',
						data: { // 前端向后端传递用户输入的数据-> 手机号
							// 前端给后端传递手机号
							phone: this.userTel
							// password: this.userPwd
						}
					}).then(res => {
						// 后端返回给前端的数据
						// console.log(res);
						if (res.success) {
							// 将短信验证码存储起来
							this.code = res.data
						}
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	section {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #f5f5f5;

		div {
			margin: 30px 0;
			width: 335px;
			height: 44px;
		}

		.login-tel {
			margin-top: 50px;

			input {
				width: 335px;
			}
		}

		.login-code {
			display: flex;

			input {
				flex: 1;
			}

			button {
				padding: 0 20px;
				line-height: 44px;
				color: #fff;
				background-color: #b0352f;
				border: 0; // 去除默认边框
				border-radius: 3px;
			}
		}

		input {
			box-sizing: border-box;
			padding: 0 10px;
			line-height: 44px;
			background-color: #FFFFFF;
			border: 1px solid #ccc;
			border-radius: 6px;
		}

		.login-btn {
			line-height: 44px;
			text-align: center;
			color: #fff;
			background-color: #b0352f;
			border-radius: 6px;
		}

		.login_tab {
			display: flex;
			justify-content: space-between;
			font-size: 16px;
		}
	}
</style>





3, views/login/Register.vue
<template>
	<div class="login container">
		<Header>
			<span>注册</span>
		</Header>
		<section>
			<div class="login-tel">
				<input type="text" v-model="userTel" placeholder="请输入手机号" pattern="[0-9]*" />
			</div>
			<div class="login-code">
				<input type="text" v-model="userCode" placeholder="请输入验证码" pattern="[0-9]*" />
				<button :disabled="disabled" @click="sendCode">{{codeMsg}}</button>
			</div>
			<div class="login-tel">
				<input type="text" v-model="userPwd" placeholder="请设置密码" pattern="[0-9]*" />
			</div>
			<div class="login-btn" @click="register">注册</div>
		</section>
		<Tabbar></Tabbar>
	</div>
</template>

<script>
	import Tabbar from '@/components/common/Tabbar.vue'
	import Header from '@/views/login/Header.vue'
	import {
		Toast
	} from 'mint-ui';
	import http from '@/common/api/request.js';
	export default {
		// 绑定数据和验证规则
		data() {
			return {
				disabled: false,
				userTel: '',
				userPwd: '',
				userCode: '',
				// 验证规则
				rules: {
					// 验证手机号
					userTel: {
						rule: /^1[23456789]\d{9}$/,
						msg: '手机号不能为空,并且是11位数字'
					},
					// 密码验证
					userPwd: {
						rule: /^\w{6,18}$/,
						msg: '密码不能为空,并且要求6,18位字母数字'
					}
				},
				// 验证倒计时
				codeNum: 6,
				codeMsg: '获取短信验证码',
				code: '' // 将短信验证码存储起来 默认为空
			}
		},
		components: {
			Header,
			Tabbar
		},
		methods: {


			// 点击获取短信验证码按钮
			sendCode() {
				// 前端先验证
				if (!this.validate('userTel')) return;

				// 只要判断手机号正确就要发送一个请求
				// 请求短信验证码接口
				// 验证通过以后前端再发送请求,给后端验证
				http.$axios({
					url: '/api/code',
					method: 'POST',
					data: { // 前端向后端传递用户输入的数据-> 手机号
						// 前端给后端传递手机号
						phone: this.userTel
						// password: this.userPwd
					}
				}).then(res => {
					// 后端返回给前端的数据
					// console.log(res);
					if (res.success) {
						// 将短信验证码存储起来
						this.code = res.data
					}
				})


				// 禁用按钮
				this.disabled = true;

				// 倒计时 定时器
				let timer = setInterval(() => {
					--this.codeNum;
					this.codeMsg = `重新发送 ${this.codeNum}`;
				}, 1000);

				// 判断什么时候停止定时器 6秒时间
				setTimeout(() => {
					// 停止定时器
					clearInterval(timer);
					// 让倒计时恢复到6秒时间
					this.codeNum = 6;
					// 让按钮可用
					this.disabled = false;
					// 让文本还是显示 '获取短信验证码'
					this.codeMsg = '获取短信验证码';
				}, 6000)
			},
			// 注册 点击'快速注册'跳转到注册页面
			goRegister() {
				this.$router.push('/register')
			},
			// 密码登录 点击'密码登录'跳转到密码登录页面
			goUserLogin() {
				this.$router.push('/userLogin');
			},
			// 验证信息提示
			validate(key) {
				// key为 'userTel' 或者 'userPwd'
				let bool = true;
				if (!this.rules[key].rule.test(this[key])) {
					// 提示信息 this.rules[key]=res
					Toast(this.rules[key].msg);
					bool = false;
					return false;
				}
				return bool;
			},
			// 当用户点击 '注册'
			register() {
				// 前端先验证密码
				if (!this.validate('userPwd')) return;

				// 判断验证码是否正确
				if (this.code != this.userCode) {
					// Toast(this.rules[key].msg);
					Toast('验证码不正确');
					return
				}

				// alret(1);
				// 接收到的验证码 和 用户输入的验证码相等,表示登录成功
				if (this.code == this.userTel) {
					// 证明用户输入的短信验证码是正确的==>发送请求,把用户存储到数据库中
					// 请求短信验证码接口
					// 验证通过以后前端再发送请求,给后端验证
					// 如果正确进行注册
					http.$axios({
						url: '/api/register',
						method: 'POST',
						data: { // 前端向后端传递用户输入的数据-> 手机号
							// 前端给后端传递手机号
							phone: this.userTel,
							pwd: this.userPwd
						}
					}).then(res => {
						// 后端返回给前端的数据
						// if (!res.success) return;
						console.log(res);
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	section {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #f5f5f5;

		div {
			margin: 30px 0;
			width: 335px;
			height: 44px;
		}

		.login-tel {
			margin-top: 30px;

			input {
				width: 335px;
			}
		}

		input {
			box-sizing: border-box;
			padding: 0 10px;
			line-height: 44px;
			background-color: #FFFFFF;
			border: 1px solid #ccc;
			border-radius: 6px;
		}

		.login-btn {
			line-height: 44px;
			text-align: center;
			color: #fff;
			background-color: #b0352f;
			border-radius: 6px;
		}

		.login-code {
			display: flex;

			input {
				flex: 1;
			}

			button {
				padding: 0 20px;
				line-height: 44px;
				color: #fff;
				background-color: #b0352f;
				border: 0; // 去除默认边框
				border-radius: 3px;
			}
		}
	}
</style>







4, views/login/UserLogin.vue

<template>
	<div class="login container">
		<Header></Header>
		<section>
			<div class="login-tel">
				<input type="text" v-model="userTel" placeholder="请输入手机号" pattern="[0-9]*" />
			</div>
			<div class="login-tel">
				<input type="text" v-model="userPwd" placeholder="请输入密码" pattern="[0-9]*" />
			</div>
			<div class="login-btn" @click="login">登录</div>
			<div class="login_tab">
				<span @click="goLogin">短信登录</span>
				<span>找回密码</span>
				<span @click="goRegister">快速注册</span>
			</div>
		</section>
		<Tabbar></Tabbar>
	</div>
</template>

<script>
	import Tabbar from '@/components/common/Tabbar.vue';
	import Header from '@/views/login/Header.vue';
	import {
		Toast
	} from 'mint-ui';
	import http from '@/common/api/request.js';
	export default {
		data() {
			return {
				// 用户输入数据
				userTel: '', // 用户输入的手机号
				userPwd: '', // 用户输入的密码
				// 验证规则
				rules: {
					// 验证手机号
					userTel: {
						rule: /^1[23456789]\d{9}$/,
						msg: '手机号不能为空,并且是11位数字'
					},
					// 密码验证
					userPwd: {
						rule: /^\w{6,18}$/,
						msg: '密码不能为空,并且要求6,18位字母数字'
					}
				}
			}
		},
		components: {
			Header,
			Tabbar
		},
		methods: {


			// 点击登录按钮
			login() {
				// 前端先验证
				if (!this.validate('userTel')) return;
				if (!this.validate('userPwd')) return;

				// 验证通过以后前端再发送请求,给后端验证
				http.$axios({
					url: '/api/login',
					method: 'POST',
					data: { // 前端向后端传递用户输入的数据
						userTel: this.userTel,
						userPwd: this.userPwd
					}
				}).then(res => { // 后端返回给前端的数据
					// console.log(res);
					// 提示信息
					Toast(res.msg);

					// 登录失败
					if (!res.success) return;

					// 登录成功 跳转页面 ==> 存储用户信息
					//
				})
			},
			// 注册 点击'快速注册'跳转到注册页面
			goRegister() {
				this.$router.push('/register')
			},
			// 短信登录 点击'短信登录' 跳转到短信登录页面
			goLogin() {
				this.$router.push('/login');
			},
			// 验证信息提示
			validate(key) {
				// key为 'userTel' 或者 'userPwd'
				let bool = true;
				if (!this.rules[key].rule.test(this[key])) {
					// 提示信息 this.rules[key]=res
					Toast(this.rules[key].msg);
					bool = false;
					return false;
				}
				return bool;
			}
		}
	}
</script>

<style scoped lang="scss">
	section {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #f5f5f5;

		div {
			margin: 30px 0;
			width: 335px;
			height: 44px;
		}

		.login-tel {
			margin-top: 30px;

			input {
				width: 335px;
			}
		}

		input {
			box-sizing: border-box;
			padding: 0 10px;
			line-height: 44px;
			background-color: #FFFFFF;
			border: 1px solid #ccc;
			border-radius: 6px;
		}

		.login-btn {
			line-height: 44px;
			text-align: center;
			color: #fff;
			background-color: #b0352f;
			border-radius: 6px;
		}

		.login_tab {
			display: flex;
			justify-content: space-between;
			font-size: 16px;
		}
	}
</style>








5, src/router/index.js
import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [{
		path: "/home",
		name: "Home",
		component: Home,
	},
	{
		path: "/",
		redirect: "/home", // 重定向
	}, {
		path: "/list",
		name: "List",
		component: () =>
			import("../views/List.vue"),
	}, {
		path: "/cart",
		name: "Cart",
		component: () =>
			import("../views/Cart.vue"),
	}, {
		path: "/my",
		name: "My",
		component: () =>
			import("../views/My.vue"),
	},
	{
		path: "/search",
		children: [{
			path: "/",
			name: "index",
			component: () =>
				import("../views/search/Search-index.vue"),
		}, {
			path: "/search/list",
			name: "Search-list",
			component: () =>
				import("../views/search/Search-list.vue"),
		}],
		component: () =>
			import("../views/Search.vue"),
	},
	{
		path: "/detail",
		name: "Detail",
		component: () =>
			import("../views/Detail.vue"),
	},
	{
		path: "/login",
		name: "Login",
		component: () =>
			import("../views/login/Login.vue"),
	},
	{
		path: "/userLogin",
		name: "UserLogin",
		component: () =>
			import("../views/login/UserLogin.vue"),
	},
	{
		path: "/register",
		name: "Register",
		component: () =>
			import("../views/login/Register.vue"),
	},
];

const router = new VueRouter({
	mode: "history",
	base: process.env.BASE_URL,
	routes,
});

export default router;








6 views/My.vue
<template>
	<div class="my container">
		<header>
			<div class="login" @click="goLogin">登录/注册</div>
		</header>
		<section>
			<ul>
				<li>地址管理</li>
			</ul>
		</section>
		<Tabbar></Tabbar>
	</div>
</template>

<script>
	import Tabbar from '@/components/common/Tabbar.vue'
	export default {
		name: "My",
		components: {
			// 挂载
			Tabbar
		},
		methods: {
			// 在我的页面点击'登录/注册' 跳转到登录页面
			goLogin() {
				this.$router.push('/login');
			}
		}
	}
</script>

<style scoped lang="scss">
	// .my {
	// 	display: flex;
	// 	flex-direction: column;
	// 	width: 100vw;
	// 	height: 100vh;
	// 	overflow: hidden;
	// }

	header {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 160px;
		background-color: #b0352f;

		.login {
			padding: 10px 30px;
			font-size: 16px;
			color: #fff;
			// background-color: rgba(255, 181, 0, 0.9);
			background-color: #F6AB32;
			border-radius: 6px;
		}
	}

	section {
		flex: 1;
		overflow: hidden;

		ul li {
			padding: 15px;
			font-size: 16px;
		}
	}
</style>








7, server/db/userSql.js
// 验证数据库中的用户相关内容
const User = {
	// 查询用户手机号  老师: 18511773322    17511557182
	queryUserTel(option) {
		return 'select * from users where tel = ' + option.userTel + '';
	},
	// 查询用户密码
	queryUserPwd(option) {
		return 'select * from users where (tel = ' + option.userTel + ') and pwd = ' + option.userPwd + '';
	},
	// 新增用户数据
	insertData(option) {
		// 接收到的数据  前端传递给后端的数据
		let userTel = option.userTel;
		let userPwd = option.userPwd || '666666';

		return 'insert into users (tel,pwd,imgurl,nickName,token) values (" ' + userTel +
			' "," ' + userPwd + ' ","1.png","1","2")';
	}
}
enports = module.exports = User;









8, server/routes/index.js
var express = require('express');
var router = express.Router();
var connection = require('../db/sql.js');
var user = require('../db/userSql.js');
var QcloudSms = require("qcloudsms_js");


// const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors());

const bodyParser = require('body-parser');
app.use(bodyParser.json()); // 解析请求体 

/* GET home page. */
router.get('/', function(req, res, next) {
	res.render('index', {
		title: 'Express'
	});
});

// 注册
router.post('/api/register', function(req, res, next) {
	// 拿到前端传递的数据
	let params = {
		userTel: req.body.phone,
		userPwd: req.body.pwd
	}

	// 查询用户是否存在
	connect.query(user.queryUserTel(params), function(error, results) {
		// 如果有错误就抛出错误
		if (error) throw error;

		// 判断用户是否存在
		if (results.length > 0) {
			// 用户存在,直接返回
			res.send({
				code: 200,
				data: {
					success: true,
					msg: '登录成功',
					data: results[0]
				}
			})
		} else {
			// 用户不存在,新增一条数据
			connection.query(user.insertData(params), function(err, result) {
				// 新增数据后,再把新增数据查询一下,看看有没有添加成功
				connection.query(user.queryUserTel(params), function(e, r) {
					// 用户存在,直接返回
					res.send({
						code: 200,
						data: {
							success: true,
							msg: '登录成功',
							data: r[0]
						}
					})
				})
			})
		}
	})
})


// 增加一个用户
router.post('/api/addUser', function(req, res, next) {
	let params = {
		userTel: req.body.phone
	}

	// let tel = {
	// 	userTel: req.body.phone
	// }

	// 查询用户是否存在
	connect.query(user.queryUserTel(params), function(error, results) {
		// 如果有错误就抛出错误
		if (error) throw error;

		// 判断用户是否存在
		if (results.length > 0) {
			// 用户存在,直接返回
			res.send({
				code: 200,
				data: {
					success: true,
					msg: '登录成功',
					data: results[0]
				}
			})
		} else {
			// 用户不存在,新增一条数据
			connection.query(user.insertData(params), function(err, result) {
				// 新增数据后,再把新增数据查询一下,看看有没有添加成功
				connection.query(user.queryUserTel(params), function(e, r) {
					// 用户存在,直接返回
					res.send({
						code: 200,
						data: {
							success: true,
							msg: '登录成功',
							data: r[0]
						}
					})
				})
			})
		}
	})
})


// 请求短信验证码接口
router.post('/api/code', function(req, res, next) {

	// 后端接收前端发送的手机号	 
	let tel = req.body.phone;

	// 短信应用SDK AppID
	// var appid = 1400187558; // 老师的
	var appid = 1400979263; // 自己的 SDK AppID是1400开头  1400979236	   1400009099

	// 短信应用SDK AppKey
	// var appkey = "9ff91d87c2cd7cd0ea762f141975d1df37481d48700d70ac37470aefc60f9bad";
	var appkey = "10fd4851f4228eb21e670ee72fe932f8"; // 自己的
	// var appkey = "dc9dc3391896235ddc2325685047edc7"; // 老师的

	// 需要发送短信的手机号码
	// var phoneNumbers = ["18017927192", "15300935233"];
	var phoneNumbers = [tel]

	// 短信模板ID,需要在短信应用中申请
	var templateId = 285590; // 老师的 NOTE: 这里的模板ID`7839`只是一个示例,真实的模板ID需要在短信控制台中申请

	// 签名
	var smsSign = "三人行慕课"; // NOTE: 这里的签名只是示例,请使用真实的已申请的签名, 签名参数使用的是`签名内容`,而不是`签名ID`

	// 实例化QcloudSms
	var qcloudsms = QcloudSms(appid, appkey);

	// 设置请求回调处理, 这里只是演示,用户需要自定义相应处理回调
	function callback(err, ress, resData) {
		if (err) {
			console.log("err: ", err);
		} else {
			res.send({
				code: 200,
				data: {
					success: true,
					data: ress.req.body.params[0]
				}
			})
			// console.log("request data: ", ress.req);
			// console.log("response data: ", resData);
		}
	}

	// 指定模板ID单发短信
	var ssender = qcloudsms.SmsSingleSender();
	// 这个变量 params 就是往手机上发送的短信
	var params = [Math.floor(Math.random() * (9999 - 1000)) + 1000];
	ssender.sendWithParam(86, phoneNumbers[0], templateId,
		params, smsSign, "", "", callback); // 签名参数不能为空串
})


// 登录接口
router.post('/api/login', function(req, res, next) {
	// 后端要接收前端传递过来的值(数据)
	let params = {
		userTel: req.body.userTel,
		userPwd: req.body.userPwd
	};

	// 查询数据库中用户手机号是否存在
	connection.query(users.queryUserTel(params), function(error, results) {
		// 判断手机号存在是否存在
		if (results.length > 0) {
			//手机号存在
			connection.query(users.queryUserPwd(params), function(err, result) {
				//判断手机号和密码
				if (result.length > 0) {
					// 手机号和密码都对
					res.send({
						code: 200,
						data: {
							success: true,
							msg: '登录成功',
							data: result[0]
						}
					})
				} else {
					// 密码不对
					res.send({
						code: 302,
						data: {
							success: false,
							msg: '密码不正确'
						}
					})
				}
			})
		} else {
			// 手机号不存在
			res.send({
				code: 301,
				data: {
					success: false,
					msg: '手机号不存在'
				}
			})
		}
	})
})


// router.post('/api/login', function(req, res, next) {
// 	res.send({
// 		code: 0,
// 		data: {
// 			a: 1
// 		}
// 	})
// })


// 查询商品id的数据接口
router.get('/api/goods/id', function(req, res, next) {
	// 获取 前端给后端传递的 id 号
	let id = req.query.id;

	// 查询数据库
	connection.query("select * from space_store where id= '+id+'", function(error, results) {
		if (error) throw error;
		res.json({
			code: 0,
			// data: results // 后端给前端返回的数据为数组,需要解析
			data: results[0] // 后端给前端返回的数据为对象
		})
	})
})


// 分类的接口
router.get('/api/goods/list', function(req, res, next) {
	res.send({
		code: 0,
		data: [{
			// 一级
			id: 0,
			name: '推荐',
			data: [{
				// 二级
				id: 0,
				name: '推荐',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 1,
			name: '新品',
			data: [{
				// 二级
				id: 1,
				name: '新品',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 2,
			name: '习茶',
			data: [{
				// 二级
				id: 2,
				name: '习茶',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 3,
			name: '绿茶',
			data: [{
				// 二级
				id: 3,
				name: '绿茶',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 4,
			name: '乌龙茶',
			data: [{
				// 二级
				id: 4,
				name: '乌龙茶',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 5,
			name: '红茶',
			data: [{
				// 二级
				id: 5,
				name: '红茶',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 6,
			name: '白茶',
			data: [{
				// 二级
				id: 6,
				name: '白茶',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 7,
			name: '普洱茶',
			data: [{
				// 二级
				id: 7,
				name: '普洱茶',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 8,
			name: '花茶',
			data: [{
				// 二级
				id: 8,
				name: '花茶',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 9,
			name: '茶具',
			data: [{
				// 二级
				id: 9,
				name: '茶具',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}, {
			// 一级
			id: 10,
			name: '手艺',
			data: [{
				// 二级
				id: 10,
				name: '手艺',
				list: [{
					// 三级
					id: 0,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}, {
					// 三级
					id: 1,
					name: '铁观音',
					imgUrl: '/images/tieguanyin.png'
				}, {
					// 三级
					id: 2,
					name: '金骏眉',
					imgUrl: '/images/jinjunmei.png'
				}, {
					// 三级
					id: 3,
					name: '武夷岩茶',
					imgUrl: '/images/wuyiyancha.png'
				}, {
					// 三级
					id: 4,
					name: '龙井',
					imgUrl: '/images/longjing.png'
				}, {
					// 三级
					id: 5,
					name: '云南滇红',
					imgUrl: '/images/yunnandianhong.png'
				}, {
					// 三级
					id: 6,
					name: '建盏',
					imgUrl: '/images/jianzhan.png'
				}, {
					// 三级
					id: 7,
					name: '功夫茶具',
					imgUrl: '/images/gonghuchaju.png'
				}, {
					// 三级
					id: 8,
					name: '紫砂壶',
					imgUrl: '/images/teapot.png'
				}]
			}]
		}]
	})
})

// 查询商品数据接口 后端写接口
router.get('/api/goods/shopList', function(req, res, next) {
	// 前端给后端的数据 拿到前端发过来的数据
	// let searchName = req.query.searchName;
	let [searchName, orderName] = Object.keys(req.query);
	let [name, order] = Object.values(req.query);
	// console.log(searchName, orderName, name, order);

	// console.log('results');
	// 查询数据库表
	connection.query('select * from space_store where name like "%' + name +
		'%" order by "+orderName+" "+order+" ',
		function(error,
			results) {
			console.log('results');
			res.send({
				code: 0,
				data: results
			})
		})
})


// 首页推荐的数据  0==> 推荐  1==> 第一塀数据
router.get('/api/index_list/0/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			topBar: [{
				id: 0,
				label: '推荐'
			}, {
				id: 1,
				label: '大红袍'
			}, {
				id: 2,
				label: '铁观音'
			}, {
				id: 3,
				label: '绿茶'
			}, {
				id: 4,
				label: '普洱'
			}, {
				id: 5,
				label: '茶具'
			}, {
				id: 6,
				label: '花茶'
			}, {
				id: 7,
				label: '红茶'
			}, {
				id: 8,
				label: '设计'
			}, ],
			// 这是我们的swiper
			data: [{ // 这是swiper数据
				id: 0,
				type: 'swiperList',
				data: [{
					id: 1,
					imgUrl: './images/swiper4.png'
				}, {
					id: 2,
					imgUrl: './images/swiper5.png'
				}, {
					id: 3,
					imgUrl: './images/swiper6.png'
				}],
			}, { // 这是Icons数据
				id: 1,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}],
			}, { // 爆款推荐
				id: 2,
				type: 'recommendList',
				data: [{
					id: 1,
					name: '龙井1号铁观音250g',
					content: '鲜爽甘醇 口粮首先',
					price: '68',
					imgUrl: './images/recommend2.png'
				}, {
					id: 2,
					name: '龙井2号铁观音250g',
					content: '鲜爽甘醇 口粮首先',
					price: '58',
					imgUrl: './images/recommend2.png'
				}]
			}, {
				// 猜你喜欢
				id: 3,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 199,
				}, {
					id: 2,
					imgUrl: './images/like9.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like10.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 399,
				}, {
					id: 4,
					imgUrl: './images/like11.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 499,
				}, {
					id: 5,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 599,
				}, {
					id: 6,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 699,
				}, {
					id: 7,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 799,
				}, {
					id: 8,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 899,
				}, {
					id: 9,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 999,
				}, {
					id: 10,
					imgUrl: './images/like10.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 1099,
				}, {
					id: 11,
					imgUrl: './images/like11.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 1199,
				}]
			}]
		}
	})
});

// 首页大红袍的数据  1==> 大红袍  1==> 第一塀数据
router.get('/api/index_list/1/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/dhp.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});

// 首页铁观音的数据  2==> 铁观音  1==> 第一塀数据
router.get('/api/index_list/2/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/tieguanyin1.png'
				}]
			}, { // 这是Icons数据
				id: 3,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});

// 首页绿茶的数据  3==> 绿茶  1==> 第一塀数据
router.get('/api/index_list/3/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/green_tea.png'
				}]
			}, { // 这是Icons数据
				id: 3,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});

// 首页普洱的数据  4==> 普洱  1==> 第一塀数据
router.get('/api/index_list/4/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/puer.png'
				}]
			}, { // 这是Icons数据
				id: 3,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});

// 首页茶具的数据  5==> 茶具  1==> 第一塀数据
router.get('/api/index_list/5/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/tea_sets.png'
				}]
			}, { // 这是Icons数据
				id: 3,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});

// 首页花茶的数据  6==> 花茶  1==> 第一塀数据
router.get('/api/index_list/6/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/scented.png'
				}]
			}, { // 这是Icons数据
				id: 3,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});

// 首页红茶的数据  7==> 红茶  1==> 第一塀数据
router.get('/api/index_list/7/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/jinjunmei.png'
				}]
			}, { // 这是Icons数据
				id: 3,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});

// 首页设计的数据  8==> 设计   1==> 第一塀数据
router.get('/api/index_list/8/data/1', function(req, res, next) {
	res.send({
		code: 0,
		data: {
			data: [{
				id: 1,
				type: 'adList',
				data: [{
					id: 1,
					imgUrl: './images/design.png'
				}]
			}, { // 这是Icons数据
				id: 3,
				type: 'iconsList',
				data: [{
					id: 1,
					title: '自饮茶',
					imgUrl: './images/icons1.png'
				}, {
					id: 2,
					title: '茶具',
					imgUrl: './images/icons2.png'
				}, {
					id: 3,
					title: '茶礼盒',
					imgUrl: './images/icons3.png'
				}, {
					id: 4,
					title: '领取福利',
					imgUrl: './images/icons4.png'
				}, {
					id: 5,
					title: '官方验证',
					imgUrl: './images/icons5.png'
				}]
			}, {
				// 猜你喜欢
				id: 2,
				type: 'likeList',
				data: [{
					id: 1,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 2,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}, {
					id: 3,
					imgUrl: './images/like8.png',
					name: '建盏茶具套装 红色芝麻毫 12件套',
					price: 299,
				}]
			}]
		}
	})
});


module.exports = router;
相关推荐
Hao_Harrision几秒前
50天50个小项目 (React19 + Tailwindcss V4) ✨ | StickyNavbar(粘性导航栏)
前端·typescript·react·tailwindcss·vite7
IT古董5 分钟前
企业级官网全栈(React·Next.js·Tailwind·Axios·Headless UI·RHF·i18n)实战教程-前言
javascript·react.js·ui
LYFlied5 分钟前
前端性能优化常见面试问题汇总
前端·面试·性能优化
不爱学习的老登7 分钟前
基于CodeServer打造一个属于自己的 LaTeX Web 编辑器
前端·编辑器
Jinuss13 分钟前
飞冰ice.js中Model数据初始化原理
前端·javascript·react.js
IT_陈寒15 分钟前
Python性能优化实战:7个让代码提速300%的冷门技巧(附基准测试)
前端·人工智能·后端
世界唯一最大变量15 分钟前
一种全新的,自创的(2d无人开车)的算法
html
karshey16 分钟前
【前端】Defer:存储Promise状态,多个异步事件都结束后处理一些逻辑
java·前端·javascript
be or not to be16 分钟前
CSS 样式基础与视觉设计:从单位到字体
前端·css
0思必得018 分钟前
[Web自动化] CSS布局与定位
前端·css·自动化·html·web自动化