Commit 4f2ad638 authored by Facius's avatar Facius

improvement: 首页跳转逻辑及接口

parent 2640a093
......@@ -49,6 +49,11 @@ let learnApiFun = function(vm) {
let removeError = async (params = {}) =>
await vm.$u.get('/rest/question/remove/error/' + params.questionId, params)
// 题库详情
let queryQuestionWarehouseById = async (questionWarehouseId) =>
await vm.$u.get(
'/rest/question/query/queryQuestionWarehouseById/' + questionWarehouseId
)
const learnApi = {
getQuestion,
getQuestionTotal,
......@@ -61,6 +66,7 @@ let learnApiFun = function(vm) {
joinCollection,
removeCollection,
removeError,
queryQuestionWarehouseById,
}
return learnApi
}
......
......@@ -164,10 +164,15 @@ export default {
produceData() {
var array = this.avatars.slice(1)
var a0 = this.$u.random(0, 49)
this.avatars = [
...array,
this.defaultUrl + (a0 > 9 ? 'a' : 'a0') + String(a0) + '.jpeg',
]
var str = (a0 > 9 ? 'a' : 'a0') + String(a0) + '.jpeg'
for (var item of this.avatars) {
if (item.indexOf(str) != -1) {
a0 = this.$u.random(0, 49)
str = (a0 > 9 ? 'a' : 'a0') + String(a0) + '.jpeg'
break
}
}
this.avatars = [...array, this.defaultUrl + str]
// this.avatars = [...array, this.defaultUrl + 'xunzhang.jpeg']
console.log(this.avatars.length)
......
......@@ -35,7 +35,7 @@
></image
><text v-if="item.title" class="detail-title">{{ item.title }}</text
><text class="detail-text">{{
item.key == 'location' ? provinceName : selected[item.key]
item.key == 'location' ? provinceName : info[item.key]
}}</text></view
>
</view>
......@@ -102,8 +102,9 @@ export default {
show: false,
type: 'select',
provinceList: [],
detail: {},
detail: { questionWarehouse: {} },
selected: {},
data: {},
}
},
computed: {
......@@ -114,7 +115,7 @@ export default {
return '/static/logo.png'
},
noExam() {
return this.$u.test.isEmpty(this.selected.name)
return this.$u.test.isEmpty(this.selected.title)
},
mokaodashiImage() {
return process.uniEnv.qn_base_url + 'mokaodashi.png'
......@@ -155,12 +156,11 @@ export default {
this.detail.questionWarehouse && this.detail.questionWarehouse.cardId,
provinceName: this.provinceName,
experience: this.selected.state,
pass: this.selected.pass,
number: this.selected.number,
pass: this.$u.random(95, 99) + '%',
days: this.detail.totalDayCount || 0,
today: this.detail.todayCount || 0,
total: this.detail.totalCount || 0,
// selected: this.selected,
totalExam: this.data.totalCount,
}
},
subItems() {
......@@ -197,7 +197,7 @@ export default {
},
provinceName() {
for (var item of this.provinceList) {
if (item.provinceId == this.selected.provinceId) {
if (item.id == this.selected.provinceId) {
return item.fullName + '题'
}
}
......@@ -219,7 +219,7 @@ export default {
},
{
title: '题目数:',
key: 'count',
key: 'totalExam',
image: process.uniEnv.qn_base_url + 'timushu.png',
imageStyle: 'width:28rpx;height:30rpx',
},
......@@ -228,7 +228,7 @@ export default {
},
onLoad() {
this.getProvinceList()
this.queryMyQuestionWarehouseDetail(0)
this.queryMyQuestionWarehouseDetail('1414854649273384960')
},
onShow() {
let pages = getCurrentPages()
......@@ -242,10 +242,42 @@ export default {
}
},
methods: {
// 题库详情
async queryQuestionWarehouseById(id) {
let res = await this.$u.api
.queryQuestionWarehouseById(id)
.catch((err) => {
console.log(err)
})
this.data = res || { questionWarehouse: {} }
this.selected = this.data.questionWarehouse
},
// 学生查询题库首页
async queryMyQuestionWarehouseDetail(id) {
let res = await this.$u.api.queryMyQuestionWarehouseDetail(id)
console.log(res)
this.provinceList = res
let res = await this.$u.api
.queryMyQuestionWarehouseDetail(id)
.catch((err) => {
console.log(err)
})
this.detail = res || { questionWarehouse: {} }
this.queryQuestionWarehouseById(res.questionWarehouse.questionWarehouseId)
// this.detail = res || {
// questionWarehouse: {
// cardId: 0,
// createTime: '',
// createdBy: 0,
// echoMap: {},
// id: 0,
// institutionId: 0,
// questionWarehouseId: 0,
// studentId: 0,
// updateTime: '',
// updatedBy: 0,
// },
// todayCount: 100,
// totalCount: 100,
// totalDayCount: 100,
// }
},
handleSelect() {
......@@ -257,12 +289,15 @@ export default {
// 每日一练
handleAnswer() {
if (this.selected.cardId) {
} else if (this.selected.name) {
} else if (this.selected.id) {
this.type = 'bound'
this.show = true
} else {
this.type = 'select'
this.show = true
// this.type = 'select'
// this.show = true
this.$u.route({
url: 'pages/learn/selectCategory',
})
}
},
handleClickLeftTop() {
......@@ -278,8 +313,12 @@ export default {
})
},
handleClickItem(key) {
if (this.selected.name) {
if (this.selected.id) {
// 跳转到学练记录
this.$u.route({
url: 'pages/learn/record?part=',
key,
})
} else {
this.$refs.uToast.show({
title: '暂未选题库',
......@@ -293,33 +332,44 @@ export default {
// ...
},
handleClickExam(index) {
if (index == 0) {
// 点击了全部试题
if (!this.info.cardId && this.info.experience) {
this.selected.state = false
// 体验
if (this.selected.cardId) {
// 已绑卡
if (index == 0) {
// 做题
// ...
} else {
// 正常做题
// 模拟考试
this.$u.route({
url: 'pages/learn/beginAnswer',
})
}
} else if (this.selected.id) {
// 已选题库
if (index == 0 && this.info.experience) {
// 体验
// ...
} else {
// 绑卡
this.type = 'bound'
this.show = true
}
} else {
// 点击了模拟考试
// 未选题库
this.$u.route({
url: 'pages/learn/beginAnswer',
url: 'pages/learn/selectCategory',
})
}
},
handleClick(path) {
// if (this.vuex_token) {
this.$u.route({
url: path,
})
// } else {
// this.$u.route({ url: 'pages/login/index' })
// }
if (!this.selected.id) {
this.$u.route({
url: 'pages/learn/selectCategory',
})
} else {
this.$u.route({
url: path,
})
}
},
async getProvinceList() {
let res = await this.$u.api.getProvinceList()
......
......@@ -97,6 +97,9 @@
<u-icon v-if="key != thirdKey" name="arrow-downward"></u-icon>
</view>
</PopView>
<view>
<u-toast ref="uToast" />
</view>
</view>
</template>
......@@ -241,16 +244,29 @@ export default {
let data = res[0]
this.setPageInfo(data)
// 学员增加自己的题库
let result = await this.$u.api.addQuestionWarehouse({
questionWarehouseId: data.id,
})
let result = await this.$u.api
.addQuestionWarehouse({
questionWarehouseId: data.id,
})
.catch((err) => {
console.log(err)
})
if (result) {
// 成功
this.showPop = false
uni.switchTab({
url: '/pages/index/index',
this.$refs.uToast.show({
title: '添加题库成功',
type: 'success',
duration: 1500,
callback: () => {
this.showPop = false
uni.switchTab({
url: '/pages/index/index',
})
},
})
} else {
this.showPop = false
}
},
changeIndex() {
......@@ -293,7 +309,6 @@ export default {
if (pages.length >= 1) {
var page = pages[0]
console.log('--------setPageInfo--------', info)
info.pass = this.$u.random(95, 99)
page.info = info
}
},
......
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