Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
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
Plain Diff
Browse Files
Authored by
陈峰
8 years ago
Commit
5d0a2c5b83c4baa4796bfaaa719b579f7279d9cc
2 parents
2f0c8573
d8734479
merge feature/demote
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
156 additions
and
124 deletions
app.js
apps/channel/controllers/index.js
apps/guang/views/action/plustar/detail.hbs
apps/home/views/action/home.hbs
apps/product/controllers/recommend-for-you.js
apps/product/controllers/search.js
apps/product/views/action/detail/detail.hbs
config/common.js
doraemon/views/partial/common/suspend-cart.hbs
public/js/common/suspend-cart.js
public/js/guang/plustar-detail-render.js
public/js/guang/plustar-detail.page.js
public/js/home/index.page.js
public/js/product/detail.page.js
public/js/product/seckill-detail.page.js
public/js/product/suspend-cart.js
app.js
View file @
5d0a2c5
...
...
@@ -74,7 +74,7 @@ app.use(session({
app
.
use
((
req
,
res
,
next
)
=>
{
req
.
user
=
{};
// 全局的用户数据
req
.
yoho
=
{};
// req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
req
.
app
.
locals
.
wap
=
app
.
locals
.
wap
;
//zookeper对象赋值
if
(
!
req
.
session
.
id
)
{
req
.
session
.
id
=
uuid
.
v4
();
}
...
...
apps/channel/controllers/index.js
View file @
5d0a2c5
...
...
@@ -91,7 +91,7 @@ let switchChannel = (req, res, next) => {
}
// 设置浏览器缓存5分钟 300000ms
res
.
set
(
'Expires'
,
(
new
Date
(
_
.
now
()
+
300000
)).
toGMTString
());
//
res.set('Expires', (new Date(_.now() + 300000)).toGMTString());
next
();
};
...
...
apps/guang/views/action/plustar/detail.hbs
View file @
5d0a2c5
...
...
@@ -6,9 +6,11 @@
<div
class=
"header-content clearfix"
>
<p
class=
"name-islike-container"
>
<span
class=
"name"
>
{{
brand_name
}}
</span>
{{#
unless
@root
.
wap
.
plustar
.
removeCollect
}}
<a
id=
"brand-like"
class=
"brand-islike iconfont"
href=
"
{{
likeUrl
}}
"
>

</a>
{{/
unless
}}
</p>
<div
id=
"more-intro-click-range"
class=
"clearfix"
>
<div
id=
"intro"
class=
"intro"
>
...
...
@@ -100,7 +102,9 @@
<input
id=
"jump-to-app"
type=
"hidden"
value=
"
{{
jumpToApp
}}
"
>
<input
id=
"brandId"
type=
"hidden"
value=
"
{{
brand_id
}}
"
>
<input
id=
"clientType"
type=
"hidden"
value=
"
{{
clientType
}}
"
>
{{#
unless
@root
.
wap
.
plustar
.
removeRelatedPost
}}
<input
id=
"related-infos-demote"
type=
"hidden"
value=
"1"
>
{{/
unless
}}
{{!-- wx-share --}}
<input
id=
"shareLink"
type=
"hidden"
value=
"
{{
shareLink
}}
"
>
<input
id=
"shareImg"
type=
"hidden"
value=
"
{{
shareImg
}}
"
>
...
...
apps/home/views/action/home.hbs
View file @
5d0a2c5
...
...
@@ -127,8 +127,9 @@
<span
class=
"iconfont num"
>

</span>
</a>
</div>
{{>
common
/
recommend-for-you
}}
{{#
unless
@root
.
wap
.
ucenter
.
removePrefer
}}
{{>
common
/
recommend-for-you
}}
{{/
unless
}}
{{>
common
/
suspend-cart
}}
</div>
...
...
apps/product/controllers/recommend-for-you.js
View file @
5d0a2c5
...
...
@@ -33,7 +33,9 @@ exports.cart = (req, res, next) => {
uid
=
req
.
user
.
uid
||
0
,
yhChannel
=
req
.
query
.
yh_channel
||
'1'
,
limit
=
30
;
if
(
req
.
app
.
locals
.
wap
.
cart
.
removePrefer
)
{
return
res
.
send
(
''
);
}
recommendForYouModel
.
getPreference
({
yh_channel
:
yhChannel
,
udid
:
udid
,
...
...
@@ -52,4 +54,5 @@ exports.cart = (req, res, next) => {
page
:
'recommend'
});
}).
catch
(
next
);
};
...
...
apps/product/controllers/search.js
View file @
5d0a2c5
...
...
@@ -132,8 +132,16 @@ const list = (req, res, next) => {
*/
const
index
=
(
req
,
res
,
next
)
=>
{
let
title
=
'搜索'
;
searchModel
.
getSearchIndex
().
then
((
result
)
=>
{
((
render
)
=>
{
if
(
req
.
app
.
locals
.
wap
.
search
.
removeHotSearch
)
{
render
([]);
}
else
{
searchModel
.
getSearchIndex
().
then
((
result
)
=>
{
render
(
result
);
}).
catch
(
next
);
}
})((
result
)
=>
{
res
.
render
(
'search/index'
,
{
module
:
'product'
,
page
:
'search-index'
,
...
...
@@ -148,7 +156,8 @@ const index = (req, res, next) => {
}
});
}).
catch
(
next
);
})
};
/**
...
...
apps/product/views/action/detail/detail.hbs
View file @
5d0a2c5
...
...
@@ -124,6 +124,9 @@
<div
class=
"chose-panel"
></div>
<div
class=
"cart-bar data-bind"
>
{{#
unless
@root
.
wap
.
common
.
removeCartCount
}}
<input
type=
"hidden"
id=
"remove-cart-count"
value=
"1"
>
{{/
unless
}}
<a
href=
""
class=
"num-incart iconfont"
><span
class=
"num-tag hide"
></span>

</a>
<a
id=
"addtoCart"
href=
"javascript:;"
class=
"addto-cart add-to-cart-url data-bind"
></a>
<a
id=
"soldOut"
href=
"javascript:;"
class=
"sold-out data-bind"
>
已售罄
</a>
...
...
config/common.js
View file @
5d0a2c5
...
...
@@ -78,7 +78,7 @@ module.exports = {
appSecret
:
'ce21ae4a3f93852279175a167e54509b'
}
},
zookeeperServer
:
false
// '10.66.1.97:2181
'
zookeeperServer
:
'192.168.102.168:2188
'
};
if
(
isProduction
)
{
...
...
@@ -103,7 +103,8 @@ if (isProduction) {
interfaceShunt
:
{
open
:
false
,
url
:
'http://123.206.2.55/strategy'
}
},
zookeeperServer
:
'10.66.1.97:2181'
});
}
else
if
(
isTest
)
{
Object
.
assign
(
module
.
exports
,
{
...
...
doraemon/views/partial/common/suspend-cart.hbs
View file @
5d0a2c5
...
...
@@ -4,5 +4,6 @@
</a>
{{#
unless
@root
.
wap
.
common
.
removeCartCount
}}
<span
class=
"cart-count hide"
>
0
</span>
<input
type=
"hidden"
id=
"remove-cart-count"
value=
"1"
>
{{/
unless
}}
</div>
...
...
public/js/common/suspend-cart.js
View file @
5d0a2c5
...
...
@@ -7,22 +7,24 @@
var
$
=
require
(
'yoho-jquery'
);
var
$cart
=
$
(
'#suspend-cart'
);
if
(
$
(
'#remove-cart-count'
).
length
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
;
if
(
count
>
99
)
{
count
=
'99+'
;
}
if
(
count
===
0
)
{
$
(
'.cart-count'
).
remove
();
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
;
if
(
count
>
99
)
{
count
=
'99+'
;
}
if
(
count
===
0
)
{
$
(
'.cart-count'
).
remove
();
}
$cart
.
find
(
'.cart-count'
).
html
(
count
).
removeClass
(
'hide'
);
}
$cart
.
find
(
'.cart-count'
).
html
(
count
).
removeClass
(
'hide'
);
}
}
});
});
}
...
...
public/js/guang/plustar-detail-render.js
View file @
5d0a2c5
...
...
@@ -7,7 +7,7 @@ var $ = require('yoho-jquery'),
module
.
exports
=
function
(
callback
)
{
var
brandId
=
$
(
'#brandId'
).
val
();
var
clientType
=
$
(
'#clientType'
).
val
();
if
(
brandId
)
{
if
(
brandId
&&
$
(
'#related-infos-demote'
).
length
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
'/guang/plustar/brandinfoAsync'
,
...
...
public/js/guang/plustar-detail.page.js
View file @
5d0a2c5
...
...
@@ -88,54 +88,54 @@ moreHammer.on('tap', function(e) {
e
.
preventDefault
();
// 防止收缩后误点到商品产生跳转
});
// 品牌收藏
likeHammer
=
new
Hammer
(
document
.
getElementById
(
'brand-like'
));
likeHammer
.
on
(
'tap'
,
function
(
e
)
{
var
opt
=
'ok'
,
$this
=
$
(
e
.
target
);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
// if (jumpToApp === '1') {
// return true;
// }
e
.
preventDefault
();
if
(
$this
.
hasClass
(
'like'
))
{
opt
=
'cancel'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/guang/opt/favoriteBrand'
,
data
:
{
id
:
brandId
,
opt
:
opt
,
uid
:
uid
,
isBrand
:
'brand'
},
success
:
function
(
data
)
{
if
(
data
.
code
===
200
)
{
$this
.
toggleClass
(
'like'
);
tip
.
show
(
data
.
message
);
}
else
if
(
data
.
code
===
400
||
data
.
code
===
412
)
{
if
(
jumpToApp
===
'1'
)
{
var
url
=
location
.
href
+
'&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+
window
.
queryString
.
id
+
'}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"'
+
$
(
'#brand-info'
).
data
(
'id'
)
+
'"}},"priority":"Y"}}'
;
$
(
'body'
).
append
(
'<a href='
+
url
+
' style="display:none;"><span class="jump-login"> </span></a>'
);
$
(
'.jump-login'
).
click
();
if
(
$
(
'#brand-like'
).
length
)
{
// 品牌收藏
likeHammer
=
new
Hammer
(
document
.
getElementById
(
'brand-like'
));
likeHammer
.
on
(
'tap'
,
function
(
e
)
{
var
opt
=
'ok'
,
$this
=
$
(
e
.
target
);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
// if (jumpToApp === '1') {
// return true;
// }
e
.
preventDefault
();
if
(
$this
.
hasClass
(
'like'
))
{
opt
=
'cancel'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/guang/opt/favoriteBrand'
,
data
:
{
id
:
brandId
,
opt
:
opt
,
uid
:
uid
,
isBrand
:
'brand'
},
success
:
function
(
data
)
{
if
(
data
.
code
===
200
)
{
$this
.
toggleClass
(
'like'
);
tip
.
show
(
data
.
message
);
}
else
if
(
data
.
code
===
400
||
data
.
code
===
412
)
{
if
(
jumpToApp
===
'1'
)
{
var
url
=
location
.
href
+
'&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+
window
.
queryString
.
id
+
'}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"'
+
$
(
'#brand-info'
).
data
(
'id'
)
+
'"}},"priority":"Y"}}'
;
$
(
'body'
).
append
(
'<a href='
+
url
+
' style="display:none;"><span class="jump-login"> </span></a>'
);
$
(
'.jump-login'
).
click
();
}
else
{
location
.
href
=
data
.
data
;
// 未登录跳转登录页面
}
}
else
{
location
.
href
=
data
.
data
;
// 未登录跳转登录页面
tip
.
show
(
data
.
message
);
}
}
else
{
tip
.
show
(
data
.
message
);
}
},
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
return
false
;
});
return
false
;
});
}
// console.log($('.logo').attr('src'))
...
...
public/js/home/index.page.js
View file @
5d0a2c5
...
...
@@ -13,8 +13,10 @@ var myImage = new Image(),
avatar
;
require
(
'../common'
);
require
(
'./recommend-for-you-user-center'
);
require
(
'../product/suspend-cart.js'
);
if
(
$
(
'.recommend-for-you'
).
length
)
{
require
(
'./recommend-for-you-user-center'
);
}
require
(
'../common/suspend-cart'
);
require
(
'../common/footer'
);
// 部分老用户没有头像,显示默认头像
...
...
public/js/product/detail.page.js
View file @
5d0a2c5
...
...
@@ -126,25 +126,27 @@ require('./detail/page-render')(function() {
require
(
'./detail/consultform'
);
require
(
'./detail/recommend-for-you-product-desc'
);
// 购物车商品数量
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
||
0
;
if
(
count
===
0
)
{
return
false
;
}
if
(
count
>
99
)
{
count
=
'99+'
;
if
(
$
(
'#remove-cart-count'
).
length
)
{
// 购物车商品数量
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
||
0
;
if
(
count
===
0
)
{
return
false
;
}
if
(
count
>
99
)
{
count
=
'99+'
;
}
$cart
.
find
(
'.num-tag'
).
html
(
count
).
removeClass
(
'hide'
);
}
$cart
.
find
(
'.num-tag'
).
html
(
count
).
removeClass
(
'hide'
);
}
}
});
});
}
if
(
$
(
'.good-detail-page'
).
length
>
0
)
{
$
(
'#yoho-footer'
).
css
(
'border-top'
,
'1px solid #e0e0e0'
);
...
...
public/js/product/seckill-detail.page.js
View file @
5d0a2c5
...
...
@@ -128,25 +128,27 @@ require('./detail/page-render')(function() {
require
(
'./detail/consultform'
);
require
(
'./detail/recommend-for-you-product-desc'
);
// 购物车商品数量
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
||
0
;
if
(
count
===
0
)
{
return
false
;
}
if
(
count
>
99
)
{
count
=
'99+'
;
if
(
$
(
'#remove-cart-count'
).
length
)
{
// 购物车商品数量
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
||
0
;
if
(
count
===
0
)
{
return
false
;
}
if
(
count
>
99
)
{
count
=
'99+'
;
}
$cart
.
find
(
'.num-tag'
).
html
(
count
).
removeClass
(
'hide'
);
}
$cart
.
find
(
'.num-tag'
).
html
(
count
).
removeClass
(
'hide'
);
}
}
});
});
}
if
(
$
(
'.good-detail-page'
).
length
>
0
)
{
$
(
'#yoho-footer'
).
css
(
'border-top'
,
'1px solid #e0e0e0'
);
...
...
public/js/product/suspend-cart.js
View file @
5d0a2c5
...
...
@@ -8,21 +8,23 @@ var $ = require('yoho-jquery');
var
$cart
=
$
(
'#suspend-cart'
);
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
if
(
$
(
'#remove-cart-count'
).
length
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/count'
,
success
:
function
(
data
)
{
var
count
;
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
;
if
(
count
>
99
)
{
count
=
'99+'
;
if
(
data
.
code
===
200
)
{
count
=
data
.
data
.
cart_goods_count
;
if
(
count
>
99
)
{
count
=
'99+'
;
}
if
(
count
===
0
)
{
$
(
'.cart-count'
).
remove
();
}
$cart
.
find
(
'.cart-count'
).
html
(
count
).
removeClass
(
'hide'
);
}
if
(
count
===
0
)
{
$
(
'.cart-count'
).
remove
();
}
$cart
.
find
(
'.cart-count'
).
html
(
count
).
removeClass
(
'hide'
);
}
}
});
});
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment