Commit 4f2ad638 authored by Facius's avatar Facius

improvement: 首页跳转逻辑及接口

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