plustar.js
2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* 国际优选
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/12
*/
'use strict';
const mRoot = '../models';
const express = require('express');
const app = express();
const plustarModel = require(`${mRoot}/plustar`);
const htmlProcess = require(`${global.utils}/html-process`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
let channels = {
boys: '1,3',
girl: '2,3',
kids: '3,3',
lifestyle: '4'
};
const getListData = (req, res, next) => {
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let recom = '4';
let all = '1';
plustarModel.getListData(gender, recom, all).then((result) => {
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
title: '国际优选',
pageHeader: headerModel.setNav({
navTitle: '国际优选'
}),
pageFooter: true,
ps: {
sName: '设计师',
pName: '经典潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
};
const getDetailData = (req, res, next) => {
let id = req.query.id;
let uid = req.user.uid;
let udid = req.sessionID || 'yoho';
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let isApp = req.query.app_version || req.query.appVersion || false;
let clientType = req.body.client_type || '';
let version = req.body.app_version || '';
if (clientType.toLowerCase() === 'ios' && version) {
clientType = 'iphone';
} else if (clientType.toLowerCase() === 'android' && version) {
clientType = 'android';
} else {
clientType = 'h5';
}
plustarModel.getDetailData(id, uid, udid, gender, isApp, clientType).then((result) => {
result.brand_intro = htmlProcess.removeHtml(result.brand_intro);
result.clientType = clientType;
result.brandId = result.brand_id;
res.render('plustar/detail', {
module: 'guang',
page: 'plustar-detail',
title: result.brand_name,
pageHeader: headerModel.setNav({
navTitle: result.brand_name
}),
ps: result
});
}).catch(next);
};
/**
* [品牌详情异步数据]
*/
const getDetailDataAsync = (req, res, next) => {
let uid = req.user.uid;
let udid = req.sessionID || 'yoho';
let clientType = req.body.client_type || '';
let brandId = req.body.brand_id || 0;
if (!brandId) {
return res.json({code: 400, message: '参数错误'});
}
plustarModel.getDetailDataAsync(brandId, uid, udid, clientType).then((result) => {
res.json({
isLike: result.isLike,
infos: result.infos
});
});
}
module.exports = {
getListData,
getDetailData,
getDetailDataAsync
};