Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
hmd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6974b695
authored
Jul 25, 2023
by
杨北旺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改文案
1 parent
edaf18e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
268 additions
and
270 deletions
pages/tab/equity/index.js
pages/tab/equity/index.js
View file @
6974b69
import
mapApi
from
'../../../utils/mapapi/mapapi'
Component
({
Page
({
options
:
{
styleIsolation
:
'shared'
},
...
...
@@ -59,309 +59,307 @@ Component({
3
:
'pt_vip_bg'
},
// 普通会员3 银卡2 金卡1 非会员 0
identity
:
0
,
titleClass
:{
0
:
''
,
1
:
'gold_title'
,
2
:
'sliver_title'
,
3
:
'card_title'
,
identity
:
0
,
titleClass
:
{
0
:
''
,
1
:
'gold_title'
,
2
:
'sliver_title'
,
3
:
'card_title'
,
},
dateClass
:{
0
:
''
,
1
:
'gold_date'
,
2
:
'sliver_date'
,
3
:
'card_date'
,
dateClass
:
{
0
:
''
,
1
:
'gold_date'
,
2
:
'sliver_date'
,
3
:
'card_date'
,
}
},
/**
* 组件的方法列表
*/
methods
:
{
onLoad
()
{
this
.
getShopPackage
()
this
.
getMemberCardData
()
let
freecard
=
wx
.
p
.
storage
.
get
(
'bindInfo'
)
if
(
freecard
)
{
let
bingInfo
=
JSON
.
parse
(
decodeURIComponent
(
freecard
))
const
sid
=
bingInfo
.
data
.
sessionId
wx
.
p
.
cache
.
storageApi
.
setSessionId
(
sid
)
this
.
handleFreeCard
(
bingInfo
)
}
this
.
setData
({
isOpen
:
wx
.
p
.
storage
.
get
(
'sessionId'
)
?
true
:
false
})
},
onShow
()
{
let
authComponent
=
this
.
selectComponent
(
'#authorize'
)
if
(
authComponent
)
authComponent
.
check
()
// if (this.data.userInfo && !this.data.userInfo.phone) return
this
.
toCheckMember
()
},
onPullDownRefresh
()
{
this
.
getShopPackage
()
this
.
toCheckMember
()
this
.
setData
(
{
'pageParam.pageSize'
:
0
,
loadingMore
:
false
},
()
=>
{
let
{
currentAddress
}
=
this
.
data
const
{
lat
,
lng
}
=
currentAddress
.
location
this
.
toGetCommodity
(
lat
,
lng
)
}
)
},
onReachBottom
()
{
if
(
this
.
data
.
unauthorized
)
{
return
onLoad
()
{
this
.
getShopPackage
()
this
.
getMemberCardData
()
let
freecard
=
wx
.
p
.
storage
.
get
(
'bindInfo'
)
if
(
freecard
)
{
let
bingInfo
=
JSON
.
parse
(
decodeURIComponent
(
freecard
))
const
sid
=
bingInfo
.
data
.
sessionId
wx
.
p
.
cache
.
storageApi
.
setSessionId
(
sid
)
this
.
handleFreeCard
(
bingInfo
)
}
this
.
setData
({
isOpen
:
wx
.
p
.
storage
.
get
(
'sessionId'
)
?
true
:
false
})
},
onShow
()
{
let
authComponent
=
this
.
selectComponent
(
'#authorize'
)
if
(
authComponent
)
authComponent
.
check
()
// if (this.data.userInfo && !this.data.userInfo.phone) return
this
.
toCheckMember
()
},
onPullDownRefresh
()
{
this
.
getShopPackage
()
this
.
toCheckMember
()
this
.
setData
(
{
'pageParam.pageSize'
:
0
,
loadingMore
:
false
},
()
=>
{
let
{
currentAddress
}
=
this
.
data
const
{
lat
,
lng
}
=
currentAddress
.
location
this
.
toGetCommodity
(
lat
,
lng
)
}
if
(
!
this
.
data
.
commodityList
.
length
)
{
return
)
},
onReachBottom
()
{
if
(
this
.
data
.
unauthorized
)
{
return
}
if
(
!
this
.
data
.
commodityList
.
length
)
{
return
}
let
{
pageParam
}
=
this
.
data
pageParam
.
pageSize
++
this
.
setData
(
{
pageParam
,
loadingMore
:
true
},
()
=>
{
let
{
currentAddress
}
=
this
.
data
const
{
lat
,
lng
}
=
currentAddress
.
location
this
.
toGetCommodity
(
lat
,
lng
)
}
let
{
pageParam
}
=
this
.
data
pageParam
.
pageSize
++
)
},
// 新版
openMorePack
(
e
)
{
const
{
show
}
=
e
.
currentTarget
.
dataset
this
.
setData
({
showMorePack
:
!
show
})
},
// 页面跳转
// toAllEquityPage() {
// wx.navigateTo({
// url: '/packageEquity/pages/allEquity/allEquity'
// })
// },
toBuyMember
()
{
wx
.
navigateTo
({
url
:
'/packageEquity/pages/open/open'
})
},
toNewPage
(
e
)
{
const
{
index
,
item
}
=
e
.
currentTarget
.
dataset
wx
.
navigateTo
({
url
:
item
.
url
})
},
this
.
setData
(
{
pageParam
,
loadingMore
:
true
},
()
=>
{
let
{
currentAddress
}
=
this
.
data
const
{
lat
,
lng
}
=
currentAddress
.
location
this
.
toGetCommodity
(
lat
,
lng
)
}
)
},
// 新版
openMorePack
(
e
)
{
const
{
show
}
=
e
.
currentTarget
.
dataset
// 定位
async
getLocation
()
{
try
{
const
res
=
await
this
.
getAddressInfo
()
this
.
toGetCommodity
(
res
.
location
.
lat
,
res
.
location
.
lng
,
1
)
this
.
setData
({
showMorePack
:
!
show
})
},
// 页面跳转
// toAllEquityPage() {
// wx.navigateTo({
// url: '/packageEquity/pages/allEquity/allEquity'
// })
// },
toBuyMember
()
{
wx
.
navigateTo
({
url
:
'/packageEquity/pages/open/open'
currentAddress
:
res
,
unauthorized
:
false
})
},
toNewPage
(
e
)
{
const
{
index
,
item
}
=
e
.
currentTarget
.
dataset
wx
.
navigateTo
({
url
:
item
.
url
})
},
wx
.
p
.
storage
.
set
(
'unauthorized'
,
false
)
}
catch
(
error
)
{
console
.
log
(
error
)
}
},
// 定位
async
getLocation
()
{
try
{
const
res
=
await
this
.
getAddressInfo
()
this
.
toGetCommodity
(
res
.
location
.
lat
,
res
.
location
.
lng
,
1
)
// 获取附近优惠数据
toGetCommodity
(
lat
,
lng
,
page
)
{
let
{
pageParam
,
loadingMore
,
commodityList
,
loadOver
}
=
this
.
data
let
para
=
{
lat
,
lng
,
...
pageParam
}
if
(
loadOver
)
{
return
}
if
(
page
)
{
para
.
pageSize
=
0
}
wx
.
p
.
api
.
equityApi
.
lasteCommodity
(
para
).
then
(
res
=>
{
if
(
!
res
)
{
this
.
setData
({
currentAddress
:
res
,
unauthorized
:
false
loadOver
:
true
})
wx
.
p
.
storage
.
set
(
'unauthorized'
,
false
)
}
catch
(
error
)
{
console
.
log
(
error
)
}
},
// 获取附近优惠数据
toGetCommodity
(
lat
,
lng
,
page
)
{
let
{
pageParam
,
loadingMore
,
commodityList
,
loadOver
}
=
this
.
data
let
para
=
{
lat
,
lng
,
...
pageParam
}
if
(
loadOver
)
{
return
}
if
(
page
)
{
para
.
pageSize
=
0
}
wx
.
p
.
api
.
equityApi
.
lasteCommodity
(
para
).
then
(
res
=>
{
if
(
!
res
)
{
this
.
setData
({
loadOver
:
true
})
return
}
let
tempArr
=
[]
if
(
res
)
{
res
.
forEach
(
item
=>
{
if
(
item
.
couponsGoodsList
)
{
tempArr
.
push
(
item
)
}
})
}
if
(
loadingMore
)
{
commodityList
=
commodityList
.
concat
(
tempArr
)
}
this
.
setData
({
commodityList
:
loadingMore
?
commodityList
:
tempArr
,
loadingMore
:
false
,
loadOver
:
false
let
tempArr
=
[]
if
(
res
)
{
res
.
forEach
(
item
=>
{
if
(
item
.
couponsGoodsList
)
{
tempArr
.
push
(
item
)
}
})
})
},
// 重新收起获取定位
relocation
()
{
}
if
(
loadingMore
)
{
commodityList
=
commodityList
.
concat
(
tempArr
)
}
this
.
setData
({
showAuth
:
true
commodityList
:
loadingMore
?
commodityList
:
tempArr
,
loadingMore
:
false
,
loadOver
:
false
})
},
/**授权失败 */
authFail
()
{
wx
.
p
.
storage
.
set
(
'unauthorized'
,
true
)
})
},
// 重新收起获取定位
relocation
()
{
this
.
setData
({
showAuth
:
true
})
},
/**授权失败 */
authFail
()
{
wx
.
p
.
storage
.
set
(
'unauthorized'
,
true
)
this
.
setData
({
unauthorized
:
true
})
},
/**授权成功 */
authSuccess
()
{
this
.
getLocation
()
},
// 获取门店套餐
getShopPackage
()
{
const
{
merchantId
}
=
wx
.
p
.
storage
.
get
(
'merchant_info'
)
let
para
=
{
merchantId
}
wx
.
p
.
api
.
equityApi
.
storePackage
(
para
).
then
(
res
=>
{
this
.
setData
({
unauthorized
:
true
storePackageList
:
res
||
[]
})
},
/**授权成功 */
authSuccess
()
{
this
.
getLocation
()
},
// 获取门店套餐
getShopPackage
()
{
const
{
merchantId
}
=
wx
.
p
.
storage
.
get
(
'merchant_info'
)
let
para
=
{
merchantId
}
wx
.
p
.
api
.
equityApi
.
storePackage
(
para
).
then
(
res
=>
{
this
.
setData
({
storePackageList
:
res
||
[]
})
})
},
})
},
// 去套餐详情页
toPackageDetail
(
e
)
{
const
{
id
}
=
e
.
currentTarget
.
dataset
wx
.
navigateTo
({
url
:
'/packageEquity/pages/package/package?id='
+
id
})
},
// 去套餐详情页
toPackageDetail
(
e
)
{
const
{
id
}
=
e
.
currentTarget
.
dataset
wx
.
navigateTo
({
url
:
'/packageEquity/pages/package/package?id='
+
id
})
},
// 获取用户会员信息
toCheckMember
()
{
let
sid
=
wx
.
p
.
storage
.
get
(
'sessionId'
)
if
(
!
sid
)
{
this
.
setData
({
isOpen
:
false
})
return
// 获取用户会员信息
toCheckMember
()
{
let
sid
=
wx
.
p
.
storage
.
get
(
'sessionId'
)
if
(
!
sid
)
{
this
.
setData
({
isOpen
:
false
})
return
}
wx
.
p
.
api
.
equityApi
.
checkOpenMember
().
then
(
res
=>
{
let
flag
=
false
,
identity
=
0
// 普通会员3 银卡2 金卡1 非会员 0
if
(
res
.
data
&&
res
.
data
.
validitDate
)
{
res
.
data
.
time
=
new
Date
(
res
.
data
.
validitDate
).
format
(
'yyyy.MM.dd'
)
}
wx
.
p
.
api
.
equityApi
.
checkOpenMember
().
then
(
res
=>
{
let
flag
=
false
,
identity
=
0
// 普通会员3 银卡2 金卡1 非会员 0
if
(
res
.
data
&&
res
.
data
.
validitDate
)
{
res
.
data
.
time
=
new
Date
(
res
.
data
.
validitDate
).
format
(
'yyyy.MM.dd'
)
}
if
(
res
.
data
&&
res
.
data
.
endTime
){
res
.
data
.
endTime
=
new
Date
(
res
.
data
.
endTime
).
format
(
'yyyy.MM.dd'
)
}
// 普通会员
if
(
res
.
code
==
0
&&
res
.
data
)
{
flag
=
true
identity
=
3
if
(
res
.
data
&&
res
.
data
.
cardTypeSpecial
){
identity
=
res
.
data
.
cardTypeSpecial
}
if
(
res
.
data
&&
res
.
data
.
endTime
)
{
res
.
data
.
endTime
=
new
Date
(
res
.
data
.
endTime
).
format
(
'yyyy.MM.dd'
)
}
// 普通会员
if
(
res
.
code
==
0
&&
res
.
data
)
{
flag
=
true
identity
=
3
if
(
res
.
data
&&
res
.
data
.
cardTypeSpecial
)
{
identity
=
res
.
data
.
cardTypeSpecial
}
wx
.
p
.
storage
.
set
(
'isVIP'
,
flag
)
this
.
setData
({
isOpen
:
flag
,
vipInfo
:
res
.
data
,
identity
})
}
wx
.
p
.
storage
.
set
(
'isVIP'
,
flag
)
this
.
setData
({
isOpen
:
flag
,
vipInfo
:
res
.
data
,
identity
})
},
})
},
// 获取门店会员卡信息
getMemberCardData
()
{
const
{
merchantId
}
=
wx
.
p
.
storage
.
get
(
'merchant_info'
)
let
para
=
{
merchantId
}
wx
.
p
.
api
.
equityApi
.
memberCard
(
para
).
then
(
res
=>
{
this
.
setData
({
memberInfo
:
res
})
// 获取门店会员卡信息
getMemberCardData
()
{
const
{
merchantId
}
=
wx
.
p
.
storage
.
get
(
'merchant_info'
)
let
para
=
{
merchantId
}
wx
.
p
.
api
.
equityApi
.
memberCard
(
para
).
then
(
res
=>
{
this
.
setData
({
memberInfo
:
res
})
},
})
},
// 处理免费领取权益页面带来的参数---弹框显示
handleFreeCard
(
bindInfo
)
{
wx
.
p
.
storage
.
rm
(
'bindInfo'
)
const
{
code
,
errId
,
message
}
=
bindInfo
if
(
code
==
0
)
{
wx
.
showModal
({
title
:
'提示'
,
content
:
'领取成功'
,
confirmText
:
'确定'
,
showCancel
:
false
,
confirmColor
:
'#F13C3D'
})
this
.
toCheckMember
()
}
else
if
(
code
==
-
1
&&
errId
==
20321
)
{
wx
.
showModal
({
title
:
'提示'
,
content
:
message
,
confirmText
:
'续费开通'
,
cancelText
:
'不用了'
,
confirmColor
:
'#F13C3D'
}).
then
(
res
=>
{
if
(
res
.
confirm
)
{
this
.
toBuyMember
()
}
})
}
else
if
(
errId
==
20320
||
errId
==
20322
)
{
wx
.
showModal
({
title
:
'提示'
,
content
:
message
,
confirmText
:
'确定'
,
showCancel
:
false
,
confirmColor
:
'#F13C3D'
})
}
},
// 处理免费领取权益页面带来的参数---弹框显示
handleFreeCard
(
bindInfo
)
{
wx
.
p
.
storage
.
rm
(
'bindInfo'
)
const
{
code
,
errId
,
message
}
=
bindInfo
if
(
code
==
0
)
{
wx
.
showModal
({
title
:
'提示'
,
content
:
'领取成功'
,
confirmText
:
'确定'
,
showCancel
:
false
,
confirmColor
:
'#F13C3D'
})
this
.
toCheckMember
()
}
else
if
(
code
==
-
1
&&
errId
==
20321
)
{
wx
.
showModal
({
title
:
'提示'
,
content
:
message
,
confirmText
:
'续费开通'
,
cancelText
:
'不用了'
,
confirmColor
:
'#F13C3D'
}).
then
(
res
=>
{
if
(
res
.
confirm
)
{
this
.
toBuyMember
()
}
})
}
else
if
(
errId
==
20320
||
errId
==
20322
)
{
wx
.
showModal
({
title
:
'提示'
,
content
:
message
,
confirmText
:
'确定'
,
showCancel
:
false
,
confirmColor
:
'#F13C3D'
})
}
},
// 检测是否已经登录
checkLogin
()
{
return
wx
.
p
.
authStatus
},
async
getAddressInfo
()
{
let
addressInfo
=
wx
.
p
.
storage
.
get
(
'address_info'
)
return
new
Promise
(
resolve
=>
{
if
(
addressInfo
&&
Date
.
now
()
-
addressInfo
.
createTime
<
2
*
60
*
1
e3
)
resolve
(
addressInfo
)
else
wx
.
getLocation
({
type
:
'gcj02'
}).
then
(({
latitude
,
longitude
})
=>
{
mapApi
.
detailedAdrress
([
latitude
,
longitude
]).
then
(
detail
=>
{
let
info
=
{
...
detail
,
createTime
:
Date
.
now
()
}
resolve
(
info
)
wx
.
p
.
storage
.
set
(
'address_info'
,
info
)
})
// 检测是否已经登录
checkLogin
()
{
return
wx
.
p
.
authStatus
},
async
getAddressInfo
()
{
let
addressInfo
=
wx
.
p
.
storage
.
get
(
'address_info'
)
return
new
Promise
(
resolve
=>
{
if
(
addressInfo
&&
Date
.
now
()
-
addressInfo
.
createTime
<
2
*
60
*
1
e3
)
resolve
(
addressInfo
)
else
wx
.
getLocation
({
type
:
'gcj02'
}).
then
(({
latitude
,
longitude
})
=>
{
mapApi
.
detailedAdrress
([
latitude
,
longitude
]).
then
(
detail
=>
{
let
info
=
{
...
detail
,
createTime
:
Date
.
now
()
}
resolve
(
info
)
wx
.
p
.
storage
.
set
(
'address_info'
,
info
)
})
})
}
})
}
)
}
})
Write
Preview
Markdown
is supported
Attach a file
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 post a comment