Commit 9af057a3 authored by Damon's avatar Damon

feat: 收藏

parent 4336834e
......@@ -4,19 +4,31 @@ let learnApiFun = function(vm) {
let getQuestion = async (params = {}) =>
await vm.$u.post('/rest/question/query/getQuestion', params)
let getQuestionTotal = async (params = {}) =>
await vm.$u.post('/rest/question/query/getQuestionTotal', params)
let answer = async (params = {}) =>
await vm.$u.post('/rest/question/save/answer', params)
let subjectList = async (params = {}) =>
await vm.$u.get('/rest/question/query/subjectList', params)
let getQuestionWarehouse = async (subjectId, params = {}) =>
await vm.$u.get(
'/rest/question/query/getQuestionWarehouse/' + subjectId,
params
)
let getProvinceList = async (params = {}) =>
await vm.$u.get('/rest/question/getProvinceList', params)
let joinCollection = async (params = {}) =>
await vm.$u.get('/rest/question/join/collection/'+params.questionId, params)
let removeCollection = async (params = {}) =>
await vm.$u.get('/rest/question/remove/collection/'+params.questionId, params)
const learnApi = {
getQuestion,
getQuestionTotal,
......@@ -24,6 +36,8 @@ let learnApiFun = function(vm) {
subjectList,
getQuestionWarehouse,
getProvinceList,
joinCollection,
removeCollection
}
return learnApi
}
......
......@@ -86,7 +86,7 @@ export default {
getCheckedNum() {
const num = this.lists.filter((v) => v.checked)
return num.length > 1 ? true : false
},
}
},
methods: {
select(index) {
......@@ -165,27 +165,19 @@ export default {
height: 40rpx;
line-height: 40rpx;
border-radius: 10rpx;
background: #2953ff;
border: 2rpx solid #2953ff;
background: url('https://qn-static.banshouhui.com/study/pass.png') no-repeat;
background-size: 40rpx 40rpx;
text-align: center;
}
.success:before {
content: '\2714';
color: #fff;
}
.error {
width: 40rpx;
height: 40rpx;
line-height: 40rpx;
border-radius: 10rpx;
background: #fa5a49;
border: 2rpx solid #fa5a49;
background: url('https://qn-static.banshouhui.com/study/fail.png') no-repeat;
background-size: 40rpx 40rpx;
text-align: center;
}
.error:before {
content: '\2716';
color: #fff;
}
.text {
color: #191C27;
padding-left: 20rpx;
......
......@@ -59,10 +59,11 @@
<view
class="c-list"
v-if="type === 1 || type === 3"
@click="collection"
@click="collection(collectionFlag)"
>
<u-icon name="star" color="#5A6073" size="40"></u-icon>
<text>收藏</text>
<u-icon v-show="!collectionFlag" name="star" color="#5A6073" size="40"></u-icon>
<u-icon v-show="collectionFlag" name="star-fill" color="#FF930D" size="40"></u-icon>
<text>{{ collectionFlag ? '已收藏' : '收藏' }}</text>
</view>
<view class="c-list" v-if="type === 2" @click="handPapers">
<u-icon name="file-text" color="#5A6073" size="40"></u-icon>
......@@ -177,7 +178,8 @@ export default {
questionWarehouseId: null,
// 1.顺序答题 2.随机练习 3.模拟考试 4.收藏答题 5.错题答题 6.专项练习-单选 7.专项练习-多选 8.专项练习-判断 9.专项练习-答案是
source: 0,
recordId: 0
recordId: 0,
currentItem: {}
}
},
computed: {
......@@ -193,6 +195,10 @@ export default {
currentNumber() {
let index = this.currentIndex
return index === -2 ? this.total : index + 1
},
collectionFlag() {
const info = this.list.find(v => v.index === this.currentIndex)
return info ? info.collectionFlag : false
}
},
onLoad(e) {
......@@ -254,7 +260,8 @@ export default {
})
},
// 切换
swiperChange(e) {
swiperChange(e, currentItem) {
this.currentItem = currentItem
let current = e.current
this.currentIndex = current
if (current == NO_PREV_PAGE || current == NO_NEXT_PAGE) {
......@@ -455,9 +462,10 @@ export default {
})
},
// 收藏
collection() {
console.log('this.list[this.currentIndex]', this.list[this.currentIndex])
console.log('收藏')
collection(status) {
const info = this.list.find(v => v.index === this.currentIndex)
const action = status ? 'joinCollection' : 'removeCollection'
this.$u.api[action]({questionId: info.id})
},
// 移除
remove() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment