Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
study
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Damon
study
Commits
5263292f
Commit
5263292f
authored
Jul 16, 2021
by
Facius
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-v1.0.0' of
https://git.banshouhui.com/wuzhenzhe/study
into dev-v1.0.0
parents
79b17618
2a9c6ee0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
45 deletions
+107
-45
index.vue
src/components/answer-sheet/index.vue
+61
-30
index.vue
src/components/swiper-limited-load/index.vue
+28
-10
answer.vue
src/pages/learn/answer.vue
+18
-5
No files found.
src/components/answer-sheet/index.vue
View file @
5263292f
...
@@ -6,25 +6,46 @@
...
@@ -6,25 +6,46 @@
:key=
"index"
:key=
"index"
@
click=
"select(index)"
@
click=
"select(index)"
>
>
<view
v-if=
"!item.confirm"
:class=
"['icons',
{
'checked': item.checked
}]">
<view
v-if=
"!item.confirm"
:class=
"['icons',
{
checked: item.checked
}]">
{{
item
.
sort
}}
{{
item
.
sort
}}
</view>
</view>
<view
v-else
:class=
"[rightKey.includes(item.sort) === true ? 'success' : 'error']"
></view>
<view
v-else
:class=
"[rightKey.includes(item.sort) ? 'success' : 'error']"
></view>
<view
class=
"text"
>
{{
item
.
text
}}
</view>
<view
class=
"text"
>
{{
item
.
text
}}
</view>
</view>
</view>
<view
class=
"btn"
v-if=
"rightKey.length > 1"
>
<view
class=
"btn"
v-if=
"rightKey.length > 1"
>
<view
:class=
"['confirm',
{'active': getCheckedNum}]" @click="confirmMultiple">确定
</view>
<view
:class=
"['confirm',
{ active: getCheckedNum }]"
@click="confirmMultiple"
>确定
</view
>
</view>
</view>
</view>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
const
equar
=
(
a
,
b
)
=>
{
// 判断数组的长度
if
(
a
.
length
!==
b
.
length
)
{
return
false
}
else
{
// 循环遍历数组的值进行比较
for
(
let
i
=
0
;
i
<
a
.
length
;
i
++
)
{
if
(
a
[
i
]
!==
b
[
i
])
{
return
false
}
}
return
true
}
}
export
default
{
export
default
{
name
:
'answerSheet'
,
name
:
'answerSheet'
,
props
:
{
props
:
{
answerList
:
{
answerList
:
{
type
:
Array
,
type
:
Array
,
default
:
[]
default
:
[]
,
},
},
multiple
:
{
multiple
:
{
type
:
Boolean
,
type
:
Boolean
,
...
@@ -32,18 +53,19 @@ export default {
...
@@ -32,18 +53,19 @@ export default {
},
},
rightKey
:
{
rightKey
:
{
type
:
Array
,
type
:
Array
,
default
:
[]
default
:
[]
,
}
}
,
},
},
data
()
{
data
()
{
return
{
return
{
lists
:
[],
lists
:
[],
submitStatus
:
false
,
submitStatus
:
false
,
answer
:
''
,
}
}
},
},
watch
:
{
watch
:
{
answerList
:
{
answerList
:
{
handler
:
function
(
newValue
,
oldValue
)
{
handler
:
function
(
newValue
,
oldValue
)
{
if
(
newValue
.
length
>
0
)
{
if
(
newValue
.
length
>
0
)
{
this
.
lists
=
newValue
.
map
((
v
)
=>
{
this
.
lists
=
newValue
.
map
((
v
)
=>
{
v
.
checked
=
false
v
.
checked
=
false
...
@@ -52,43 +74,53 @@ export default {
...
@@ -52,43 +74,53 @@ export default {
})
})
}
}
},
},
immediate
:
true
immediate
:
true
,
}
}
,
},
},
computed
:
{
computed
:
{
getCheckedNum
()
{
getCheckedNum
()
{
const
num
=
this
.
lists
.
filter
(
v
=>
v
.
checked
)
const
num
=
this
.
lists
.
filter
(
(
v
)
=>
v
.
checked
)
return
num
.
length
>
1
?
true
:
false
return
num
.
length
>
1
?
true
:
false
}
}
,
},
},
methods
:
{
methods
:
{
select
(
index
)
{
select
(
index
)
{
// 已选定
if
(
this
.
submitStatus
)
return
if
(
this
.
submitStatus
)
return
if
(
!
this
.
multiple
)
{
if
(
!
this
.
multiple
)
{
this
.
lists
.
forEach
(
v
=>
{
// 非多选处理
this
.
lists
.
forEach
((
v
)
=>
{
v
.
checked
=
false
// 勾选
v
.
checked
=
false
// 勾选
v
.
confirm
=
false
// 确认答案
v
.
confirm
=
false
// 确认答案
})
})
this
.
$set
(
this
.
lists
[
index
],
'confirm'
,
true
)
this
.
$set
(
this
.
lists
[
index
],
'confirm'
,
true
)
// 判断所选答案是否正确
this
.
answer
=
this
.
rightKey
.
includes
(
this
.
lists
[
index
].
sort
)
?
'pass'
:
'fail'
}
}
this
.
$set
(
this
.
lists
[
index
],
'checked'
,
!
this
.
lists
[
index
].
checked
)
this
.
$set
(
this
.
lists
[
index
],
'checked'
,
!
this
.
lists
[
index
].
checked
)
// 单选、判断提交答案
if
(
!
this
.
multiple
)
this
.
submitAnswer
()
if
(
!
this
.
multiple
)
this
.
submitAnswer
()
},
},
//
确认多选
答案
//
多选提交
答案
confirmMultiple
()
{
confirmMultiple
()
{
const
num
=
this
.
lists
.
filter
(
v
=>
v
.
checked
)
const
num
=
this
.
lists
.
filter
(
(
v
)
=>
v
.
checked
)
if
(
num
.
length
>
1
)
{
if
(
num
.
length
>
1
)
{
this
.
lists
.
forEach
(
v
=>
{
// 判断所选答案是否正确
if
(
this
.
rightKey
.
includes
(
v
.
sort
))
this
.
$set
(
v
,
'checked'
,
true
)
const
checkedList
=
num
.
map
((
v
)
=>
v
.
sort
)
if
(
v
.
checked
)
this
.
$set
(
v
,
'confirm'
,
true
)
this
.
answer
=
equar
(
checkedList
,
this
.
rightKey
)
?
'pass'
:
'fail'
// 处理显示逻辑
this
.
lists
.
forEach
((
v
)
=>
{
if
(
this
.
rightKey
.
includes
(
v
.
sort
))
this
.
$set
(
v
,
'checked'
,
true
)
if
(
v
.
checked
)
this
.
$set
(
v
,
'confirm'
,
true
)
})
})
this
.
submitAnswer
()
this
.
submitAnswer
()
}
}
},
},
submitAnswer
()
{
submitAnswer
()
{
this
.
submitStatus
=
true
this
.
submitStatus
=
true
this
.
$emit
(
'change'
)
this
.
$emit
(
'change'
,
this
.
answer
)
}
}
,
},
},
}
}
</
script
>
</
script
>
...
@@ -100,8 +132,8 @@ export default {
...
@@ -100,8 +132,8 @@ export default {
width
:
100%
;
width
:
100%
;
.icons
{
.icons
{
font-size
:
28rpx
;
font-size
:
28rpx
;
color
:
#191
C
27
;
color
:
#191
c
27
;
border
:
2rpx
solid
#9
EA5BB
;
border
:
2rpx
solid
#9
ea5bb
;
text-align
:
center
;
text-align
:
center
;
width
:
40rpx
;
width
:
40rpx
;
height
:
40rpx
;
height
:
40rpx
;
...
@@ -109,8 +141,8 @@ export default {
...
@@ -109,8 +141,8 @@ export default {
border-radius
:
10rpx
;
border-radius
:
10rpx
;
}
}
.checked
{
.checked
{
background
:
#2953
FF
;
background
:
#2953
ff
;
border
:
2rpx
solid
#2953
FF
;
border
:
2rpx
solid
#2953
ff
;
color
:
#fff
;
color
:
#fff
;
}
}
.success
{
.success
{
...
@@ -118,8 +150,8 @@ export default {
...
@@ -118,8 +150,8 @@ export default {
height
:
40rpx
;
height
:
40rpx
;
line-height
:
40rpx
;
line-height
:
40rpx
;
border-radius
:
10rpx
;
border-radius
:
10rpx
;
background
:
#2953
FF
;
background
:
#2953
ff
;
border
:
2rpx
solid
#2953
FF
;
border
:
2rpx
solid
#2953
ff
;
text-align
:
center
;
text-align
:
center
;
}
}
.success
:before
{
.success
:before
{
...
@@ -131,8 +163,8 @@ export default {
...
@@ -131,8 +163,8 @@ export default {
height
:
40rpx
;
height
:
40rpx
;
line-height
:
40rpx
;
line-height
:
40rpx
;
border-radius
:
10rpx
;
border-radius
:
10rpx
;
background
:
#
FA5A
49
;
background
:
#
fa5a
49
;
border
:
2rpx
solid
#
FA5A
49
;
border
:
2rpx
solid
#
fa5a
49
;
text-align
:
center
;
text-align
:
center
;
}
}
.error
:before
{
.error
:before
{
...
@@ -151,7 +183,7 @@ export default {
...
@@ -151,7 +183,7 @@ export default {
width
:
400rpx
;
width
:
400rpx
;
height
:
100rpx
;
height
:
100rpx
;
line-height
:
100rpx
;
line-height
:
100rpx
;
background
:
#
D4D7DF
;
background
:
#
d4d7df
;
color
:
#fff
;
color
:
#fff
;
border-radius
:
50rpx
;
border-radius
:
50rpx
;
font-size
:
32rpx
;
font-size
:
32rpx
;
...
@@ -159,9 +191,8 @@ export default {
...
@@ -159,9 +191,8 @@ export default {
text-align
:
center
;
text-align
:
center
;
}
}
.active
{
.active
{
background
:
#2953
FF
;
background
:
#2953
ff
;
}
}
}
}
}
}
</
style
>
</
style
>
src/components/swiper-limited-load/index.vue
View file @
5263292f
<
template
>
<
template
>
<view>
<view
class=
"swipers"
>
<swiper
<swiper
style=
"
height: 80vh
;"
style=
"
flex: 1
;"
:duration=
"swiperDuration"
:duration=
"swiperDuration"
:current=
"swiperCurrent"
:current=
"swiperCurrent"
@
change=
"swiperChange"
@
change=
"swiperChange"
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
>
>
<swiper-item
v-for=
"(item, index) in swiperList"
:key=
"index"
>
<swiper-item
v-for=
"(item, index) in swiperList"
:key=
"index"
>
<view
class=
"u-flex subject"
>
<view
class=
"u-flex subject"
>
<view
class=
"title"
><text>
{{
type
[
item
.
type
-
1
]
}}
</text>
{{
item
.
title
}}
</view>
<view
class=
"title"
><text>
{{
t
itleT
ype
[
item
.
type
-
1
]
}}
</text>
{{
item
.
title
}}
</view>
<view
class=
"content"
>
<view
class=
"content"
>
<answer-sheet
<answer-sheet
ref=
"answerSheet"
ref=
"answerSheet"
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
@
change=
"answerChange"
@
change=
"answerChange"
></answer-sheet>
></answer-sheet>
</view>
</view>
<view
class=
"explain"
>
<view
class=
"explain"
v-if=
"type === 1"
>
<answer-explanation
:answer=
"item.answer"
:explain=
"item.explain"
></answer-explanation>
<answer-explanation
v-show=
"model === 2 || errShow"
:answer=
"item.answer"
:explain=
"item.explain"
></answer-explanation>
</view>
</view>
</view>
</view>
</swiper-item>
</swiper-item>
...
@@ -57,6 +57,14 @@ export default {
...
@@ -57,6 +57,14 @@ export default {
type
:
Number
,
type
:
Number
,
default
:
0
default
:
0
},
},
type
:
{
type
:
Number
,
default
:
1
},
model
:
{
type
:
Number
,
default
:
1
},
// 值为0禁止切换动画
// 值为0禁止切换动画
swiperDuration
:
{
swiperDuration
:
{
type
:
String
,
type
:
String
,
...
@@ -70,13 +78,15 @@ export default {
...
@@ -70,13 +78,15 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
type
:
[
'单选题'
,
'判断题'
,
'多选题'
],
t
itleT
ype
:
[
'单选题'
,
'判断题'
,
'多选题'
],
// 滑动到的位置
// 滑动到的位置
swiperIndex
:
0
,
swiperIndex
:
0
,
// 此值控制swiper的位置
// 此值控制swiper的位置
swiperCurrent
:
0
,
swiperCurrent
:
0
,
// 当前swiper渲染的items
// 当前swiper渲染的items
swiperList
:
[]
swiperList
:
[],
// 错题显示解释
errShow
:
false
}
}
},
},
watch
:
{
watch
:
{
...
@@ -115,15 +125,15 @@ export default {
...
@@ -115,15 +125,15 @@ export default {
answerChange
(
e
)
{
answerChange
(
e
)
{
// this.swiperCurrent = this.swiperCurrent + 1
// this.swiperCurrent = this.swiperCurrent + 1
this
.
$emit
(
"answerChange"
,
e
)
this
.
$emit
(
"answerChange"
,
e
)
},
this
.
errShow
=
e
===
'fail'
confirmMultiple
(
index
)
{
console
.
log
(
"e"
,
e
)
this
.
$refs
.
answerSheet
[
index
].
confirmMultiple
()
},
},
clear
()
{
clear
()
{
this
.
list
=
[]
this
.
list
=
[]
this
.
swiperList
=
[]
this
.
swiperList
=
[]
},
},
swiperChange
:
function
(
e
)
{
swiperChange
:
function
(
e
)
{
this
.
errShow
=
false
let
current
=
e
.
detail
.
current
let
current
=
e
.
detail
.
current
let
lastIndex
=
this
.
swiperIndex
let
lastIndex
=
this
.
swiperIndex
let
currentItem
=
this
.
swiperList
[
current
]
let
currentItem
=
this
.
swiperList
[
current
]
...
@@ -223,6 +233,13 @@ export default {
...
@@ -223,6 +233,13 @@ export default {
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.swipers
{
height
:
100%
;
display
:
flex
;
flex-direction
:
column
;
swiper-item
{
overflow
:
auto
;
}
.subject
{
.subject
{
flex-flow
:
column
;
flex-flow
:
column
;
padding
:
20rpx
;
padding
:
20rpx
;
...
@@ -252,4 +269,5 @@ export default {
...
@@ -252,4 +269,5 @@ export default {
padding-top
:
50rpx
;
padding-top
:
50rpx
;
}
}
}
}
}
</
style
>
</
style
>
src/pages/learn/answer.vue
View file @
5263292f
...
@@ -24,6 +24,8 @@
...
@@ -24,6 +24,8 @@
:swiperDuration=
"swiperDuration"
:swiperDuration=
"swiperDuration"
:list=
"list"
:list=
"list"
:current=
"current"
:current=
"current"
:type=
"type"
:model=
"model"
@
answerChange=
"answerChange"
@
answerChange=
"answerChange"
@
change=
"swiperChange"
@
change=
"swiperChange"
>
>
...
@@ -37,11 +39,11 @@
...
@@ -37,11 +39,11 @@
</view>
</view>
</view>
</view>
<view
class=
"u-flex"
>
<view
class=
"u-flex"
>
<view
class=
"c-list"
v-if=
"type === 1"
>
<view
class=
"c-list"
v-if=
"type === 1"
@
click=
"collection"
>
<u-icon
name=
"star"
color=
"#5A6073"
size=
"40"
></u-icon>
<u-icon
name=
"star"
color=
"#5A6073"
size=
"40"
></u-icon>
<text>
收藏
</text>
<text>
收藏
</text>
</view>
</view>
<view
class=
"c-list"
v-else
>
<view
class=
"c-list"
v-else
@
click=
"handPapers"
>
<u-icon
name=
"file-text"
color=
"#5A6073"
size=
"40"
></u-icon>
<u-icon
name=
"file-text"
color=
"#5A6073"
size=
"40"
></u-icon>
<text>
交卷
</text>
<text>
交卷
</text>
</view>
</view>
...
@@ -198,9 +200,20 @@ export default {
...
@@ -198,9 +200,20 @@ export default {
changeModel
(
i
)
{
changeModel
(
i
)
{
this
.
model
=
i
this
.
model
=
i
},
},
collection
()
{
console
.
log
(
"this.list[this.currentIndex]"
,
this
.
list
[
this
.
currentIndex
])
console
.
log
(
"收藏"
)
},
// 作答完毕
answerChange
(
e
)
{
answerChange
(
e
)
{
console
.
log
(
'e'
,
e
)
console
.
log
(
'e'
,
e
)
},
},
// 交卷
handPapers
()
{
this
.
visible
=
true
console
.
log
(
"交卷"
)
},
// 提前交卷
submit
()
{
submit
()
{
console
.
log
(
"提前交卷"
)
console
.
log
(
"提前交卷"
)
}
}
...
@@ -217,7 +230,7 @@ export default {
...
@@ -217,7 +230,7 @@ export default {
background-repeat
:
no-repeat
;
background-repeat
:
no-repeat
;
.head
{
.head
{
width
:
100%
;
width
:
100%
;
flex
:
1
;
height
:
90rpx
;
.tab
{
.tab
{
margin
:
10rpx
auto
;
margin
:
10rpx
auto
;
border
:
2rpx
solid
#2953FF
;
border
:
2rpx
solid
#2953FF
;
...
@@ -235,7 +248,7 @@ export default {
...
@@ -235,7 +248,7 @@ export default {
}
}
}
}
.count-down
{
.count-down
{
color
:
#5A6073
;
color
:
#5A6073
;
font-size
:
32rpx
;
font-size
:
32rpx
;
margin
:
10rpx
auto
;
margin
:
10rpx
auto
;
width
:
230rpx
;
width
:
230rpx
;
...
@@ -243,7 +256,7 @@ export default {
...
@@ -243,7 +256,7 @@ export default {
}
}
.swiper
{
.swiper
{
width
:
100%
;
width
:
100%
;
flex
:
1
;
flex
:
1
;
}
}
.bottom
{
.bottom
{
width
:
100%
;
width
:
100%
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment