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
e8c704c0
Commit
e8c704c0
authored
Sep 10, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
集点体验权限
parent
0f9c739e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
234 additions
and
99 deletions
+234
-99
app.js
src/app.js
+5
-0
pointDetail.js
src/pages/pointDetail/pointDetail.js
+95
-43
pointList.js
src/pages/pointList/pointList.js
+23
-5
userCenter.js
src/pages/userCenter/userCenter.js
+0
-48
helper.js
src/utils/helper.js
+6
-0
watch.js
src/utils/watch.js
+46
-0
wxService.js
src/utils/wxService.js
+59
-3
No files found.
src/app.js
View file @
e8c704c0
...
@@ -39,6 +39,11 @@ App({
...
@@ -39,6 +39,11 @@ App({
onShow
:
function
(
options
=
{})
{
onShow
:
function
(
options
=
{})
{
console
.
log
(
'app-onshow'
,
options
)
console
.
log
(
'app-onshow'
,
options
)
const
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
const
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
// 获取当前会员是否是体验者
const
{
member
}
=
baseUserInfo
const
curMemberTrial
=
member
.
trial
||
false
wx
.
setStorageSync
(
'isExperiencer'
,
curMemberTrial
)
if
(
options
.
referrerInfo
.
extraData
!=
null
){
if
(
options
.
referrerInfo
.
extraData
!=
null
){
const
{
activate_ticket
,
card_id
,
code
,
errCode
,
wx_activate_after_submit_url
}
=
options
.
referrerInfo
.
extraData
const
{
activate_ticket
,
card_id
,
code
,
errCode
,
wx_activate_after_submit_url
}
=
options
.
referrerInfo
.
extraData
let
urlData
=
wx_activate_after_submit_url
.
split
(
"?"
);
let
urlData
=
wx_activate_after_submit_url
.
split
(
"?"
);
...
...
src/pages/pointDetail/pointDetail.js
View file @
e8c704c0
...
@@ -41,8 +41,54 @@ wxService.page({
...
@@ -41,8 +41,54 @@ wxService.page({
/**
/**
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
:
function
(
options
)
{
onLoad
()
{},
watch
:
{
experAccessible
(
newVal
,
oldVal
)
{
if
(
newVal
)
{
// 登录接口返回err
const
reLoginErrFlag
=
wx
.
getStorageSync
(
'reLoginErr'
)
const
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
let
id
if
(
baseUserInfo
&&
!
reLoginErrFlag
)
{
this
.
setData
({
isAuthorization
:
false
},
()
=>
{
const
option
=
this
.
options
||
{}
const
{
scene
}
=
option
if
(
scene
)
{
let
idParam
=
decodeURIComponent
(
scene
).
split
(
'&'
)[
0
]
let
shareId
=
idParam
&&
idParam
.
split
(
'='
)[
1
]
||
0
id
=
shareId
}
else
{
id
=
option
.
id
}
if
(
id
)
{
this
.
setData
({
id
},
()
=>
{
this
.
getPointDetail
(
id
)
})
}
// 隐藏 dialog
this
.
isShowDialog
(
false
)
})
}
else
if
(
!
baseUserInfo
&&
reLoginErrFlag
)
{
this
.
setData
({
isAuthorization
:
true
})
}
else
{
this
.
setData
({
isAuthorization
:
true
})
}
}
else
{
// 去别的页面
wxService
.
router
(
`/subPackage/page/pages/goToHome/goToHome`
).
replace
()
}
}
},
},
// 集点详情
// 集点详情
getPointDetail
(
id
)
{
getPointDetail
(
id
)
{
...
@@ -71,7 +117,7 @@ wxService.page({
...
@@ -71,7 +117,7 @@ wxService.page({
}
else
if
(
currentEndTime
<
currentTime
)
{
}
else
if
(
currentEndTime
<
currentTime
)
{
// 结束时间 小于 现在时间 已结束
// 结束时间 小于 现在时间 已结束
timeFlag
=
2
timeFlag
=
2
}
else
if
(
currentTime
<
currentstartTime
)
{
}
else
if
(
currentTime
<
currentstartTime
)
{
// 未开始
// 未开始
timeFlag
=
3
timeFlag
=
3
}
}
...
@@ -193,11 +239,11 @@ wxService.page({
...
@@ -193,11 +239,11 @@ wxService.page({
// 显示 dialog
// 显示 dialog
this
.
isShowDialog
(
true
)
this
.
isShowDialog
(
true
)
// popupType == 0 3s 关闭
// popupType == 0 3s 关闭
if
(
popupType
==
0
){
if
(
popupType
==
0
)
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
isShowDialog
(
false
)
this
.
isShowDialog
(
false
)
this
.
getPointDetail
(
id
)
this
.
getPointDetail
(
id
)
},
3000
)
},
3000
)
}
}
}
}
}
}
...
@@ -236,45 +282,51 @@ wxService.page({
...
@@ -236,45 +282,51 @@ wxService.page({
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
:
function
()
{
onShow
:
function
()
{
// 登录接口返回err
// const { experAccessible } = this.data
const
reLoginErrFlag
=
wx
.
getStorageSync
(
'reLoginErr'
)
// if (experAccessible) {
const
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
// // 登录接口返回err
let
id
// const reLoginErrFlag = wx.getStorageSync('reLoginErr')
if
(
baseUserInfo
&&
!
reLoginErrFlag
){
// const baseUserInfo = wx.getStorageSync('_baseUserInfo')
this
.
setData
({
// let id
isAuthorization
:
false
// if (baseUserInfo && !reLoginErrFlag) {
},()
=>
{
// this.setData({
const
option
=
this
.
options
||
{}
// isAuthorization: false
const
{
scene
}
=
option
// }, () => {
if
(
scene
)
{
// const option = this.options || {}
let
idParam
=
decodeURIComponent
(
scene
).
split
(
'&'
)[
0
]
// const { scene } = option
let
shareId
=
idParam
&&
idParam
.
split
(
'='
)[
1
]
||
0
// if (scene) {
id
=
shareId
// let idParam = decodeURIComponent(scene).split('&')[0]
}
else
{
// let shareId = idParam && idParam.split('=')[1] || 0
id
=
option
.
id
// id = shareId
}
// } else {
// id = option.id
// }
if
(
id
)
{
// if (id) {
this
.
setData
({
// this.setData({
id
// id
},
()
=>
{
// }, () => {
this
.
getPointDetail
(
id
)
// this.getPointDetail(id)
})
// })
}
// }
// 隐藏 dialog
// // 隐藏 dialog
this
.
isShowDialog
(
false
)
// this.isShowDialog(false)
})
// })
}
// }
else
if
(
!
baseUserInfo
&&
reLoginErrFlag
){
// else if (!baseUserInfo && reLoginErrFlag) {
this
.
setData
({
// this.setData({
isAuthorization
:
true
// isAuthorization: true
})
// })
}
// }
else
{
// else {
this
.
setData
({
// this.setData({
isAuthorization
:
true
// isAuthorization: true
})
// })
}
// }
// } else {
// // 去别的页面
// wxService.router(`/subPackage/page/pages/goToHome/goToHome`).replace()
// }
},
},
/**
/**
...
...
src/pages/pointList/pointList.js
View file @
e8c704c0
...
@@ -16,8 +16,17 @@ wxService.page({
...
@@ -16,8 +16,17 @@ wxService.page({
/**
/**
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
()
{
},
onLoad
()
{},
watch
:
{
experAccessible
(
newVal
,
oldVal
)
{
if
(
newVal
)
{
this
.
getPointList
()
}
else
{
// 去别的页面
wxService
.
router
(
`/subPackage/page/pages/goToHome/goToHome`
).
replace
()
}
}
},
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
*/
*/
...
@@ -27,7 +36,16 @@ wxService.page({
...
@@ -27,7 +36,16 @@ wxService.page({
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
()
{
onShow
()
{
this
.
getPointList
()
// wxService.nextTick(() => {
// const { experAccessible } = this.data
// console.log('experAccessible', experAccessible)
// if (experAccessible) {
// this.getPointList()
// } else {
// // 去别的页面
// // wxService.router(`/subPackage/page/pages/goToHome/goToHome`).replace()
// }
// })
},
},
getPointList
()
{
getPointList
()
{
wx
.
showLoading
({
wx
.
showLoading
({
...
@@ -46,14 +64,14 @@ wxService.page({
...
@@ -46,14 +64,14 @@ wxService.page({
let
currentEndTime
=
(
new
Date
(
endT
.
replace
(
/-/g
,
'/'
))).
getTime
();
let
currentEndTime
=
(
new
Date
(
endT
.
replace
(
/-/g
,
'/'
))).
getTime
();
let
currentstartTime
=
(
new
Date
(
startT
.
replace
(
/-/g
,
'/'
))).
getTime
();
let
currentstartTime
=
(
new
Date
(
startT
.
replace
(
/-/g
,
'/'
))).
getTime
();
let
currentTime
=
(
new
Date
()).
getTime
();
let
currentTime
=
(
new
Date
()).
getTime
();
// 开始时间 小于 现在 && 小于 结束时间 进行中
// 开始时间 小于 现在 && 小于 结束时间 进行中
if
(
currentstartTime
<
currentTime
&&
currentTime
<
currentEndTime
)
{
if
(
currentstartTime
<
currentTime
&&
currentTime
<
currentEndTime
)
{
timeFlag
=
1
timeFlag
=
1
}
else
if
(
currentEndTime
<
currentTime
)
{
}
else
if
(
currentEndTime
<
currentTime
)
{
// 结束时间 小于 现在时间 已结束
// 结束时间 小于 现在时间 已结束
timeFlag
=
2
timeFlag
=
2
}
else
if
(
currentTime
<
currentstartTime
)
{
}
else
if
(
currentTime
<
currentstartTime
)
{
// 未开始
// 未开始
timeFlag
=
3
timeFlag
=
3
}
}
...
...
src/pages/userCenter/userCenter.js
View file @
e8c704c0
...
@@ -76,24 +76,6 @@ wxService.page({
...
@@ -76,24 +76,6 @@ wxService.page({
handlerDataOnPage
.
init
(
this
,
'pages'
)
handlerDataOnPage
.
init
(
this
,
'pages'
)
this
.
initPage
(
this
.
data
.
pageId
)
this
.
initPage
(
this
.
data
.
pageId
)
// _cardMemebr
// if (baseUserInfo){
// this.setData({
// token: wx.getStorageSync('token'),
// baseUserInfo,
// cardMember,
// isAuthorization: false
// })
// // 积分数量
// this.getMemberPointInfo()
// // 优惠券数量
// this.getMemberCouponInfo()
// } else {
// this.setData({
// isAuthorization: true
// })
// }
if
(
baseUserInfo
&&
!
reLoginErrFlag
)
{
if
(
baseUserInfo
&&
!
reLoginErrFlag
)
{
this
.
setData
({
this
.
setData
({
token
:
wx
.
getStorageSync
(
'token'
),
token
:
wx
.
getStorageSync
(
'token'
),
...
@@ -105,18 +87,6 @@ wxService.page({
...
@@ -105,18 +87,6 @@ wxService.page({
this
.
getMemberPointInfo
()
this
.
getMemberPointInfo
()
// 优惠券数量
// 优惠券数量
this
.
getMemberCouponInfo
()
this
.
getMemberCouponInfo
()
// 获取当前会员是否是体验者
const
{
member
}
=
baseUserInfo
const
curMemberTrial
=
member
.
trial
||
true
console
.
log
(
'curMemberTrial'
,
curMemberTrial
)
if
(
curMemberTrial
)
{
this
.
setData
({
curMemberTrial
},
()
=>
{
// 获取当前体验版信息
this
.
trialList
()
})
}
})
})
}
}
else
if
(
!
baseUserInfo
&&
reLoginErrFlag
)
{
else
if
(
!
baseUserInfo
&&
reLoginErrFlag
)
{
...
@@ -130,24 +100,6 @@ wxService.page({
...
@@ -130,24 +100,6 @@ wxService.page({
})
})
}
}
},
},
trialList
()
{
console
.
log
(
'wxService.getAssPath()'
,
wxService
.
getAssPath
())
wx
.
showLoading
({
title
:
'加载中'
})
wxService
.
get
(
`/member/trial/list`
).
then
(
res
=>
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
console
.
log
(
'res'
,
res
)
this
.
setData
({
curAccessiblePathArr
:
data
})
}
}
})
},
// 查询积分信息
// 查询积分信息
getMemberPointInfo
()
{
getMemberPointInfo
()
{
wx
.
showLoading
({
wx
.
showLoading
({
...
...
src/utils/helper.js
View file @
e8c704c0
...
@@ -88,6 +88,12 @@ export function getAppUserInfo () {
...
@@ -88,6 +88,12 @@ export function getAppUserInfo () {
}
}
}
}
export
function
getCurrentRouter
()
{
var
pages
=
getCurrentPages
()
// 获取加载的页面
var
currentPage
=
pages
[
pages
.
length
-
1
]
// 获取当前页面的对象
return
currentPage
}
export
default
{
export
default
{
c1C2Map
,
c1C2Map
,
c2C3Map
c2C3Map
...
...
src/utils/watch.js
0 → 100644
View file @
e8c704c0
function
observe
(
obj
,
key
,
watchFun
,
deep
,
page
)
{
let
val
=
obj
[
key
];
if
(
val
!=
null
&&
typeof
val
===
"object"
&&
deep
)
{
Object
.
keys
(
val
).
forEach
((
item
)
=>
{
observe
(
val
,
item
,
watchFun
,
deep
,
page
);
});
}
Object
.
defineProperty
(
obj
,
key
,
{
configurable
:
true
,
enumerable
:
true
,
set
:
function
(
value
)
{
watchFun
.
call
(
page
,
value
,
val
);
val
=
value
;
if
(
deep
)
{
observe
(
obj
,
key
,
watchFun
,
deep
,
page
);
}
},
get
:
function
()
{
return
val
;
}
});
}
export
function
setWatcher
(
page
)
{
let
data
=
page
.
data
;
let
watch
=
page
.
watch
;
if
(
!
watch
)
return
false
Object
.
keys
(
watch
).
forEach
((
item
)
=>
{
let
targetData
=
data
;
let
keys
=
item
.
split
(
"."
);
for
(
let
i
=
0
;
i
<
keys
.
length
-
1
;
i
++
)
{
targetData
=
targetData
[
keys
[
i
]];
}
let
targetKey
=
keys
[
keys
.
length
-
1
];
let
watchFun
=
watch
[
item
].
handler
||
watch
[
item
];
let
deep
=
watch
[
item
].
deep
;
observe
(
targetData
,
targetKey
,
watchFun
,
deep
,
page
);
});
}
src/utils/wxService.js
View file @
e8c704c0
...
@@ -15,6 +15,8 @@ const config = require('../config/index').envInfo
...
@@ -15,6 +15,8 @@ const config = require('../config/index').envInfo
import
utils
from
'./util'
import
utils
from
'./util'
let
openCardLister
=
null
let
openCardLister
=
null
const
pathData
=
require
(
'./currentAccessiblePath.js'
)
const
pathData
=
require
(
'./currentAccessiblePath.js'
)
import
*
as
watch
from
"./watch.js"
;
/**
/**
* 单例
* 单例
*/
*/
...
@@ -285,17 +287,54 @@ class WXService extends Http {
...
@@ -285,17 +287,54 @@ class WXService extends Http {
})
})
})
})
}
}
getAssPath
()
{
getAssPath
()
{
const
paths
=
pathData
const
paths
=
pathData
let
pathArr
=
[]
let
pathArr
=
[]
for
(
const
key
in
paths
){
for
(
const
key
in
paths
){
if
(
paths
.
hasOwnProperty
(
key
))
{
if
(
paths
.
hasOwnProperty
(
key
))
{
pathArr
.
push
(
key
)
let
pathObj
=
{}
pathObj
[
key
]
=
paths
[
key
]
pathArr
.
push
(
pathObj
)
}
}
}
}
return
pathArr
return
pathArr
}
}
trialList
()
{
let
localPath
=
this
.
getAssPath
()
wx
.
showLoading
({
title
:
'加载中'
})
return
this
.
get
(
`/member/trial/list`
).
then
(
res
=>
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
// 对应的path
let
currentPaths
=
[];
localPath
.
forEach
(
item
=>
{
if
(
item
.
hasOwnProperty
(
data
))
{
currentPaths
=
item
[
data
]
}
else
{
console
.
log
(
222
);
}
})
return
Promise
.
resolve
({
currentPaths
})
}
}
})
}
// getAssPath () {
// const paths = pathData
// let pathArr = []
// for(const key in paths){
// if (paths.hasOwnProperty(key)) {
// pathArr.push(key)
// }
// }
// return pathArr
// }
// handlerPage (page) {
// handlerPage (page) {
// const AccreditWhitePages = [
// const AccreditWhitePages = [
// 'pages/welcome/welcome'
// 'pages/welcome/welcome'
...
@@ -372,17 +411,34 @@ class WXService extends Http {
...
@@ -372,17 +411,34 @@ class WXService extends Http {
page
(
config
)
{
page
(
config
)
{
const
_self
=
this
const
_self
=
this
const
{
sr
}
=
this
.
getApp
()
const
{
sr
}
=
this
.
getApp
()
config
.
data
.
experAccessible
=
false
;
const
CONFIG_PAPGE
=
{
const
CONFIG_PAPGE
=
{
onLoad
:
function
(...
args
)
{
onLoad
:
function
(...
args
)
{
const
page
=
this
const
page
=
this
_self
.
initAppGlobalDataSync
()
_self
.
initAppGlobalDataSync
()
watch
.
setWatcher
(
page
);
config
.
onLoad
&&
config
.
onLoad
.
apply
(
page
,
args
)
config
.
onLoad
&&
config
.
onLoad
.
apply
(
page
,
args
)
},
},
onShow
:
function
(...
args
)
{
onShow
:
function
(...
args
)
{
const
isExperiencer
=
wx
.
getStorageSync
(
'isExperiencer'
)
const
page
=
this
const
page
=
this
_self
.
currentPage
=
page
_self
.
currentPage
=
page
config
.
onShow
&&
config
.
onShow
.
apply
(
page
,
args
)
config
.
onShow
&&
config
.
onShow
.
apply
(
page
,
args
)
// 获取当前页
let
router
=
getCurrentRouter
()
_self
.
trialList
().
then
(
res
=>
{
if
(
!
res
)
return
false
const
{
currentPaths
}
=
res
if
(
currentPaths
.
indexOf
(
router
.
route
)
>
-
1
&&
isExperiencer
)
{
this
.
setData
({
experAccessible
:
true
})
}
})
},
},
onReady
:
function
(...
args
)
{
onReady
:
function
(...
args
)
{
config
.
onReady
&&
config
.
onReady
.
apply
(
this
,
args
)
config
.
onReady
&&
config
.
onReady
.
apply
(
this
,
args
)
...
...
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