Commit c8d552ac by 李伟康

提交问卷需求

1 parent 11b36a5d
...@@ -18,5 +18,15 @@ module.exports = { ...@@ -18,5 +18,15 @@ module.exports = {
projectName, projectName,
...data ...data
}) })
} },
/**
* 调查问卷-领取红包
*/
receiveQuestionnaireRedEnvelope(data = {}) {
return api.post({
method: 'marketing.api.activityRedEnvelope.questionnaire.binding',
projectName,
...data
})
},
} }
\ No newline at end of file \ No newline at end of file
...@@ -15,8 +15,48 @@ Component({ ...@@ -15,8 +15,48 @@ Component({
count: 5 count: 5
}, },
lifetimes: { lifetimes: {
attached() { async attached() {
this.countDown() const {
data
} = this.data
if (data.activityType) {
let url = '/packageEquity/pages/freecard/freecard',
options = {
bindingSource: 1,
notIntercept: true
}
if (data.activityType == 3) {
const {
userInfo
} = wx.p.router.getPageInstance().data
const res = await wx.p.api.questionnaireApi.receiveQuestionnaireRedEnvelope({
questionnaireId: data.id,
activityRedEnvelopeId: data.activityId,
nickName: userInfo.nickName
})
if (res.isActivityRedEnvelopeFlag && !res.isReceiveFlag) this.setData({
jumpOption: {
url: res.activityRedEnvelopeLink,
type: data.activityType
}
})
this.countDown()
} else {
if (data.activityType == 2) {
options.couponId = data.activityId
url = '/packageMall/pages/coupon/coupon'
}
this.setData({
jumpOption: {
url,
type: data.activityType,
options
}
})
this.countDown()
}
}
} }
}, },
timer: null, timer: null,
...@@ -24,24 +64,17 @@ Component({ ...@@ -24,24 +64,17 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
back() { async back() {
clearTimeout(this.timer) clearTimeout(this.timer)
this.timer = null this.timer = null
const { const {
data jumpOption
} = this.data } = this.data
if (data.activityType) { if (jumpOption) {
let url = '/packageEquity/pages/freecard/freecard', if (jumpOption.type == 3) wx.p.router.switchTab('/pages/tab/index/index', {
options = { jumpH5Url: jumpOption.url
bindingSource: 1, })
notIntercept: true else wx.p.router.redirectTo(jumpOption.url, jumpOption.options)
}
if (data.activityType == 2) {
options.couponId = data.activityId
url = '/packageMall/pages/coupon/coupon'
}
if (data.activityType == 3) console.log('红包')
else wx.p.router.redirectTo(url, options)
} else wx.p.router.goHome() } else wx.p.router.goHome()
}, },
countDown() { countDown() {
......
/* packageMine/pages/questionnaire/components/Finish/Finish.wxss */ /* packageMine/pages/questionnaire/components/Finish/Finish.wxss */
@keyframes show-finish{
0%{
left: 100vw;
}
100%{
left: 0;
}
}
.finish-box { .finish-box {
position: fixed;
left: 0;
top: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background-color: #fff; background-color: #fff;
...@@ -9,7 +20,7 @@ ...@@ -9,7 +20,7 @@
font-weight: 500; font-weight: 500;
font-size: 40rpx; font-size: 40rpx;
color: #333333; color: #333333;
animation: show-finish .25s forwards;
.icon { .icon {
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="tips">{{count}}S后自动跳转</view> <view class="tips">{{count}}S后自动跳转</view>
</view> </view>
<!-- 红包会员弹窗 --> <!-- 红包会员弹窗 -->
<block wx:if="{{data.activityType == 3}}"> <block wx:if="{{data.activityType == 3 && jumpOption}}">
<view class="member-dialog"> <view class="member-dialog">
<view class="bg" /> <view class="bg" />
<view class="content"> <view class="content">
......
...@@ -66,12 +66,13 @@ Page({ ...@@ -66,12 +66,13 @@ Page({
} }
} }
}, },
transformData(data) { transformData(data, maxLength = 3) {
const result = [] const result = []
data.forEach((item, index) => { data.forEach(item => {
const levels = item.split('/') const levels = item.split('/')
let currentLevel = result let currentLevel = result
for (let i = 0; i < levels.length; i++) { for (let i = 0; i < levels.length; i++) {
if (i == maxLength) break
const text = levels[i], const text = levels[i],
value = text, value = text,
existingOption = currentLevel.find((option) => option.text === text) existingOption = currentLevel.find((option) => option.text === text)
...@@ -86,8 +87,7 @@ Page({ ...@@ -86,8 +87,7 @@ Page({
value, value,
children: [] children: []
} }
currentLevel.push(newOption) if (text && value) currentLevel.push(newOption)
if (i === levels.length - 1) { if (i === levels.length - 1) {
delete newOption.children delete newOption.children
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
padding: 30rpx 40rpx 44rpx 0; padding: 30rpx 40rpx 44rpx 0;
padding: 30rpx 40rpx 44rpx 0; padding: 30rpx 40rpx 44rpx 0;
background-color: #fff; background-color: #fff;
min-height: 75vh;
.tips { .tips {
font-size: 28rpx; font-size: 28rpx;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!