Commit 809fd407 authored by Facius's avatar Facius

feat: 接口调试

parent 291d5d75
...@@ -120,6 +120,14 @@ let learnApiFun = function(vm) { ...@@ -120,6 +120,14 @@ let learnApiFun = function(vm) {
let examCancel = async (params = {}) => let examCancel = async (params = {}) =>
await vm.$u.post(`/rest/question/exam/cancel/${params.id}`, params) await vm.$u.post(`/rest/question/exam/cancel/${params.id}`, params)
// 提交问卷
let submitSurvey = async (params = {}) =>
await vm.$u.post('/rest/survey/submit/survey', params)
// 领取奖励
let receiveAward = async (params = {}) =>
await vm.$u.post('/rest/reward/receive/award', params)
const learnApi = { const learnApi = {
getQuestion, getQuestion,
getQuestionTotal, getQuestionTotal,
...@@ -146,7 +154,9 @@ let learnApiFun = function(vm) { ...@@ -146,7 +154,9 @@ let learnApiFun = function(vm) {
studyRecord, studyRecord,
inProgress, inProgress,
examSuspend, examSuspend,
examCancel examCancel,
submitSurvey,
receiveAward
} }
return learnApi return learnApi
} }
......
...@@ -71,11 +71,7 @@ export default { ...@@ -71,11 +71,7 @@ export default {
}, },
computed: { computed: {
questionData() { questionData() {
return this.isAdd return (this.isAdd ? this.info : this.info && this.info.echoMap && this.info.echoMap.questionWarehouseId) || {}
? this.info
: this.info &&
this.info.echoMap &&
this.info.echoMap.questionWarehouseId
}, },
examTypeText() { examTypeText() {
var str = this.questionData.echoMap && this.questionData.echoMap.type var str = this.questionData.echoMap && this.questionData.echoMap.type
...@@ -178,7 +174,7 @@ export default { ...@@ -178,7 +174,7 @@ export default {
this.$emit('action', this.questionData, this.type) this.$emit('action', this.questionData, this.type)
}, },
handleClickCell() { handleClickCell() {
this.$emit('click', this.questionData) this.$emit('click', this.questionData, this.info.echoMap && this.info.echoMap.cardId)
}, },
getTodayDate() { getTodayDate() {
let day = new Date() let day = new Date()
......
...@@ -40,11 +40,12 @@ ...@@ -40,11 +40,12 @@
<view class="bottom-view"> <view class="bottom-view">
<u-button <u-button
:customStyle="buttonStyle" :customStyle="buttonStyle"
:loading="loading"
@click="handleClick" @click="handleClick"
type="primary" type="primary"
shape="circle" shape="circle"
> >
绑定学习卡 提交
</u-button> </u-button>
</view> </view>
</view> </view>
...@@ -54,6 +55,7 @@ ...@@ -54,6 +55,7 @@
export default { export default {
data() { data() {
return { return {
loading: false,
list: [ list: [
{ {
title: '您通过什么渠道了解到模考大师?', title: '您通过什么渠道了解到模考大师?',
...@@ -155,14 +157,55 @@ export default { ...@@ -155,14 +157,55 @@ export default {
for (var question of this.list[index].answerList) { for (var question of this.list[index].answerList) {
question.checked = false question.checked = false
} }
// 没有选中有计划就重置第三项
if (!this.bePlanning) {
for (var question of this.list[2].answerList) {
question.checked = false
}
}
this.list[index].answerList[i].checked = event.value this.list[index].answerList[i].checked = event.value
}, },
handleClick() { handleClick() {
if (!this.checked) return if (!this.checked) return
this.$u.route({ this.loading = true
url: 'pages/advertisement/results', var options = []
type: 'redirectTo', var i = 0
}) for (var item of this.list) {
var data = {questionId: i + 1, questionName: item.title}
for (var question of item.answerList) {
if (question.checked == true) {
data.answer = question.text
}
}
i ++
options.push(data)
}
let params = {
options: options,
surveyId: 1,
surveyName: "调查小问卷"
}
let trackParams = {
openId: this.openId,
nickname: this.userInfo.nickName,
...options
}
getApp().track("submitSurvey", trackParams)
this.$u.api
.submitSurvey(params)
.then((res) => {
// this.loading = false
this.$u.route({
url: 'pages/advertisement/results',
type: 'redirectTo',
})
})
.catch((err) => {
// this.loading = false
console.log(err)
})
}, },
}, },
} }
...@@ -170,8 +213,12 @@ export default { ...@@ -170,8 +213,12 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
/deep/ .u-checkbox__label { /deep/ .u-checkbox__label {
width: 220rpx; width: 300rpx;
padding-left: 6rpx; padding-left: 80rpx;
height: 104rpx;
display: flex;
align-items: center;
margin-left: -60rpx !important;
} }
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 0; width: 0;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<QuestionBankCell <QuestionBankCell
:info="label" :info="label"
:beSelected=" :beSelected="
label.echoMap && label.echoMap.questionWarehouseId.id == selectedData.id selectedData.id && (label.echoMap && label.echoMap.questionWarehouseId.id == selectedData.id)
" "
type="select" type="select"
@click="handleClickCell" @click="handleClickCell"
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<u-button <u-button
:customStyle="buttonStyle" :customStyle="buttonStyle"
@click="handleClick" @click="handleClick"
:loading="loading"
type="primary" type="primary"
shape="circle" shape="circle"
> >
...@@ -48,8 +49,9 @@ export default { ...@@ -48,8 +49,9 @@ export default {
data() { data() {
return { return {
list: [], // 已选题库列表 list: [], // 已选题库列表
loading: true, loading: false,
selectedData: {}, selectedData: {},
cardData: {}
} }
}, },
computed: { computed: {
...@@ -85,27 +87,43 @@ export default { ...@@ -85,27 +87,43 @@ export default {
this.loadList() // 获取已选题库列表 this.loadList() // 获取已选题库列表
}, },
methods: { methods: {
handleClickCell(questionData) { handleClickCell(questionData, cardData) {
this.selectedData = questionData this.selectedData = questionData
this.cardData = cardData
}, },
handleClick() { handleClick() {
if (!this.selected) return if (!this.selected) return
// 切换题库 this.loading = true
this.setPageInfo(this.selectedData)
this.$u.vuex('searchHistory', []) let params = {
this.$u.route({ questionWarehouseId: this.selectedData.id,
type: 'back', cardId: this.cardData.id,
}) sourse: 'SURVEY' // 问卷调查
}, }
// 获取题库列表
loadList() {
// 埋点-获取题库列表
let trackParams = { let trackParams = {
openId: this.openId, openId: this.openId,
nickname: this.userInfo.nickName, nickname: this.userInfo.nickName,
...params
} }
getApp().track('getUserQuestionWareHouse-results', trackParams) getApp().track("receiveAward", trackParams)
this.$u.api
.receiveAward(params)
.then((res) => {
// this.loading = false
// 切换题库
this.setPageInfo(this.selectedData)
this.$u.vuex('searchHistory', [])
this.$u.route({
type: 'back',
})
})
.catch((err) => {
// this.loading = false
console.log(err)
})
},
// 获取题库列表
loadList() {
this.$u.api this.$u.api
.getUserQuestionWareHouse() .getUserQuestionWareHouse()
.then((res) => { .then((res) => {
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
</view> </view>
</view> </view>
<AdvertisementSwiper v-if="showAdvertisement" @click="handleClickAdvertisement"/> <AdvertisementSwiper v-if="showAdvertisement" @click="handleClickAdvertisement"/>
<view class="bottom-view"> <view :class="['bottom-view', {'showAdvertisement': showAdvertisement}]">
<image <image
class="bottom-image" class="bottom-image"
:src="slognImage" :src="slognImage"
...@@ -278,7 +278,15 @@ export default { ...@@ -278,7 +278,15 @@ export default {
return `width:570rpx;margin-top:${this.tipTop0}rpx` return `width:570rpx;margin-top:${this.tipTop0}rpx`
}, },
showAdvertisement() { showAdvertisement() {
return true return this.selected.id > 0 && (this.filledQuestionnaire || this.notQuestionnaire) || true
},
// 已参与调查未领取奖励
filledQuestionnaire() {
return this.questionnaireStatus == '已答卷未领取'
},
// 未参与调查
notQuestionnaire() {
return this.questionnaireStatus == '未答卷'
} }
}, },
watch: { watch: {
...@@ -632,7 +640,7 @@ export default { ...@@ -632,7 +640,7 @@ export default {
this.showMask = true this.showMask = true
}, },
}) })
}, 2000) },1500)
} }
}) })
}, },
...@@ -653,8 +661,14 @@ export default { ...@@ -653,8 +661,14 @@ export default {
}) })
}, },
handleClickAdvertisement(id) { handleClickAdvertisement(id) {
var path = 'questionnaire'
if (this.notQuestionnaire) {
path = 'questionnaire'
} else if (this.filledQuestionnaire) {
path = 'results'
}
this.$u.route({ this.$u.route({
url: 'pages/advertisement/questionnaire', url: 'pages/advertisement/' + path,
params: { params: {
advertisementId: id, advertisementId: id,
}, },
...@@ -669,7 +683,8 @@ export default { ...@@ -669,7 +683,8 @@ export default {
this.$u.api this.$u.api
.inProgress() .inProgress()
.then((res) => { .then((res) => {
// this.havingExamination = res && res.pop().id || false let data = res && res.pop() || {}
this.havingExamination = data.id || false
}) })
.catch((err) => { .catch((err) => {
console.log(err) console.log(err)
...@@ -855,7 +870,10 @@ export default { ...@@ -855,7 +870,10 @@ export default {
justify-content: center; justify-content: center;
font-size: 26rpx; font-size: 26rpx;
color: #adbdd4; color: #adbdd4;
margin-top: 32rpx; margin-top: 112rpx;
&.showAdvertisement {
margin-top: 32rpx;
}
.bottom-image { .bottom-image {
width: 520rpx; width: 520rpx;
height: 28rpx; height: 28rpx;
......
...@@ -252,7 +252,7 @@ export default { ...@@ -252,7 +252,7 @@ export default {
if (e?.passPoint) this.passPoint = parseInt(e.passPoint) // 合格分数 if (e?.passPoint) this.passPoint = parseInt(e.passPoint) // 合格分数
if (e?.totalPoint) this.totalPoint = parseInt(e.totalPoint) // 考试总分/总条数 if (e?.totalPoint) this.totalPoint = parseInt(e.totalPoint) // 考试总分/总条数
if (e?.duration) this.timestamp = parseInt(e.duration) * 60 // 考试时间 if (e?.duration) this.timestamp = parseInt(e.duration) * 60 // 考试时间
debugger
switch (this.source) { switch (this.source) {
case 1: case 1:
case 2: case 2:
...@@ -323,9 +323,11 @@ export default { ...@@ -323,9 +323,11 @@ export default {
// 考试 // 考试
if (this.type === 2) { if (this.type === 2) {
this.pageSize = this.totalPoint this.pageSize = this.totalPoint
total = this.totalPoint if (total == 0) {
this.timestamp = res.remainderSecond total = this.totalPoint
}
} }
this.total = total this.total = total
// 练习模式-初始化答题卡列表 // 练习模式-初始化答题卡列表
...@@ -333,8 +335,15 @@ export default { ...@@ -333,8 +335,15 @@ export default {
this.cachePageDataMap = new Map() this.cachePageDataMap = new Map()
// 上次答到了第几题 // 上次答到了第几题
let index = let index = 0
this.source === 1 ? this.lastIndex[this.questionWarehouseId] || 0 : 0 if (!i) {
if (this.source === 3 && res.inProcessQuestionIndex && Number(res.inProcessQuestionIndex) > 0) {
this.timestamp = res.remainderSecond
index = Number(res.inProcessQuestionIndex)
} else if (this.source === 1) {
index = this.lastIndex[this.questionWarehouseId] || 0
}
}
this.refresh(i ? i : index) this.refresh(i ? i : index)
// } // }
}) })
...@@ -496,6 +505,10 @@ export default { ...@@ -496,6 +505,10 @@ export default {
item.result = status item.result = status
item.errShow = this.type === 2 ? true : status === 'fail' item.errShow = this.type === 2 ? true : status === 'fail'
item.userAnswer = userAnswer item.userAnswer = userAnswer
if (this.currentIndex + 1 < this.total) {
const nextItem = this.list.find((v) => v.index === this.currentIndex + 1)
item.inProcessQuestionId = nextItem && nextItem.id
}
// 保存答案 // 保存答案
if (this.model === 1) this.saveAnswer(item) if (this.model === 1) this.saveAnswer(item)
...@@ -562,6 +575,7 @@ export default { ...@@ -562,6 +575,7 @@ export default {
answer: info.userAnswer, answer: info.userAnswer,
answerRight: info.result === 'pass', answerRight: info.result === 'pass',
questionId: info.id, questionId: info.id,
inProcessQuestionId: info.inProcessQuestionId,
questionWarehouseId: this.questionWarehouseId, questionWarehouseId: this.questionWarehouseId,
recordId: this.recordId, recordId: this.recordId,
source: this.source, source: this.source,
......
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