Merge remote-tracking branch 'origin/master'
Showing
20 changed files
with
562 additions
and
289 deletions
@@ -100,7 +100,6 @@ try { | @@ -100,7 +100,6 @@ try { | ||
100 | // YOHO 后置中间件 | 100 | // YOHO 后置中间件 |
101 | app.use(errorHanlder.serverError()); | 101 | app.use(errorHanlder.serverError()); |
102 | } catch (err) { | 102 | } catch (err) { |
103 | - console.error(err); | ||
104 | logger.error(err); | 103 | logger.error(err); |
105 | } | 104 | } |
106 | 105 |
@@ -136,7 +136,7 @@ const _getChannelResource = (params) => { | @@ -136,7 +136,7 @@ const _getChannelResource = (params) => { | ||
136 | if (result && result.code === 200) { | 136 | if (result && result.code === 200) { |
137 | return resourcesProcess(result.data.list); | 137 | return resourcesProcess(result.data.list); |
138 | } else { | 138 | } else { |
139 | - logger.error('首页资源位接口返回状态码 不是 200'); | 139 | + logger.error('index resouce is not 200'); |
140 | return result; | 140 | return result; |
141 | } | 141 | } |
142 | }); | 142 | }); |
@@ -156,7 +156,7 @@ const _getLeftNav = (choosed) => { | @@ -156,7 +156,7 @@ const _getLeftNav = (choosed) => { | ||
156 | if (result && result.code === 200) { | 156 | if (result && result.code === 200) { |
157 | return _processSideBar(result.data, choosed); | 157 | return _processSideBar(result.data, choosed); |
158 | } else { | 158 | } else { |
159 | - logger.error('侧边栏数据接口返回状态码 不是 200'); | 159 | + logger.error('sidebar code is not 200'); |
160 | return result; | 160 | return result; |
161 | } | 161 | } |
162 | }); | 162 | }); |
@@ -191,7 +191,7 @@ const _getChannelList = () => { | @@ -191,7 +191,7 @@ const _getChannelList = () => { | ||
191 | }); | 191 | }); |
192 | return Object.keys(list).length ? list : channelList; | 192 | return Object.keys(list).length ? list : channelList; |
193 | } else { | 193 | } else { |
194 | - logger.error('频道选择接口返回状态码 不是 200'); | 194 | + logger.error('channel select code is not 200'); |
195 | return channelList; | 195 | return channelList; |
196 | } | 196 | } |
197 | }); | 197 | }); |
@@ -210,7 +210,7 @@ const _getChannelBg = () => { | @@ -210,7 +210,7 @@ const _getChannelBg = () => { | ||
210 | if (result && result.code === 200) { | 210 | if (result && result.code === 200) { |
211 | return result.data.length && result.data[0] && result.data[0].data && result.data[0].data.list[0]; | 211 | return result.data.length && result.data[0] && result.data[0].data && result.data[0].data.list[0]; |
212 | } else { | 212 | } else { |
213 | - logger.error('频道选择页背景图接口返回状态码 不是 200'); | 213 | + logger.error('channel select background code is not 200'); |
214 | return { | 214 | return { |
215 | src: '' | 215 | src: '' |
216 | }; | 216 | }; |
@@ -29,7 +29,7 @@ const _getResources = (page) => { | @@ -29,7 +29,7 @@ const _getResources = (page) => { | ||
29 | if (result && result.code === 200) { | 29 | if (result && result.code === 200) { |
30 | return resourcesProcess(result.data); | 30 | return resourcesProcess(result.data); |
31 | } else { | 31 | } else { |
32 | - logger.error('星潮教室页面资源位返回 code 不是 200'); | 32 | + logger.error('star class content resource return code no 200'); |
33 | return []; | 33 | return []; |
34 | } | 34 | } |
35 | }); | 35 | }); |
@@ -158,7 +158,7 @@ const getIndexData = () => { | @@ -158,7 +158,7 @@ const getIndexData = () => { | ||
158 | if (result && result.code === 200) { | 158 | if (result && result.code === 200) { |
159 | return _processIndexData(result); | 159 | return _processIndexData(result); |
160 | } else { | 160 | } else { |
161 | - logger.error('星潮教室首页数据返回 code 不是 200'); | 161 | + logger.error('star class content resource return code no 200'); |
162 | return {}; | 162 | return {}; |
163 | } | 163 | } |
164 | }); | 164 | }); |
@@ -183,7 +183,7 @@ const getDetailData = (params, uid) => { | @@ -183,7 +183,7 @@ const getDetailData = (params, uid) => { | ||
183 | return _processGuangData(result.data.list, true); | 183 | return _processGuangData(result.data.list, true); |
184 | } | 184 | } |
185 | } else { | 185 | } else { |
186 | - logger.error('明星专题文章数据返回 code 不是 200'); | 186 | + logger.error('api app.starClass.lastTagArticle code no 200'); |
187 | return []; | 187 | return []; |
188 | } | 188 | } |
189 | }); | 189 | }); |
@@ -227,7 +227,7 @@ const getCollocationListData = (params, uid) => { | @@ -227,7 +227,7 @@ const getCollocationListData = (params, uid) => { | ||
227 | if (result && result.code === 200) { | 227 | if (result && result.code === 200) { |
228 | return _processGuangData(result.data.list.artList); | 228 | return _processGuangData(result.data.list.artList); |
229 | } else { | 229 | } else { |
230 | - logger.error('获取星搭配文章列表返回 code 不是 200'); | 230 | + logger.error('getStarClassroomArticleList code no 200'); |
231 | return []; | 231 | return []; |
232 | } | 232 | } |
233 | }); | 233 | }); |
@@ -10,8 +10,11 @@ const mRoot = '../models'; | @@ -10,8 +10,11 @@ const mRoot = '../models'; | ||
10 | const headerModel = require('../../../doraemon/models/header'); // 头部model | 10 | const headerModel = require('../../../doraemon/models/header'); // 头部model |
11 | const detailModel = require(`${mRoot}/detail`); // 商品详情 model | 11 | const detailModel = require(`${mRoot}/detail`); // 商品详情 model |
12 | const introModel = require(`${mRoot}/intro`); // 商品尺码信息 model | 12 | const introModel = require(`${mRoot}/intro`); // 商品尺码信息 model |
13 | -const preference = require(`${mRoot}/preference`); // 商品偏好 model | 13 | +const preferenceModel = require(`${mRoot}/preference`); // 商品偏好 model |
14 | const detailRelated = require(`${mRoot}/consult-comment`); // 商品评论咨询 model | 14 | const detailRelated = require(`${mRoot}/consult-comment`); // 商品评论咨询 model |
15 | +const _ = require('lodash'); | ||
16 | + | ||
17 | +const helpers = global.yoho.helpers; | ||
15 | 18 | ||
16 | /** | 19 | /** |
17 | * 商品基本信息 | 20 | * 商品基本信息 |
@@ -34,6 +37,42 @@ exports.index = (req, res, next) => { | @@ -34,6 +37,42 @@ exports.index = (req, res, next) => { | ||
34 | uid: uid, | 37 | uid: uid, |
35 | ua: req.get('user-agent') || '' | 38 | ua: req.get('user-agent') || '' |
36 | }).then((result) => { | 39 | }).then((result) => { |
40 | + if (_.isEmpty(result)) { | ||
41 | + return next(); | ||
42 | + } | ||
43 | + res.render('detail/detail', { | ||
44 | + pageHeader: headerData, | ||
45 | + result: result, | ||
46 | + page: 'detail', | ||
47 | + title: result.goodsName, | ||
48 | + pageFooter: true | ||
49 | + }); | ||
50 | + }).catch(next); | ||
51 | +}; | ||
52 | + | ||
53 | +/** | ||
54 | + * 商品基本信息 SKN 进入 | ||
55 | + * @param {[type]} req [description] | ||
56 | + * @param {[type]} res [description] | ||
57 | + * @return {[type]} [description] | ||
58 | + */ | ||
59 | +exports.indexSkn = (req, res, next) => { | ||
60 | + if (!req.params[0]) { | ||
61 | + return next(); | ||
62 | + } | ||
63 | + let uid = req.user.uid || 0; | ||
64 | + let headerData = headerModel.setNav({ | ||
65 | + navTitle: '商品详情' | ||
66 | + }); | ||
67 | + | ||
68 | + detailModel.getProductData({ | ||
69 | + productSkn: req.params[0], | ||
70 | + uid: uid, | ||
71 | + ua: req.get('user-agent') || '' | ||
72 | + }).then((result) => { | ||
73 | + if (_.isEmpty(result)) { | ||
74 | + return next(); | ||
75 | + } | ||
37 | res.render('detail/detail', { | 76 | res.render('detail/detail', { |
38 | pageHeader: headerData, | 77 | pageHeader: headerData, |
39 | result: result, | 78 | result: result, |
@@ -71,8 +110,8 @@ exports.intro = (req, res, next) => { | @@ -71,8 +110,8 @@ exports.intro = (req, res, next) => { | ||
71 | * @param {[type]} res [description] | 110 | * @param {[type]} res [description] |
72 | * @return {[type]} [description] | 111 | * @return {[type]} [description] |
73 | */ | 112 | */ |
74 | -exports.preference = (req, res) => { | ||
75 | - preference({ | 113 | +exports.preference = (req, res, next) => { |
114 | + preferenceModel({ | ||
76 | productskn: req.query.productSkn, | 115 | productskn: req.query.productSkn, |
77 | yhchannel: req.yoho.channel, | 116 | yhchannel: req.yoho.channel, |
78 | brandId: req.query.brandId | 117 | brandId: req.query.brandId |
@@ -80,19 +119,24 @@ exports.preference = (req, res) => { | @@ -80,19 +119,24 @@ exports.preference = (req, res) => { | ||
80 | res.render('detail/preference', Object.assign({ | 119 | res.render('detail/preference', Object.assign({ |
81 | layout: false | 120 | layout: false |
82 | }, result)); | 121 | }, result)); |
83 | - }); | 122 | + }).catch(next); |
84 | }; | 123 | }; |
85 | 124 | ||
86 | /** | 125 | /** |
87 | * 购买评价页 | 126 | * 购买评价页 |
88 | */ | 127 | */ |
89 | exports.comments = (req, res, next) => { | 128 | exports.comments = (req, res, next) => { |
129 | + if (!req.query.product_id) { | ||
130 | + return next(); | ||
131 | + } | ||
132 | + | ||
90 | let headerData = headerModel.setNav({ | 133 | let headerData = headerModel.setNav({ |
91 | navTitle: '购买评价' | 134 | navTitle: '购买评价' |
92 | }); | 135 | }); |
93 | 136 | ||
94 | detailRelated.comments(req.query).then((result) => { | 137 | detailRelated.comments(req.query).then((result) => { |
95 | res.render('detail/comments', Object.assign({ | 138 | res.render('detail/comments', Object.assign({ |
139 | + title: '购买评价', | ||
96 | pageHeader: headerData, | 140 | pageHeader: headerData, |
97 | pageFooter: true | 141 | pageFooter: true |
98 | }, result)); | 142 | }, result)); |
@@ -103,12 +147,17 @@ exports.comments = (req, res, next) => { | @@ -103,12 +147,17 @@ exports.comments = (req, res, next) => { | ||
103 | * 购买咨询 | 147 | * 购买咨询 |
104 | */ | 148 | */ |
105 | exports.consults = (req, res, next) => { | 149 | exports.consults = (req, res, next) => { |
150 | + if (!req.query.product_id) { | ||
151 | + return next(); | ||
152 | + } | ||
153 | + | ||
106 | let headerData = headerModel.setNav({ | 154 | let headerData = headerModel.setNav({ |
107 | navTitle: '购买咨询' | 155 | navTitle: '购买咨询' |
108 | }); | 156 | }); |
109 | 157 | ||
110 | detailRelated.consults(req.query).then((result) => { | 158 | detailRelated.consults(req.query).then((result) => { |
111 | res.render('detail/consults', Object.assign({ | 159 | res.render('detail/consults', Object.assign({ |
160 | + title: '购买咨询', | ||
112 | pageHeader: headerData, | 161 | pageHeader: headerData, |
113 | pageFooter: true | 162 | pageFooter: true |
114 | }, result)); | 163 | }, result)); |
@@ -116,17 +165,46 @@ exports.consults = (req, res, next) => { | @@ -116,17 +165,46 @@ exports.consults = (req, res, next) => { | ||
116 | }; | 165 | }; |
117 | 166 | ||
118 | /** | 167 | /** |
168 | + * 咨询点赞 | ||
169 | + */ | ||
170 | +exports.consultUpvoteOrUseful = (req, res, next) => { | ||
171 | + let uid = req.user.uid || 0; | ||
172 | + | ||
173 | + if (!uid) { | ||
174 | + return res.json({ | ||
175 | + code: 401, | ||
176 | + message: '用户id为空', | ||
177 | + data: helpers.urlFormat('/signin.html', { | ||
178 | + refer: helpers.urlFormat('/product/detail/consults', { | ||
179 | + product_id: req.body.product_id, | ||
180 | + total: req.body.total | ||
181 | + }) | ||
182 | + }) | ||
183 | + }); | ||
184 | + } | ||
185 | + | ||
186 | + req.body.isUpvote = /upvote/.test(req.path); | ||
187 | + req.body.uid = uid; | ||
188 | + | ||
189 | + detailRelated.upvoteConsult(req.body).then((result) => { | ||
190 | + res.json(result); | ||
191 | + }).catch(next); | ||
192 | +}; | ||
193 | + | ||
194 | +/** | ||
119 | * 咨询表单页 | 195 | * 咨询表单页 |
120 | */ | 196 | */ |
121 | exports.consultform = (req, res, next) => { | 197 | exports.consultform = (req, res, next) => { |
198 | + if (!req.query.product_id) { | ||
199 | + return next(); | ||
200 | + } | ||
201 | + | ||
122 | let headerData = headerModel.setNav({ | 202 | let headerData = headerModel.setNav({ |
123 | navTitle: '我要咨询' | 203 | navTitle: '我要咨询' |
124 | }); | 204 | }); |
125 | 205 | ||
126 | - if (!req.query.product_id) { | ||
127 | - return next(); | ||
128 | - } | ||
129 | res.render('detail/consult-form', { | 206 | res.render('detail/consult-form', { |
207 | + title: '我要咨询', | ||
130 | pageHeader: headerData, | 208 | pageHeader: headerData, |
131 | productId: req.query.product_id, | 209 | productId: req.query.product_id, |
132 | formUrl: '/product/detail/consultsubmit', | 210 | formUrl: '/product/detail/consultsubmit', |
@@ -6,8 +6,9 @@ | @@ -6,8 +6,9 @@ | ||
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -const api = global.yoho.API; | ||
10 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | +const api = global.yoho.API; | ||
11 | +const helpers = global.yoho.helpers; | ||
11 | 12 | ||
12 | /** | 13 | /** |
13 | * 获取默认咨询列表 | 14 | * 获取默认咨询列表 |
@@ -31,33 +32,6 @@ const _getCommonConsult = () => { | @@ -31,33 +32,6 @@ const _getCommonConsult = () => { | ||
31 | }; | 32 | }; |
32 | 33 | ||
33 | /** | 34 | /** |
34 | - * 处理评价列表数据 | ||
35 | - * @data {[object]} 评价列表原始数据 | ||
36 | - * @return {[object]} | ||
37 | - */ | ||
38 | -const _formatCommentsList = (data) => { | ||
39 | - let comment = { | ||
40 | - list: [], | ||
41 | - total: 0 | ||
42 | - }; | ||
43 | - | ||
44 | - if (data.length) { | ||
45 | - _.forEach(data, (value) => { | ||
46 | - comment.list.push({ | ||
47 | - userName: value.nickname, | ||
48 | - desc: `${value.color_name}/${value.size_name}`, | ||
49 | - content: value.content, | ||
50 | - time: value.create_time | ||
51 | - }); | ||
52 | - | ||
53 | - comment.total = value.total; | ||
54 | - }); | ||
55 | - } | ||
56 | - | ||
57 | - return comment; | ||
58 | -}; | ||
59 | - | ||
60 | -/** | ||
61 | * 处理咨询列表数据 | 35 | * 处理咨询列表数据 |
62 | * @data {[object]} 咨询列表原始数据 | 36 | * @data {[object]} 咨询列表原始数据 |
63 | * @return {[object]} | 37 | * @return {[object]} |
@@ -84,15 +58,15 @@ const _formatConsultsList = (data) => { | @@ -84,15 +58,15 @@ const _formatConsultsList = (data) => { | ||
84 | }; | 58 | }; |
85 | 59 | ||
86 | /** | 60 | /** |
87 | - * 获取评价数据 | 61 | + * 获取咨询数据 |
88 | * @id {[number]} 商品id | 62 | * @id {[number]} 商品id |
89 | * @page {[number]} 页码 | 63 | * @page {[number]} 页码 |
90 | - * @limit {[number]} 每页评价数量 | 64 | + * @limit {[number]} 每页咨询数量 |
91 | * @return {[object]} | 65 | * @return {[object]} |
92 | */ | 66 | */ |
93 | -const _getComments = (id, page, limit) => { | 67 | +const getConsults = (id, page, limit) => { |
94 | let params = { | 68 | let params = { |
95 | - method: 'app.comment.li', | 69 | + method: 'app.consult.li', |
96 | product_id: id, | 70 | product_id: id, |
97 | page: page ? page : 1, | 71 | page: page ? page : 1, |
98 | limit: limit ? limit : 300 | 72 | limit: limit ? limit : 300 |
@@ -103,8 +77,12 @@ const _getComments = (id, page, limit) => { | @@ -103,8 +77,12 @@ const _getComments = (id, page, limit) => { | ||
103 | }).then(result => { | 77 | }).then(result => { |
104 | let data = {}; | 78 | let data = {}; |
105 | 79 | ||
106 | - if (result.data) { | ||
107 | - Object.assign(data, _formatCommentsList(result.data)); | 80 | + if (result.data && result.data.list) { |
81 | + Object.assign(data, { | ||
82 | + list: _formatConsultsList(result.data.list), | ||
83 | + pageTotal: result.data.page_total, | ||
84 | + total: result.data.total | ||
85 | + }); | ||
108 | } | 86 | } |
109 | 87 | ||
110 | return data; | 88 | return data; |
@@ -112,34 +90,42 @@ const _getComments = (id, page, limit) => { | @@ -112,34 +90,42 @@ const _getComments = (id, page, limit) => { | ||
112 | }; | 90 | }; |
113 | 91 | ||
114 | /** | 92 | /** |
115 | - * 获取咨询数据 | ||
116 | - * @id {[number]} 商品id | ||
117 | - * @page {[number]} 页码 | ||
118 | - * @limit {[number]} 每页咨询数量 | ||
119 | - * @return {[object]} | 93 | + * 处理评论数据 |
120 | */ | 94 | */ |
121 | -const _getConsults = (id, page, limit) => { | ||
122 | - let params = { | ||
123 | - method: 'app.consult.li', | ||
124 | - product_id: id, | ||
125 | - page: page ? page : 1, | ||
126 | - limit: limit ? limit : 300 | 95 | +let _processComment = (data) => { |
96 | + let result = { | ||
97 | + commentsNum: data.pageResponse.totalCount, | ||
98 | + comments: [] | ||
127 | }; | 99 | }; |
128 | 100 | ||
129 | - return api.get('', params, { | ||
130 | - code: 200 | ||
131 | - }).then(result => { | ||
132 | - let data = {}; | 101 | + _.forEach(data.pageResponse.list, (item) => { |
102 | + result.comments.push({ | ||
103 | + userName: item.userInfo.nickName, | ||
104 | + desc: `${item.goods.color_name}/${item.goods.size_name}`, | ||
105 | + content: item.content, | ||
106 | + time: helpers.dateFormat('YYYY-MM-DD HH:mm:ss', new Date(item.createTime * 1000)) | ||
107 | + }); | ||
108 | + }); | ||
109 | + return result; | ||
110 | +}; | ||
133 | 111 | ||
134 | - if (result.data && result.data.list) { | ||
135 | - Object.assign(data, { | ||
136 | - list: _formatConsultsList(result.data.list), | ||
137 | - pageTotal: result.data.page_total, | ||
138 | - total: result.data.total | ||
139 | - }); | 112 | +/** |
113 | + * 获取评论信息 | ||
114 | + */ | ||
115 | +let getCommentInfo = (params) => { | ||
116 | + return api.get('', Object.assign({ | ||
117 | + method: 'show.productShareOrderList', | ||
118 | + limit: '1', | ||
119 | + page: '1', | ||
120 | + filterId: '7' | ||
121 | + }, params), { | ||
122 | + cache: true | ||
123 | + }).then((result) => { | ||
124 | + if (result.code === 200) { | ||
125 | + return _processComment(result.data); | ||
140 | } | 126 | } |
141 | 127 | ||
142 | - return data; | 128 | + return {}; |
143 | }); | 129 | }); |
144 | }; | 130 | }; |
145 | 131 | ||
@@ -149,14 +135,17 @@ const _getConsults = (id, page, limit) => { | @@ -149,14 +135,17 @@ const _getConsults = (id, page, limit) => { | ||
149 | * @return {[object]} | 135 | * @return {[object]} |
150 | */ | 136 | */ |
151 | let comments = (params) => { | 137 | let comments = (params) => { |
152 | - return _getComments(params.product_id, 1, 60).then(result => { | 138 | + return getCommentInfo({ |
139 | + productId: params.product_id, | ||
140 | + limit: '60' | ||
141 | + }).then(result => { | ||
153 | let data = {}; | 142 | let data = {}; |
154 | 143 | ||
155 | - if (result.list && result.list.length) { | ||
156 | - if (result.total) { | ||
157 | - _.set(data, 'pageHeader.navTitle', `购买评价(${result.total})`); | 144 | + if (result.comments && result.comments.length) { |
145 | + if (result.commentsNum) { | ||
146 | + _.set(data, 'pageHeader.navTitle', `购买评价(${result.commentsNum})`); | ||
158 | } | 147 | } |
159 | - data.comments = result.list; | 148 | + data.comments = result.comments; |
160 | } | 149 | } |
161 | 150 | ||
162 | return data; | 151 | return data; |
@@ -171,7 +160,7 @@ let comments = (params) => { | @@ -171,7 +160,7 @@ let comments = (params) => { | ||
171 | let consults = (params) => { | 160 | let consults = (params) => { |
172 | return api.all([ | 161 | return api.all([ |
173 | _getCommonConsult(), | 162 | _getCommonConsult(), |
174 | - _getConsults(params.product_id, 1, 60) | 163 | + getConsults(params.product_id, 1, 60) |
175 | ]).then(result => { | 164 | ]).then(result => { |
176 | let data = { | 165 | let data = { |
177 | link: `/product/detail/consultform?product_id=${params.product_id}` | 166 | link: `/product/detail/consultform?product_id=${params.product_id}` |
@@ -186,10 +175,20 @@ let consults = (params) => { | @@ -186,10 +175,20 @@ let consults = (params) => { | ||
186 | data.consults = result[1].list; | 175 | data.consults = result[1].list; |
187 | } | 176 | } |
188 | 177 | ||
178 | + data.showReadMore = result[1].list.length > 2; | ||
179 | + | ||
189 | return data; | 180 | return data; |
190 | }); | 181 | }); |
191 | }; | 182 | }; |
192 | 183 | ||
184 | +let upvoteConsult = (params) => { | ||
185 | + return api.get('', { | ||
186 | + method: params.isUpvote ? 'app.consult.like' : 'app.consult.useful', | ||
187 | + id: params.id, | ||
188 | + uid: params.uid | ||
189 | + }); | ||
190 | +}; | ||
191 | + | ||
193 | /** | 192 | /** |
194 | * 购买咨询列表 | 193 | * 购买咨询列表 |
195 | * @uid {[number]} 用户id | 194 | * @uid {[number]} 用户id |
@@ -214,7 +213,10 @@ let addConsult = (uid, productId, content) => { | @@ -214,7 +213,10 @@ let addConsult = (uid, productId, content) => { | ||
214 | }; | 213 | }; |
215 | 214 | ||
216 | module.exports = { | 215 | module.exports = { |
216 | + getCommentInfo, // 商品详情相关,获取评价,来自晒单 | ||
217 | comments, // 商品详情相关-购买评价 | 217 | comments, // 商品详情相关-购买评价 |
218 | consults, // 商品详情相关-购买咨询 | 218 | consults, // 商品详情相关-购买咨询 |
219 | - addConsult // 商品详情相关-添加咨询 | 219 | + addConsult, // 商品详情相关-添加咨询 |
220 | + upvoteConsult, // 咨询点赞 | ||
221 | + getConsults // 获取咨询 | ||
220 | }; | 222 | }; |
@@ -6,10 +6,14 @@ | @@ -6,10 +6,14 @@ | ||
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -const api = global.yoho.API; | ||
10 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | +const comment = require('./consult-comment'); | ||
11 | + | ||
12 | +const api = global.yoho.API; | ||
11 | const helpers = global.yoho.helpers; | 13 | const helpers = global.yoho.helpers; |
12 | 14 | ||
15 | +const SINGLE_TICKETS_SKN = 512579596;// 展览票 | ||
16 | + | ||
13 | /** | 17 | /** |
14 | * 获取用户数据信息 | 18 | * 获取用户数据信息 |
15 | * @param {[string]} uid | 19 | * @param {[string]} uid |
@@ -148,6 +152,9 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -148,6 +152,9 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
148 | 152 | ||
149 | dest.goodsName = origin.productName; | 153 | dest.goodsName = origin.productName; |
150 | 154 | ||
155 | + // 是否是虚拟商品 | ||
156 | + dest.virtualGoods = origin.attribute * 1 === 3 ? true : false; | ||
157 | + | ||
151 | // 用户未登录时 | 158 | // 用户未登录时 |
152 | if (!uid) { | 159 | if (!uid) { |
153 | let params = {}; | 160 | let params = {}; |
@@ -237,47 +244,19 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -237,47 +244,19 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
237 | dest.periodOfMarket = `${origin.expectArrivalTime}月`; | 244 | dest.periodOfMarket = `${origin.expectArrivalTime}月`; |
238 | } | 245 | } |
239 | 246 | ||
240 | - // 促销信息 TODO: 换新接口 | ||
241 | - if (origin.promotionBoList) { | ||
242 | - let discountList = []; | ||
243 | - | ||
244 | - _.forEach(origin.promotionBoList, function(value) { | ||
245 | - discountList.push({ | ||
246 | - text: `【${value.promotionType}】${value.promotionTitle}` | ||
247 | - }); | ||
248 | - }); | ||
249 | - | ||
250 | - if (discountList.length) { | ||
251 | - dest.goodsDiscount = { | ||
252 | - list: discountList | ||
253 | - }; | ||
254 | - } | ||
255 | - } | ||
256 | - | ||
257 | // 商品咨询 | 247 | // 商品咨询 |
258 | dest.feedbacks = { | 248 | dest.feedbacks = { |
259 | consults: [], | 249 | consults: [], |
260 | consultsNum: 0 | 250 | consultsNum: 0 |
261 | }; | 251 | }; |
262 | 252 | ||
263 | - if (origin.consultBoWrapper) { | ||
264 | - dest.feedbacks.consultsNum = origin.consultBoWrapper.consultTotal; | ||
265 | - _.forEach(origin.consultBoWrapper.consultBoList, function(value) { | ||
266 | - dest.feedbacks.consults.push({ | ||
267 | - question: value.ask, | ||
268 | - time: value.askTime, | ||
269 | - answer: value.answer | ||
270 | - }); | ||
271 | - }); | ||
272 | - } | ||
273 | - | ||
274 | let consultParams = { | 253 | let consultParams = { |
275 | product_id: origin.id | 254 | product_id: origin.id |
276 | }; | 255 | }; |
277 | 256 | ||
278 | if (_.has(dest, 'feedbacks.consultsNum')) { | 257 | if (_.has(dest, 'feedbacks.consultsNum')) { |
279 | consultParams.total = dest.feedbacks.consultsNum; | 258 | consultParams.total = dest.feedbacks.consultsNum; |
280 | - dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consult', consultParams); | 259 | + dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consults', consultParams); |
281 | } else { | 260 | } else { |
282 | dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams); | 261 | dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams); |
283 | } | 262 | } |
@@ -320,13 +299,13 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -320,13 +299,13 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
320 | if (origin.goodsList) { | 299 | if (origin.goodsList) { |
321 | let goodsGroup = [], | 300 | let goodsGroup = [], |
322 | sizeName = '', | 301 | sizeName = '', |
323 | - colorList = {}, | 302 | + colorList = [], |
324 | sizeList = {}, | 303 | sizeList = {}, |
325 | allSizeList = {}, | 304 | allSizeList = {}, |
326 | colorStorageGroup = {}, | 305 | colorStorageGroup = {}, |
327 | colorStorageNum = 0; | 306 | colorStorageNum = 0; |
328 | 307 | ||
329 | - _.forEach(origin.goodsList, function(value, key) { | 308 | + _.forEach(origin.goodsList, function(value) { |
330 | if (value.status === 0) { | 309 | if (value.status === 0) { |
331 | return; | 310 | return; |
332 | } | 311 | } |
@@ -367,7 +346,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -367,7 +346,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
367 | }; | 346 | }; |
368 | 347 | ||
369 | allSizeList[sizeName] = (allSizeList[sizeName] === null || | 348 | allSizeList[sizeName] = (allSizeList[sizeName] === null || |
370 | - typeof allSizeList[sizeName] === 'undefined') ? build : | 349 | + typeof allSizeList[sizeName] === 'undefined') ? build : |
371 | allSizeList[sizeName]; | 350 | allSizeList[sizeName]; |
372 | 351 | ||
373 | colorStorageNum += parseInt(size.goodsSizeStorageNum, 10); | 352 | colorStorageNum += parseInt(size.goodsSizeStorageNum, 10); |
@@ -375,13 +354,13 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -375,13 +354,13 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
375 | }); | 354 | }); |
376 | 355 | ||
377 | // 颜色分组 | 356 | // 颜色分组 |
378 | - colorList[key] = { | 357 | + colorList.push({ |
379 | id: value.colorId, | 358 | id: value.colorId, |
380 | skcId: value.productSkc, | 359 | skcId: value.productSkc, |
381 | name: value.colorName, | 360 | name: value.colorName, |
382 | goodsName: value.goodsName, | 361 | goodsName: value.goodsName, |
383 | colorNum: colorStorageNum | 362 | colorNum: colorStorageNum |
384 | - }; | 363 | + }); |
385 | } | 364 | } |
386 | 365 | ||
387 | // 缩略图 | 366 | // 缩略图 |
@@ -399,10 +378,12 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -399,10 +378,12 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
399 | sizeGroup[0] = { | 378 | sizeGroup[0] = { |
400 | size: [] | 379 | size: [] |
401 | }; | 380 | }; |
402 | - _.forEach(allSizeList, function(value) { | 381 | + |
382 | + _.forEach(allSizeList, (value, key) => { | ||
383 | + | ||
403 | // 默认尺码 | 384 | // 默认尺码 |
404 | sizeGroup[0].size.push({ | 385 | sizeGroup[0].size.push({ |
405 | - name: sizeName, | 386 | + name: key, |
406 | sizeNum: _.toNumber(value.storage) > 0 ? true : false, | 387 | sizeNum: _.toNumber(value.storage) > 0 ? true : false, |
407 | id: value.id | 388 | id: value.id |
408 | }); | 389 | }); |
@@ -412,13 +393,16 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -412,13 +393,16 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
412 | }; | 393 | }; |
413 | 394 | ||
414 | // 各个颜色的尺码, 每行显示一个尺码对应的颜色 | 395 | // 各个颜色的尺码, 每行显示一个尺码对应的颜色 |
415 | - _.forEach(colorList, function(colorArr) { | ||
416 | - colorArr.colorNum = 0; | ||
417 | - if (colorStorageGroup[colorArr.skcId] && | ||
418 | - colorStorageGroup[colorArr.skcId][sizeName]) { | ||
419 | - colorArr.colorNum = colorStorageGroup[colorArr.skcId][sizeName]; | 396 | + _.forEach(colorList, (colorArr) => { |
397 | + let tempColorArr = _.cloneDeep(colorArr); | ||
398 | + | ||
399 | + if (colorStorageGroup[tempColorArr.skcId] && | ||
400 | + colorStorageGroup[tempColorArr.skcId][key]) { | ||
401 | + tempColorArr.colorNum = colorStorageGroup[tempColorArr.skcId][key]; | ||
402 | + } else { | ||
403 | + tempColorArr.colorNum = 0; | ||
420 | } | 404 | } |
421 | - colorGroup[i].color.push(colorArr); | 405 | + colorGroup[i].color.push(Object.assign({}, tempColorArr)); |
422 | }); | 406 | }); |
423 | colorGroup[i].id = value.id; | 407 | colorGroup[i].id = value.id; |
424 | 408 | ||
@@ -443,6 +427,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -443,6 +427,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
443 | ++i; | 427 | ++i; |
444 | }); | 428 | }); |
445 | 429 | ||
430 | + | ||
446 | // 商品图:多个 | 431 | // 商品图:多个 |
447 | if (goodsGroup.length > 1) { | 432 | if (goodsGroup.length > 1) { |
448 | let bannerList = []; | 433 | let bannerList = []; |
@@ -492,7 +477,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -492,7 +477,7 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
492 | if (origin.isLimitBuy === 'Y') { | 477 | if (origin.isLimitBuy === 'Y') { |
493 | // 是否开售 | 478 | // 是否开售 |
494 | let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' && | 479 | let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' && |
495 | - origin.saleStatus === 1); | 480 | + origin.saleStatus === 1); |
496 | 481 | ||
497 | // 限购商品有关的展示状态 | 482 | // 限购商品有关的展示状态 |
498 | let showStatus = 1; | 483 | let showStatus = 1; |
@@ -527,6 +512,31 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | @@ -527,6 +512,31 @@ const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
527 | dest.introUrl = '/product/detail/intro/' + origin.erpProductId; | 512 | dest.introUrl = '/product/detail/intro/' + origin.erpProductId; |
528 | dest.id = origin.id; | 513 | dest.id = origin.id; |
529 | 514 | ||
515 | + // 虚拟商品(门票) | ||
516 | + if (origin.attribute * 1 === 3) { | ||
517 | + dest.tickets = true; | ||
518 | + dest.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm'); | ||
519 | + | ||
520 | + // 展览票 | ||
521 | + if (origin.erpProductId * 1 === SINGLE_TICKETS_SKN) { | ||
522 | + dest.single = true; | ||
523 | + } else { | ||
524 | + // 套票 | ||
525 | + dest.package = true; | ||
526 | + } | ||
527 | + | ||
528 | + // 购票限制 | ||
529 | + dest.cartInfo.limit = 4; | ||
530 | + | ||
531 | + // 清空活动 | ||
532 | + dest.goodsDiscount = []; | ||
533 | + | ||
534 | + // 来自登录页,自动弹出选择框 | ||
535 | + // if (isset($_GET['product_type']) && $_GET['product_type'] == 'ticket') { | ||
536 | + // $result['showPannel'] = true; | ||
537 | + // } | ||
538 | + } | ||
539 | + | ||
530 | return dest; | 540 | return dest; |
531 | }; | 541 | }; |
532 | 542 | ||
@@ -560,13 +570,44 @@ let _getPromotionInfo = (skn) => { | @@ -560,13 +570,44 @@ let _getPromotionInfo = (skn) => { | ||
560 | }); | 570 | }); |
561 | }; | 571 | }; |
562 | 572 | ||
573 | + | ||
574 | +/** | ||
575 | + * 获取默认咨询列表 | ||
576 | + */ | ||
577 | +const _getCommonConsult = () => { | ||
578 | + let params = { | ||
579 | + method: 'app.consult.common' | ||
580 | + }; | ||
581 | + | ||
582 | + return api.get('', params, { | ||
583 | + code: 200 | ||
584 | + }).then(result => { | ||
585 | + let data = {}; | ||
586 | + | ||
587 | + if (result.data) { | ||
588 | + data = result.data; | ||
589 | + } | ||
590 | + | ||
591 | + return data; | ||
592 | + }); | ||
593 | +}; | ||
594 | + | ||
563 | let getProductData = (data) => { | 595 | let getProductData = (data) => { |
564 | let finalResult; | 596 | let finalResult; |
565 | let params = { | 597 | let params = { |
566 | - productId: _.toString(data.id), | ||
567 | method: 'h5.product.data' | 598 | method: 'h5.product.data' |
568 | }; | 599 | }; |
569 | 600 | ||
601 | + if (data.id) { // 通过 productId 获取商品详情 | ||
602 | + Object.assign(params, { | ||
603 | + productId: _.toString(data.id) | ||
604 | + }); | ||
605 | + } else if (data.productSkn) { // 通过 productSkn 获取商品详情 | ||
606 | + Object.assign(params, { | ||
607 | + product_skn: _.toString(data.productSkn) | ||
608 | + }); | ||
609 | + } | ||
610 | + | ||
570 | if (!_.isEmpty(data.uid)) { | 611 | if (!_.isEmpty(data.uid)) { |
571 | params.uid = data.uid; | 612 | params.uid = data.uid; |
572 | } | 613 | } |
@@ -577,12 +618,42 @@ let getProductData = (data) => { | @@ -577,12 +618,42 @@ let getProductData = (data) => { | ||
577 | return api.get('', params, { | 618 | return api.get('', params, { |
578 | cache: true | 619 | cache: true |
579 | }).then(result => { | 620 | }).then(result => { |
580 | - return Promise.all([_getShopsInfo(result.brandId), _getPromotionInfo(result.erpProductId)]).then((info) => { | 621 | + if (result.code === 500) { |
622 | + return {}; | ||
623 | + } | ||
624 | + return Promise.all([ | ||
625 | + _getShopsInfo(result.brandId), | ||
626 | + _getPromotionInfo(result.erpProductId), | ||
627 | + comment.getCommentInfo({ | ||
628 | + productId: result.id | ||
629 | + }), | ||
630 | + _getCommonConsult(), | ||
631 | + comment.getConsults(result.id, 1, 2) | ||
632 | + ]).then((info) => { | ||
581 | result.promotionBoList = info[1]; | 633 | result.promotionBoList = info[1]; |
582 | 634 | ||
583 | finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua); | 635 | finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua); |
584 | finalResult.enterStore = info[0]; | 636 | finalResult.enterStore = info[0]; |
585 | 637 | ||
638 | + Object.assign(finalResult.feedbacks, info[2]); | ||
639 | + | ||
640 | + /* 如果有咨询,显示咨询,否则显示常见问题 */ | ||
641 | + if (info[4].total) { | ||
642 | + finalResult.feedbacks.consultsNum = parseInt(info[4].total, 10); | ||
643 | + | ||
644 | + Object.assign(finalResult.feedbacks, { | ||
645 | + commonConsults: false, | ||
646 | + consultsNum: parseInt(info[4].total, 10), | ||
647 | + consults: _.take(info[4].list, 2) | ||
648 | + }); | ||
649 | + } else if (!_.isEmpty(info[3]) && !_.get(info[2], 'feedbacks.consultsNum', 0)) { | ||
650 | + Object.assign(finalResult.feedbacks, { | ||
651 | + commonConsults: true, | ||
652 | + consultsNum: true, | ||
653 | + consults: _.take(info[3], 2) | ||
654 | + }); | ||
655 | + } | ||
656 | + | ||
586 | return finalResult; | 657 | return finalResult; |
587 | }); | 658 | }); |
588 | 659 |
@@ -75,9 +75,9 @@ const getSizeInfo = (sizeInfo) => { | @@ -75,9 +75,9 @@ const getSizeInfo = (sizeInfo) => { | ||
75 | dest.sizeInfo.detail.list = []; | 75 | dest.sizeInfo.detail.list = []; |
76 | 76 | ||
77 | // 参考尺码 | 77 | // 参考尺码 |
78 | - let boyReference = !_.isEmpty(sizeInfo.productExtra.boyReference); | ||
79 | - let girlReference = !_.isEmpty(sizeInfo.productExtra.girlReference); | ||
80 | - let gender = !_.isEmpty(sizeInfo.productDescBo.gender) ? sizeInfo.productDescBo.gender : 3; | 78 | + let boyReference = sizeInfo.productExtra.boyReference; |
79 | + let girlReference = sizeInfo.productExtra.girlReference; | ||
80 | + let gender = sizeInfo.productDescBo.gender ? sizeInfo.productDescBo.gender : 3; | ||
81 | let referenceName = '参考尺码'; | 81 | let referenceName = '参考尺码'; |
82 | 82 | ||
83 | if ((gender === 1 && boyReference) || (gender === 2 && girlReference)) { | 83 | if ((gender === 1 && boyReference) || (gender === 2 && girlReference)) { |
@@ -102,12 +102,14 @@ const getSizeInfo = (sizeInfo) => { | @@ -102,12 +102,14 @@ const getSizeInfo = (sizeInfo) => { | ||
102 | 102 | ||
103 | if (!_.isEmpty(sizeInfo.sizeInfoBo.sizeAttributeBos)) { | 103 | if (!_.isEmpty(sizeInfo.sizeInfoBo.sizeAttributeBos)) { |
104 | 104 | ||
105 | + // [{param: attrName}] th | ||
105 | let sizeNameList = []; | 106 | let sizeNameList = []; |
106 | 107 | ||
107 | temp = {}; | 108 | temp = {}; |
108 | temp.param = '吊牌尺码'; | 109 | temp.param = '吊牌尺码'; |
109 | sizeNameList.push(temp); | 110 | sizeNameList.push(temp); |
110 | 111 | ||
112 | + // {id: [{param: str},......]} sizeBoGroup[id][0] 属性名, sizeBoGroup[id][index] 属性值 | ||
111 | let sizeBoGroup = {}; | 113 | let sizeBoGroup = {}; |
112 | 114 | ||
113 | _.forEach(sizeInfo.sizeInfoBo.sizeAttributeBos, function(attr) { | 115 | _.forEach(sizeInfo.sizeInfoBo.sizeAttributeBos, function(attr) { |
@@ -126,13 +128,11 @@ const getSizeInfo = (sizeInfo) => { | @@ -126,13 +128,11 @@ const getSizeInfo = (sizeInfo) => { | ||
126 | 128 | ||
127 | if (boyReference && (gender === 1 || gender === 3)) { | 129 | if (boyReference && (gender === 1 || gender === 3)) { |
128 | temp = {}; | 130 | temp = {}; |
129 | - temp.param = _.isEmpty(value.boyReferSize.referenceName) ? | ||
130 | - ' ' : value.boyReferSize.referenceName; | 131 | + temp.param = value.boyReferSize.referenceName || ''; |
131 | referenceList.push(temp); | 132 | referenceList.push(temp); |
132 | } else if (girlReference && (gender === 2 || gender === 3)) { | 133 | } else if (girlReference && (gender === 2 || gender === 3)) { |
133 | temp = {}; | 134 | temp = {}; |
134 | - temp.param = _.isEmpty(value.girlReferSize.referenceName) ? | ||
135 | - ' ' : value.girlReferSize.referenceName; | 135 | + temp.param = value.girlReferSize.referenceName || ''; |
136 | referenceList.push(temp); | 136 | referenceList.push(temp); |
137 | } else { | 137 | } else { |
138 | showReference = false; | 138 | showReference = false; |
@@ -140,7 +140,7 @@ const getSizeInfo = (sizeInfo) => { | @@ -140,7 +140,7 @@ const getSizeInfo = (sizeInfo) => { | ||
140 | 140 | ||
141 | _.forEach(value.sortAttributes, function(attr) { | 141 | _.forEach(value.sortAttributes, function(attr) { |
142 | temp = {}; | 142 | temp = {}; |
143 | - temp.param = _.isEmpty(attr.sizeValue) ? ' ' : attr.sizeValue; | 143 | + temp.param = attr.sizeValue || ' '; |
144 | sizeBoGroup[attr.id].push(temp); | 144 | sizeBoGroup[attr.id].push(temp); |
145 | }); | 145 | }); |
146 | }); | 146 | }); |
@@ -149,6 +149,7 @@ const getSizeInfo = (sizeInfo) => { | @@ -149,6 +149,7 @@ const getSizeInfo = (sizeInfo) => { | ||
149 | dest.sizeInfo.detail.list[0] = {}; | 149 | dest.sizeInfo.detail.list[0] = {}; |
150 | dest.sizeInfo.detail.list[0].params = sizeNameList; | 150 | dest.sizeInfo.detail.list[0].params = sizeNameList; |
151 | if (showReference) { | 151 | if (showReference) { |
152 | + dest.sizeInfo.detail.list[1] = {}; | ||
152 | dest.sizeInfo.detail.list[1].params = referenceList; | 153 | dest.sizeInfo.detail.list[1].params = referenceList; |
153 | } | 154 | } |
154 | _.forEach(sizeBoGroup, function(value) { | 155 | _.forEach(sizeBoGroup, function(value) { |
@@ -302,15 +303,15 @@ const getSizeInfo = (sizeInfo) => { | @@ -302,15 +303,15 @@ const getSizeInfo = (sizeInfo) => { | ||
302 | dest.productDetail.enTitle = 'DETAILS'; | 303 | dest.productDetail.enTitle = 'DETAILS'; |
303 | 304 | ||
304 | dest.productDetail.desc = productIntro.replace(/\r\n\t/g, ''). | 305 | dest.productDetail.desc = productIntro.replace(/\r\n\t/g, ''). |
305 | - replace(/<\/p>/g, ''). | ||
306 | - replace(/<img src=/g, '<img class="lazy" src="data:image/gif;' + | ||
307 | - 'base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=="' + | ||
308 | - ' data-original='). | ||
309 | - replace(/<img border="0" src=/g, '<img border="0" class="lazy" ' + | ||
310 | - 'src="data:image/gif;base64,' + | ||
311 | - 'R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=="' + | ||
312 | - ' data-original='). | ||
313 | - replace(/.jpg/g, '.jpg?imageMogr2/thumbnail/750x/quality/90'); | 306 | + replace(/<\/p>/g, ''). |
307 | + replace(/<img src=/g, '<img class="lazy" src="data:image/gif;' + | ||
308 | + 'base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=="' + | ||
309 | + ' data-original='). | ||
310 | + replace(/<img border="0" src=/g, '<img border="0" class="lazy" ' + | ||
311 | + 'src="data:image/gif;base64,' + | ||
312 | + 'R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=="' + | ||
313 | + ' data-original='). | ||
314 | + replace(/.jpg/g, '.jpg?imageMogr2/thumbnail/750x/quality/90'); | ||
314 | } | 315 | } |
315 | 316 | ||
316 | // 清空变量,释放内存 | 317 | // 清空变量,释放内存 |
@@ -229,7 +229,7 @@ const _getResources = (page, channel) => { | @@ -229,7 +229,7 @@ const _getResources = (page, channel) => { | ||
229 | if (result && result.code === 200) { | 229 | if (result && result.code === 200) { |
230 | return resourcesProcess(result.data); | 230 | return resourcesProcess(result.data); |
231 | } else { | 231 | } else { |
232 | - logger.error('SALE 页面资源位返回 code 不是 200'); | 232 | + logger.error('SALE content resource code no 200'); |
233 | return []; | 233 | return []; |
234 | } | 234 | } |
235 | }); | 235 | }); |
@@ -250,7 +250,7 @@ const _getBreakingSort = (yhChannel) => { | @@ -250,7 +250,7 @@ const _getBreakingSort = (yhChannel) => { | ||
250 | if (result && result.code === 200) { | 250 | if (result && result.code === 200) { |
251 | return _processBreakingSort(result.data); | 251 | return _processBreakingSort(result.data); |
252 | } else { | 252 | } else { |
253 | - logger.error('断码区分类接口返回 code 不是 200'); | 253 | + logger.error('api app.sale.getBreakingSort code no 200'); |
254 | return {}; | 254 | return {}; |
255 | } | 255 | } |
256 | }); | 256 | }); |
@@ -268,7 +268,7 @@ const getSearchData = (params, uid) => { | @@ -268,7 +268,7 @@ const getSearchData = (params, uid) => { | ||
268 | showSale: false | 268 | showSale: false |
269 | }); | 269 | }); |
270 | } else { | 270 | } else { |
271 | - logger.error('SALE 商品搜索返回 code 不是 200'); | 271 | + logger.error('api SALE product search code no 200'); |
272 | return []; | 272 | return []; |
273 | } | 273 | } |
274 | }), | 274 | }), |
@@ -276,7 +276,7 @@ const getSearchData = (params, uid) => { | @@ -276,7 +276,7 @@ const getSearchData = (params, uid) => { | ||
276 | if (result && result.code === 200) { | 276 | if (result && result.code === 200) { |
277 | return result.data.vip_info ? camelCase(result.data.vip_info) : {}; | 277 | return result.data.vip_info ? camelCase(result.data.vip_info) : {}; |
278 | } else { | 278 | } else { |
279 | - logger.error('获取用户信息返回 code 不是 200'); | 279 | + logger.error('api get user info code no 200'); |
280 | return {}; | 280 | return {}; |
281 | } | 281 | } |
282 | }) | 282 | }) |
@@ -296,7 +296,7 @@ const getFilterData = (params) => { | @@ -296,7 +296,7 @@ const getFilterData = (params) => { | ||
296 | hideSort: params.saleType === '1' | 296 | hideSort: params.saleType === '1' |
297 | }); | 297 | }); |
298 | } else { | 298 | } else { |
299 | - logger.error('SALE 商品搜索返回 code 不是 200'); | 299 | + logger.error('SALE search product code no 200'); |
300 | return []; | 300 | return []; |
301 | } | 301 | } |
302 | }); | 302 | }); |
@@ -328,12 +328,12 @@ const getVipData = (channel) => { | @@ -328,12 +328,12 @@ const getVipData = (channel) => { | ||
328 | const getBreakCodeData = (params) => { | 328 | const getBreakCodeData = (params) => { |
329 | params = params || {}; | 329 | params = params || {}; |
330 | return Promise.all([_getResources('breakCode', params.yhChannel), _getBreakingSort(params.yhChannel)]) | 330 | return Promise.all([_getResources('breakCode', params.yhChannel), _getBreakingSort(params.yhChannel)]) |
331 | - .then((result) => { | ||
332 | - return { | ||
333 | - content: result[0], | ||
334 | - nav: result[1] | ||
335 | - }; | ||
336 | - }); | 331 | + .then((result) => { |
332 | + return { | ||
333 | + content: result[0], | ||
334 | + nav: result[1] | ||
335 | + }; | ||
336 | + }); | ||
337 | }; | 337 | }; |
338 | 338 | ||
339 | /** | 339 | /** |
@@ -350,7 +350,7 @@ const getDiscountData = (yhChannel) => { | @@ -350,7 +350,7 @@ const getDiscountData = (yhChannel) => { | ||
350 | list: _processDiscount(result.data) | 350 | list: _processDiscount(result.data) |
351 | }; | 351 | }; |
352 | } else { | 352 | } else { |
353 | - logger.error('折扣专场专题列表返回 code 不是 200'); | 353 | + logger.error('api discount list code no 200'); |
354 | return {}; | 354 | return {}; |
355 | } | 355 | } |
356 | }); | 356 | }); |
@@ -383,7 +383,7 @@ const getDiscountDetailData = (id, yhChannel) => { | @@ -383,7 +383,7 @@ const getDiscountDetailData = (id, yhChannel) => { | ||
383 | } | 383 | } |
384 | }; | 384 | }; |
385 | } else { | 385 | } else { |
386 | - logger.error('折扣专场专题详情返回 code 不是 200'); | 386 | + logger.error('discount detail code no 200'); |
387 | return {}; | 387 | return {}; |
388 | } | 388 | } |
389 | }); | 389 | }); |
@@ -28,13 +28,18 @@ const recommendForYou = require(`${cRoot}/recommend-for-you`); | @@ -28,13 +28,18 @@ const recommendForYou = require(`${cRoot}/recommend-for-you`); | ||
28 | 28 | ||
29 | // /pro_136349_455445/HEARTSOFARMianMaShuJiaoXiuXianKuPS1684.html | 29 | // /pro_136349_455445/HEARTSOFARMianMaShuJiaoXiuXianKuPS1684.html |
30 | router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.index); // 商品详情页 | 30 | router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.index); // 商品详情页 |
31 | +// /show_51047967.html | ||
32 | +router.get(/\/show_([\d]+)/, detail.indexSkn); // 商品详情页 SKN 进入 | ||
31 | router.get('/detail/intro/:productskn', detail.intro); // 商品内嵌页 | 33 | router.get('/detail/intro/:productskn', detail.intro); // 商品内嵌页 |
32 | router.get('/detail/preference', detail.preference); // 为你优选 | 34 | router.get('/detail/preference', detail.preference); // 为你优选 |
33 | router.get('/detail/consults', detail.consults); // 商品咨询页 | 35 | router.get('/detail/consults', detail.consults); // 商品咨询页 |
34 | router.get('/detail/consultform', auth, detail.consultform); // 商品咨询表单页 | 36 | router.get('/detail/consultform', auth, detail.consultform); // 商品咨询表单页 |
35 | -router.get('/detail/comments', detail.comments); | 37 | +router.get('/detail/comments', detail.comments); // 商品评价 |
36 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 | 38 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 |
37 | 39 | ||
40 | +router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口 | ||
41 | +router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口 | ||
42 | + | ||
38 | router.get('/sale', sale.index); | 43 | router.get('/sale', sale.index); |
39 | router.get('/sale/discount', sale.discount); | 44 | router.get('/sale/discount', sale.discount); |
40 | router.get('/sale/discount/detail', sale.discountDetail); | 45 | router.get('/sale/discount/detail', sale.discountDetail); |
@@ -135,8 +135,7 @@ | @@ -135,8 +135,7 @@ | ||
135 | <a href="{{cartUrl}}" class="num-incart iconfont"><span class="num-tag hide"></span></a> | 135 | <a href="{{cartUrl}}" class="num-incart iconfont"><span class="num-tag hide"></span></a> |
136 | 136 | ||
137 | {{#if addToCartUrl}} | 137 | {{#if addToCartUrl}} |
138 | - <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> --> | ||
139 | - <a id="addtoCart" href="javascript:;" class="addto-cart">加入购物车</a> | 138 | + <a id="addtoCart" href="javascript:;" class="addto-cart">{{#if ../tickets}}立即购买{{else}}加入购物车{{/if}}</a> |
140 | {{/if}} | 139 | {{/if}} |
141 | 140 | ||
142 | {{#if soldOut}} | 141 | {{#if soldOut}} |
@@ -183,5 +182,16 @@ | @@ -183,5 +182,16 @@ | ||
183 | <input type="hidden" name="loginUrl" id="loginUrl" value="{{.}}"> | 182 | <input type="hidden" name="loginUrl" id="loginUrl" value="{{.}}"> |
184 | {{/loginUrl}} | 183 | {{/loginUrl}} |
185 | 184 | ||
185 | + {{#if tickets}} | ||
186 | + <form id="buyNowForm" method="post" action="{{ticketsConfirm}}"> | ||
187 | + <input type="hidden" name="productSku" id="productSku"> | ||
188 | + <input type="hidden" name="buyNumber" id="buyNumber"> | ||
189 | + </form> | ||
190 | + {{/if}} | ||
191 | + | ||
192 | + {{#if showPannel}} | ||
193 | + <input type="hidden" id="showPannel" value="1"> | ||
194 | + {{/if}} | ||
195 | + | ||
186 | </div> | 196 | </div> |
187 | {{/ result}} | 197 | {{/ result}} |
1 | <ul id="nav-tab" class="nav-tab clearfix"> | 1 | <ul id="nav-tab" class="nav-tab clearfix"> |
2 | <li class="comment-nav tap-hightlight">商品评价(<span class="comments-num">{{commentsNum}}</span>)</li> | 2 | <li class="comment-nav tap-hightlight">商品评价(<span class="comments-num">{{commentsNum}}</span>)</li> |
3 | - <li class="consult-nav tap-hightlight">购买咨询(<span class="consults-num">{{consultsNum}}</span>)</li> | 3 | + {{#if commonConsults}} |
4 | + <li class="consult-nav tap-hightlight">常见问题</li> | ||
5 | + {{^}} | ||
6 | + <li class="consult-nav tap-hightlight">购买咨询(<span class="consults-num">{{consultsNum}}</span>)</li> | ||
7 | + {{/if}} | ||
4 | </ul> | 8 | </ul> |
5 | <div id="feedback-content" > | 9 | <div id="feedback-content" > |
6 | <div class="comment-content content "> | 10 | <div class="comment-content content "> |
7 | {{#if commentsNum}} | 11 | {{#if commentsNum}} |
8 | - <div class="comment-content-main content-main"> | ||
9 | - {{# comments}} | ||
10 | - <span class="user-name"> | ||
11 | - {{userName}} | ||
12 | - </span> | 12 | + <div class="comment-content-main content-main"> |
13 | + {{# comments}} | ||
14 | + <span class="user-name"> | ||
15 | + {{userName}} | ||
16 | + </span> | ||
13 | <span class="goods-spec"> | 17 | <span class="goods-spec"> |
14 | 购买了{{desc}} | 18 | 购买了{{desc}} |
15 | </span> | 19 | </span> |
16 | - <p class="detail-content"> | ||
17 | - {{content}} | ||
18 | - </p> | 20 | + <p class="detail-content"> |
21 | + {{content}} | ||
22 | + </p> | ||
19 | <span class="comment-time"> | 23 | <span class="comment-time"> |
20 | {{time}} | 24 | {{time}} |
21 | </span> | 25 | </span> |
22 | - {{/ comments}} | ||
23 | - </div> | ||
24 | - <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}"> | 26 | + {{/ comments}} |
27 | + </div> | ||
28 | + <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}"> | ||
25 | 查看更多 | 29 | 查看更多 |
26 | <span class="iconfont"></span> | 30 | <span class="iconfont"></span> |
27 | - </a> | 31 | + </a> |
28 | {{^}} | 32 | {{^}} |
29 | - <div class="comment-content-main content-main no-item"> | ||
30 | - <span class="iconfont"></span>暂无评论 | ||
31 | - </div> | 33 | + <div class="comment-content-main content-main no-item"> |
34 | + <span class="iconfont"></span>暂无评论 | ||
35 | + </div> | ||
32 | {{/if}} | 36 | {{/if}} |
33 | </div> | 37 | </div> |
34 | 38 | ||
35 | <div class="consult-content content hide "> | 39 | <div class="consult-content content hide "> |
36 | {{#if consultsNum}} | 40 | {{#if consultsNum}} |
37 | - <div class="consult-content-main content-main"> | ||
38 | - {{# consults}} | ||
39 | - <div class="question"> | ||
40 | - <span class="iconfont"></span> | ||
41 | - <p> | ||
42 | - {{question}}<br> | ||
43 | - <span class="time">{{time}}</span> | ||
44 | - </p> | ||
45 | - </div> | 41 | + <div class="consult-content-main content-main"> |
42 | + {{# consults}} | ||
43 | + <div class="question"> | ||
44 | + <span class="iconfont"></span> | ||
45 | + <p> | ||
46 | + {{question}}<br> | ||
47 | + <span class="time">{{time}}</span> | ||
48 | + </p> | ||
49 | + </div> | ||
46 | 50 | ||
47 | - <div class="answer"> | ||
48 | - <span class="iconfont"></span> | ||
49 | - <p>{{answer}}</p> | 51 | + <div class="answer"> |
52 | + <span class="iconfont"></span> | ||
53 | + <p>{{answer}}</p> | ||
54 | + </div> | ||
55 | + {{/ consults}} | ||
50 | </div> | 56 | </div> |
51 | - {{/ consults}} | ||
52 | - </div> | ||
53 | - <a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}"> | ||
54 | - 查看更多 | ||
55 | - <span class="iconfont"></span> | ||
56 | - </a> | 57 | + <a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}"> |
58 | + 查看更多 | ||
59 | + <span class="iconfont"></span> | ||
60 | + </a> | ||
57 | {{else}} | 61 | {{else}} |
58 | - <div class="consult-content-main content-main no-item"> | ||
59 | - <span class="iconfont"></span>暂无咨询 | ||
60 | - </div> | 62 | + <div class="consult-content-main content-main no-item"> |
63 | + <span class="iconfont"></span>暂无咨询 | ||
64 | + </div> | ||
61 | 65 | ||
62 | - <div class="consult-content-footer tap-hightlight"> | ||
63 | - <a href="{{consultsUrl}}"> | ||
64 | - 我要咨询 | ||
65 | - <span class="iconfont"></span></a> | ||
66 | - </div> | 66 | + <div class="consult-content-footer tap-hightlight"> |
67 | + <a href="{{consultsUrl}}"> | ||
68 | + 我要咨询 | ||
69 | + <span class="iconfont"></span></a> | ||
70 | + </div> | ||
67 | {{/if}} | 71 | {{/if}} |
68 | </div> | 72 | </div> |
69 | </div> | 73 | </div> |
@@ -33,9 +33,9 @@ module.exports = { | @@ -33,9 +33,9 @@ module.exports = { | ||
33 | useOneapm: false, | 33 | useOneapm: false, |
34 | useCache: false, | 34 | useCache: false, |
35 | memcache: { | 35 | memcache: { |
36 | - master: ['192.168.102.222:12111'], | ||
37 | - slave: ['192.168.102.222:12111'], | ||
38 | - session: ['192.168.102.222:12111'], | 36 | + master: ['192.168.102.205:12111'], |
37 | + slave: ['192.168.102.205:12111'], | ||
38 | + session: ['192.168.102.205:12111'], | ||
39 | timeout: 1000, | 39 | timeout: 1000, |
40 | retries: 0 | 40 | retries: 0 |
41 | }, | 41 | }, |
@@ -63,7 +63,6 @@ module.exports = { | @@ -63,7 +63,6 @@ module.exports = { | ||
63 | handleExceptions: true | 63 | handleExceptions: true |
64 | }, | 64 | }, |
65 | udp: { // send by udp | 65 | udp: { // send by udp |
66 | - measurement: 'yohobuywap_node_log', | ||
67 | level: 'debug', // logger level | 66 | level: 'debug', // logger level |
68 | host: '192.168.102.162', // influxdb host | 67 | host: '192.168.102.162', // influxdb host |
69 | port: '4444' // influxdb port | 68 | port: '4444' // influxdb port |
@@ -90,9 +89,9 @@ if (isProduction) { | @@ -90,9 +89,9 @@ if (isProduction) { | ||
90 | service: 'http://service.yoho.yohoops.org/' | 89 | service: 'http://service.yoho.yohoops.org/' |
91 | }, | 90 | }, |
92 | memcache: { | 91 | memcache: { |
93 | - master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111'], | ||
94 | - slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112'], | ||
95 | - session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111'], | 92 | + master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], |
93 | + slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'], | ||
94 | + session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], | ||
96 | timeout: 1000, | 95 | timeout: 1000, |
97 | retries: 0 | 96 | retries: 0 |
98 | }, | 97 | }, |
1 | {{#cartInfo}} | 1 | {{#cartInfo}} |
2 | <div class="chose-panel"> | 2 | <div class="chose-panel"> |
3 | <div class="main"> | 3 | <div class="main"> |
4 | - <div class="infos"> | 4 | + <div class="infos {{#if ../tickets}}tickets-info{{/if}}"> |
5 | <div class="basic-info" > | 5 | <div class="basic-info" > |
6 | {{#thumbs}} | 6 | {{#thumbs}} |
7 | <img class="thumb {{#unless @first}}hide{{/unless}}" src={{image img 60 60}}> | 7 | <img class="thumb {{#unless @first}}hide{{/unless}}" src={{image img 60 60}}> |
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | </div> | 18 | </div> |
19 | <div class="chose-items"> | 19 | <div class="chose-items"> |
20 | <div class="color-list block-list"> | 20 | <div class="color-list block-list"> |
21 | - <span>颜色</span> | 21 | + <span>{{#if ../tickets}}日期{{else}}颜色{{/if}}</span> |
22 | {{# colors}} | 22 | {{# colors}} |
23 | <ul id="{{id}}" data-index="{{@index}}" class="size-row clearfix {{#unless @first}}hide{{/unless}}"> | 23 | <ul id="{{id}}" data-index="{{@index}}" class="size-row clearfix {{#unless @first}}hide{{/unless}}"> |
24 | {{# color}} | 24 | {{# color}} |
@@ -29,8 +29,8 @@ | @@ -29,8 +29,8 @@ | ||
29 | </ul> | 29 | </ul> |
30 | {{/ colors}} | 30 | {{/ colors}} |
31 | </div> | 31 | </div> |
32 | - <div class="size-list block-list"> | ||
33 | - <span>尺码</span> | 32 | + <div class="size-list block-list {{#if ../single}}hide{{/if}}"> |
33 | + <span>{{#if ../tickets}}区域{{else}}尺码{{/if}}</span> | ||
34 | {{# sizes}} | 34 | {{# sizes}} |
35 | <ul class="size-row clearfix {{#unless @first}}hide{{/unless}}"> | 35 | <ul class="size-row clearfix {{#unless @first}}hide{{/unless}}"> |
36 | {{# size}} | 36 | {{# size}} |
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | </ul> | 41 | </ul> |
42 | {{/ sizes}} | 42 | {{/ sizes}} |
43 | </div> | 43 | </div> |
44 | - <p> | 44 | + |
45 | <div class="num"> | 45 | <div class="num"> |
46 | <span>数量</span> | 46 | <span>数量</span> |
47 | <div class="clearfix"> | 47 | <div class="clearfix"> |
@@ -55,13 +55,16 @@ | @@ -55,13 +55,16 @@ | ||
55 | </div> | 55 | </div> |
56 | <span class="left-num"></span> | 56 | <span class="left-num"></span> |
57 | <input id="left-num" type="hidden" value="0"> | 57 | <input id="left-num" type="hidden" value="0"> |
58 | + <input id="limitNum" type="hidden" value="{{limit}}"> | ||
58 | </div> | 59 | </div> |
60 | + | ||
59 | </div> | 61 | </div> |
60 | </div> | 62 | </div> |
61 | <div class="btn-wrap"> | 63 | <div class="btn-wrap"> |
62 | - <button id="chose-btn-sure" class="btn btn-sure">加入购物车</button> | 64 | + <button id="chose-btn-sure" class="btn btn-sure">{{#if ../tickets}}立即购买{{else}}加入购物车{{/if}}</button> |
63 | </div> | 65 | </div> |
64 | </div> | 66 | </div> |
65 | </div> | 67 | </div> |
66 | {{/cartInfo}} | 68 | {{/cartInfo}} |
67 | -<input id="promotionId" type="hidden" value="{{promotionId}}"> | ||
69 | +<input id="promotionId" type="hidden" value="{{promotionId}}"> | ||
70 | +<input id="single" type="hidden" value="{{single}}"> |
1 | { | 1 | { |
2 | "name": "m-yohobuy-node", | 2 | "name": "m-yohobuy-node", |
3 | - "version": "4.8.11", | 3 | + "version": "4.8.12", |
4 | "private": true, | 4 | "private": true, |
5 | "description": "A New Yohobuy Project With Express", | 5 | "description": "A New Yohobuy Project With Express", |
6 | "repository": { | 6 | "repository": { |
@@ -100,7 +100,7 @@ | @@ -100,7 +100,7 @@ | ||
100 | "yoho-jquery": "^2.2.4", | 100 | "yoho-jquery": "^2.2.4", |
101 | "yoho-jquery-lazyload": "^1.9.7", | 101 | "yoho-jquery-lazyload": "^1.9.7", |
102 | "yoho-mlellipsis": "0.0.3", | 102 | "yoho-mlellipsis": "0.0.3", |
103 | - "yoho-node-lib": "0.0.31", | 103 | + "yoho-node-lib": "0.0.32", |
104 | "yoho-swiper": "^3.3.1" | 104 | "yoho-swiper": "^3.3.1" |
105 | } | 105 | } |
106 | } | 106 | } |
@@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
10 | // 增加init函数,异步请求的接口需要重新初始化一下选择列表 | 10 | // 增加init函数,异步请求的接口需要重新初始化一下选择列表 |
11 | // 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框 | 11 | // 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框 |
12 | 12 | ||
13 | + | ||
13 | var $ = require('yoho-jquery'), | 14 | var $ = require('yoho-jquery'), |
14 | tip = require('../plugin/tip'), | 15 | tip = require('../plugin/tip'), |
15 | loading = require('../plugin/loading'); | 16 | loading = require('../plugin/loading'); |
@@ -37,7 +38,14 @@ var $chosePanel = $('#chose-panel'), | @@ -37,7 +38,14 @@ var $chosePanel = $('#chose-panel'), | ||
37 | $choseArea, | 38 | $choseArea, |
38 | $cartBar, | 39 | $cartBar, |
39 | $soonSoldOut = $('.soonSoldOut-tag'), | 40 | $soonSoldOut = $('.soonSoldOut-tag'), |
40 | - $yohoPage = $('.yoho-page'); | 41 | + $yohoPage = $('.yoho-page'), |
42 | + | ||
43 | + // 门票 限购数量 | ||
44 | + ticketsLimit = $('#limitNum').val() || 0, | ||
45 | + single = $('#single').val() || 0, | ||
46 | + $productSku = $('#productSku'), | ||
47 | + $buyNumber = $('#buyNumber'), | ||
48 | + $buyNowForm = $('#buyNowForm'); | ||
41 | 49 | ||
42 | // 购物车编辑标相关变量 | 50 | // 购物车编辑标相关变量 |
43 | var isEdit, | 51 | var isEdit, |
@@ -66,7 +74,6 @@ function init() { | @@ -66,7 +74,6 @@ function init() { | ||
66 | hasChooseColor = false; | 74 | hasChooseColor = false; |
67 | hasChooseSize = false; | 75 | hasChooseSize = false; |
68 | $curSizeBlock = null; | 76 | $curSizeBlock = null; |
69 | - | ||
70 | queryString = $.queryString(); | 77 | queryString = $.queryString(); |
71 | $imgsThumb = $('.chose-panel').find('.thumb'); | 78 | $imgsThumb = $('.chose-panel').find('.thumb'); |
72 | $choseArea = $('.chose-panel .main .chose-items'); | 79 | $choseArea = $('.chose-panel .main .chose-items'); |
@@ -126,7 +133,35 @@ function removePannel() { | @@ -126,7 +133,35 @@ function removePannel() { | ||
126 | } | 133 | } |
127 | } | 134 | } |
128 | 135 | ||
136 | +// 检查门票选择 | ||
137 | +function checkTickets() { | ||
138 | + if (!hasChooseColor && !hasChooseSize) { | ||
139 | + if (single) { | ||
140 | + tip.show('请选择日期~'); | ||
141 | + } else { | ||
142 | + tip.show('请选择日期和区域~'); | ||
143 | + } | ||
144 | + return false; | ||
145 | + } else if (!hasChooseColor) { | ||
146 | + tip.show('请选择日期~'); | ||
147 | + return false; | ||
148 | + } else if (!hasChooseSize && !single) { | ||
149 | + tip.show('请选择区域~'); | ||
150 | + return false; | ||
151 | + } | ||
152 | + return true; | ||
153 | +} | ||
154 | + | ||
129 | function checkColorSizeNum() { | 155 | function checkColorSizeNum() { |
156 | + | ||
157 | + if (ticketsLimit) { | ||
158 | + | ||
159 | + // 门票 | ||
160 | + if (!checkTickets()) { | ||
161 | + return; | ||
162 | + } | ||
163 | + } | ||
164 | + | ||
130 | if (!hasChooseColor && !hasChooseSize) { | 165 | if (!hasChooseColor && !hasChooseSize) { |
131 | tip.show('请选择颜色和尺码~'); | 166 | tip.show('请选择颜色和尺码~'); |
132 | return false; | 167 | return false; |
@@ -140,8 +175,6 @@ function checkColorSizeNum() { | @@ -140,8 +175,6 @@ function checkColorSizeNum() { | ||
140 | return true; | 175 | return true; |
141 | } | 176 | } |
142 | 177 | ||
143 | - | ||
144 | - | ||
145 | function show(html, cb) { | 178 | function show(html, cb) { |
146 | if (html) { | 179 | if (html) { |
147 | $chosePanel.html(html); | 180 | $chosePanel.html(html); |
@@ -174,7 +207,7 @@ function updateConformButtonClassAndText() { | @@ -174,7 +207,7 @@ function updateConformButtonClassAndText() { | ||
174 | $chosed = $allChoseItems.find('.chosed'); | 207 | $chosed = $allChoseItems.find('.chosed'); |
175 | if ($chosed.closest('.zero-stock').length === 2) { | 208 | if ($chosed.closest('.zero-stock').length === 2) { |
176 | $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄'); | 209 | $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄'); |
177 | - } else if (limitProductCode) { | 210 | + } else if (limitProductCode || ticketsLimit) { |
178 | $('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买'); | 211 | $('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买'); |
179 | } else { | 212 | } else { |
180 | $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车'); | 213 | $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车'); |
@@ -184,7 +217,14 @@ function updateConformButtonClassAndText() { | @@ -184,7 +217,14 @@ function updateConformButtonClassAndText() { | ||
184 | // 显示剩余件数 | 217 | // 显示剩余件数 |
185 | function displayGoodNum(curGoodNum) { | 218 | function displayGoodNum(curGoodNum) { |
186 | 219 | ||
187 | - // 数量大于0 | 220 | + // 门票限购 |
221 | + if (ticketsLimit) { | ||
222 | + $allChoseItems.find('.num .left-num').html('限购' + ticketsLimit + '件'); | ||
223 | + $leftNum.val(curGoodNum); | ||
224 | + return; | ||
225 | + } | ||
226 | + | ||
227 | + // 数量大于 | ||
188 | if (curGoodNum > 0) { | 228 | if (curGoodNum > 0) { |
189 | if ($soonSoldOut.length > 0) { | 229 | if ($soonSoldOut.length > 0) { |
190 | $allChoseItems.find('.num .left-num').html('即将售罄'); | 230 | $allChoseItems.find('.num .left-num').html('即将售罄'); |
@@ -204,6 +244,7 @@ function displayGoodNum(curGoodNum) { | @@ -204,6 +244,7 @@ function displayGoodNum(curGoodNum) { | ||
204 | // 老的选中尺码去掉勾选,新的选中尺码加上勾选 | 244 | // 老的选中尺码去掉勾选,新的选中尺码加上勾选 |
205 | function changeSizeChosed(newSizeIndex) { | 245 | function changeSizeChosed(newSizeIndex) { |
206 | var sizes, | 246 | var sizes, |
247 | + queryString, | ||
207 | i; | 248 | i; |
208 | 249 | ||
209 | if (curColorIndex && $curSizeBlock && $curSizeBlock.length > 0) { | 250 | if (curColorIndex && $curSizeBlock && $curSizeBlock.length > 0) { |
@@ -247,6 +288,38 @@ function changeColorChosed(newColorIndex) { | @@ -247,6 +288,38 @@ function changeColorChosed(newColorIndex) { | ||
247 | return 0; | 288 | return 0; |
248 | } | 289 | } |
249 | 290 | ||
291 | +// 添加门票 | ||
292 | +function addTickets(productSku, buyNumber) { | ||
293 | + var data = { | ||
294 | + productSku: productSku, | ||
295 | + buyNumber: buyNumber | ||
296 | + }; | ||
297 | + | ||
298 | + // 校验电子票 | ||
299 | + $.ajax({ | ||
300 | + url: '/cart/index/checkTickets', | ||
301 | + dataType: 'json', | ||
302 | + data: data, | ||
303 | + type: 'post', | ||
304 | + success: function(addRestult) { | ||
305 | + if (addRestult.code !== 200) { | ||
306 | + if (addRestult.code === 401) { | ||
307 | + window.location.href = '//m.yohobuy.com/signin.html?refer=' + window.location.href; | ||
308 | + } | ||
309 | + tip.show(addRestult.message); | ||
310 | + } else { | ||
311 | + $productSku.val(productSku); | ||
312 | + $buyNumber.val(buyNumber); | ||
313 | + $buyNowForm.submit(); | ||
314 | + } | ||
315 | + }, | ||
316 | + error: function() { | ||
317 | + tip.show('网络异常~'); | ||
318 | + } | ||
319 | + | ||
320 | + }); | ||
321 | +} | ||
322 | + | ||
250 | init(); | 323 | init(); |
251 | 324 | ||
252 | 325 | ||
@@ -327,6 +400,20 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | @@ -327,6 +400,20 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | ||
327 | 400 | ||
328 | // 设置按钮的样式和文字 | 401 | // 设置按钮的样式和文字 |
329 | updateConformButtonClassAndText(); | 402 | updateConformButtonClassAndText(); |
403 | + | ||
404 | + // 展览票 | ||
405 | + if (ticketsLimit && single) { | ||
406 | + // 选中日期 | ||
407 | + $curSizeBlock = $('.size-list .size-row .block').eq(index + 1); | ||
408 | + $curSizeBlock.addClass('chosed'); | ||
409 | + | ||
410 | + // 显示剩余数量 | ||
411 | + displayGoodNum($curColorBlock.data('num')); | ||
412 | + hasChooseSize = true; | ||
413 | + return false; | ||
414 | + } | ||
415 | + | ||
416 | + | ||
330 | }).on('touchstart', '.size-list .block', function() { | 417 | }).on('touchstart', '.size-list .block', function() { |
331 | var $this = $(this), | 418 | var $this = $(this), |
332 | index, | 419 | index, |
@@ -391,7 +478,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -391,7 +478,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
391 | return; | 478 | return; |
392 | } | 479 | } |
393 | 480 | ||
394 | - if (num === 1 || (leftNum - 0) === 0) { | 481 | + if (num === 1 || leftNum - 0 === 0) { |
395 | tip.show('您选择的数量不能为零~'); | 482 | tip.show('您选择的数量不能为零~'); |
396 | return; | 483 | return; |
397 | } | 484 | } |
@@ -402,9 +489,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -402,9 +489,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
402 | 489 | ||
403 | $num.val(num - 1); | 490 | $num.val(num - 1); |
404 | }).on('touchstart', '.btn-plus', function() { | 491 | }).on('touchstart', '.btn-plus', function() { |
405 | - var num = parseInt($num.val(), 10); | 492 | + var num = parseInt($num.val(), 10), |
493 | + maxTips = ticketsLimit ? '每人只可购买' + ticketsLimit + '张当日门票' : '您选择的数量超过了最大库存量~'; | ||
406 | 494 | ||
407 | - leftNum = $('#left-num').val(); | 495 | + leftNum = ticketsLimit || $('#left-num').val(); |
408 | 496 | ||
409 | if (!checkColorSizeNum()) { | 497 | if (!checkColorSizeNum()) { |
410 | return; | 498 | return; |
@@ -416,7 +504,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -416,7 +504,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
416 | 504 | ||
417 | // TODO:库存数验证 | 505 | // TODO:库存数验证 |
418 | if (num > leftNum - 1) { | 506 | if (num > leftNum - 1) { |
419 | - tip.show('您选择的数量超过了最大库存量~'); | 507 | + tip.show(maxTips); |
420 | return; | 508 | return; |
421 | } | 509 | } |
422 | $num.val(num + 1); | 510 | $num.val(num + 1); |
@@ -458,9 +546,18 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -458,9 +546,18 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
458 | return false; | 546 | return false; |
459 | } | 547 | } |
460 | 548 | ||
461 | - confirming = true; | 549 | + if (!ticketsLimit) { |
550 | + confirming = true; | ||
551 | + } | ||
552 | + | ||
462 | loading.showLoadingMask(); | 553 | loading.showLoadingMask(); |
463 | 554 | ||
555 | + // 立即购买门票 | ||
556 | + if (ticketsLimit) { | ||
557 | + addTickets(productSku, buyNumber); | ||
558 | + return; | ||
559 | + } | ||
560 | + | ||
464 | // 针对是否处于编辑模式设置不同的url和需要post的数据 | 561 | // 针对是否处于编辑模式设置不同的url和需要post的数据 |
465 | if (isEdit) { | 562 | if (isEdit) { |
466 | cartGoodData = { | 563 | cartGoodData = { |
@@ -41,6 +41,7 @@ var navtabEle = document.getElementById('nav-tab'), | @@ -41,6 +41,7 @@ var navtabEle = document.getElementById('nav-tab'), | ||
41 | $('#feedback-content .consult-content').removeClass('hide'); | 41 | $('#feedback-content .consult-content').removeClass('hide'); |
42 | } | 42 | } |
43 | 43 | ||
44 | + $('.goods-consults .consult-item:lt(2)').removeClass('hide'); | ||
44 | }()); | 45 | }()); |
45 | 46 | ||
46 | if (navtabHammer) { | 47 | if (navtabHammer) { |
@@ -91,8 +92,7 @@ if ($('.goods-consults-page').length > 0) { | @@ -91,8 +92,7 @@ if ($('.goods-consults-page').length > 0) { | ||
91 | if (readmoreHammer) { | 92 | if (readmoreHammer) { |
92 | readmoreHammer.on('tap', function() { | 93 | readmoreHammer.on('tap', function() { |
93 | $('.readmore').hide(); | 94 | $('.readmore').hide(); |
94 | - $('.goods-consults.customer-consults').removeClass('customer-consults'); | ||
95 | - | 95 | + $('.goods-consults').find('.consult-item').removeClass('hide'); |
96 | return false; | 96 | return false; |
97 | }); | 97 | }); |
98 | } | 98 | } |
@@ -47,28 +47,27 @@ function hiddenTips($ele) { | @@ -47,28 +47,27 @@ function hiddenTips($ele) { | ||
47 | // } | 47 | // } |
48 | // } | 48 | // } |
49 | 49 | ||
50 | -function wrapElements(selector, count) { | ||
51 | - var elArr = null; | 50 | +// function wrapElements(selector, count) { |
51 | +// var elArr = null; | ||
52 | 52 | ||
53 | - $(selector).each(function(idx) { | ||
54 | - elArr = $(selector).slice(idx, idx + count); | 53 | +// $(selector).each(function(idx) { |
54 | +// elArr = $(selector).slice(idx, idx + count); | ||
55 | 55 | ||
56 | - if (elArr.length === count && idx % count === 0) { | ||
57 | - $(elArr).wrapAll($('<div class="js-wraper"></div>')); | ||
58 | - } | ||
59 | - }); | ||
60 | -} | 56 | +// if (elArr.length === count && idx % count === 0) { |
57 | +// $(elArr).wrapAll($('<div class="js-wraper"></div>')); | ||
58 | +// } | ||
59 | +// }); | ||
60 | +// } | ||
61 | 61 | ||
62 | 62 | ||
63 | 63 | ||
64 | function search() { | 64 | function search() { |
65 | - if (searching || end) { | 65 | + if (searching || end || !introUrl) { |
66 | return; | 66 | return; |
67 | } | 67 | } |
68 | searching = true; | 68 | searching = true; |
69 | 69 | ||
70 | // alert($('#reference-swiper-container .swiper-wrapper').width()); | 70 | // alert($('#reference-swiper-container .swiper-wrapper').width()); |
71 | - | ||
72 | loading.showLoadingMask(); | 71 | loading.showLoadingMask(); |
73 | 72 | ||
74 | $.ajax({ | 73 | $.ajax({ |
@@ -98,7 +97,7 @@ function search() { | @@ -98,7 +97,7 @@ function search() { | ||
98 | // if (!isFlexSupport()) { | 97 | // if (!isFlexSupport()) { |
99 | // $('.detail .column').removeClass('column').addClass('oldbox'); | 98 | // $('.detail .column').removeClass('column').addClass('oldbox'); |
100 | // } | 99 | // } |
101 | - wrapElements('.detail .column', 2); | 100 | + // wrapElements('.detail .column', 2); |
102 | searching = false; | 101 | searching = false; |
103 | end = true; | 102 | end = true; |
104 | loading.hideLoadingMask(); | 103 | loading.hideLoadingMask(); |
@@ -56,26 +56,28 @@ $basicBtnC: #eb0313; | @@ -56,26 +56,28 @@ $basicBtnC: #eb0313; | ||
56 | 56 | ||
57 | &.table { | 57 | &.table { |
58 | width: 100%; | 58 | width: 100%; |
59 | - | ||
60 | - .js-wraper { | ||
61 | - display: flex; | ||
62 | - flex-wrap: wrap; | ||
63 | - justify-content: flex-start; | ||
64 | - } | 59 | + overflow: hidden; |
65 | 60 | ||
66 | .column { | 61 | .column { |
67 | - display: flex; | ||
68 | - flex-basis: 49.9%; | ||
69 | - align-items: center; | ||
70 | box-sizing: border-box; | 62 | box-sizing: border-box; |
71 | padding: 6px 3%; | 63 | padding: 6px 3%; |
72 | width: 49.9%; | 64 | width: 49.9%; |
73 | border: 1px solid #fff; | 65 | border: 1px solid #fff; |
74 | background-color: $tableCellC; | 66 | background-color: $tableCellC; |
75 | - word-wrap: break-word; | 67 | + text-overflow: ellipsis; |
68 | + overflow: hidden; | ||
69 | + white-space: nowrap; | ||
76 | font-size: 24px; | 70 | font-size: 24px; |
77 | } | 71 | } |
78 | 72 | ||
73 | + .column:nth-child(2n+1) { | ||
74 | + float: left; | ||
75 | + } | ||
76 | + | ||
77 | + .column:nth-child(2n+2) { | ||
78 | + float: right; | ||
79 | + } | ||
80 | + | ||
79 | .oldbox { | 81 | .oldbox { |
80 | float: left; | 82 | float: left; |
81 | overflow: hidden; | 83 | overflow: hidden; |
@@ -284,7 +286,7 @@ $basicBtnC: #eb0313; | @@ -284,7 +286,7 @@ $basicBtnC: #eb0313; | ||
284 | .limit-sale { | 286 | .limit-sale { |
285 | position: absolute; | 287 | position: absolute; |
286 | top: 50%; | 288 | top: 50%; |
287 | - right: 84px; | 289 | + right: 24px; |
288 | margin-top: -24px; | 290 | margin-top: -24px; |
289 | padding: 4px 20px; | 291 | padding: 4px 20px; |
290 | height: 48px; | 292 | height: 48px; |
@@ -384,13 +386,13 @@ $basicBtnC: #eb0313; | @@ -384,13 +386,13 @@ $basicBtnC: #eb0313; | ||
384 | text-align: left; | 386 | text-align: left; |
385 | 387 | ||
386 | .vip-img { | 388 | .vip-img { |
387 | - background: resolve('product/silver.png') no-repeat; | 389 | + background: resolve("product/silver.png") no-repeat; |
388 | } | 390 | } |
389 | } | 391 | } |
390 | 392 | ||
391 | &:nth-child(2) { | 393 | &:nth-child(2) { |
392 | .vip-img { | 394 | .vip-img { |
393 | - background: resolve('product/golden.png') no-repeat; | 395 | + background: resolve("product/golden.png") no-repeat; |
394 | } | 396 | } |
395 | } | 397 | } |
396 | 398 | ||
@@ -398,7 +400,7 @@ $basicBtnC: #eb0313; | @@ -398,7 +400,7 @@ $basicBtnC: #eb0313; | ||
398 | text-align: right; | 400 | text-align: right; |
399 | 401 | ||
400 | .vip-img { | 402 | .vip-img { |
401 | - background: resolve('product/platinum.png') no-repeat; | 403 | + background: resolve("product/platinum.png") no-repeat; |
402 | } | 404 | } |
403 | } | 405 | } |
404 | } | 406 | } |
@@ -707,52 +709,53 @@ $basicBtnC: #eb0313; | @@ -707,52 +709,53 @@ $basicBtnC: #eb0313; | ||
707 | 709 | ||
708 | a { | 710 | a { |
709 | display: inline-block; | 711 | display: inline-block; |
712 | + } | ||
710 | 713 | ||
711 | - &.num-incart { | ||
712 | - color: #444; | ||
713 | - font-size: 47px; | ||
714 | - } | 714 | + .num-incart { |
715 | + position: relative; | ||
716 | + color: #444; | ||
717 | + font-size: 47px; | ||
718 | + } | ||
715 | 719 | ||
716 | - &.favorite { | ||
717 | - color: #ccc; | ||
718 | - font-size: 34px; | ||
719 | - } | 720 | + .favorite { |
721 | + color: #ccc; | ||
722 | + font-size: 34px; | ||
723 | + background-color: transparent; | ||
724 | + } | ||
720 | 725 | ||
721 | - &.favorite.liked { | ||
722 | - color: $basicBtnC; | ||
723 | - } | 726 | + .favorite.liked { |
727 | + color: $basicBtnC; | ||
728 | + } | ||
724 | 729 | ||
725 | - &.addto-cart, | ||
726 | - &.sold-out { | ||
727 | - margin: 0 100px 0 115px; | ||
728 | - width: 260px; | ||
729 | - height: 80px; | ||
730 | - background-color: $basicBtnC; | ||
731 | - color: #fff; | ||
732 | - text-align: center; | ||
733 | - font-size: 32px; | ||
734 | - line-height: 80px; | ||
735 | - } | 730 | + .addto-cart, |
731 | + .sold-out { | ||
732 | + margin: 0 100px 0 115px; | ||
733 | + width: 260px; | ||
734 | + height: 80px; | ||
735 | + background-color: $basicBtnC; | ||
736 | + color: #fff; | ||
737 | + text-align: center; | ||
738 | + font-size: 32px; | ||
739 | + line-height: 80px; | ||
740 | + } | ||
736 | 741 | ||
737 | - &.sold-out { | ||
738 | - background-color: #f58189; | ||
739 | - } | 742 | + .sold-out { |
743 | + background-color: #ccc; | ||
740 | } | 744 | } |
741 | 745 | ||
742 | .num-tag { | 746 | .num-tag { |
743 | position: absolute; | 747 | position: absolute; |
744 | top: 0; | 748 | top: 0; |
745 | - left: 48px; | 749 | + right: -15px; |
746 | display: block; | 750 | display: block; |
747 | - width: 72px; | ||
748 | - height: 72px; | 751 | + width: 30px; |
752 | + height: 30px; | ||
749 | border-radius: 50%; | 753 | border-radius: 50%; |
750 | background: $basicBtnC; | 754 | background: $basicBtnC; |
751 | color: #fff; | 755 | color: #fff; |
752 | text-align: center; | 756 | text-align: center; |
753 | - font-size: 40px; | ||
754 | - line-height: 72px; | ||
755 | - transform: scale(0.5); | 757 | + font-size: 20px; |
758 | + line-height: 30px; | ||
756 | 759 | ||
757 | &.hide { | 760 | &.hide { |
758 | display: none; | 761 | display: none; |
@@ -768,3 +771,7 @@ $basicBtnC: #eb0313; | @@ -768,3 +771,7 @@ $basicBtnC: #eb0313; | ||
768 | top: 40%; | 771 | top: 40%; |
769 | } | 772 | } |
770 | } | 773 | } |
774 | + | ||
775 | +iframe { | ||
776 | + display: none; | ||
777 | +} |
@@ -4,10 +4,8 @@ | @@ -4,10 +4,8 @@ | ||
4 | padding-bottom: 20px; | 4 | padding-bottom: 20px; |
5 | 5 | ||
6 | .service { | 6 | .service { |
7 | - margin-left: 50px; | ||
8 | - width: 494px; | ||
9 | height: 28px; | 7 | height: 28px; |
10 | - background: resolve('product/service.png') no-repeat; | 8 | + background: resolve("product/service.png") no-repeat; |
11 | background-size: cover; | 9 | background-size: cover; |
12 | } | 10 | } |
13 | 11 |
-
Please register or login to post a comment