diff --git a/apps/product/controllers/sale.js b/apps/product/controllers/sale.js index 543fb8d..32b3bdc 100644 --- a/apps/product/controllers/sale.js +++ b/apps/product/controllers/sale.js @@ -10,9 +10,12 @@ const headerModel = require('../../../doraemon/models/header'); const mRoot = '../models'; // sale 页 model -const sale = require(`${mRoot}/sale`); +// const sale = require(`${mRoot}/sale`); -const saleDiscount = require(`${mRoot}/sale-discount`); +// const saleDiscount = require(`${mRoot}/sale-discount`); + +// 开发用模拟数据 +const simulation = require(`${mRoot}/simulation`); /** * sale 首页 @@ -32,16 +35,16 @@ exports.index = (req, res) => { response.devEnv = true; // 假数据输出 - // res.render('sale/index', Object.assign(response, sale.outputDevData())); + res.render('sale/index', Object.assign(response, simulation.saleIndex())); // 真实数据输出 - return sale.getSaleDate().then(result => { + /* return sale.getSaleDate().then(result => { response.result = result; response.resultShow = JSON.stringify(result, null, 4); res.render('sale/index', response); - }); + });*/ }) .catch(() => { res.render('error', { devEnv: true, pageErr: true }); @@ -63,13 +66,112 @@ exports.discount = (req, res) => { response.footerTop = true; response.devEnv = true; - return saleDiscount.getSaleDiscountData() + // 假数据输出 + res.render('sale/discount', Object.assign(response, simulation.discount())); + + /* return saleDiscount.getSaleDiscountData() .then(result => { response.result = result; response.resultShow = JSON.stringify(result, null, 4); res.render('sale/discount', response); - }); + });*/ + + }) + .catch(() => { + res.render('error', { devEnv: true, pageErr: true }); + }); +}; + +/** + * VIP会员专享 + * @param {[type]} req [description] + * @param {[type]} res [description] + * @return {[type]} [description] + */ +exports.vip = (req, res) => { + headerModel.requestHeaderData() + .then(response => { + response = headerModel.setHeaderData(response.data, 'vip'); + response.module = 'product'; + response.page = 'sale'; + response.footerTop = true; + response.devEnv = true; + + // 假数据输出 + res.render('sale/other', Object.assign(response, simulation.other())); + + /* return saleVip.getSaleVipData() + .then(result => { + response.result = result; + response.resultShow = JSON.stringify(result, null, 4); + + res.render('sale/other', response); + });*/ + + }) + .catch(() => { + res.render('error', { devEnv: true, pageErr: true }); + }); +}; + +/** + * 断码专区 + * @param {[type]} req [description] + * @param {[type]} res [description] + * @return {[type]} [description] + */ +exports.breakingYards = (req, res) => { + headerModel.requestHeaderData() + .then(response => { + response = headerModel.setHeaderData(response.data, 'breakingYards'); + response.module = 'product'; + response.page = 'sale'; + response.footerTop = true; + response.devEnv = true; + + // 假数据输出 + res.render('sale/other', Object.assign(response, simulation.other())); + + /* return breakingYards.getSaleBreakingYardsData() + .then(result => { + response.result = result; + response.resultShow = JSON.stringify(result, null, 4); + + res.render('sale/other', response); + });*/ + + }) + .catch(() => { + res.render('error', { devEnv: true, pageErr: true }); + }); +}; + +/** + * 断码专区 + * @param {[type]} req [description] + * @param {[type]} res [description] + * @return {[type]} [description] + */ +exports.newSale = (req, res) => { + headerModel.requestHeaderData() + .then(response => { + response = headerModel.setHeaderData(response.data, 'newSale'); + response.module = 'product'; + response.page = 'sale'; + response.footerTop = true; + response.devEnv = true; + + // 假数据输出 + res.render('sale/other', Object.assign(response, simulation.other())); + + /* return newSale.getSaleNewSaleData() + .then(result => { + response.result = result; + response.resultShow = JSON.stringify(result, null, 4); + + res.render('sale/other', response); + });*/ }) .catch(() => { diff --git a/apps/product/models/sale.js b/apps/product/models/sale.js index dd0942b..79b9d97 100644 --- a/apps/product/models/sale.js +++ b/apps/product/models/sale.js @@ -2,7 +2,7 @@ * @Author: Targaryen * @Date: 2016-05-19 10:20:08 * @Last Modified by: Targaryen - * @Last Modified time: 2016-05-19 11:34:38 + * @Last Modified time: 2016-05-19 16:49:04 */ 'use strict'; @@ -24,254 +24,6 @@ const handleSaleData = (origin) => { }; /** - * 输出开发用假数据 - * @return {[type]} [description] - */ -exports.outputDevData = () => { - return { - module: 'product', - page: 'sale', - topBanner: { - list: [ - { - bannerHeight: 200, - href: 'http://www.yoho.cn', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327' - }, - { - bannerHeight: 200, - href: 'http://www.yoho.cn', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327' - }, - { - bannerHeight: 200, - href: 'http://www.yoho.cn', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327' - } - ] - }, - - activityEnter: [ - { - link: 'www.baidu.com', - icon: 'dasdasdas', - title: '我是标题', - desc: '参加活动' - }, - { - link: 'www.baidu.com', - icon: 'dasdasdas', - title: '我是标题', - desc: '参加活动' - }, - { - link: 'www.baidu.com', - icon: 'dasdasdas', - title: '我是标题', - desc: '参加活动' - } - ], - - brandSale: [ - { - big: [ - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '低于一小时', - brand: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/80/h/50', - discount: '1折起' - }, - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '低于一小时', - brand: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/80/h/50', - discount: '1折起' - }, - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '低于一小时', - brand: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/80/h/50', - discount: '1折起' - } - ], - normal: [ - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '剩余22小时', - title: 'yoho!buy 新品大促销,全场100折' - }, - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '剩余22小时', - title: 'yoho!buy 新品大促销,全场100折' - }, - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '剩余22小时', - title: 'yoho!buy 新品大促销,全场100折' - }, - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '剩余22小时', - title: 'yoho!buy 新品大促销,全场100折' - }, - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '剩余22小时', - title: 'yoho!buy 新品大促销,全场100折' - }, - { - link: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - time: '剩余22小时', - title: 'yoho!buy 新品大促销,全场100折' - } - ] - - } - ], - - saleCategory: [ - { - title: 'VIP会员专享', - navItem: [ - { - vip: true, - url: '/sa/ds', - title: '今日推荐' - }, - { - incompleteSize: true, - url: '/sa/ds', - title: '上装' - }, - { - newDiscount: true, - url: '/sa/ds', - title: '裤装' - }, - { - vip: true, - url: '/sa/ds', - title: '鞋履' - }, - { - vip: true, - url: '/sa/ds', - title: '配饰' - } - ], - saleImage: [ - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - }, - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - }, - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - }, - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - }, - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - }, - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - }, - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - }, - { - href: 'www.baidu.com', - img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', - name: '测试商品', - originPrice: '11321', - price: '213', - vip: true - } - ] - }, - { - title: '断码区', - navItem: [ - { - vip: true, - url: '/sa/ds', - title: '今日推荐' - }, - { - incompleteSize: true, - url: '/sa/ds', - title: '上装' - }, - { - newDiscount: true, - url: '/sa/ds', - title: '裤装' - }, - { - vip: true, - url: '/sa/ds', - title: '鞋履' - }, - { - vip: true, - url: '/sa/ds', - title: '配饰' - } - ] - } - ] - - }; -}; - -/** * 获取首页数据 * @return {[type]} [description] */ diff --git a/apps/product/models/simulation.js b/apps/product/models/simulation.js new file mode 100644 index 0000000..3dfe7e5 --- /dev/null +++ b/apps/product/models/simulation.js @@ -0,0 +1,227 @@ +/* + * @Author: Targaryen + * @Date: 2016-05-19 16:48:43 + * @Last Modified by: Targaryen + * @Last Modified time: 2016-05-19 17:02:34 + */ + +'use strict'; + +/** + * 输出开发用假数据 首页 + * @return {[type]} [description] + */ +exports.saleIndex = () => { + return { + module: 'product', + page: 'sale', + topBanner: { + list: [{ + bannerHeight: 200, + href: 'http://www.yoho.cn', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327' + }, { + bannerHeight: 200, + href: 'http://www.yoho.cn', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327' + }, { + bannerHeight: 200, + href: 'http://www.yoho.cn', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/830/h/327' + }] + }, + + activityEnter: [{ + link: 'www.baidu.com', + icon: 'dasdasdas', + title: '我是标题', + desc: '参加活动' + }, { + link: 'www.baidu.com', + icon: 'dasdasdas', + title: '我是标题', + desc: '参加活动' + }, { + link: 'www.baidu.com', + icon: 'dasdasdas', + title: '我是标题', + desc: '参加活动' + }], + + brandSale: [{ + big: [{ + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '低于一小时', + brand: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/80/h/50', + discount: '1折起' + }, { + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '低于一小时', + brand: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/80/h/50', + discount: '1折起' + }, { + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '低于一小时', + brand: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/80/h/50', + discount: '1折起' + }], + normal: [{ + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '剩余22小时', + title: 'yoho!buy 新品大促销,全场100折' + }, { + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '剩余22小时', + title: 'yoho!buy 新品大促销,全场100折' + }, { + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '剩余22小时', + title: 'yoho!buy 新品大促销,全场100折' + }, { + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '剩余22小时', + title: 'yoho!buy 新品大促销,全场100折' + }, { + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '剩余22小时', + title: 'yoho!buy 新品大促销,全场100折' + }, { + link: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + time: '剩余22小时', + title: 'yoho!buy 新品大促销,全场100折' + }] + + }], + + saleCategory: [{ + title: 'VIP会员专享', + navItem: [{ + vip: true, + url: '/sa/ds', + title: '今日推荐' + }, { + incompleteSize: true, + url: '/sa/ds', + title: '上装' + }, { + newDiscount: true, + url: '/sa/ds', + title: '裤装' + }, { + vip: true, + url: '/sa/ds', + title: '鞋履' + }, { + vip: true, + url: '/sa/ds', + title: '配饰' + }], + saleImage: [{ + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }, { + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }, { + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }, { + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }, { + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }, { + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }, { + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }, { + href: 'www.baidu.com', + img: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/13/19/0144078a008a5dc2be52a6ec65c74c1f2c.jpg?imageView2/1/w/378/h/500', + name: '测试商品', + originPrice: '11321', + price: '213', + vip: true + }] + }, { + title: '断码区', + navItem: [{ + vip: true, + url: '/sa/ds', + title: '今日推荐' + }, { + incompleteSize: true, + url: '/sa/ds', + title: '上装' + }, { + newDiscount: true, + url: '/sa/ds', + title: '裤装' + }, { + vip: true, + url: '/sa/ds', + title: '鞋履' + }, { + vip: true, + url: '/sa/ds', + title: '配饰' + }] + }] + + }; +}; + +/** + * 专场折扣 + * @return {[type]} [description] + */ +exports.discount = () => { + return {}; +}; + +/** + * sale 下其他页面 + * @return {[type]} [description] + */ +exports.other = () => { + return {}; +}; diff --git a/apps/product/router.js b/apps/product/router.js index 1b83e06..aa441ee 100644 --- a/apps/product/router.js +++ b/apps/product/router.js @@ -19,5 +19,8 @@ const sale = require(`${cRoot}/sale`); // router.get('/detail/:id/:gid', detail.index); router.get('/sale/index', sale.index); router.get('/sale/discount', sale.discount); +router.get('/sale/vip', sale.vip); +router.get('/sale/breakingYards', sale.breakingYards); +router.get('/sale/newSale', sale.newSale); module.exports = router; diff --git a/apps/product/views/action/sale/arena.hbs b/apps/product/views/action/sale/arena.hbs deleted file mode 100644 index 6560465..0000000 --- a/apps/product/views/action/sale/arena.hbs +++ /dev/null @@ -1,3 +0,0 @@ -<div class="sale-arena-page yoho-page"> - <p>coding here arena</p> -</div> diff --git a/apps/product/views/action/sale/other.hbs b/apps/product/views/action/sale/other.hbs new file mode 100644 index 0000000..be27f2b --- /dev/null +++ b/apps/product/views/action/sale/other.hbs @@ -0,0 +1 @@ +<div>keep coding</div> \ No newline at end of file