Commit 012c7a8e authored by Facius's avatar Facius

improvement:我的页面

parent 45225586
......@@ -8,15 +8,29 @@ let learnApiFun = function(vm) {
await vm.$u.post('/rest/question/query/getQuestionTotal', params)
let answer = async (params = {}) =>
await vm.$u.post('/rest/question/save/answer', params)
// 获取科目
let subjectList = async (params = {}) =>
await vm.$u.get('/rest/question/query/subjectList', params)
// 获取科目对应的题库
let getQuestionWarehouse = async (subjectId, params = {}) =>
await vm.$u.get(
'/rest/question/query/getQuestionWarehouse/' + subjectId,
params
)
// 查询省份列表
let getProvinceList = async (params = {}) =>
await vm.$u.get('/rest/question/getProvinceList', params)
// 学生查询题库首页
let queryMyQuestionWarehouseDetail = async (questionWarehouseId) =>
await vm.$u.get(
'/rest/question/query/queryMyQuestionWarehouseDetail/' +
questionWarehouseId
)
// 学员增加自己的题库
let addQuestionWarehouse = async (params = {}) =>
await vm.$u.post('/rest/question/query/addQuestionWarehouse', params)
const learnApi = {
getQuestion,
getQuestionTotal,
......@@ -24,6 +38,8 @@ let learnApiFun = function(vm) {
subjectList,
getQuestionWarehouse,
getProvinceList,
queryMyQuestionWarehouseDetail,
addQuestionWarehouse,
}
return learnApi
}
......
......@@ -166,7 +166,7 @@ export default {
var a0 = this.$u.random(0, 49)
this.avatars = [
...array,
this.defaultUrl + a0 > 9 ? 'a' : 'a0' + a0 + '.jpeg',
this.defaultUrl + (a0 > 9 ? 'a' : 'a0') + String(a0) + '.jpeg',
]
// this.avatars = [...array, this.defaultUrl + 'xunzhang.jpeg']
console.log(this.avatars.length)
......
......@@ -86,11 +86,6 @@ export default {
days: '累计天数',
}
},
avatars() {
return this.info.avatar.length > 4
? this.info.avatar.slice(0, 4)
: this.info.avatar
},
meiriyilianImage() {
return process.uniEnv.qn_base_url + 'meiriyilianquyu.png'
},
......
......@@ -34,7 +34,9 @@
:src="item.image"
></image
><text v-if="item.title" class="detail-title">{{ item.title }}</text
><text class="detail-text">{{ selected[item.key] }}</text></view
><text class="detail-text">{{
item.key == 'location' ? provinceName : selected[item.key]
}}</text></view
>
</view>
<SubjectStatistics
......@@ -96,24 +98,17 @@ export default {
components: { SubjectStatistics, ExperiencePop, ToastPop },
data() {
return {
visible: false,
visible: false, // 免费体验弹窗
show: false,
type: 'select',
selected: {
key: 0,
name: '熔化焊接与热切割作业',
location: '黑龙江省题',
count: '899',
all: '10000',
pass: '96%',
cardId: '', // 绑卡
free: true, // true:可以体验;false: 没有体验机会了
},
provinceList: [],
detail: {},
selected: {},
}
},
computed: {
title() {
return this.selected.name || '请选择题库'
return this.selected.title || '请选择题库'
},
imageUrl() {
return '/static/logo.png'
......@@ -144,10 +139,10 @@ export default {
]
},
labelColor() {
return this.selected.free ? '#FA5A49' : '#9EA5BB'
return this.selected.state ? '#FA5A49' : '#9EA5BB'
},
examText() {
return this.selected.free
return this.selected.state
? '免费体验1次'
: this.selected.card
? this.selected.count + '/' + this.selected.all
......@@ -155,12 +150,15 @@ export default {
},
info() {
return {
days: 9,
today: 0,
total: 0,
dynamic: ['2分钟前 李**完成了“高空作业习题”练习'],
avatar: [this.imageUrl, this.imageUrl, this.imageUrl, this.imageUrl],
selected: this.selected,
id: this.selected.id,
provinceName: this.provinceName,
experience: this.selected.state,
pass: this.selected.pass,
number: this.selected.number,
days: this.detail.totalDayCount,
today: this.detail.todayCount,
total: this.detail.totalCount,
// selected: this.selected,
}
},
subItems() {
......@@ -195,6 +193,14 @@ export default {
},
]
},
provinceName() {
for (var item of this.provinceList) {
if (item.provinceId == this.selected.provinceId) {
return item.fullName + '题'
}
}
return ''
},
detailItems() {
return [
{
......@@ -218,7 +224,10 @@ export default {
]
},
},
onLoad() {},
onLoad() {
this.getProvinceList()
this.queryMyQuestionWarehouseDetail(0)
},
onShow() {
let pages = getCurrentPages()
let page = pages[pages.length - 1]
......@@ -226,10 +235,17 @@ export default {
if (info) {
this.selected = info
page.info = null
this.visible = info.cardId
this.visible = info.state
this.queryMyQuestionWarehouseDetail(this.selected.id)
}
},
methods: {
async queryMyQuestionWarehouseDetail(id) {
let res = await this.$u.api.queryMyQuestionWarehouseDetail(id)
console.log(res)
this.provinceList = res
},
handleSelect() {
// if (this.vuex_token) {
var str = this.selected ? 'selectedList' : 'addExam'
......@@ -292,6 +308,11 @@ export default {
// this.$u.route({ url: 'pages/login/index' })
// }
},
async getProvinceList() {
let res = await this.$u.api.getProvinceList()
console.log(res)
this.provinceList = res
},
},
}
</script>
......
......@@ -215,11 +215,18 @@ export default {
handleClickSure() {
this.showPop = true
},
// 获取省份列表
async getProvinceList() {
let res = await this.$u.api.getProvinceList()
console.log(res)
this.range = res
},
// 学员增加自己的题库
async addQuestionWarehouse(params) {
let res = await this.$u.api.addQuestionWarehouse({ params })
console.log(res)
this.range = res
},
async handleClickSubmit() {
if (this.buttonDisabled) return
if (this.index == 0) {
......@@ -229,13 +236,22 @@ export default {
provinceId: this.range[this.index].id,
type: this.selectedTypeId,
}
// 获取科目对应的题库
let res = await this.$u.api.getQuestionWarehouse(this.category.id, param)
this.setPageInfo(res[0])
this.showPop = false
uni.switchTab({
url: '/pages/index/index',
let data = res[0]
this.setPageInfo(data)
// 学员增加自己的题库
let result = await this.$u.api.addQuestionWarehouse({
questionWarehouseId: data.id,
})
if (result) {
// 成功
this.showPop = false
uni.switchTab({
url: '/pages/index/index',
})
} else {
}
},
changeIndex() {
for (var i = 0; i < this.range.length; i++) {
......@@ -277,6 +293,7 @@ export default {
if (pages.length >= 1) {
var page = pages[0]
console.log('--------setPageInfo--------', info)
info.pass = this.$u.random(95, 99)
page.info = info
}
},
......
......@@ -131,6 +131,7 @@ export default {
let res = await this.$u.api.subjectList(param)
this.tapLoading = false
this.result = res
console.log('-----------res-------------', res)
var filterItems = res.filter((item) => {
return item.parentId == 0
})
......
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