Commit 6974b695 by 杨北旺

修改文案

1 parent edaf18e9
import mapApi from '../../../utils/mapapi/mapapi' import mapApi from '../../../utils/mapapi/mapapi'
Component({ Page({
options: { options: {
styleIsolation: 'shared' styleIsolation: 'shared'
}, },
...@@ -59,309 +59,307 @@ Component({ ...@@ -59,309 +59,307 @@ Component({
3: 'pt_vip_bg' 3: 'pt_vip_bg'
}, },
// 普通会员3 银卡2 金卡1 非会员 0 // 普通会员3 银卡2 金卡1 非会员 0
identity:0, identity: 0,
titleClass:{ titleClass: {
0:'', 0: '',
1:'gold_title', 1: 'gold_title',
2:'sliver_title', 2: 'sliver_title',
3:'card_title', 3: 'card_title',
}, },
dateClass:{ dateClass: {
0:'', 0: '',
1:'gold_date', 1: 'gold_date',
2:'sliver_date', 2: 'sliver_date',
3:'card_date', 3: 'card_date',
} }
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { onLoad() {
onLoad() { this.getShopPackage()
this.getShopPackage() this.getMemberCardData()
this.getMemberCardData() let freecard = wx.p.storage.get('bindInfo')
let freecard = wx.p.storage.get('bindInfo') if (freecard) {
if (freecard) { let bingInfo = JSON.parse(decodeURIComponent(freecard))
let bingInfo = JSON.parse(decodeURIComponent(freecard)) const sid = bingInfo.data.sessionId
const sid = bingInfo.data.sessionId wx.p.cache.storageApi.setSessionId(sid)
wx.p.cache.storageApi.setSessionId(sid) this.handleFreeCard(bingInfo)
this.handleFreeCard(bingInfo) }
} this.setData({
this.setData({ isOpen: wx.p.storage.get('sessionId') ? true : false
isOpen: wx.p.storage.get('sessionId') ? true : false })
}) },
}, onShow() {
onShow() { let authComponent = this.selectComponent('#authorize')
let authComponent = this.selectComponent('#authorize') if (authComponent) authComponent.check()
if (authComponent) authComponent.check() // if (this.data.userInfo && !this.data.userInfo.phone) return
// if (this.data.userInfo && !this.data.userInfo.phone) return this.toCheckMember()
this.toCheckMember() },
}, onPullDownRefresh() {
onPullDownRefresh() { this.getShopPackage()
this.getShopPackage() this.toCheckMember()
this.toCheckMember() this.setData(
this.setData( {
{ 'pageParam.pageSize': 0,
'pageParam.pageSize': 0, loadingMore: false
loadingMore: false },
}, () => {
() => { let { currentAddress } = this.data
let { currentAddress } = this.data const { lat, lng } = currentAddress.location
const { lat, lng } = currentAddress.location this.toGetCommodity(lat, lng)
this.toGetCommodity(lat, lng)
}
)
},
onReachBottom() {
if (this.data.unauthorized) {
return
} }
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( // 定位
{ async getLocation() {
pageParam, try {
loadingMore: true const res = await this.getAddressInfo()
}, this.toGetCommodity(res.location.lat, res.location.lng, 1)
() => {
let { currentAddress } = this.data
const { lat, lng } = currentAddress.location
this.toGetCommodity(lat, lng)
}
)
},
// 新版
openMorePack(e) {
const { show } = e.currentTarget.dataset
this.setData({ this.setData({
showMorePack: !show currentAddress: res,
}) unauthorized: false
},
// 页面跳转
// toAllEquityPage() {
// wx.navigateTo({
// url: '/packageEquity/pages/allEquity/allEquity'
// })
// },
toBuyMember() {
wx.navigateTo({
url: '/packageEquity/pages/open/open'
}) })
}, wx.p.storage.set('unauthorized', false)
toNewPage(e) { } catch (error) {
const { index, item } = e.currentTarget.dataset console.log(error)
wx.navigateTo({ }
url: item.url },
})
},
// 定位 // 获取附近优惠数据
async getLocation() { toGetCommodity(lat, lng, page) {
try { let { pageParam, loadingMore, commodityList, loadOver } = this.data
const res = await this.getAddressInfo() let para = {
this.toGetCommodity(res.location.lat, res.location.lng, 1) lat,
lng,
...pageParam
}
if (loadOver) {
return
}
if (page) {
para.pageSize = 0
}
wx.p.api.equityApi.lasteCommodity(para).then(res => {
if (!res) {
this.setData({ this.setData({
currentAddress: res, loadOver: true
unauthorized: false
}) })
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 return
} }
if (page) { let tempArr = []
para.pageSize = 0 if (res) {
} res.forEach(item => {
wx.p.api.equityApi.lasteCommodity(para).then(res => { if (item.couponsGoodsList) {
if (!res) { tempArr.push(item)
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
}) })
}) }
}, if (loadingMore) {
commodityList = commodityList.concat(tempArr)
// 重新收起获取定位 }
relocation() {
this.setData({ 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({ 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) { toPackageDetail(e) {
const { id } = e.currentTarget.dataset const { id } = e.currentTarget.dataset
wx.navigateTo({ wx.navigateTo({
url: '/packageEquity/pages/package/package?id=' + id url: '/packageEquity/pages/package/package?id=' + id
}) })
}, },
// 获取用户会员信息 // 获取用户会员信息
toCheckMember() { toCheckMember() {
let sid = wx.p.storage.get('sessionId') let sid = wx.p.storage.get('sessionId')
if (!sid) { if (!sid) {
this.setData({ this.setData({
isOpen: false isOpen: false
}) })
return 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 => { if (res.data && res.data.endTime) {
let flag = false,identity = 0 // 普通会员3 银卡2 金卡1 非会员 0 res.data.endTime = new Date(res.data.endTime).format('yyyy.MM.dd')
if (res.data && res.data.validitDate) { }
res.data.time = new Date(res.data.validitDate).format('yyyy.MM.dd') // 普通会员
} if (res.code == 0 && res.data) {
if(res.data&&res.data.endTime){ flag = true
res.data.endTime = new Date(res.data.endTime).format('yyyy.MM.dd') identity = 3
} if (res.data && res.data.cardTypeSpecial) {
// 普通会员 identity = res.data.cardTypeSpecial
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({ wx.p.storage.set('isVIP', flag)
isOpen: flag, this.setData({
vipInfo: res.data, isOpen: flag,
identity vipInfo: res.data,
}) identity
}) })
}, })
},
// 获取门店会员卡信息 // 获取门店会员卡信息
getMemberCardData() { getMemberCardData() {
const {merchantId} = wx.p.storage.get('merchant_info') const { merchantId } = wx.p.storage.get('merchant_info')
let para = { let para = {
merchantId merchantId
} }
wx.p.api.equityApi.memberCard(para).then(res => { wx.p.api.equityApi.memberCard(para).then(res => {
this.setData({ this.setData({
memberInfo: res memberInfo: res
})
}) })
}, })
},
// 处理免费领取权益页面带来的参数---弹框显示 // 处理免费领取权益页面带来的参数---弹框显示
handleFreeCard(bindInfo) { handleFreeCard(bindInfo) {
wx.p.storage.rm('bindInfo') wx.p.storage.rm('bindInfo')
const { code, errId, message } = bindInfo const { code, errId, message } = bindInfo
if (code == 0) { if (code == 0) {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: '领取成功', content: '领取成功',
confirmText: '确定', confirmText: '确定',
showCancel: false, showCancel: false,
confirmColor: '#F13C3D' confirmColor: '#F13C3D'
}) })
this.toCheckMember() this.toCheckMember()
} else if (code == -1 && errId == 20321) { } else if (code == -1 && errId == 20321) {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: message, content: message,
confirmText: '续费开通', confirmText: '续费开通',
cancelText: '不用了', cancelText: '不用了',
confirmColor: '#F13C3D' confirmColor: '#F13C3D'
}).then(res => { }).then(res => {
if (res.confirm) { if (res.confirm) {
this.toBuyMember() this.toBuyMember()
} }
}) })
} else if (errId == 20320 || errId == 20322) { } else if (errId == 20320 || errId == 20322) {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: message, content: message,
confirmText: '确定', confirmText: '确定',
showCancel: false, showCancel: false,
confirmColor: '#F13C3D' confirmColor: '#F13C3D'
}) })
} }
}, },
// 检测是否已经登录 // 检测是否已经登录
checkLogin() { checkLogin() {
return wx.p.authStatus return wx.p.authStatus
}, },
async getAddressInfo() { async getAddressInfo() {
let addressInfo = wx.p.storage.get('address_info') let addressInfo = wx.p.storage.get('address_info')
return new Promise(resolve => { return new Promise(resolve => {
if (addressInfo && Date.now() - addressInfo.createTime < 2 * 60 * 1e3) resolve(addressInfo) if (addressInfo && Date.now() - addressInfo.createTime < 2 * 60 * 1e3) resolve(addressInfo)
else else
wx.getLocation({ wx.getLocation({
type: 'gcj02' type: 'gcj02'
}).then(({ latitude, longitude }) => { }).then(({ latitude, longitude }) => {
mapApi.detailedAdrress([latitude, longitude]).then(detail => { mapApi.detailedAdrress([latitude, longitude]).then(detail => {
let info = { let info = {
...detail, ...detail,
createTime: Date.now() createTime: Date.now()
} }
resolve(info) resolve(info)
wx.p.storage.set('address_info', info) wx.p.storage.set('address_info', info)
})
}) })
}) })
} })
} }
}) })
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!