Commit 0323b236 authored by Facius's avatar Facius

improvement: 获取省份接口优化

parent e6afd79e
...@@ -22,7 +22,7 @@ let learnApiFun = function(vm) { ...@@ -22,7 +22,7 @@ let learnApiFun = function(vm) {
// 查询省份列表 // 查询省份列表
let getProvinceList = async (subjectId) => let getProvinceList = async (subjectId) =>
await vm.$u.get('/rest/question/getProvinceList' + subjectId) await vm.$u.get('/rest/question/getProvinceList/' + subjectId)
// 学生查询题库首页 // 学生查询题库首页
let queryMyQuestionWarehouseDetail = async (questionWarehouseId) => let queryMyQuestionWarehouseDetail = async (questionWarehouseId) =>
......
...@@ -47,9 +47,7 @@ ...@@ -47,9 +47,7 @@
:src="item.image" :src="item.image"
></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">{{ info[item.key] }}</text></view
item.key == 'location' ? provinceName : info[item.key]
}}</text></view
> >
</view> </view>
<SubjectStatistics <SubjectStatistics
...@@ -117,10 +115,10 @@ export default { ...@@ -117,10 +115,10 @@ export default {
visible: false, // 免费体验弹窗 visible: false, // 免费体验弹窗
show: false, show: false,
type: 'select', type: 'select',
provinceList: [], // provinceList: [],
detail: { questionWarehouse: {} }, detail: { questionWarehouse: {} },
selected: {}, selected: {},
data: {}, data: { questionWarehouse: {} },
// relationId: 0, // 绑卡用 // relationId: 0, // 绑卡用
loading: false, loading: false,
canExperience: false, // 体验资格 canExperience: false, // 体验资格
...@@ -166,7 +164,10 @@ export default { ...@@ -166,7 +164,10 @@ export default {
id: this.selected.id, id: this.selected.id,
cardId: cardId:
this.detail.questionWarehouse && this.detail.questionWarehouse.cardId, this.detail.questionWarehouse && this.detail.questionWarehouse.cardId,
provinceName: this.provinceName, provinceName:
this.data.questionWarehouse.echoMap &&
this.data.questionWarehouse.echoMap.provinceId &&
this.data.questionWarehouse.echoMap.provinceId.fullName,
experience: this.canExperience, experience: this.canExperience,
pass: this.$u.random(95, 99) + '%', pass: this.$u.random(95, 99) + '%',
days: this.detail.totalDayCount || 0, days: this.detail.totalDayCount || 0,
...@@ -208,19 +209,19 @@ export default { ...@@ -208,19 +209,19 @@ export default {
}, },
] ]
}, },
provinceName() { // provinceName() {
for (var item of this.provinceList) { // for (var item of this.provinceList) {
if (item.id == this.selected.provinceId) { // if (item.id == this.selected.provinceId) {
return item.fullName + '题' // return item.fullName + '题'
} // }
} // }
return '' // return ''
}, // },
detailItems() { detailItems() {
return [ return [
{ {
title: '', title: '',
key: 'location', key: 'provinceName',
image: process.uniEnv.qn_base_url + 'quyu.png', image: process.uniEnv.qn_base_url + 'quyu.png',
imageStyle: 'width:24rpx;height:28rpx', imageStyle: 'width:24rpx;height:28rpx',
}, },
...@@ -248,7 +249,7 @@ export default { ...@@ -248,7 +249,7 @@ export default {
onLoad() { onLoad() {
if (this.vuex_token) { if (this.vuex_token) {
this.loading = true this.loading = true
this.getProvinceList() // this.getProvinceList()
} }
}, },
onShow() { onShow() {
...@@ -269,7 +270,7 @@ export default { ...@@ -269,7 +270,7 @@ export default {
}, },
methods: { methods: {
initData() { initData() {
this.getProvinceList() // this.getProvinceList()
this.queryMyQuestionWarehouseDetail('0') this.queryMyQuestionWarehouseDetail('0')
}, },
// 检查是否具有体验资格 // 检查是否具有体验资格
...@@ -497,16 +498,16 @@ export default { ...@@ -497,16 +498,16 @@ export default {
}) })
} }
}, },
getProvinceList() { // getProvinceList() {
this.$u.api // this.$u.api
.getProvinceList() // .getProvinceList()
.then((res) => { // .then((res) => {
this.provinceList = res || [] // this.provinceList = res || []
}) // })
.catch((err) => { // .catch((err) => {
console.log(err) // console.log(err)
}) // })
}, // },
setPageInfo(info) { setPageInfo(info) {
var pages = getCurrentPages() var pages = getCurrentPages()
if (pages.length >= 1) { if (pages.length >= 1) {
......
...@@ -194,7 +194,7 @@ export default { ...@@ -194,7 +194,7 @@ export default {
onLoad(e) { onLoad(e) {
this.getPageInfo() this.getPageInfo()
this.getLocation() this.getLocation()
this.getProvinceList(this.questionWarehouseId) this.getProvinceList(this.category.id)
}, },
methods: { methods: {
handleClickArea() { handleClickArea() {
...@@ -228,8 +228,8 @@ export default { ...@@ -228,8 +228,8 @@ export default {
this.showPop = true this.showPop = true
}, },
// 获取省份列表 // 获取省份列表
async getProvinceList(questionWarehouseId) { async getProvinceList(id) {
let res = await this.$u.api.getProvinceList(questionWarehouseId) let res = await this.$u.api.getProvinceList(id)
console.log(res) console.log(res)
this.range = res this.range = res
}, },
...@@ -250,6 +250,7 @@ export default { ...@@ -250,6 +250,7 @@ export default {
} }
// 获取科目对应的题库 // 获取科目对应的题库
let res = await this.$u.api.getQuestionWarehouse(this.category.id, param) let res = await this.$u.api.getQuestionWarehouse(this.category.id, param)
if (res && res.length > 0) {
let data = res[0] let data = res[0]
this.setPageInfo(data) this.setPageInfo(data)
// 学员增加自己的题库 // 学员增加自己的题库
...@@ -277,6 +278,14 @@ export default { ...@@ -277,6 +278,14 @@ export default {
} else { } else {
this.showPop = false this.showPop = false
} }
} else {
this.$refs.uToast.show({
title: '所选科目没有对应的题库',
type: 'warning',
duration: 1500,
callback: () => {},
})
}
}, },
changeIndex() { changeIndex() {
for (var i = 0; i < this.range.length; i++) { for (var i = 0; i < this.range.length; i++) {
......
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