Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
zhwy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7f2f74e3
authored
Oct 23, 2023
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
问卷需求
1 parent
c8d552ac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
packageMine/pages/questionnaire/questionnaire.js
packageMine/pages/questionnaire/questionnaire.js
View file @
7f2f74e
...
@@ -35,20 +35,27 @@ Page({
...
@@ -35,20 +35,27 @@ Page({
if
(
!
userInfo
.
nickName
)
return
this
.
getNickNameAndHeadUrl
()
if
(
!
userInfo
.
nickName
)
return
this
.
getNickNameAndHeadUrl
()
try
{
try
{
const
data
=
await
wx
.
p
.
api
.
questionnaireApi
.
getQuestionnaireDetail
(
options
)
const
data
=
await
wx
.
p
.
api
.
questionnaireApi
.
getQuestionnaireDetail
(
options
)
if
(
data
.
activityType
==
3
)
{
if
(
data
.
status
==
-
1
)
{
// const a = await wx.p.api.equityApi.checkReceiveRed({
return
wx
.
showModal
({
// equityFreeCardId: data.activityId,
title
:
'温馨提示'
,
// nickName: userInfo.nickName
content
:
'问卷已结束。'
,
// })
showCancel
:
false
,
// console.log(a)
confirmText
:
'返回首页'
,
confirmColor
:
'#3772EC'
,
complete
:
(
res
)
=>
{
if
(
res
.
confirm
)
wx
.
p
.
router
.
goHome
()
}
})
}
}
console
.
log
(
data
)
if
(
data
)
{
if
(
data
)
{
data
.
questions
.
map
(
e
=>
{
data
.
questions
.
map
(
e
=>
{
if
(
e
.
type
!=
3
)
{
if
(
e
.
type
!=
3
)
{
let
option
=
e
.
option
.
split
(
'\n'
)
let
option
=
e
.
option
.
split
(
'\n'
)
if
(
e
.
type
==
5
)
e
.
data
=
this
.
transformData
(
option
)
if
(
e
.
type
==
5
)
{
else
e
.
data
=
option
const
[,
two
,
three
]
=
option
[
0
].
split
(
'/'
)
option
.
splice
(
0
,
1
)
e
.
data
=
this
.
transformData
(
option
,
three
?
3
:
two
?
2
:
1
)
}
else
e
.
data
=
option
}
}
e
.
answer
=
''
e
.
answer
=
''
e
.
userFormId
=
e
.
formId
e
.
userFormId
=
e
.
formId
...
@@ -66,18 +73,17 @@ Page({
...
@@ -66,18 +73,17 @@ Page({
}
}
}
}
},
},
transformData
(
data
,
maxLength
=
3
)
{
transformData
(
data
,
childrenDepth
)
{
const
result
=
[]
const
result
=
[]
data
.
forEach
(
item
=>
{
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
<
childrenDepth
;
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
)
if
(
existingOption
)
{
if
(
existingOption
)
{
if
(
i
===
levels
.
leng
th
-
1
)
{
if
(
i
===
childrenDep
th
-
1
)
{
continue
continue
}
}
currentLevel
=
existingOption
.
children
currentLevel
=
existingOption
.
children
...
@@ -88,7 +94,7 @@ Page({
...
@@ -88,7 +94,7 @@ Page({
children
:
[]
children
:
[]
}
}
if
(
text
&&
value
)
currentLevel
.
push
(
newOption
)
if
(
text
&&
value
)
currentLevel
.
push
(
newOption
)
if
(
i
===
levels
.
leng
th
-
1
)
{
if
(
i
===
childrenDep
th
-
1
)
{
delete
newOption
.
children
delete
newOption
.
children
}
}
currentLevel
=
newOption
.
children
currentLevel
=
newOption
.
children
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment