Commit 7c210060 by chenwq

领取会员联调

1 parent e39e5184
...@@ -32,6 +32,16 @@ module.exports = { ...@@ -32,6 +32,16 @@ module.exports = {
true true
); );
}, },
// 判断领取权益会员卡绑定活动红包
checkReceiveRed(data) {
return api.post(
{
method: `scrm.api.equity.card.activity.red.envelope.binding`,
...data,
},
true
);
},
// 获取商品信息 // 获取商品信息
commodityMsg(data) { commodityMsg(data) {
return api.post({ return api.post({
......
...@@ -142,7 +142,8 @@ ...@@ -142,7 +142,8 @@
"pages/road/index/index", "pages/road/index/index",
"pages/road/roadInfo/roadInfo", "pages/road/roadInfo/roadInfo",
"pages/freecard/freecard", "pages/freecard/freecard",
"pages/gCoupons/index" "pages/gCoupons/index",
"pages/receiveRed/receiveRed"
] ]
} }
], ],
......
...@@ -12,7 +12,8 @@ Page({ ...@@ -12,7 +12,8 @@ Page({
navTitleStyle, navTitleStyle,
imgList: new Array(3), imgList: new Array(3),
authStatus: true, authStatus: true,
hasUserInfo: false hasUserInfo: false,
isOpenMember: false
}, },
navbarReady(e) { navbarReady(e) {
let { height, statusBarHeight } = e.detail let { height, statusBarHeight } = e.detail
...@@ -87,6 +88,15 @@ Page({ ...@@ -87,6 +88,15 @@ Page({
}) })
}, },
//
async tofreeReceive() {
const userInfo = wx.p.storage.get('userInfo')
let { merchantId, phone } = userInfo
wx.p.wxApi.showLoading()
this.toPostFreeCard(merchantId, phone, userInfo)
},
// 领取会员卡
toPostFreeCard(merchantId, phone, userInfo) { toPostFreeCard(merchantId, phone, userInfo) {
let para = { let para = {
merchantId, merchantId,
...@@ -94,7 +104,7 @@ Page({ ...@@ -94,7 +104,7 @@ Page({
} }
wx.p.api.couponsApi.tolqFreecard(para).then(res => { wx.p.api.couponsApi.tolqFreecard(para).then(res => {
wx.hideLoading() wx.hideLoading()
const { errId, code, message } = res const { errId, code, message, data } = res
if ((code == -1 && errId == 20313) || (code == -1 && errId == 20322)) { if ((code == -1 && errId == 20313) || (code == -1 && errId == 20322)) {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
...@@ -105,28 +115,59 @@ Page({ ...@@ -105,28 +115,59 @@ Page({
}) })
return return
} }
let bindInfo = { console.log(res, '////')
code, if (code == 0) {
errId, // 获取会员卡信息
message, wx.p.api.equityApi.checkOpenMember().then(res => {
data: { if (res.code == 0 && res.data) {
sessionId: userInfo.sessionId this.receiveRed(res.data.equityFreeCardId)
} }
})
}
})
},
receiveRed(equityFreeCardId) {
let { isOpenMember } = this.data
let params = {
equityFreeCardId
}
wx.p.api.equityApi.checkReceiveRed(params).then(res => {
console.log(res)
let { code, message, data } = res
if (code != 0) {
this.showTips(message || '服务不可用')
return
}
if (!data.isReceiveFlag) {
wx.p.router.go('/packageEquity/pages/receiveRed/receiveRed', {
isOpenMember: isOpenMember,
activityRedEnvelopeLink: data.activityRedEnvelopeLink
})
} else if (isOpenMember) {
wx.p.router.switchTab('/pages/tab/mine/index', {
isMemberShow: true,
});
} }
let temp = encodeURIComponent(JSON.stringify(bindInfo))
wx.p.storage.set('bindInfo', temp)
wx.p.router.reLaunch('/pages/tab/equity/index');
}) })
}, },
async tofreeReceive() {
// 先判断登录
const loginStatus = await wx.p.router.intercept()
if (loginStatus) return
const userInfo = wx.p.storage.get('userInfo') async toCheckMember() {
let { merchantId, phone } = userInfo // 先判断登录
wx.p.wxApi.showLoading() const authStatus = await wx.p.router.intercept(false)
this.toPostFreeCard(merchantId, phone, userInfo) if (authStatus) return
wx.p.api.equityApi.checkOpenMember().then(res => {
let flag = false
if (res.code == 0 && res.data) {
flag = true
this.receiveRed(res.data.equityFreeCardId)
}
this.setData({
isOpenMember: flag
})
if (!flag) {
this.tofreeReceive()
}
})
}, },
async onLoad(options) { async onLoad(options) {
......
/* packageEquity/pages/freecard/freecard.wxss */ /* packageEquity/pages/freecard/freecard.wxss */
.navigation-bar {
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
.bg-iamge { .bg-iamge {
width: 100%; width: 100%;
position: absolute; position: absolute;
......
<!-- <view class="navigation-bar"> -->
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" showBack="{{true}}" navTitleStyle="{{navTitleStyle}}" page-title="领取会员卡">领取会员卡</navigation-bar> <navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" showBack="{{true}}" navTitleStyle="{{navTitleStyle}}" page-title="领取会员卡">领取会员卡</navigation-bar>
<!-- </view> -->
<view class="bg-iamge" style="height: calc({{statusBarHeight + navigationBarHeight + 110}}px);"> <view class="bg-iamge" style="height: calc({{statusBarHeight + navigationBarHeight + 110}}px);">
<glsx-image src="equity/bg-card.png" class="image-class" /> <glsx-image src="equity/bg-card.png" class="image-class" />
<glsx-image src="equity/card.png" class="img-card" /> <glsx-image src="equity/card.png" class="img-card" />
...@@ -15,7 +13,9 @@ ...@@ -15,7 +13,9 @@
<button wx:if="{{authStatus}}" open-type="getPhoneNumber" catchgetphonenumber="getPhoneNumber" class="text-center btn-defalut">登陆</button> <button wx:if="{{authStatus}}" open-type="getPhoneNumber" catchgetphonenumber="getPhoneNumber" class="text-center btn-defalut">登陆</button>
<button wx:elif="{{!hasUserInfo}}" catchtap="jumpAuthUserInfo" class="text-center btn-defalut">头像昵称</button> <button wx:elif="{{!hasUserInfo}}" catchtap="jumpAuthUserInfo" class="text-center btn-defalut">头像昵称</button>
<view wx:else> <view wx:else>
<view class="btn-defalut" bindtap="tofreeReceive">免费领取</view> <view class="btn-defalut" bindtap="toCheckMember">免费领取</view>
<!-- <view class="btn-defalut" bindtap="tofreeReceive">免费领取</view> -->
<!-- <view class="btn-defalut" bindtap="receiveRed">免费领取</view> -->
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
......
// packageEquity/pages/receiveRed/receiveRed.js
const navStyle = 'background-color: transparent;'
const navTitleStyle = "font-weight: 600; font- size: 34rpx; color: #000000;"
Page({
/**
* 页面的初始数据
*/
data: {
navStyle,
navTitleStyle,
isMember: 'noMember',
txtObj: {
noMember: '恭喜领取成功',
member: '恭喜您已成为会员用户'
},
count: 3
},
navbarReady(e) {
let { height, statusBarHeight } = e.detail
this.setData({
tabBarStyle: height / 2 + statusBarHeight,
tabBoxStyle: `height: ${height}px`,
statusBarHeight,
navigationBarHeight: height
})
},
countDown() {
let { count, timer } = this.data
let _this = this
if (this.data.count == 0) {
this.jump()
return
}
clearTimeout(timer)
timer = new setTimeout(() => {
_this.setData({
count: count - 1
})
this.countDown()
}, 1000)
},
jump() {
let { activityRedEnvelopeLink } = this.data
wx.p.router.jumpH5(activityRedEnvelopeLink)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.p.router.getData(obj => {
this.setData({
isMember: obj.isOpenMember ? 'member' : 'noMember',
activityRedEnvelopeLink: obj.activityRedEnvelopeLink
})
})
this.countDown()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"navigationStyle": "custom",
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* packageEquity/pages/receiveRed/receiveRed.wxss */
.bg-iamge {
width: 100%;
position: absolute;
left: 0;
top: 0;
.image-class {
background-color: #fff;
width: 100%;
height: 320rpx;
}
.img-card {
position: absolute;
bottom: -42rpx;
left: 35%;
width: 136rpx;
height: 136rpx;
}
}
.receive-red {
text-align: center;
.title {
font-weight: 600;
font-size: 48rpx;
color: #3871E1;
text-align: center;
line-height: 48rpx;
}
}
// 提示
.member-dialog {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 998;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.bg {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
background: rgba(0, 0, 0, .5);
}
.content {
position: relative;
text-align: center;
box-sizing: border-box;
.member-bg {
width: 550rpx;
height: 910rpx;
}
.count-down {
position: absolute;
top: 26rpx;
right: 26rpx;
width: 72rpx;
height: 72rpx;
line-height: 72rpx;
background: #EA4D3A;
border-radius: 36rpx;
font-weight: 600;
font-size: 42rpx;
color: #FFFFFF;
}
.open-btn {
position: absolute;
bottom: 50rpx;
left: 28%;
width: 158rpx;
height: 158rpx;
}
}
}
\ No newline at end of file \ No newline at end of file
<!--packageEquity/pages/receiveRed/receiveRed.wxml-->
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" showBack="{{true}}" navTitleStyle="{{navTitleStyle}}" page-title=""></navigation-bar>
<view class="bg-iamge" style="height: calc({{statusBarHeight + navigationBarHeight + 26}}px);">
<glsx-image src="equity/bg-receive.png" class="image-class" />
<glsx-image src="equity/icon-receive.png" class="img-card" />
</view>
<view class="receive-red" style="margin-top:calc({{statusBarHeight + navigationBarHeight + 100}}px);">
<view class="title">{{txtObj[isMember]}}</view>
</view>
<!-- 红包会员弹窗 -->
<view class="member-dialog">
<view class="bg" />
<view class="content">
<view class="count-down">{{count}}</view>
<glsx-image class="member-bg" src="equity/bg-red.png"></glsx-image>
<glsx-image bindtap="jump" class="open-btn" src="equity/icon-open.png"></glsx-image>
</view>
</view>
\ No newline at end of file \ No newline at end of file
...@@ -63,6 +63,11 @@ Page({ ...@@ -63,6 +63,11 @@ Page({
}) })
}, },
onLoad(options) { onLoad(options) {
if (options?.isMemberShow) {
this.setData({
isMemberShow: true
})
}
this.getMemberCardData() this.getMemberCardData()
}, },
navbarReady(e) { navbarReady(e) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!