Authored by 陈轩

Merge remote-tracking branch 'origin/develop' into develop

@@ -10,3 +10,6 @@ @@ -10,3 +10,6 @@
10 <hr> 10 <hr>
11 Cookies:<br> 11 Cookies:<br>
12 {{{cookies}}} 12 {{{cookies}}}
  13 +
  14 +<hr>
  15 +<input type="date">
@@ -39,6 +39,12 @@ const component = { @@ -39,6 +39,12 @@ const component = {
39 res.render('index', _.merge(result, data[1])); 39 res.render('index', _.merge(result, data[1]));
40 }).catch(next); 40 }).catch(next);
41 }, 41 },
  42 + mydetails: (req, res) => {
  43 + res.render('mydetails', {
  44 + module: 'home',
  45 + page: 'mydetails'
  46 + });
  47 + },
42 help: (req, res, next) => { 48 help: (req, res, next) => {
43 homeModel.getHelpInfo().then(helpList => { 49 homeModel.getHelpInfo().then(helpList => {
44 res.render('help', { 50 res.render('help', {
@@ -104,8 +110,6 @@ const component = { @@ -104,8 +110,6 @@ const component = {
104 } 110 }
105 }).catch(next); 111 }).catch(next);
106 }, 112 },
107 -  
108 - // 关于我们  
109 aboutUs: (req, res) => { 113 aboutUs: (req, res) => {
110 res.render('about-us', { 114 res.render('about-us', {
111 module: 'home', 115 module: 'home',
@@ -33,7 +33,7 @@ const refund = { @@ -33,7 +33,7 @@ const refund = {
33 res.render('logistics', { 33 res.render('logistics', {
34 module: 'home', 34 module: 'home',
35 page: 'logistics', 35 page: 'logistics',
36 - company_list: result ? JSON.stringify(result.data) : "" 36 + company_list: result ? JSON.stringify(result.data) : ''
37 }); 37 });
38 }).catch(next); 38 }).catch(next);
39 }, 39 },
@@ -50,6 +50,7 @@ router.get('/exchange', exchange.exchange); @@ -50,6 +50,7 @@ router.get('/exchange', exchange.exchange);
50 router.get('/exchange/order', exchange.order); // AJAX 获取订单 商品 50 router.get('/exchange/order', exchange.order); // AJAX 获取订单 商品
51 router.get('/exchange/delivery', exchange.delivery); // AJAX 获取 退货方式 51 router.get('/exchange/delivery', exchange.delivery); // AJAX 获取 退货方式
52 52
  53 +router.get('/mydetails', home.mydetails); // 个人信息设置
53 router.get('/about-us', home.aboutUs); // 个人中心 - 关于我们 54 router.get('/about-us', home.aboutUs); // 个人中心 - 关于我们
54 55
55 56
  1 +<div class="personal-details" id="details">
  2 + <mydetails gender="women" birthday="1990.07.17"></mydetails>
  3 +</div>
  1 +/**
  2 + *
  3 + * @author: Aiden Xu<aiden.xu@yoho.cn>
  4 + * @date: 2016/07/25
  5 + */
  6 +'use strict';
  7 +
  8 +// const _ = require('lodash');
  9 +
  10 +// const helpers = global.yoho.helpers;
  11 +const model = require('../models/detail');
  12 +
  13 +/**
  14 + * 商品详情
  15 + */
  16 +const component = {
  17 + index(req, res) {
  18 + res.render('detail', {
  19 + module: 'news',
  20 + page: 'detail',
  21 + newsId: req.params[0]
  22 + });
  23 + },
  24 + news(req, res, next) {
  25 + const id = req.params[0];
  26 +
  27 + let params = {
  28 + // uid: req.user.uid || 8050378 // TODO: fix this hard coded uid
  29 + article_id: id,
  30 + client_type: 'h5'
  31 + };
  32 +
  33 +
  34 + model.index(params).then(result => {
  35 + res.json(result);
  36 + }).catch(next);
  37 + }
  38 +};
  39 +
  40 +module.exports = component;
  1 +/**
  2 + * Created by PhpStorm.
  3 + * User: Targaryen
  4 + * Date: 2016/7/26
  5 + * Time: 17:22
  6 + */
  7 +'use strict';
  8 +
  9 +module.exports = {
  10 + index: (req, res) => {
  11 + res.render('index', {
  12 + module: 'news',
  13 + page: 'index'
  14 + });
  15 + }
  16 +};
  1 +/**
  2 + * sub app
  3 + * @author: Bi Kai<kai.bi@yoho.cn>
  4 + * @date: 2016/05/09
  5 + */
  6 +
  7 +const express = require('express');
  8 +const path = require('path');
  9 +const hbs = require('express-handlebars');
  10 +
  11 +const app = express();
  12 +
  13 +// set view engine
  14 +const doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
  15 +
  16 +app.on('mount', function(parent) {
  17 + delete parent.locals.settings; // 不继承父 App 的设置
  18 + Object.assign(app.locals, parent.locals);
  19 +});
  20 +
  21 +app.set('views', path.join(__dirname, 'views/action'));
  22 +
  23 +app.engine('.hbs', hbs({
  24 + extname: '.hbs',
  25 + defaultLayout: 'layout',
  26 + layoutsDir: doraemon,
  27 + partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
  28 + helpers: global.yoho.helpers
  29 +}));
  30 +
  31 +// router
  32 +app.use(require('./router'));
  33 +
  34 +module.exports = app;
  1 +/**
  2 + *
  3 + * @author: Aiden Xu<aiden.xu@yoho.cn>
  4 + * @date: 2016/07/25
  5 + */
  6 +'use strict';
  7 +
  8 +// const _ = require('lodash');
  9 +
  10 +// const helpers = global.yoho.helpers;
  11 +const serviceAPI = global.yoho.ServiceAPI;
  12 +const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
  13 +const co = require('co');
  14 +const camelCase = global.yoho.camelCase;
  15 +
  16 +/**
  17 + * 资讯详情
  18 + */
  19 +const model = {
  20 + index(params) {
  21 + return co(function*() {
  22 + const article = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticle', params);
  23 + const content = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticleContent', params);
  24 + const brands = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getBrand', params);
  25 + const other = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getOtherArticle', Object.assign({
  26 + tags: article.data.tag,
  27 + offset: 0,
  28 + limit: 3
  29 + }, params));
  30 +
  31 + return camelCase([article, content, brands, other]);
  32 + });
  33 + }
  34 +};
  35 +
  36 +module.exports = model;
  1 +/**
  2 + * router of sub app news
  3 + * @author: Aiden Xu<aiden.xu@yoho.cn>
  4 + * @date: 2016/07/25
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const expressRouter = require('express').Router;
  10 +const cRoot = './controllers';
  11 +const router = expressRouter();
  12 +
  13 +// 详情controller
  14 +const detail = require(`${cRoot}/detail`);
  15 +
  16 +router.get(/\/([\d]+)(.*)/, detail.index); // 详情routers
  17 +router.get(/news_(\d+)\.json/, detail.news);
  18 +
  19 +const news = require(`${cRoot}/index`);
  20 +
  21 +router.get('', news.index);
  22 +module.exports = router;
  1 +<div id="app" class="news-page" data-news-id="{{newsId}}">
  2 + <app/>
  3 +</div>
  1 +<div class="index">
  2 + <index-box></index-box>
  3 +</div>
  1 +/**
  2 + * 产品搜索 controller
  3 + * @author 陈轩 <xuan.chen@yoho.cn>
  4 + */
  5 +'use strict';
  6 +
  7 +const newModel = require('../models/new');
  8 +
  9 +/* 最新商品 页面 */
  10 +exports.index = (req, res) => {
  11 + const view = {
  12 + module: 'product',
  13 + page: 'new'
  14 + };
  15 +
  16 + res.render('new', view);
  17 +};
  18 +
  19 +/* 获取 筛选配置 */
  20 +exports.fetchFilters = (req, res, next) => {
  21 + const params = Object.assign({
  22 + uid: req.user.uid,
  23 + page: 1,
  24 + order: 1,
  25 + yh_channel: 'all',
  26 + channel: 'all',
  27 + }, req.query);
  28 +
  29 + newModel.getNewData(params).then(result => {
  30 + res.json(result);
  31 + }).catch(next);
  32 +};
  33 +
  34 +/* 查询 产品列表 */
  35 +exports.fetchProducts = (req, res, next) => {
  36 + const params = Object.assign({
  37 + uid: req.user.uid,
  38 + page: 1,
  39 + order: 1
  40 + }, req.query);
  41 +
  42 + newModel.getNewData(params).catch(next);
  43 +};
  1 +const api = global.yoho.API;
  2 +const camelCase = global.yoho.camelCase;
  3 +const prettyFilter = require(`${global.utils}/beautify/filters`);
  4 +const processProductList = require(`${global.utils}/beautify/product`);
  5 +
  6 +/* 查询最新产品列表 */
  7 +exports.getNewData = (params) => {
  8 + params = Object.assign({
  9 + method: 'app.search.newProduct',
  10 + }, params);
  11 +
  12 + api.post('', params, {
  13 + cache: true,
  14 + code: 200
  15 + }).then(result => {
  16 + if (result.data) {
  17 + result.data.productList = processProductList(result.data.productList);
  18 + result = camelCase(result);
  19 + }
  20 +
  21 + return result;
  22 + });
  23 +};
  24 +
  25 +/* 查询最新产品筛选条件 */
  26 +exports.getNewFilterData = (params) => {
  27 + params = Object.assign({
  28 + method: 'app.search.newProduct',
  29 + }, params);
  30 +
  31 + api.post('', params, {
  32 + cache: true,
  33 + code: 200
  34 + }).then(result => {
  35 + let filterConfig = {};
  36 +
  37 + if (result.data) {
  38 + prettyFilter(result.data.filter);
  39 + filterConfig = camelCase(result.data.filter);
  40 + }
  41 +
  42 + return {
  43 + code: result.code,
  44 + data: filterConfig
  45 + };
  46 + });
  47 +};
@@ -17,6 +17,8 @@ const search = require(`${cRoot}/search`); @@ -17,6 +17,8 @@ const search = require(`${cRoot}/search`);
17 router.get('/search', search.index); 17 router.get('/search', search.index);
18 router.get('/search.json', search.fetchProducts); // ajax 18 router.get('/search.json', search.fetchProducts); // ajax
19 19
  20 +router.get('/new', search.index);
  21 +router.get('/new.json', search.fetchProducts);
20 22
21 // 产品 列表页 23 // 产品 列表页
22 const productList = require(`${cRoot}/list`); 24 const productList = require(`${cRoot}/list`);
  1 +<div id="product-new"></div>
@@ -15,8 +15,8 @@ module.exports = { @@ -15,8 +15,8 @@ module.exports = {
15 port: 6004, 15 port: 6004,
16 siteUrl: '//m.yohoblk.com', 16 siteUrl: '//m.yohoblk.com',
17 domains: { 17 domains: {
18 - api: 'http://192.168.102.205:8080/gateway/',  
19 - service: 'http://192.168.102.205:8080/gateway/' 18 + api: 'http://devapi.yoho.cn:58078/',
  19 + service: 'http://devservice.yoho.cn:58077/'
20 }, 20 },
21 subDomains: { 21 subDomains: {
22 host: '.m.yohoblk.com', 22 host: '.m.yohoblk.com',
@@ -10,6 +10,7 @@ module.exports = app => { @@ -10,6 +10,7 @@ module.exports = app => {
10 app.use('/api', require('./apps/api')); 10 app.use('/api', require('./apps/api'));
11 app.use('/product', require('./apps/product')); 11 app.use('/product', require('./apps/product'));
12 app.use('/home', require('./apps/home')); 12 app.use('/home', require('./apps/home'));
  13 + app.use('/news', require('./apps/news'));
13 14
14 // 组件示例 15 // 组件示例
15 if (!app.locals.proEnv) { 16 if (!app.locals.proEnv) {
@@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
21 "dependencies": { 21 "dependencies": {
22 "bluebird": "^3.4.1", 22 "bluebird": "^3.4.1",
23 "body-parser": "^1.15.2", 23 "body-parser": "^1.15.2",
  24 + "co": "^4.6.0",
24 "connect-memcached": "^0.2.0", 25 "connect-memcached": "^0.2.0",
25 "connect-multiparty": "^2.0.0", 26 "connect-multiparty": "^2.0.0",
26 "cookie-parser": "^1.4.3", 27 "cookie-parser": "^1.4.3",
1 let Vue = require('yoho-vue'); 1 let Vue = require('yoho-vue');
2 - 2 +const moment = require('moment');
3 3
4 /** 4 /**
5 * 替换参数 5 * 替换参数
@@ -113,3 +113,11 @@ Vue.filter('convertTime', (value) => { @@ -113,3 +113,11 @@ Vue.filter('convertTime', (value) => {
113 113
114 return Y + M + D + h + m + s; 114 return Y + M + D + h + m + s;
115 }); 115 });
  116 +
  117 +
  118 +/**
  119 + * 格式化时间
  120 + */
  121 +Vue.filter('formatUnixTime', (value, format) => {
  122 + return moment.unix(value).format(format || 'YYYY-MM-DD HH:mm:ss');
  123 +});
  1 +const Vue = require('yoho-vue');
  2 +const Mydetails = require('home/mydetails.vue');
  3 +
  4 +new Vue({
  5 + el: '#details',
  6 + components: {
  7 + Mydetails
  8 + }
  9 +});
  1 +const Vue = require('yoho-vue');
  2 +const lazyload = require('yoho-vue-lazyload');
  3 +
  4 +const app = require('news/detail.vue');
  5 +
  6 +new Vue({
  7 + el: '#app',
  8 + components: {
  9 + app
  10 + }
  11 +});
  12 +
  13 +Vue.use(lazyload);
  1 +/**
  2 + * Created by PhpStorm.
  3 + * User: Targaryen
  4 + * Date: 2016/7/26
  5 + * Time: 17:37
  6 + */
  7 +const Vue = require('yoho-vue');
  8 +const lazyload = require('yoho-vue-lazyload');
  9 +const infinitScroll = require('yoho-vue-infinite-scroll');
  10 +
  11 +const indexBox = require('news/index-box.vue');
  12 +
  13 +Vue.use(lazyload);
  14 +Vue.use(infinitScroll);
  15 +
  16 +new Vue({
  17 + el: '#index',
  18 + components: {
  19 + indexBox
  20 + }
  21 +});
  1 +const Vue = require('yoho-vue');
  2 +const search = require('product/search/index.vue');
  3 +
  4 +new Vue(search);
  1 +.personal-details {
  2 + width: 100%;
  3 + height: auto;
  4 + overflow: hidden;
  5 + margin-top: 20px;
  6 + background-color: #fff;
  7 +
  8 + ul {
  9 + width: 95%;
  10 + height: auto;
  11 + overflow: hidden;
  12 + float: right;
  13 +
  14 + li {
  15 + &:first-of-type {
  16 + height: 100px;
  17 + line-height: 100px;
  18 + }
  19 +
  20 + height: 80px;
  21 + border-bottom: 1px solid #e0e0e0;
  22 +
  23 + .details-icon {
  24 + float: right;
  25 + height: 90px;
  26 + margin-right: 15px;
  27 +
  28 + .icon {
  29 + vertical-align: middle;
  30 + color: #b0b0b0;
  31 + }
  32 + }
  33 +
  34 + .user-avatar {
  35 + display: inline-block;
  36 + width: 100%;
  37 + height: 100%;
  38 + background-image: resolve("home/user-icon.png");
  39 + background-size: 100%;
  40 + }
  41 +
  42 + .head-portrait {
  43 + width: 90px;
  44 + height: 90px;
  45 + overflow: hidden;
  46 + border-radius: 50%;
  47 + border: 1px solid #eee;
  48 + vertical-align: middle;
  49 + }
  50 +
  51 + > label {
  52 + width: 100%;
  53 + height: 100%;
  54 + line-height: 80px;
  55 + font-size: 32px;
  56 + margin-right: 8%;
  57 + text-overflow: ellipsis;
  58 + white-space: nowrap;
  59 + overflow: hidden;
  60 + display: inline-block;
  61 +
  62 + .details-nickname,
  63 + .details-gender,
  64 + .details-birthday {
  65 + text-align: right;
  66 + float: right;
  67 + margin-right: 40px;
  68 + color: #b0b0b0;
  69 + }
  70 + }
  71 + }
  72 + }
  73 +}
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 @import "help"; 2 @import "help";
3 @import "feedback"; 3 @import "feedback";
4 @import "fav"; 4 @import "fav";
  5 +@import "details";
5 @import "about-us"; 6 @import "about-us";
6 @import "coin"; 7 @import "coin";
7 @import "logistics"; 8 @import "logistics";
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 $.ajax({ 36 $.ajax({
37 url: '/channel/channel.json' 37 url: '/channel/channel.json'
38 }).then(res => { 38 }).then(res => {
39 - if (res.data.length) { 39 + if (res.data && res.data.length) {
40 const channel = []; 40 const channel = [];
41 41
42 res.data.forEach(c => { 42 res.data.forEach(c => {
@@ -21,6 +21,13 @@ @@ -21,6 +21,13 @@
21 </div> 21 </div>
22 </template> 22 </template>
23 <script> 23 <script>
  24 + const Vue = require('yoho-vue');
  25 + const lazyload = require('yoho-vue-lazyload');
  26 + const infinitScroll = require('yoho-vue-infinite-scroll');
  27 +
  28 + Vue.use(lazyload);
  29 + Vue.use(infinitScroll);
  30 +
24 let bus = require('common/vue-bus'); 31 let bus = require('common/vue-bus');
25 32
26 module.exports = { 33 module.exports = {
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 props: ['brandUrl'], 36 props: ['brandUrl'],
37 data() { 37 data() {
38 return { 38 return {
39 - nullbox : 'hide', 39 + nullbox: 'hide',
40 busy: false, 40 busy: false,
41 editmodel: false, 41 editmodel: false,
42 page: 0, 42 page: 0,
@@ -46,13 +46,13 @@ @@ -46,13 +46,13 @@
46 methods: { 46 methods: {
47 loadMore: function() { 47 loadMore: function() {
48 let _this = this; 48 let _this = this;
49 - this.busy = true;  
50 49
  50 + this.busy = true;
51 $.ajax({ 51 $.ajax({
52 url: '/home/favorite/favpaging', 52 url: '/home/favorite/favpaging',
53 data: { 53 data: {
54 - page : ++_this.page,  
55 - tab : "brand" 54 + page: ++_this.page,
  55 + tab: 'brand'
56 } 56 }
57 }).then(result => { 57 }).then(result => {
58 if (result.isend) { 58 if (result.isend) {
@@ -62,12 +62,12 @@ @@ -62,12 +62,12 @@
62 } 62 }
63 63
64 if (result.list.length) { 64 if (result.list.length) {
65 - result.list.forEach(function(o){ 65 + result.list.forEach(function(o) {
66 _this.brandData.push(o); 66 _this.brandData.push(o);
67 }); 67 });
68 } 68 }
69 69
70 - _this.nullbox = _this.brandData.length ? "hide" : ""; 70 + _this.nullbox = _this.brandData.length ? 'hide' : '';
71 }).fail(() => { 71 }).fail(() => {
72 tip('网络错误'); 72 tip('网络错误');
73 }); 73 });
@@ -80,17 +80,19 @@ @@ -80,17 +80,19 @@
80 }, 80 },
81 showDelBtn(index) { 81 showDelBtn(index) {
82 this.hideDelBth(); 82 this.hideDelBth();
83 - var delBtn = $("#del-" + index);  
84 - var width = delBtn.width();  
85 - $("#li-" + index).css("transform","translateX(-" + width + "px)"); 83 + let delBtn = $('#del-' + index);
  84 + let width = delBtn.width();
  85 +
  86 + $('#li-' + index).css('transform', 'translateX(-' + width + 'px)');
86 }, 87 },
87 hideDelBth() { 88 hideDelBth() {
88 - this.brandData.forEach(function(d, index){  
89 - $("#li-" + index).css("transform","translateX(0px)");  
90 - }) 89 + this.brandData.forEach(function(d, index) {
  90 + $('#li-' + index).css('transform', 'translateX(0px)');
  91 + });
91 }, 92 },
92 delItem(index, id) { 93 delItem(index, id) {
93 let _this = this; 94 let _this = this;
  95 +
94 $.ajax({ 96 $.ajax({
95 method: 'POST', 97 method: 'POST',
96 url: '/home/del-favdel', 98 url: '/home/del-favdel',
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
44 props: ['productUrl'], 44 props: ['productUrl'],
45 data() { 45 data() {
46 return { 46 return {
47 - nullbox : 'hide', 47 + nullbox: 'hide',
48 busy: false, 48 busy: false,
49 editmodel: false, 49 editmodel: false,
50 page: 0, 50 page: 0,
@@ -54,12 +54,12 @@ @@ -54,12 +54,12 @@
54 methods: { 54 methods: {
55 loadMore: function() { 55 loadMore: function() {
56 let _this = this; 56 let _this = this;
57 - this.busy = true;  
58 57
  58 + this.busy = true;
59 $.ajax({ 59 $.ajax({
60 url: '/home/favorite/favpaging', 60 url: '/home/favorite/favpaging',
61 data: { 61 data: {
62 - page : ++_this.page 62 + page: ++_this.page
63 } 63 }
64 }).then(result => { 64 }).then(result => {
65 if (result.isend) { 65 if (result.isend) {
@@ -69,12 +69,12 @@ @@ -69,12 +69,12 @@
69 } 69 }
70 70
71 if (result.list.length) { 71 if (result.list.length) {
72 - result.list.forEach(function(o){ 72 + result.list.forEach(function(o) {
73 _this.productData.push(o); 73 _this.productData.push(o);
74 }); 74 });
75 } 75 }
76 76
77 - _this.nullbox = _this.productData.length ? "hide" : ""; 77 + _this.nullbox = _this.productData.length ? 'hide' : '';
78 }).fail(() => { 78 }).fail(() => {
79 tip('网络错误'); 79 tip('网络错误');
80 }); 80 });
@@ -87,17 +87,19 @@ @@ -87,17 +87,19 @@
87 }, 87 },
88 showDelBtn(index) { 88 showDelBtn(index) {
89 this.hideDelBth(); 89 this.hideDelBth();
90 - var delBtn = $("#del-" + index);  
91 - var width = delBtn.width();  
92 - $("#li-" + index).css("transform","translateX(-" + width + "px)"); 90 + let delBtn = $('#del-' + index);
  91 + let width = delBtn.width();
  92 +
  93 + $('#li-' + index).css('transform', 'translateX(-' + width + 'px)');
93 }, 94 },
94 hideDelBth() { 95 hideDelBth() {
95 - this.productData.forEach(function(d, index){  
96 - $("#li-" + index).css("transform","translateX(0px)");  
97 - }) 96 + this.productData.forEach(function(d, index) {
  97 + $('#li-' + index).css('transform', 'translateX(0px)');
  98 + });
98 }, 99 },
99 delItem(index, id) { 100 delItem(index, id) {
100 let _this = this; 101 let _this = this;
  102 +
101 $.ajax({ 103 $.ajax({
102 method: 'POST', 104 method: 'POST',
103 url: '/home/del-favdel', 105 url: '/home/del-favdel',
  1 +<template>
  2 + <ul>
  3 + <li>
  4 + <label>头像
  5 + <span class="details-icon">
  6 + <span class="head-portrait user-avatar" data-avatar="{{head_ico}}"></span>
  7 + <span class="icon icon-right"></span>
  8 + </span>
  9 + </label>
  10 + </li>
  11 + <li>
  12 + <label>昵称<input class="details-nickname" v-model='nickname'></label>
  13 + </li>
  14 + <li>
  15 + <label>性别<span class="details-gender">{{ gender }}</span></label>
  16 + </li>
  17 + <li>
  18 + <label>生日<span class="details-birthday">{{ birthday }}</span></label>
  19 + </li>
  20 + </ul>
  21 +</template>
  22 +
  23 +<script>
  24 + module.exports = {
  25 + props: ['head_ico', 'nickname', 'gender', 'birthday'],
  26 + data() {
  27 + return {
  28 + };
  29 + }
  30 + };
  31 +</script>
@@ -14,7 +14,6 @@ @@ -14,7 +14,6 @@
14 </template> 14 </template>
15 15
16 <script> 16 <script>
17 - const $ = require('yoho-jquery');  
18 const indexList = require('component/tool/index-list.vue'); 17 const indexList = require('component/tool/index-list.vue');
19 18
20 module.exports = { 19 module.exports = {
@@ -31,28 +30,32 @@ @@ -31,28 +30,32 @@
31 }, 30 },
32 methods: { 31 methods: {
33 search: function() { 32 search: function() {
34 - var inputname = this.inputname; 33 + let inputname = this.inputname;
  34 +
35 if (!inputname) { 35 if (!inputname) {
36 this.showData = this.company_list; 36 this.showData = this.company_list;
37 return; 37 return;
38 } 38 }
39 39
40 - var filter = {};  
41 - for (var k in this.company_list) {  
42 - this.company_list[k].forEach(function(d){ 40 + let filter = {};
  41 +
  42 + for (let k in this.company_list) {
  43 + this.company_list[k].forEach(function(d) {
43 if (d.company_name.indexOf(inputname) > -1) { 44 if (d.company_name.indexOf(inputname) > -1) {
44 - if (!filter[k]) filter[k] = []; 45 + if (!filter[k]) {
  46 + filter[k] = [];
  47 + }
45 filter[k].push(d); 48 filter[k].push(d);
46 } 49 }
47 - }) 50 + });
48 } 51 }
49 this.showData = filter; 52 this.showData = filter;
50 }, 53 },
51 - select: function(company_id, company_name) { 54 + select: function(companyId, companyName) {
52 this.$dispatch('changeView', { 55 this.$dispatch('changeView', {
53 view: 'logistics', 56 view: 'logistics',
54 - company_id: company_id,  
55 - company_name: company_name 57 + company_id: companyId,
  58 + company_name: companyName
56 }); 59 });
57 60
58 // 重置列表 61 // 重置列表
@@ -26,18 +26,18 @@ @@ -26,18 +26,18 @@
26 }; 26 };
27 }, 27 },
28 methods: { 28 methods: {
29 - companylist: function(){ 29 + companylist: function() {
30 this.$dispatch('changeView', { 30 this.$dispatch('changeView', {
31 view: 'logisticsCompany' 31 view: 'logisticsCompany'
32 }); 32 });
33 }, 33 },
34 - submit: function(){ 34 + submit: function() {
35 if (!this.company_name) { 35 if (!this.company_name) {
36 - tip("请选择快递公司"); 36 + tip('请选择快递公司');
37 return false; 37 return false;
38 } 38 }
39 if (!this.num || !/^[0-9]*$/.test(this.num)) { 39 if (!this.num || !/^[0-9]*$/.test(this.num)) {
40 - tip("请输入正确的快递单号"); 40 + tip('请输入正确的快递单号');
41 return false; 41 return false;
42 } 42 }
43 43
  1 +<template>
  2 + <div v-if="block.text" class="text-block">
  3 + {{{block.text.data.text}}}
  4 + </div>
  5 +
  6 + <div v-if="block.singleImage">
  7 + <div v-for="(index, item) in block.singleImage.data">
  8 + <a :href="item.url">
  9 + <img :title="item.title"
  10 + :alt="item.alt"
  11 + :src="item.src | resize 750 469" width="375"/>
  12 + </a>
  13 + </div>
  14 + </div>
  15 +</template>
  16 +<style></style>
  17 +<script>
  18 + module.exports = {
  19 + props: {
  20 + block: Object
  21 + }
  22 + };
  23 +</script>
  1 +<template>
  2 + <div class="show-box no-padding no-top-border">
  3 + <div class="news-box">
  4 + <h1>{{article.articleTitle}}</h1>
  5 + <div class="status-bar">
  6 + <span class="icon icon-love"></span><span class="label">{{article.publishTime | formatUnixTime 'MM.DD HH:mm'}}</span>
  7 + <span class="icon icon-love"></span><span class="label">{{article.pageViews}}</span>
  8 + </div>
  9 + </div>
  10 +
  11 + <div class="content-box">
  12 + <div v-for="(index, block) in content">
  13 + <content-block :block="block"></content-block>
  14 + </div>
  15 + </div>
  16 + </div>
  17 +
  18 + <div class="show-box no-padding" v-if="recommendProducts">
  19 + <h2>相关推荐</h2>
  20 +
  21 + <product-list :data="recommendProducts.goods"></product-list>
  22 + </div>
  23 +
  24 + <div class="brand-list show-box" v-if="brands">
  25 + <h2>相关品牌</h2>
  26 + <ul>
  27 + <li v-for="item in brands">
  28 + <a :href="item.url"><img :src="item.thumb"></a>
  29 + </li>
  30 + </ul>
  31 + </div>
  32 +
  33 + <div class="show-box" v-if="other">
  34 + <h2>相关文章</h2>
  35 + <div class="other-box" v-for="item in other">
  36 + <div>
  37 + <div class="image-box">
  38 + <a :href="item.url">
  39 + <img :src="item.thumb | resize 213 134"/>
  40 + </a>
  41 + </div>
  42 + <h3><a :href="item.url">{{item.title}}</a></h3>
  43 + <div class="sub-time">
  44 + <span class="icon icon-love"></span><span class="label">{{article.publishTime | formatUnixTime 'MM.DD HH:mm'}}</span>
  45 + </div>
  46 + <div class="clearfix"></div>
  47 + </div>
  48 + </div>
  49 + </div>
  50 +</template>
  51 +<style class="scss">
  52 + $bgcolor: #fff;
  53 +
  54 + .news-page {
  55 + background: #f6f6f6;
  56 + }
  57 +
  58 + .show-box {
  59 + background: $bgcolor;
  60 + margin-top: 30px;
  61 + border-bottom: 1px solid #eee;
  62 +
  63 + &:not(.no-padding) {
  64 + padding: 30px;
  65 + }
  66 +
  67 + &:not(.no-top-border) {
  68 + border-top: 1px solid #eee;
  69 + }
  70 + }
  71 +
  72 + h1 {
  73 + font-size: 43px;
  74 + font-weight: bold;
  75 + overflow: hidden;
  76 + margin-top: 36px;
  77 + margin-bottom: 0;
  78 + }
  79 +
  80 + .news-box {
  81 + padding: 30px;
  82 + background: $bgcolor;
  83 + }
  84 +
  85 + .content-box {
  86 + background: #fff;
  87 +
  88 + img {
  89 + width: 100%;
  90 + display: block;
  91 + }
  92 +
  93 + p {
  94 + font-size: 28px;
  95 + }
  96 +
  97 + .text-block {
  98 + padding: 30px;
  99 + }
  100 +
  101 + }
  102 +
  103 + .other-box {
  104 + margin-top: 40px;
  105 +
  106 + .image-box {
  107 + float: left;
  108 + max-width: 214px;
  109 + max-height: 134px;
  110 + overflow: hidden;
  111 +
  112 + img {
  113 + width: 214px;
  114 + }
  115 + }
  116 +
  117 + h3 {
  118 + margin-top: 16px;
  119 + margin-left: 30px;
  120 + float: left;
  121 + max-width: 420px;
  122 + min-height: 90px;
  123 + font-size: 32px;
  124 + }
  125 +
  126 + .sub-time {
  127 + margin-left: 30px;
  128 + float: left;
  129 + color: #b3b3b3;
  130 +
  131 + .icon {
  132 + margin-right: 12px;
  133 + }
  134 + }
  135 + }
  136 +
  137 + h2 {
  138 + text-align: center;
  139 + line-height: 100px;
  140 + }
  141 +
  142 + .status-bar {
  143 + color: #ccc;
  144 + font-size: 24px;
  145 + margin-top: 30px;
  146 +
  147 + span.icon {
  148 + margin-right: 12px;
  149 + }
  150 +
  151 + span.label {
  152 + margin-right: 78px;
  153 + }
  154 + }
  155 +
  156 + .brand-list {
  157 + li {
  158 + display: inline-block;
  159 + width: 171px;
  160 + text-align: center;
  161 +
  162 + img {
  163 + max-width: 140px;
  164 + }
  165 + }
  166 +
  167 + ul {
  168 + :not(:last-child) {
  169 + border-right: 1px solid #eee;
  170 + }
  171 + }
  172 + }
  173 +
  174 +</style>
  175 +<script>
  176 + require('common/vue-filter');
  177 +
  178 + module.exports = {
  179 + components: {
  180 + 'content-block': require('./content-block.vue'),
  181 + 'product-list': require('component/product/list.vue')
  182 + },
  183 + data() {
  184 + return {
  185 + article: {},
  186 + content: {},
  187 + brands: {},
  188 + other: {},
  189 + recommendProducts: []
  190 + };
  191 + },
  192 + created() {
  193 + const newsId = $('#app').data('newsId');
  194 +
  195 + $.get(`/news/news_${newsId}.json`).then(result => {
  196 + const article = result[0],
  197 + content = result[1],
  198 + brands = result[2],
  199 + other = result[3];
  200 +
  201 + if (article && article.code === 200 && article.data) {
  202 + this.article = article.data;
  203 + }
  204 +
  205 + if (content && content.code === 200 && content.data) {
  206 + this.content = content.data;
  207 +
  208 + this.recommendProducts = this.content.filter((block)=> {
  209 + return block && typeof block.goods === 'object';
  210 + });
  211 + }
  212 +
  213 + if (brands && brands.code === 200 && brands.data) {
  214 + this.brands = brands.data;
  215 + }
  216 +
  217 + if (other && other.code === 200 && content.data) {
  218 + this.other = other.data;
  219 + }
  220 + });
  221 + }
  222 + };
  223 +</script>
  1 +<template>
  2 + <div></div>
  3 +</template>
  4 +<style>
  5 +</style>
  6 +<script>
  7 + module.exports = {
  8 + data() {
  9 + return {
  10 + msg: 'hello vue'
  11 + };
  12 + }
  13 + };
  14 +</script>
  1 +<template>
  2 + <div>
  3 + <template v-if="productList.length">
  4 + <Sort :config="sortConfig" :val="sort">
  5 + </Sort>
  6 + <List :data="productList"></List>
  7 + </template>
  8 + <div class="empty-tip" v-if="empty">
  9 + <i class="icon icon-search"></i>
  10 + <p class="empty-tip-cn">未找到相关商品</p>
  11 + <p class="empty-tip-en">Did not find the relevant goods</p>
  12 + </div>
  13 + </div>
  14 +</template>
  15 +<script>
  16 + const Vue = require('yoho-vue');
  17 + const lazyload = require('yoho-vue-lazyload');
  18 + const infinitScroll = require('yoho-vue-infinite-scroll');
  19 +
  20 + const qs = require('yoho-qs');
  21 + const bus = require('common/vue-bus');
  22 + const tip = require('common/tip');
  23 +
  24 + const sort = require('component/product/sort.vue');
  25 + const list = require('component/product/list.vue');
  26 +
  27 + Vue.use(lazyload);
  28 + Vue.use(infinitScroll);
  29 +
  30 + require('common/vue-filter');
  31 +
  32 + module.exports = {
  33 + el: '#product-new',
  34 + data: function() {
  35 + return {
  36 + sortConfig: global.sortConfig,
  37 + filterConfig: global.filterConfig,
  38 +
  39 + // query
  40 + url: '/product/search.json',
  41 + sort: null,
  42 + query: qs.query,
  43 + page: 0, // 未搜索 page=0; 全部加载完 page = totalPage; 无数据: page !=0 && productList.length=0
  44 + totalPage: null,
  45 +
  46 + // 产品列表
  47 + productList: [],
  48 +
  49 + // state
  50 + inSearching: false // 请求中
  51 + };
  52 + },
  53 + computed: {
  54 + // 无数据
  55 + empty: function() {
  56 + return this.page !== 0 && !this.productList.length;
  57 + }
  58 + },
  59 + components: {
  60 + list,
  61 + sort
  62 + },
  63 + methods: {
  64 + search: function() {
  65 + const self = this;
  66 + const nextPage = this.page + 1;
  67 +
  68 + if (this.inSearching) {
  69 + return;
  70 + }
  71 +
  72 + // page = 0, 始终执行搜索
  73 + if (this.page && nextPage > this.totalPage) {
  74 + return;
  75 + }
  76 +
  77 + this.inSearching = true;
  78 + console.log(nextPage);
  79 + $.get(this.url, {
  80 + order: this.sort, // 排序 信息
  81 + query: this.query,
  82 + page: nextPage
  83 + })
  84 + .done(res => {
  85 + if (res.code === 200) {
  86 + self.page = res.data.page;
  87 + self.totalPage = res.data.pageTotal;
  88 + self.$set('productList', self.productList.concat(res.data.productList));
  89 + }
  90 + })
  91 + .fail(() => {
  92 + tip('网络出错~');
  93 + })
  94 + .always(() => {
  95 + self.inSearching = false;
  96 + });
  97 + },
  98 +
  99 + /**
  100 + * 清空数据(page=0) 重新搜索
  101 + */
  102 + research: function() {
  103 + this.page = 0;
  104 + this.$set('productList', []);
  105 + this.search();
  106 + }
  107 + },
  108 + watch: {
  109 + /* sort 改变 都会触发 重新搜索 */
  110 + sort: function() {
  111 + this.research();
  112 + }
  113 + },
  114 +
  115 + created: function() {
  116 + const self = this;
  117 +
  118 +
  119 + bus.$on('list.paging', function() {
  120 + self.search();
  121 + });
  122 +
  123 + bus.$on('sort.change', function({
  124 + val
  125 + }) {
  126 + self.sort = val;
  127 + });
  128 +
  129 + this.search();
  130 + }
  131 + };
  132 +
  133 +</script>
  134 +<style>
  135 + .empty-tip {
  136 + margin-top: 380px;
  137 + color: #b0b0b0;
  138 + text-align: center;
  139 + .icon-search {
  140 + display: inline-block;
  141 + font-size: 200px;
  142 + margin-bottom: 56px;
  143 + }
  144 + }
  145 +
  146 + .empty-tip-cn {
  147 + font-size: 34px;
  148 + margin-bottom: 30px;
  149 + }
  150 +
  151 + .empty-tip-en {
  152 + font-size: 20px;
  153 + }
  154 +
  155 +</style>