Commit 0323b236 authored by Facius's avatar Facius

improvement: 获取省份接口优化

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