Commit 58163d92 by 李伟康

修改接龙

1 parent a5bda94d
......@@ -35,6 +35,7 @@ module.exports = {
method: 'marketing.api.self.red.envelope.banding.link',
projectName,
...data
})
},true)
},
}
\ No newline at end of file
......@@ -59,6 +59,7 @@ module.exports = {
...data
})
},
/**提交地址信息 */
submitDelivery(data) {
return api.post({
method: 'marketing.api.self.red.envelope.customer.write.detail.save',
......@@ -66,6 +67,7 @@ module.exports = {
...data
}, true)
},
/**查询红包详情 */
getActivityRedEnvelopeDetail(data = {}) {
return api.post({
method: 'marketing.api.activityRedEnvelope.findOne',
......@@ -73,5 +75,30 @@ module.exports = {
...data
})
},
//
/** 自研红包抽奖记录保存(即抽奖本身) */
saveRedEnvelopeShowRecord(data = {}) {
return api.post({
method: 'marketing.api.self.red.envelope.lottery.draw.record.save',
projectName,
...data
})
},
/** 开奖成功后记录信息 */
recordedPrizeInfo(data = {}) {
return api.post({
method: 'marketing.api.activityRedEnvelope.relay.user.claim',
projectName,
...data
})
},
/**
* 发放关联活动优惠券
*/
getCoupon(data = {}) {
return api.post({
method: 'scrm.api.coupon.activity.user.get',
...data,
receiveWay: 17
})
},
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ Page({
* 页面的初始数据
*/
data: {
count: 3
},
/**
......@@ -35,43 +35,135 @@ Page({
const {
options
} = this
if (options.isLogin) this.jumpRedEnvelopeH5()
if (options.isLogin) this.getRedEnvelopeH5()
else this.jumpLoading() //直接打开时跳转、防止sessionId失效
},
async jumpRedEnvelopeH5() {
async getRedEnvelopeH5() {
const res = await wx.p.router.intercept()
if (!res) {
const {
userInfo
} = this.data, {
activityId,
merchantId,
linkId
} = this.options, {
sessionId
} = wx.p.storage.get()
activityId,
businessId,
source,
linkId
} = this.options
if (!userInfo.nickName) return this.getNickNameAndHeadUrl()
const {
accountId,
nickName,
unionId,
openid,
phone
} = userInfo
let user = encodeURIComponent(JSON.stringify({
try {
const {
sourceType
} = await wx.p.api.solitaireApi.getActivityRedEnvelopeDetail({
id: activityId
})
if (linkId) this.jumpRedEnvelopeH5({
activityId,
linkId,
source
})
else {
const {
code,
data,
message
} = await wx.p.api.questionnaireApi.bindRedEnvelopeLink({
activityId,
bindingSource: source,
wechatName: userInfo.nickName,
businessId
})
if (code == 0) {
if (data.id && data.link) {
// /**sourceType 0-自研,1-外采 */
if (sourceType == 1) wx.p.router.go('/packageEquity/pages/receiveRed/receiveRed', {
isOpenMember: source == 0,
activityRedEnvelopeLink: res.link
})
else this.jumpRedEnvelopeH5({
activityId,
linkId: res.id,
source
})
} else throw message
} else throw message
}
} catch (error) {
if (error) wx.showModal({
title: '温馨提示',
content: error,
confirmText: '知道了',
showCancel: false,
confirmColor: '#F13C3D',
success: function (res) {
if (res.confirm) wx.p.router.goHome()
}
})
}
}
},
jumpRedEnvelopeH5({
activityId,
linkId,
source
}) {
const {
awardInfoId,
merchantId,
recordId
} = this.options, {
accountId,
nickName,
unionId,
openid,
phone
} = this.data.userInfo, {
sessionId
} = wx.p.storage.get()
let user = encodeURIComponent(JSON.stringify({
accountId,
nickName,
unionId,
openid,
phone
})),
query = `activityId=${activityId}&merchantId=${merchantId}&sessionId=${sessionId}&userInfo=${user}`
if(linkId) query += `&linkId=${linkId}`
this.setData({
// url: `${domain}/scrm-wx-red-packet/#/redEnvelope?activityId=${activityId}&merchantId=${merchantId}&sessionId=${sessionId}&userInfo=${user}` //测试、预发布、生产
url: `${domain}/dj-scrm-wx-work-main-lwk/#/?${query}` //开发环境
})
query = `activityId=${activityId}&merchantId=${merchantId || userInfo.merchantId}&sessionId=${sessionId}&userInfo=${user}`
if (linkId) query += `&linkId=${linkId}`
// 绑定来源 0:权益会员卡;1:调查问卷;2:群接龙
if (source > -1) query += `&source=${source}`
if (recordId) query += `&recordId=${recordId}`
if(awardInfoId) query += `&awardInfoId=${awardInfoId}`
this.linkQuery = query
this.setData({
show: true
})
this.countDown()
},
countDown() {
let {
count,
timer,
isJump
} = this.data
let _this = this
if (this.data.count == 0) {
!isJump && this.jump()
return
}
clearTimeout(timer)
timer = new setTimeout(() => {
_this.setData({
count: count - 1
})
this.countDown()
}, 1000)
},
jump() {
this.setData({
isJump: true,
show: false,
// url: `${domain}/scrm-wx-red-packet/#/redEnvelope?activityId=${activityId}&merchantId=${merchantId}&sessionId=${sessionId}&userInfo=${user}` //测试、预发布、生产
url: `${domain}/dj-scrm-wx-work-main-lwk/#/?${this.linkQuery}` //开发环境
})
},
/**
* 生命周期函数--监听页面隐藏
......
/* packageActivity/pages/redEnvelope/index/index.wxss */
\ No newline at end of file
/* packageActivity/pages/redEnvelope/index/index.wxss */
// 提示
.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
<web-view src="{{url}}"/>
\ No newline at end of file
<web-view src="{{url}}" />
<!-- 红包会员弹窗 -->
<block wx:if="{{show}}">
<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>
</block>
\ No newline at end of file
// packageActivity/pages/solitaire/components/Coupon/Coupon.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: Boolean,
item: Object
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
close() {
this.setData({
show: false
})
},
jump() {
const {item } = this.data,
{discountType} = item
if (discountType == 2 || discountType == 4) {
wx.p.router.redirectTo('/packageMall/pages/coupon/coupon', {
userCouponId: id,
useMemberType: 0
})
return
}
// /**线上商品代金券 */
if (discountType == 3) {
wx.p.router.redirectTo('/packageMine/pages/coupon/recommend/recommend', {
couponInfo: item
})
return
}
if (discountType == 8) {
wx.p.router.redirectTo('/packageSaveMoney/pages/detail/detail', {
param:{
brandName:item.brandName,
supplier:'HW'
}
})
return
}
wx.p.router.redirectTo('/packageMine/pages/coupon/detail/detail', {
item
})
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
}
}
\ No newline at end of file
.box {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: 102;
background-color: rgba($color: #000000, $alpha: .5);
.flex {
display: flex;
align-items: center;
}
.content {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 590rpx;
height: 628rpx;
background-image: linear-gradient(149deg, #FFC296 4%, #FFEED0 47%, #FFF0E6 100%);
box-shadow: 0 0 48rpx 4rpx #fff08ab3;
border-radius: 44rpx;
display: flex;
flex-direction: column;
align-items: center;
.card {
flex-direction: column;
.content-icon {
top: -120rpx;
}
.name {
font-weight: 600;
font-size: 40rpx;
color: #863e00;
letter-spacing: 0;
width: 95%;
padding: 114rpx 0 8rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.describe {
height: 52rpx;
background: #f6dcaa;
border-radius: 26rpx;
padding: 0 32rpx;
font-size: 28rpx;
color: #985e23;
text-align: center;
}
.price {
font-weight: 700;
font-size: 116rpx;
color: #f32226;
display: flex;
align-items: baseline;
line-height: 134rpx;
.unit {
font-weight: 600;
font-size: 68rpx;
color: #f32226;
}
}
.tips {
font-weight: 600;
font-size: 40rpx;
color: #F32226;
}
.btn {
width: 312rpx;
height: 80rpx;
background-image: linear-gradient(88deg, #FF444D 16%, #FF5BA8 90%);
border: 2rpx solid #FF7887;
box-shadow: inset 0 4rpx 24rpx 0 #ffffff80;
border-radius: 50rpx;
font-weight: 600;
font-size: 40rpx;
color: #FFFFFF;
justify-content: center;
margin: 22rpx 0;
}
.time {
font-size: 28rpx;
color: #8B7E7C;
}
}
}
.close {
width: 72rpx;
height: 72rpx;
position: absolute;
left: 50%;
bottom: -132rpx;
transform: translateX(-50%);
}
}
\ No newline at end of file
<block wx:if="{{show}}">
<view class="box">
<view class="content">
<view class="card flex">
<view class=""></view>
<view class="name">
恭喜你获得{{item.couponName}}一张
</view>
<view class="describe flex">优惠券已存入您的卡包里</view>
<block wx:if="{{item.discountType == 2}}">
<view class="price">
{{ item.discountIntensity}}
<view class="unit">折</view>
</view>
</block>
<block wx:else>
<view class="price">
<view class="unit">¥</view>
{{item.denomination}}
</view>
</block>
<view class="tips">全场通用</view>
<view class="btn flex" bindtap="jump">去使用</view>
<view class="time">使用期限:{{item.receiveStartTime}}-{{item.receiveEndTime}}</view>
</view>
<view class="close">
<glsx-image src="activity/close.png" bindtap="close"></glsx-image>
</view>
</view>
</view>
</block>
\ No newline at end of file
......@@ -69,11 +69,11 @@ Page({
console.log('chatId:', res.data)
options.chatId = res.data || ''
this.options = options
_this.getSolitaireUserInfo(options)
_this.getSolitaireDetail(options)
} else throw message
},
fail(err) {
_this.getSolitaireUserInfo(options)
_this.getSolitaireDetail(options)
}
})
} catch (error) {
......@@ -103,70 +103,170 @@ Page({
openId,
unionId
})
this.getSolitaireDetail(params)
if (code == 0) {
if (data) {
/**
* recordId 记录id
* stateCode 状态码 -1.未参与 0.已参加 1.未中奖 2.已中奖
* relayContent 接龙内容
* prizeType 奖品类型 1.红包 2.优惠券 3.权益
* prizeId 奖品id (已领取时返回)
* claimState 领取状态 0.未领取 1.已领取
*/
const {
stateCode,
stateName,
relayContent
relayContent,
claimState,
prizeType,
recordId,
prizeId
} = data
if (stateCode == 0) this.setData({
['popupConfig.type']: 1,
['popupConfig.title']: stateName,
['popupConfig.relayContent']: relayContent,
})
if (stateCode == 1) this.setData({
['popupConfig.type']: 2,
['popupConfig.relayContent']: relayContent,
})
if (stateCode == 0 || stateCode == 1) this.setData({
show: true
})
if (stateCode == 1 || stateCode == 2) this.setData({
disabled: true
})
if (stateCode == 2) {
this.setData({
disabled: true
})
if (claimState == 0) {
if (prizeType == 1) this.bindActivityRedEnvelope(recordId)
else this.getCoupon(recordId)
} else {
if (prizeType == 1) this.getRedEnvelopeAwardInfo({
awardInfoId: prizeId,
params
})
else this.getCouponInfo(prizeId)
}
} else {
if (stateCode == 0 || stateCode == 1) this.setData({
['popupConfig.type']: stateCode == 0 ? 1 : 2,
['popupConfig.title']: stateName || '',
})
this.setData({
show: stateCode == 0 || stateCode == 1,
disabled: stateCode == 1,
['popupConfig.relayContent']: relayContent
})
}
}
} else throw message
} catch (error) {
console.log(error)
this.showGroupNoAccess(error)
}
},
async getCoupon(recordId) {
const {
activityObject: {
rewardId,
merchantId,
merchantName
}
} = this.data,
data = await wx.p.api.solitaireApi.getCoupon({
couponId: rewardId,
merchantId,
merchantName
})
if (data && data.length) {
let [info] = data
this.setCouponInfo(info)
wx.p.api.solitaireApi.recordedPrizeInfo({
prizeId: info.userCouponId,
recordId
})
} else wx.p.wxApi.showToas('奖品已发完')
},
async getCouponInfo(userCouponId) {
const info = await wx.p.api.couponsApi.couponsDetail({
userCouponId
})
info.userCouponId = userCouponId
this.setCouponInfo(info)
},
setCouponInfo(info) {
info.receiveStartTime = new Date(info.receiveStartTime).format('yyyy/MM/dd')
info.receiveEndTime = new Date(info.receiveStartTime).format('yyyy/MM/dd')
if (info.discountIntensity) info.discountIntensity = Number(info.discountIntensity / 100)
if (info.denomination) info.denomination = Number(info.denomination / 100)
info.id = info.userCouponId
this.setData({
couponInfo: info,
showCoupon: true
})
},
/**获取接龙活动详情 */
async getSolitaireDetail(params) {
try {
wx.p.wxApi.showLoading()
const res = await wx.p.api.solitaireApi.getSolitaireDetail(params)
if (res.groupLimitOpen) {
const {
chatId
} = this.options
if (!chatId) this.showGroupNoAccess('此群无法参加接龙游戏')
}
this.getSolitaireUserInfo(params)
this.getSolitaireAewardList(params)
this.setData({
activityDetail: decodeURIComponent(res.description),
title: res.title,
array: generateOptionsArray(res.numLimit),
loading: true,
activityObject: res
})
if (new Date(wx.p.format.iosTimeFormat(res.lotteryTime)).getTime() <= Date.now()) this.setData({
['popupConfig.numWin']: res.numWin
})
wx.p.wxApi.hideLoading()
const {
list
} = await wx.p.api.solitaireApi.getSolitaireAewardList(params)
this.setData({
list
})
} catch (error) {
console.log(error)
if (error) wx.p.wxApi.showToast(error)
}
},
/**获取接龙明细 */
async getSolitaireAewardList(params) {
const {
list
} = await wx.p.api.solitaireApi.getSolitaireAewardList(params)
this.setData({
list
})
},
/**领取红包 */
async bindActivityRedEnvelope(recordId) {
const {
activityObject: {
rewardId,
id
},
userInfo
} = this.data, {
data
} = await wx.p.api.questionnaireApi.bindRedEnvelopeLink({
activityId: rewardId,
bindingSource: 2,
wechatName: userInfo.nickName,
businessId: id
})
wx.p.router.go('/packageActivity/pages/redEnvelope/index/index', {
activityId: rewardId,
merchantId: userInfo.merchantId,
linkId: data.id,
source: 2,
recordId,
isLogin: 1
})
},
async getRedEnvelopeAwardInfo({
awardInfoId,
params
}) {
const {
activityObject: {
rewardId
}
} = this.data
wx.p.router.redirectTo('/packageActivity/pages/redEnvelope/index/index', {
activityId: rewardId,
merchantId: params.merchantId,
awardInfoId,
isLogin: 1
})
},
showGroupNoAccess(title) {
this.setData({
['popupConfig.type']: 1,
......@@ -192,6 +292,7 @@ Page({
'params.name': userInfo.nickName
})
},
/**提交 */
async submit() {
try {
const {
......@@ -218,7 +319,10 @@ Page({
if (code == 0) {
if (data) {
wx.p.wxApi.showToast('提交成功!')
this.getSolitaireDetail({
this.setData({
disabled: true
})
this.getSolitaireAewardList({
relayLotteryId
})
} else throw message
......
{
"usingComponents": {
"mp-html": "/components/mp-html/index",
"solitaire-popup":"../components/solitairePopup/solitairePopup"
"solitaire-popup":"../components/solitairePopup/solitairePopup",
"coupon":"../components/Coupon/Coupon"
},
"navigationBarTitleText": "群接龙抽奖"
}
\ No newline at end of file
......@@ -53,4 +53,5 @@
</view>
</block>
<solitaire-popup popupConfig="{{popupConfig}}" model:show="{{show}}"></solitaire-popup>
\ No newline at end of file
<solitaire-popup popupConfig="{{popupConfig}}" model:show="{{show}}"></solitaire-popup>
<coupon item="{{couponInfo}}" model:show="{{showCoupon}}"></coupon>
\ No newline at end of file
......@@ -187,44 +187,33 @@ Page({
nickName: nickName
}
if (bindingSource) params.bindingSource = bindingSource
wx.p.api.equityApi.checkReceiveRed(params).then(res => {
wx.p.api.equityApi.checkReceiveRed(params).then(async res => {
console.log(res, 'checkReceiveRed---')
let {
code,
message,
data
} = res
if (code != 0) {
this.showTips(message || '服务不可用')
return
}
if (!data.isActivityRedEnvelopeFlag) {
this.jumpMine()
} else {
if (code != 0) return this.showTips(message || '服务不可用')
/**isActivityRedEnvelopeFlag 是否关联红包活动 */
if (!data.isActivityRedEnvelopeFlag) this.jumpMine()
else {
/**是否领取过红包 */
if (!data.isReceiveFlag) {
/**用户是否已添加福利官 true:是;false:否; */
// const {
// sourceType
// } = await wx.p.api.solitaireApi.getActivityRedEnvelopeDetail({
// id: equityFreeCardId
// })
// console.log(sourceType)
// /**sourceType 0-自研,1-外采 */
if (!data.isAddWelfareOfficerFlag) {
wx.p.router.switchTab('/pages/tab/mine/index', {
isMemberShow: true,
isOpenMember: true,
addWelfareOfficer: 'bg-member-welfare'
})
} else {
wx.p.router.go('/packageEquity/pages/receiveRed/receiveRed', {
isOpenMember: isOpenMember,
activityRedEnvelopeLink: data.activityRedEnvelopeLink
})
}
} else {
this.jumpMine()
}
} else wx.p.router.go('/packageActivity/pages/redEnvelope/index/index', {
activityId: data.activityRedEnvelopeId,
businessId: equityFreeCardId,
source: 0,
isLogin: 1
})
} else this.jumpMine()
}
})
},
......
......@@ -17,7 +17,11 @@ Component({
lifetimes: {
async attached() {
const {
data
data,
data: {
activityId,
merchantId
}
} = this.data
if (data.activityType) {
let url = '/packageEquity/pages/freecard/freecard',
......@@ -29,48 +33,23 @@ Component({
const {
userInfo
} = wx.p.router.getPageInstance().data
// const response = await wx.p.api.questionnaireApi.receiveQuestionnaireRedEnvelope({
// questionnaireId: data.id,
// activityRedEnvelopeId: data.activityId,
// nickName: userInfo.nickName
// })
// if (response.isActivityRedEnvelopeFlag && !response.isReceiveFlag) {
const {
sourceType
} = await wx.p.api.solitaireApi.getActivityRedEnvelopeDetail({
id: data.activityId
}),
/**sourceType 0-自研,1-外采 */
res = await wx.p.api.questionnaireApi.bindRedEnvelopeLink({
activityId: data.activityId,
bindingSource: 1,
wechatName: userInfo.nickName,
businessId: data.id
})
if (sourceType == 1) {
this.setData({
jumpOption: {
url: res.link,
type: data.activityType
}
})
} else this.setData({
jumpOption: {
url: '/packageActivity/pages/redEnvelope/index/index',
type: 1,
options: {
activityId: data.activityId,
merchantId: data.merchantId,
linkId: res.id
}
}
})
this.countDown()
// } else this.countDown()
const response = await wx.p.api.questionnaireApi.receiveQuestionnaireRedEnvelope({
questionnaireId: data.id,
activityRedEnvelopeId: activityId,
nickName: userInfo.nickName
})
if (response.isActivityRedEnvelopeFlag && !response.isReceiveFlag) wx.p.router.go('/packageActivity/pages/redEnvelope/index/index', {
activityId,
businessId: data.id,
merchantId,
source: 1,
isLogin: 1
})
else this.countDown()
} else {
if (data.activityType == 2) {
options.couponId = data.activityId
options.couponId = activityId
url = '/packageMall/pages/coupon/coupon'
}
this.setData({
......
......@@ -5,15 +5,4 @@
提交成功
<view class="btn" bindtap="back">返回</view>
<view class="tips">{{count}}S后自动跳转</view>
</view>
<!-- 红包会员弹窗 -->
<block wx:if="{{data.activityType == 3 && jumpOption}}">
<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="back" class="open-btn" src="equity/icon-open.png"></glsx-image>
</view>
</view>
</block>
\ No newline at end of file
</view>
\ No newline at end of file
......@@ -23,6 +23,7 @@ Page({
this.toCheckMember()
},
onLoad: function (options) {
console.log(options)
// options = JSON.stringify(options)==='{}'?this.options:options
this.data.isGameUse = options.inType == 'game'
const query = options ? options.param : this.data.query
......
{
"appid": "wxb818f6bc908c52fc",
"compileType": "miniprogram",
"libVersion": "3.2.0",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"coverView": true,
"es6": true,
......@@ -21,11 +15,17 @@
},
"useCompilerPlugins": [
"sass"
]
],
"ignoreUploadUnusedFiles": true
},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
},
"packOptions": {
"ignore": [],
"include": []
},
"appid": "wxb818f6bc908c52fc"
}
\ 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!