Commit c8d552ac by 李伟康

提交问卷需求

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