Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohoblk-wap
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
徐炜
8 years ago
Commit
9f9513eef454fa6410268ac7ba22ff4b62f4c8aa
1 parent
6e72d79a
product list ssr
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
134 additions
and
21 deletions
apps/channel/controllers/channel.js
apps/channel/views/action/index.hbs
apps/product/controllers/product-list.js
apps/product/views/action/product-list.hbs
config/common.js
public/vue/component/resources/index.vue
public/vue/product/list/index.vue
utils/helpers.js
apps/channel/controllers/channel.js
View file @
9f9513e
...
...
@@ -16,7 +16,7 @@ const _ = require('lodash');
* 频道选择页
*/
module
.
exports
=
{
index
(
req
,
res
)
{
index
(
req
,
res
,
next
)
{
let
channel
=
req
.
path
.
split
(
'/'
)[
1
]
||
req
.
yoho
.
channel
;
channelModel
.
getResourcesData
({
...
...
@@ -38,7 +38,7 @@ module.exports = {
page
:
'home'
,
channel
:
channel
});
});
})
.
catch
(
next
)
;
},
channel
(
req
,
res
,
next
)
{
...
...
apps/channel/views/action/index.hbs
View file @
9f9513e
<div
id=
"channel"
>
<div
id=
"ssr"
class=
"resources"
>
<div
id=
"ssr"
class=
"resources"
style=
"position: absolute; top: 2.25rem;"
>
{{#
resources
}}
{{#if
focus
}}
<div
class=
"focus-floor"
style=
"height: 9.1rem;"
>
...
...
apps/product/controllers/product-list.js
View file @
9f9513e
...
...
@@ -8,11 +8,17 @@ const searchModel = require('../models/search');
/* 搜索 页面 */
exports
.
index
=
(
req
,
res
)
=>
{
res
.
render
(
'product-list'
,
{
module
:
'product'
,
page
:
'list'
});
exports
.
index
=
(
req
,
res
,
next
)
=>
{
const
params
=
req
.
query
;
searchModel
.
products
(
params
).
then
(
result
=>
{
res
.
render
(
'product-list'
,
{
navTitle
:
params
.
title
||
params
.
sort_name
,
module
:
'product'
,
page
:
'list'
,
list
:
result
&&
result
.
data
?
result
.
data
.
productList
:
[]
});
}).
catch
(
next
);
};
/* 查询 产品列表 method:GET */
...
...
apps/product/views/action/product-list.hbs
View file @
9f9513e
<div
id=
"ssr"
style=
"position: absolute; top: 0;"
>
<div
class=
"blk-header-wrap"
class=
"is-fixed"
>
<div
class=
"blk-header"
>
<div
class=
"blk-header-left"
>
<i
class=
"icon icon-left go-back-btn"
></i>
</div>
<div
class=
"blk-header-right"
>
</div>
<div
class=
"blk-header-main"
>
<span
class=
"blk-header-title"
>
{{
navTitle
}}
</span>
</div>
</div>
<div
class=
"blk-header-gap"
></div>
</div>
<ul
class=
"order-navs clearfix"
>
<li
class=
"order-item active"
>
<span
class=
"order-name"
>
默认
</span>
</li>
<li
class=
"order-item"
>
<span
class=
"order-name"
>
最新
</span>
</li>
<li
class=
"order-item"
>
<span
class=
"order-name"
>
价格
</span>
<span
class=
"order-icon"
>
<i
class=
"icon icon-sort-up"
></i>
<i
class=
"icon icon-sort-down"
></i>
</span>
</li>
<li
class=
"order-item"
>
<span
class=
"order-name"
>
折扣
</span>
<span
class=
"order-icon"
>
<i
class=
"icon icon-sort-up"
></i>
<i
class=
"icon icon-sort-down"
></i>
</span>
</li>
</ul>
<div
class=
"goods-box"
>
<ul
class=
"cardlist card-large clearfix"
>
{{#
list
}}
<li
class=
"card"
>
<div
class=
"card-pic"
>
<a
href=
"
{{
goodsUrl
this
}}
"
>
<img
src=
"
{{
resizeImage
defaultImages
372
499
}}
"
alt=
"
{{
productName
}}
"
>
</a>
</div>
<div
class=
"card-bd"
>
<h2
class=
"card-label"
>
<a
href=
"
{{
goodsUrl
this
}}
"
class=
"line-clamp-2"
>
{{
productName
}}
</a>
</h2>
{{#if
marketPrice
}}
<span
class=
"good-price"
class=
"old-price"
>
¥
{{
toFixed
marketPrice
}}
</span>
{{/if}}
<span
class=
"good-price
{{#if
marketPrice
}}
sale-price
{{/if}}
"
>
¥
{{
toFixed
salesPrice
}}
</span>
</div>
</li>
{{/
list
}}
</ul>
</div>
</div>
<div
id=
"product-list"
></div>
...
...
config/common.js
View file @
9f9513e
...
...
@@ -21,9 +21,12 @@ module.exports = {
// api: 'http://api-test1.yohops.com:9999/',
// service: 'http://service-test1.yohops.com:9999/'
api
:
'http://dev-api.yohops.com:9999/'
,
service
:
'http://dev-service.yohops.com:9999/'
,
singleApi
:
'http://192.168.102.27:8092/'
//api: 'http://dev-api.yohops.com:9999/',
//service: 'http://dev-service.yohops.com:9999/',
//singleApi: 'http://192.168.102.27:8092/'
singleApi
:
'http://single.yoho.cn/'
,
api
:
'http://api.yoho.cn/'
,
service
:
'http://service.yoho.cn/'
},
subDomains
:
{
host
:
'.m.yohoblk.com'
,
...
...
@@ -33,9 +36,9 @@ module.exports = {
useOneapm
:
false
,
useCache
:
false
,
memcache
:
{
master
:
[
'192.168.102.205:12111'
],
slave
:
[
'192.168.102.205:12111'
],
session
:
[
'192.168.102.205:12111'
],
master
:
[
'127.0.0.1:11211'
],
slave
:
[
'127.0.0.1:11211'
],
session
:
[
'127.0.0.1:11211'
],
timeout
:
1000
,
retries
:
0
},
...
...
public/vue/component/resources/index.vue
View file @
9f9513e
...
...
@@ -94,11 +94,12 @@
dataCache[param] = result;
}
$('#ssr').remove();
}).fail(() => {
tip('网络错误');
});
setTimeout(()=> {
$('#ssr').remove();
}, 2000);
}).fail(() => {
tip('网络错误');
});
}
},
created() {
...
...
public/vue/product/list/index.vue
View file @
9f9513e
...
...
@@ -116,6 +116,12 @@
})
.always(() => {
self.inSearching = false;
// 完成后删除服务端渲染的元素
setTimeout(()=> {
$('#ssr').remove();
});
});
},
...
...
utils/helpers.js
View file @
9f9513e
...
...
@@ -95,6 +95,39 @@ module.exports = {
return
options
.
fn
(
this
);
}
return
options
.
inverse
(
this
);
},
goodsUrl
:
(
product
,
kind
)
=>
{
let
productId
,
goodsId
,
cnAlphabet
;
switch
(
kind
)
{
case
'collection'
:
productId
=
product
.
productId
;
goodsId
=
product
.
goodsId
;
cnAlphabet
=
product
.
cnAlphabet
;
break
;
default
:
productId
=
product
.
productId
;
goodsId
=
product
.
goodsList
[
0
].
goodsId
;
cnAlphabet
=
product
.
cnAlphabet
;
}
return
`
/
product
/
pro_$
{
productId
}
_$
{
goodsId
}
/${cnAlphabet}.html`
;
},
toFixed
:
(
value
,
num
)
=>
{
if
(
typeof
value
===
'undefined'
)
{
return
;
}
return
Number
(
value
).
toFixed
(
num
||
2
);
},
resizeImage
:
(
src
,
width
,
height
,
mode
)
=>
{
return
src
?
src
.
replace
(
/
(\{
width}|
\{
height}|
\{
mode}
)
/g
,
function
(
$0
)
{
const
dict
=
{
'{width}'
:
width
||
300
,
'{height}'
:
height
||
300
,
'{mode}'
:
mode
||
2
};
return
dict
[
$0
];
}).
replace
(
/https
?
:/
,
''
)
+
'/interlace/1'
:
''
;
}
}
;
};
...
...
Please
register
or
login
to post a comment