Commit 012c7a8e authored by Facius's avatar Facius

improvement:我的页面

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