Commit 77c4dd84 by 李伟康

Merge branch 'v1.0.0' of http://192.168.3.233:8090/saas/mini-program/hmd into v1.0.0

2 parents 2cddd324 1c61e5a8
...@@ -46,7 +46,7 @@ Page({ ...@@ -46,7 +46,7 @@ Page({
} }
}, },
// 领取定向礼包 // 领取定向礼包
toRecivedGifts() { async toRecivedGifts() {
const { giftsData } = this.data const { giftsData } = this.data
const mPattern = /^[1]([3-9])[0-9]{9}$/ const mPattern = /^[1]([3-9])[0-9]{9}$/
const { merchantId } = wx.p.storage.get('merchant_info') const { merchantId } = wx.p.storage.get('merchant_info')
...@@ -68,6 +68,9 @@ Page({ ...@@ -68,6 +68,9 @@ Page({
if (this.staff) { if (this.staff) {
Object.assign(para, this.staff) Object.assign(para, this.staff)
} }
// 先判断登录
const loginStatus = await wx.p.router.intercept()
if (loginStatus) return
wx.p.wxApi.showLoading('领取中') wx.p.wxApi.showLoading('领取中')
wx.p.api.couponsApi.giftsRecive(para).then(res => { wx.p.api.couponsApi.giftsRecive(para).then(res => {
wx.hideLoading(); wx.hideLoading();
......
...@@ -60,64 +60,29 @@ Page({ ...@@ -60,64 +60,29 @@ Page({
} }
}) })
}, },
tofreeReceive() { async tofreeReceive() {
// if(this.op){ // 先判断登录
// wx.p.wxApi.showLoading() const loginStatus = await wx.p.router.intercept()
// this.freeLogin() if (loginStatus) return
// return
// } const userInfo = wx.p.storage.get('userInfo')
let { loginInfo } = this.data let { merchantId, phone } = userInfo
let { merchantId, phone } = loginInfo
if (!phone) { if (!phone) {
return return
} }
wx.p.wxApi.showLoading() wx.p.wxApi.showLoading()
this.toPostFreeCard(merchantId, phone, loginInfo) this.toPostFreeCard(merchantId, phone, userInfo)
},
login() {
wx.p.api.userApi.login().then(res => {
if (res.data) {
console.log(res.data)
let { phone, sessionId } = res.data
wx.p.authStatus = phone ? false : true
if (res.data.isLogin) {
wx.p.cache.storageApi.setUserInfo(res.data)
wx.p.cache.storageApi.setSessionId(res.data.sessionId)
// this.handlerCustomerId()
}
this.setData({
loginInfo: res.data,
showAuthBtn: phone ? false : true,
sessionId
})
}
})
},
getPhoneNumber({ detail }) {
const { sessionId } = this.data
if (!sessionId) return
wx.p.api.userApi.authUserPhone(detail, sessionId).then(({ data, code, message }) => {
wx.hideLoading()
if (code == '0') {
wx.p.authStatus = false
wx.p.cache.storageApi.setUserInfo(data)
wx.p.cache.storageApi.setSessionId(data.sessionId)
let { merchantId, phone } = data
this.toPostFreeCard(merchantId, phone, data)
// this.handlerCustomerId()
} else wx.p.wxApi.showToast(message)
})
}, },
onLoad(options) { onLoad(options) {
let system = wx.getSystemInfoSync() let system = wx.getSystemInfoSync()
const {merchantId} = wx.p.storage.get('merchant_info') const { merchantId } = wx.p.storage.get('merchant_info')
// if (options && options.scene) {
if (options && options.scene) { // this.getLiveActivityId(decodeURIComponent(options.scene))
this.getLiveActivityId(decodeURIComponent(options.scene)) // } else {
} else { // this.toGetFreeCardDay(merchantId)
// }
this.toGetFreeCardDay(merchantId) this.toGetFreeCardDay(merchantId)
this.login()
}
this.setData({ this.setData({
paddingH: system.windowHeight * 0.11, paddingH: system.windowHeight * 0.11,
textpadding: system.windowHeight * 0.31 textpadding: system.windowHeight * 0.31
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
</view> </view>
<view class="wrapper1"> <view class="wrapper1">
<!-- <view class="btnText" bind:tap="tofreeReceive">免费领取</view> --> <!-- <view class="btnText" bind:tap="tofreeReceive">免费领取</view> -->
<block wx:if="{{showAuthBtn}}"> <!-- <block wx:if="{{showAuthBtn}}">
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="auth-button"></button> <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="auth-button"></button>
</block> </block> -->
<glsx-image webp bind:tap="tofreeReceive" webp class="bottomIcon animaiton" mode="widthFix" src="equity/freecard_btn_icon_new.png" /> <glsx-image webp bind:tap="tofreeReceive" webp class="bottomIcon animaiton" mode="widthFix" src="equity/freecard_btn_icon_new.png" />
</view> </view>
<view style="height:22rpx"></view> <view style="height:22rpx"></view>
......
...@@ -15,13 +15,14 @@ Page({ ...@@ -15,13 +15,14 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: async function (options) {
this.setNaviTitle() this.setNaviTitle()
// decodeUrlLink(options) // decodeUrlLink(options)
if (!options.id) { if (!options.id) {
return return
} }
this.getPackageDetail(options.id) this.packageId = options.id
// this.getPackageDetail(options.id)
// if (options.shareStaffUuid) { // if (options.shareStaffUuid) {
// this.data.shareStaff = { // this.data.shareStaff = {
// shareStaffUuid: options.shareStaffUuid, // shareStaffUuid: options.shareStaffUuid,
...@@ -38,6 +39,12 @@ Page({ ...@@ -38,6 +39,12 @@ Page({
// wx.p.cache.storageApi.reportData(options, true, false) // wx.p.cache.storageApi.reportData(options, true, false)
// } // }
}, },
async onShow() {
this.getPackageDetail(this.packageId)
this.setData({ showAuthBtn: false })
const loginStatus = await wx.p.router.intercept(false)
if (loginStatus) return this.setData({ showAuthBtn: true })
},
// 登录 // 登录
// login() { // login() {
// wx.p.api.userApi.login().then(res => { // wx.p.api.userApi.login().then(res => {
...@@ -58,31 +65,33 @@ Page({ ...@@ -58,31 +65,33 @@ Page({
// }, // },
// 设置标题名称 // 设置标题名称
setNaviTitle(tile) { setNaviTitle(tile) {
const {merchantName} = wx.p.storage.get('merchant_info') const { merchantName } = wx.p.storage.get('merchant_info')
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title:merchantName title: merchantName
})
},
getPhoneNumber({ detail }) {
const { sessionId } = this.data
if (!sessionId) return
wx.p.api.userApi.authUserPhone(detail, sessionId).then(({ data, code, message }) => {
wx.hideLoading()
if (code == '0') {
// wx.$Track.setTrack({}, 3)
wx.p.authStatus = false
wx.p.cache.storageApi.setUserInfo(data)
wx.p.cache.storageApi.setSessionId(data.sessionId)
this.toCreatePackageNum()
// this.handlerCustomerId()
} else wx.p.wxApi.showToast(message)
}) })
}, },
// getPhoneNumber({ detail }) {
// const { sessionId } = this.data
// if (!sessionId) return
// wx.p.api.userApi.authUserPhone(detail, sessionId).then(({ data, code, message }) => {
// wx.hideLoading()
// if (code == '0') {
// // wx.$Track.setTrack({}, 3)
// wx.p.authStatus = false
// wx.p.cache.storageApi.setUserInfo(data)
// wx.p.cache.storageApi.setSessionId(data.sessionId)
// this.toCreatePackageNum()
// // this.handlerCustomerId()
// } else wx.p.wxApi.showToast(message)
// })
// },
// 获取套餐详情 // 获取套餐详情
getPackageDetail(id) { getPackageDetail(id) {
const { merchantId } = wx.p.storage.get('merchant_info')
wx.p.api.couponsApi wx.p.api.couponsApi
.packageInfo({ .packageInfo({
id id,
merchantId
}) })
.then(res => { .then(res => {
if (res.couponsDetailList.length) { if (res.couponsDetailList.length) {
...@@ -99,7 +108,9 @@ Page({ ...@@ -99,7 +108,9 @@ Page({
}) })
}, },
// 获取门店单号 // 获取门店单号
toCreatePackageNum() { async toCreatePackageNum() {
const loginStatus = await wx.p.router.intercept()
if (loginStatus) return
wx.p.wxApi.showLoading() wx.p.wxApi.showLoading()
wx.p.api.couponsApi.createOrderNum().then(res => { wx.p.api.couponsApi.createOrderNum().then(res => {
wx.hideLoading() wx.hideLoading()
......
...@@ -44,13 +44,13 @@ ...@@ -44,13 +44,13 @@
</view> </view>
</block> --> </block> -->
<view class="fixed-button-wrap"> <view class="fixed-button-wrap">
<block wx:if="{{showAuthBtn}}"> <!-- <block wx:if="{{showAuthBtn}}">
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="auth-button"></button> <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="auth-button"></button>
</block> </block> -->
<view wx:if="{{packageInfo.isPayFlag}}" class="button-item" bind:tap="toCreatePackageNum"> <view wx:if="{{packageInfo.isPayFlag || showAuthBtn}}" class="button-item" bind:tap="toCreatePackageNum">
限时特价仅需¥{{packageInfo.packagePrice }},点击购买 限时特价仅需¥{{packageInfo.packagePrice }},点击购买
</view> </view>
<view wx:if="{{!packageInfo.isPayFlag}}" class="button-item grey-btn">非指定用户不可购买</view> <view wx:if="{{!packageInfo.isPayFlag&&!showAuthBtn}}" class="button-item grey-btn">非指定用户不可购买</view>
</view> </view>
<view style="height: 164rpx"></view> <view style="height: 164rpx"></view>
</view> </view>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!