Commit c5abad0a authored by Facius's avatar Facius

feat: 接口调试

parent 809fd407
;(function() { ;(function() {
let NODE_ENV = 'dev' // dev:开发环境 | test:测试环境 | prod:生产环境 let NODE_ENV = 'test' // dev:开发环境 | test:测试环境 | prod:生产环境
let ENV_VAR = null let ENV_VAR = null
let VERSION = 'v1.3.0' let VERSION = 'v1.3.0'
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
......
...@@ -108,8 +108,7 @@ let learnApiFun = function(vm) { ...@@ -108,8 +108,7 @@ let learnApiFun = function(vm) {
// 获取进行中的考试记录 // 获取进行中的考试记录
let inProgress = async (params = {}) => let inProgress = async (params = {}) =>
await vm.$u.get( await vm.$u.get(
'/rest/question/exam/inProgress', '/rest/question/exam/inProgress/' + params.questionWarehouseId
params
) )
// 考试暂存 // 考试暂存
...@@ -128,6 +127,10 @@ let learnApiFun = function(vm) { ...@@ -128,6 +127,10 @@ let learnApiFun = function(vm) {
let receiveAward = async (params = {}) => let receiveAward = async (params = {}) =>
await vm.$u.post('/rest/reward/receive/award', params) await vm.$u.post('/rest/reward/receive/award', params)
// 获取问卷回答状态
let answerStatus = async (params = {}) =>
await vm.$u.get('/rest/survey/answer/status', params)
const learnApi = { const learnApi = {
getQuestion, getQuestion,
getQuestionTotal, getQuestionTotal,
...@@ -156,7 +159,8 @@ let learnApiFun = function(vm) { ...@@ -156,7 +159,8 @@ let learnApiFun = function(vm) {
examSuspend, examSuspend,
examCancel, examCancel,
submitSurvey, submitSurvey,
receiveAward receiveAward,
answerStatus
} }
return learnApi return learnApi
} }
......
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
return { return {
list: [{ list: [{
image: process.uniEnv.qn_base_url + 'wenjuandatiguagngao.jpg', image: process.uniEnv.qn_base_url + 'wenjuandatiguagngao.jpg',
title: '昨夜星辰昨夜风,画楼西畔桂堂东', id: 1
id: 0
} }
], ],
} }
......
...@@ -56,6 +56,7 @@ export default { ...@@ -56,6 +56,7 @@ export default {
data() { data() {
return { return {
loading: false, loading: false,
surveyId: 1,
list: [ list: [
{ {
title: '您通过什么渠道了解到模考大师?', title: '您通过什么渠道了解到模考大师?',
...@@ -183,7 +184,7 @@ export default { ...@@ -183,7 +184,7 @@ export default {
} }
let params = { let params = {
options: options, options: options,
surveyId: 1, surveyId: 1, // 问卷id,暂时写死
surveyName: "调查小问卷" surveyName: "调查小问卷"
} }
let trackParams = { let trackParams = {
......
...@@ -89,7 +89,7 @@ export default { ...@@ -89,7 +89,7 @@ export default {
methods: { methods: {
handleClickCell(questionData, cardData) { handleClickCell(questionData, cardData) {
this.selectedData = questionData this.selectedData = questionData
this.cardData = cardData this.cardData = cardData || {}
}, },
handleClick() { handleClick() {
if (!this.selected) return if (!this.selected) return
...@@ -98,7 +98,8 @@ export default { ...@@ -98,7 +98,8 @@ export default {
let params = { let params = {
questionWarehouseId: this.selectedData.id, questionWarehouseId: this.selectedData.id,
cardId: this.cardData.id, cardId: this.cardData.id,
sourse: 'SURVEY' // 问卷调查 sourse: 'SURVEY', // 问卷调查
bizId: 1,// bizId 问卷id,暂时写死
} }
let trackParams = { let trackParams = {
openId: this.openId, openId: this.openId,
......
...@@ -147,7 +147,8 @@ export default { ...@@ -147,7 +147,8 @@ export default {
showOrgId: false, // 显示机构id showOrgId: false, // 显示机构id
tipTop: 410, tipTop: 410,
tipTop0: 50, tipTop0: 50,
havingExamination: false // 有进行中的考试 havingExamination: false, // 有进行中的考试
questionnaireStatus: 10,
} }
}, },
computed: { computed: {
...@@ -278,15 +279,16 @@ export default { ...@@ -278,15 +279,16 @@ export default {
return `width:570rpx;margin-top:${this.tipTop0}rpx` return `width:570rpx;margin-top:${this.tipTop0}rpx`
}, },
showAdvertisement() { showAdvertisement() {
return this.selected.id > 0 && (this.filledQuestionnaire || this.notQuestionnaire) || true return this.selected.id > 0 && (this.filledQuestionnaire || this.notQuestionnaire)
}, },
// 0-未参与问卷, 1-已参与未领取奖品, 2-已参与已领取奖品, 10-已参与无奖品问卷
// 已参与调查未领取奖励 // 已参与调查未领取奖励
filledQuestionnaire() { filledQuestionnaire() {
return this.questionnaireStatus == '已答卷未领取' return this.questionnaireStatus == 1
}, },
// 未参与调查 // 未参与调查
notQuestionnaire() { notQuestionnaire() {
return this.questionnaireStatus == '未答卷' return this.questionnaireStatus == 0
} }
}, },
watch: { watch: {
...@@ -330,7 +332,6 @@ export default { ...@@ -330,7 +332,6 @@ export default {
this.queryMyQuestionWarehouseDetail(this.info.id || 0) this.queryMyQuestionWarehouseDetail(this.info.id || 0)
} }
this.chagefinishCount() this.chagefinishCount()
this.getInProgress()
} }
}, },
onUnload() {}, onUnload() {},
...@@ -361,6 +362,11 @@ export default { ...@@ -361,6 +362,11 @@ export default {
this.data = res || { questionWarehouse: {} } this.data = res || { questionWarehouse: {} }
if (!this.data.questionWarehouse) this.data.questionWarehouse = {} if (!this.data.questionWarehouse) this.data.questionWarehouse = {}
this.selected = this.data.questionWarehouse this.selected = this.data.questionWarehouse
// 是否有继续答题
this.getInProgress()
// 是否显示广告:调查问卷
this.answerStatus()
}) })
.catch((err) => { .catch((err) => {
this.loading = false this.loading = false
...@@ -670,18 +676,13 @@ export default { ...@@ -670,18 +676,13 @@ export default {
this.$u.route({ this.$u.route({
url: 'pages/advertisement/' + path, url: 'pages/advertisement/' + path,
params: { params: {
advertisementId: id, surveyId: id,
}, },
}) })
}, },
getInProgress() { getInProgress() {
let trackParams = {
openId: this.openId,
nickname: this.userInfo.nickName,
}
getApp().track("handPaper", trackParams)
this.$u.api this.$u.api
.inProgress() .inProgress({questionWarehouseId: this.selected.id})
.then((res) => { .then((res) => {
let data = res && res.pop() || {} let data = res && res.pop() || {}
this.havingExamination = data.id || false this.havingExamination = data.id || false
...@@ -689,6 +690,17 @@ export default { ...@@ -689,6 +690,17 @@ export default {
.catch((err) => { .catch((err) => {
console.log(err) console.log(err)
}) })
},
answerStatus() {
// surveyId 问卷id,暂时写死
this.$u.api
.answerStatus({surveyId: 1})
.then((res) => {
this.questionnaireStatus = res
})
.catch((err) => {
console.log(err)
})
} }
}, },
} }
......
...@@ -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:
...@@ -340,6 +340,9 @@ debugger ...@@ -340,6 +340,9 @@ debugger
if (this.source === 3 && res.inProcessQuestionIndex && Number(res.inProcessQuestionIndex) > 0) { if (this.source === 3 && res.inProcessQuestionIndex && Number(res.inProcessQuestionIndex) > 0) {
this.timestamp = res.remainderSecond this.timestamp = res.remainderSecond
index = Number(res.inProcessQuestionIndex) index = Number(res.inProcessQuestionIndex)
if (index > 0) {
this.continueToast()
}
} else if (this.source === 1) { } else if (this.source === 1) {
index = this.lastIndex[this.questionWarehouseId] || 0 index = this.lastIndex[this.questionWarehouseId] || 0
} }
...@@ -505,10 +508,7 @@ debugger ...@@ -505,10 +508,7 @@ debugger
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)
...@@ -571,7 +571,7 @@ debugger ...@@ -571,7 +571,7 @@ debugger
}, },
// 保存答案 // 保存答案
saveAnswer(info) { saveAnswer(info) {
const params = { const params = {list:[{
answer: info.userAnswer, answer: info.userAnswer,
answerRight: info.result === 'pass', answerRight: info.result === 'pass',
questionId: info.id, questionId: info.id,
...@@ -579,16 +579,22 @@ debugger ...@@ -579,16 +579,22 @@ debugger
questionWarehouseId: this.questionWarehouseId, questionWarehouseId: this.questionWarehouseId,
recordId: this.recordId, recordId: this.recordId,
source: this.source, source: this.source,
}]}
if (this.source === 3) {
params.remainderSecond = this.$refs.uCountDown.seconds
if (this.currentIndex + 1 < this.total) {
const nextItem = this.list.find((v) => v.index === this.currentIndex + 1)
params.inProcessQuestionId = nextItem && nextItem.id
}
} }
let time = this.$refs.uCountDown.seconds
let trackParams = { let trackParams = {
openId: this.openId, openId: this.openId,
nickname: this.userInfo.nickName, nickname: this.userInfo.nickName,
...params, ...params,
remainderSecond: time,
} }
getApp().track("submitAnswers", trackParams) getApp().track("submitAnswers", trackParams)
this.$u.api.answer({list: [params], remainderSecond: time}).then((res) => { this.$u.api.answer(params).then((res) => {
if (this.source === 2) { if (this.source === 2) {
// 每日一练 // 每日一练
if (this.daily.status && res === 10) this.dailyComplete() if (this.daily.status && res === 10) this.dailyComplete()
......
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