Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高淑倩
7-Eleven
Commits
5e04947f
Commit
5e04947f
authored
Oct 18, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企业微信区分环境登录
parent
36be4393
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
43 deletions
+49
-43
app.js
src/app.js
+3
-1
activateCardCallback.js
src/pages/activateCard/activateCardCallback.js
+2
-1
wxService.js
src/utils/wxService.js
+44
-41
No files found.
src/app.js
View file @
5e04947f
...
...
@@ -16,10 +16,12 @@ App({
// 默认 false
wx
.
setStorageSync
(
'reLoginErr'
,
false
)
try
{
let
res
=
wx
.
getSystemInfoSync
();
let
res
=
wx
.
getSystemInfoSync
();
// 获取当前运行环境
config
.
pixelRate
=
res
.
windowWidth
/
750
;
config
.
platform
=
res
.
platform
;
config
.
statusBarHeight
=
res
.
statusBarHeight
;
const
qyWeChat
=
res
&&
res
.
environment
||
''
// 在企业微信固定返回wxwork,在微信不返回该字段,开发者可此判断当前是否在企业微信运行
wx
.
setStorageSync
(
'_qyWeChat'
,
qyWeChat
)
if
(
res
.
platform
.
toLowerCase
()
==
'devtools'
)
{
config
.
capsuleHeight
=
44
;
}
...
...
src/pages/activateCard/activateCardCallback.js
View file @
5e04947f
...
...
@@ -65,7 +65,8 @@ wxService.page({
})
},
handelReLogin
(){
wx
.
login
({
const
currentEnv
=
wx
.
getStorageSync
(
'_qyWeChat'
)
currentEnv
?
wx
.
qy
.
login
:
wx
.
login
({
success
:
(
res
)
=>
{
wx
.
setStorageSync
(
'_loginCode'
,
res
.
code
)
if
(
res
.
code
){
...
...
src/utils/wxService.js
View file @
5e04947f
...
...
@@ -62,31 +62,31 @@ class WXService extends Http {
}).
catch
(
res
=>
{
if
(
res
.
msg
&&
res
.
msg
.
indexOf
(
'未登录'
)
>
-
1
)
{
wx
.
removeStorageSync
(
'_baseUserInfo'
)
// if (!this.getUserInfoLimitCount) {
// this.getUserInfoLimitCount = 1
// } else {
// this.getUserInfoLimitCount++
// }
// console.log('count', this.getUserInfoLimitCount)
// if (this.getUserInfoLimitCount > 3) {
// wx.showToast({
// title: '会员系统异常,请联系管理员',
// icon: 'none',
// duration: 2000
// })
// } else {
// // 重新登陆之前判断是否登陆过 重新登陆
// const baseUserInfo = this.getBaseUserInfo()
// if (baseUserInfo) {
// // this.reLogin()
// return false
// }
// }
}
else
if
(
res
.
msg
&&
res
.
msg
.
indexOf
(
'请重新授权'
)
>
-
1
)
{
wx
.
setStorageSync
(
'reLoginErr'
,
true
)
wxService
.
router
(
`/pages/userCenter/userCenter`
).
back
()
}
// if (!this.getUserInfoLimitCount) {
// this.getUserInfoLimitCount = 1
// } else {
// this.getUserInfoLimitCount++
// }
// console.log('count', this.getUserInfoLimitCount)
// if (this.getUserInfoLimitCount > 3) {
// wx.showToast({
// title: '会员系统异常,请联系管理员',
// icon: 'none',
// duration: 2000
// })
// } else {
// // 重新登陆之前判断是否登陆过 重新登陆
// const baseUserInfo = this.getBaseUserInfo()
// if (baseUserInfo) {
// // this.reLogin()
// return false
// }
// }
}
else
if
(
res
.
msg
&&
res
.
msg
.
indexOf
(
'请重新授权'
)
>
-
1
)
{
wx
.
setStorageSync
(
'reLoginErr'
,
true
)
wxService
.
router
(
`/pages/userCenter/userCenter`
).
back
()
}
})
}
...
...
@@ -140,7 +140,7 @@ class WXService extends Http {
let
dataResp
=
response
.
data
.
data
wx
.
setStorageSync
(
'token'
,
dataResp
.
token
)
wx
.
setStorageSync
(
'_baseUserInfo'
,
dataResp
)
return
Promise
.
resolve
({
response
})
...
...
@@ -160,8 +160,11 @@ class WXService extends Http {
}
login
()
{
const
currentEnv
=
wx
.
getStorageSync
(
'_qyWeChat'
)
console
.
log
(
'全局'
,
currentEnv
)
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
login
({
// 企业 wx.qy.login
currentEnv
?
wx
.
qy
.
login
:
wx
.
login
({
success
:
(
res
)
=>
{
resolve
(
res
)
wx
.
setStorageSync
(
'_loginCode'
,
res
.
code
)
...
...
@@ -400,7 +403,7 @@ class WXService extends Http {
if
(
item
.
hasOwnProperty
(
data
))
{
currentPaths
=
item
[
data
]
}
else
{
}
})
return
Promise
.
resolve
({
currentPaths
})
...
...
@@ -448,11 +451,11 @@ class WXService extends Http {
'/pages/pointList/pointList'
,
'/subPackage/page/pages/friendShareList/friendShareList'
,
]
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
NoLoginAuthPage
.
indexOf
(
page
)
>
-
1
)
{
resolve
({
needAuth
:
false
})
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
NoLoginAuthPage
.
indexOf
(
page
)
>
-
1
)
{
resolve
({
needAuth
:
false
})
}
else
{
resolve
({
needAuth
:
true
})
resolve
({
needAuth
:
true
})
}
}).
catch
((
err
)
=>
{
console
.
log
(
'不需要登录err'
,
err
)
...
...
@@ -560,13 +563,13 @@ class WXService extends Http {
item
[
'id'
]
=
Integer
.
digit
(
item
[
'i'
],
64
,
10
);
}
}
if
(
item
[
'm'
])
{
if
(
item
[
'm'
])
{
item
[
'memberId'
]
=
Integer
.
digit
(
item
[
'm'
],
64
,
10
);
if
(
item
[
'i'
])
{
item
[
'id'
]
=
Integer
.
digit
(
item
[
'i'
],
64
,
10
);
}
}
if
(
item
[
'scene'
])
{
if
(
item
[
'scene'
])
{
let
idParam
=
decodeURIComponent
(
item
[
'scene'
]).
split
(
'&'
)[
0
]
let
shareId
=
idParam
&&
idParam
.
split
(
'='
)[
1
]
||
0
item
[
'id'
]
=
Integer
.
digit
(
shareId
,
64
,
10
)
...
...
@@ -596,19 +599,19 @@ class WXService extends Http {
const
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
const
premiumExpireTime
=
baseUserInfo
&&
baseUserInfo
.
member
&&
baseUserInfo
.
member
.
premiumExpireTime
||
''
wx
.
setStorageSync
(
'_premiumExpireTime'
,
premiumExpireTime
)
const
premiumExpireStorage
=
wx
.
getStorageSync
(
'_premiumExpireTime'
)
const
premiumExpireStorage
=
wx
.
getStorageSync
(
'_premiumExpireTime'
)
// ios 兼容 是不是plus vip
let
currentEndTime
=
(
new
Date
(
premiumExpireStorage
.
replace
(
/-/g
,
'/'
))).
getTime
();
// 到期时间
let
currentTime
=
(
new
Date
()).
getTime
();
let
currentTime
=
(
new
Date
()).
getTime
();
let
vipFlag
=
currentTime
<=
currentEndTime
?
true
:
false
// 当前时间 < 到期时间为vip
console
.
log
(
'premiumExpireStorage'
,
premiumExpireStorage
)
console
.
log
(
'当前时间 < 到期时间为vip'
,
vipFlag
)
console
.
log
(
'premiumExpireStorage'
,
premiumExpireStorage
)
console
.
log
(
'当前时间 < 到期时间为vip'
,
vipFlag
)
if
(
baseUserInfo
)
{
page
.
setData
({
currentHasUserInfo
:
true
,
isVip
:
vipFlag
},
()
=>
{
},
()
=>
{
_self
.
trialList
().
then
(
res
=>
{
if
(
!
res
)
return
false
const
{
currentPaths
}
=
res
...
...
@@ -675,13 +678,13 @@ class WXService extends Http {
_self
.
getAuthUserInfo
(
res
.
detail
)
},
//处理分享页面打开时参数为memberId时生成触点对象信息
generatePointObject
(
tentacleInfo
){
generatePointObject
(
tentacleInfo
)
{
console
.
log
(
'---call 生成触点接口----'
)
console
.
log
(
tentacleInfo
)
_self
.
getTentacleContent
(
tentacleInfo
).
then
(
res
=>
{
console
.
log
(
'-----处理分享页面打开时参数为memberId时生成触点对象信息------'
)
console
.
log
(
'-----成功返回是------'
,
res
);
console
.
log
(
'-----成功返回是------'
,
res
);
if
(
res
&&
res
.
tentacleId
)
{
let
data
=
res
;
let
TENTACLE_CONTENT
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment