Commit 9af057a3 authored by Damon's avatar Damon

feat: 收藏

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