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
Email Patches
Plain Diff
Browse Files
Authored by
yyq
7 years ago
Commit
8b74f857985623324d950a51b63f32f0027505ed
1 parent
e68e7a1a
fix seckill login
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
25 deletions
doraemon/middleware/user.js
public/js/product/seckill.page.js
public/js/yoho-app.js
doraemon/middleware/user.js
View file @
8b74f85
...
...
@@ -7,7 +7,6 @@ const config = global.yoho.config;
module
.
exports
=
()
=>
{
return
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
yoho
.
isApp
)
{
// 从 SESSION 中获取到当前登录用户的 UID
if
(
req
.
session
&&
_
.
isNumber
(
req
.
session
.
LOGIN_UID_
))
{
...
...
@@ -39,9 +38,11 @@ module.exports = () => {
};
}
}
else
{
let
params
=
req
.
method
===
'POST'
?
req
.
body
:
req
.
query
;
if
(
!
req
.
user
.
uid
&&
(
(
req
.
query
.
uid
&&
req
.
query
.
uid
!==
'0'
)
||
(
params
.
uid
&&
params
.
uid
!==
'0'
)
||
(
req
.
cookies
.
app_uid
&&
req
.
cookies
.
app_uid
!==
'0'
&&
...
...
@@ -50,12 +51,12 @@ module.exports = () => {
)
)
)
{
let
appUid
=
req
.
query
.
uid
||
req
.
cookies
.
app_uid
;
let
appVersion
=
req
.
query
.
app_version
||
req
.
cookies
.
app_version
||
config
.
appVersion
;
let
appSessionType
=
req
.
query
.
client_type
||
req
.
cookies
.
app_client_type
;
let
sessionKey
=
req
.
query
.
session_key
||
req
.
cookies
.
app_session_key
;
let
appUid
=
params
.
uid
||
req
.
cookies
.
app_uid
;
let
appVersion
=
params
.
app_version
||
req
.
cookies
.
app_version
||
config
.
appVersion
;
let
appSessionType
=
params
.
client_type
||
req
.
cookies
.
app_client_type
;
let
sessionKey
=
params
.
session_key
||
req
.
cookies
.
app_session_key
;
req
.
user
.
uid
=
req
.
query
.
uid
=
{
req
.
user
.
uid
=
params
.
uid
=
{
toString
:
()
=>
{
return
_
.
parseInt
(
appUid
);
},
...
...
@@ -82,7 +83,7 @@ module.exports = () => {
return
_
.
parseInt
(
req
.
cookies
.
app_uid
);
},
sessionKey
:
req
.
cookies
.
app_session_key
,
appVersion
:
req
.
cookies
.
app_version
||
req
.
query
.
app_version
||
config
.
appVersion
,
appVersion
:
req
.
cookies
.
app_version
||
params
.
app_version
||
config
.
appVersion
,
appSessionType
:
req
.
cookies
.
app_client_type
};
}
...
...
public/js/product/seckill.page.js
View file @
8b74f85
...
...
@@ -390,7 +390,6 @@ seckillObj = {
onsuccess
=
$
.
noop
;
if
(
actionName
===
'cancel'
)
{
on_off
=
false
;
action
=
'go.delSecKill'
;
...
...
@@ -398,31 +397,43 @@ seckillObj = {
failTip
=
'取消提醒失败'
;
}
onsuccess
=
function
()
{
$
.
post
(
'/product/seckill/remind'
,
{
onsuccess
=
function
(
info
)
{
$
.
post
(
'/product/seckill/remind'
,
$
.
extend
({
on_off
:
on_off
,
activity_id
:
$product
.
data
(
'activity'
),
product_skn
:
$product
.
data
(
'skn'
),
uid
:
yoho
.
isLogin
(),
sec_kill_id
:
1
,
app_type
:
0
})
.
done
(
function
(
res
)
{
if
(
res
.
code
===
200
&&
res
.
data
===
'success'
)
{
$remindBtn
.
hide
().
siblings
().
show
();
tip
.
show
(
okTip
);
}
else
{
tip
.
show
(
failTip
);
}
})
.
fail
(
function
()
{
},
info
)).
done
(
function
(
res
)
{
if
(
res
.
code
===
200
&&
res
.
data
===
'success'
)
{
$remindBtn
.
hide
().
siblings
().
show
();
tip
.
show
(
okTip
);
}
else
{
tip
.
show
(
failTip
);
});
}
}).
fail
(
function
()
{
tip
.
show
(
failTip
);
});
};
yoho
.
invokeMethod
(
action
,
params
,
onsuccess
,
function
()
{
yoho
.
invokeMethod
(
action
,
params
,
function
()
{
let
uid
=
yoho
.
isLogin
();
if
(
uid
&&
uid
!==
'0'
)
{
onsuccess
({
uid
});
}
else
{
setTimeout
(
function
()
{
yoho
.
getClientUserInfo
().
then
(
res
=>
{
onsuccess
(
res
);
}).
catch
(()
=>
{
tip
.
show
(
failTip
);
});
},
0
);
}
},
function
()
{
tip
.
show
(
failTip
);
});
},
pageLoad
:
function
(
callback
)
{
...
...
public/js/yoho-app.js
View file @
8b74f85
...
...
@@ -125,6 +125,31 @@ yoho = {
};
},
getClientUserInfo
:
function
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
userInfo
=
{};
let
successFn
=
function
(
info
)
{
$
.
extend
(
userInfo
,
info
);
if
(
userInfo
.
hasOwnProperty
(
'uid'
)
&&
userInfo
.
hasOwnProperty
(
'session_key'
))
{
return
resolve
(
userInfo
);
}
};
this
.
invokeMethod
(
'get.uid'
,
{},
uid
=>
{
successFn
({
uid
:
uid
});
},
()
=>
{
return
reject
();
});
this
.
invokeMethod
(
'get.sessionId'
,
{},
sessionId
=>
{
successFn
({
session_key
:
sessionId
});
},
()
=>
{
return
reject
();
});
});
},
getUid
:
function
()
{
if
(
yoho
.
isApp
)
{
return
qs
.
uid
||
cookie
.
get
(
'_YOHOUID'
)
||
cookie
.
get
(
'app_uid'
);
...
...
@@ -137,7 +162,7 @@ yoho = {
* 判断是否是 登录
*/
isLogin
:
function
()
{
return
+
this
.
getUid
();
return
this
.
getUid
();
},
goLogin
:
function
(
refer
,
data
)
{
...
...
Please
register
or
login
to post a comment