Commit e2e85b81 authored by Facius's avatar Facius

improvement: 首页加载中

parent b10d50fe
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
></u-navbar> ></u-navbar>
<view class="content"> <view class="content">
<view class="exam-title-view" @click="$u.throttle(handleSelect, 500)"> <view class="exam-title-view" @click="$u.throttle(handleSelect, 500)">
<text>{{ title }}</text> <view class="title-loading" v-if="loading">
<u-loading mode="flower"></u-loading>
</view>
<text v-else>{{ title }}</text>
<u-icon class="icon-view" name="arrow-up-fill"></u-icon> <u-icon class="icon-view" name="arrow-up-fill"></u-icon>
</view> </view>
<view v-if="noExam" class="tip-view"> <view v-if="noExam" class="tip-view">
...@@ -108,6 +111,8 @@ export default { ...@@ -108,6 +111,8 @@ export default {
detail: { questionWarehouse: {} }, detail: { questionWarehouse: {} },
selected: {}, selected: {},
data: {}, data: {},
relationId: 0, // 绑卡用
loading: false,
} }
}, },
computed: { computed: {
...@@ -131,7 +136,7 @@ export default { ...@@ -131,7 +136,7 @@ export default {
{ {
name: '全部试题', name: '全部试题',
label: this.examText, label: this.examText,
leftLabel: this.selected.count, // 已做题目数 leftLabel: String(this.finishCount), // 已做题目数
image: process.uniEnv.qn_base_url + 'quanbushiti.png', image: process.uniEnv.qn_base_url + 'quanbushiti.png',
}, },
{ {
...@@ -141,9 +146,14 @@ export default { ...@@ -141,9 +146,14 @@ export default {
}, },
] ]
}, },
finishCount() {
return this.questionList.reduce((accumulator, currentValue) => {
if (currentValue.id) accumulator++
return accumulator
}, 0)
},
examText() { examText() {
return this.info.cardId ? '/' + this.selected.totalExam : '题库进阶练习' return this.info.cardId ? '/' + this.info.totalExam : '题库进阶练习'
}, },
info() { info() {
return { return {
...@@ -250,14 +260,19 @@ export default { ...@@ -250,14 +260,19 @@ export default {
}, },
methods: { methods: {
// 题库详情 // 题库详情
async queryQuestionWarehouseById(id) { queryQuestionWarehouseById(id) {
let res = await this.$u.api this.$u.api
.queryQuestionWarehouseById(id) .queryQuestionWarehouseById(id)
.then((res) => {
this.loading = false
this.data = res || { questionWarehouse: {} }
this.selected = this.data.questionWarehouse
})
.catch((err) => { .catch((err) => {
this.loading = false
console.log(err) console.log(err)
}) })
this.data = res || { questionWarehouse: {} }
this.selected = this.data.questionWarehouse
// this.$u.vuex( // this.$u.vuex(
// 'experience', // 'experience',
// this.selected.state && !this.detail.questionWarehouse.cardId // this.selected.state && !this.detail.questionWarehouse.cardId
...@@ -266,14 +281,20 @@ export default { ...@@ -266,14 +281,20 @@ export default {
// ) // )
}, },
// 学生查询题库首页 // 学生查询题库首页
async queryMyQuestionWarehouseDetail(id) { queryMyQuestionWarehouseDetail(id) {
let res = await this.$u.api this.loading = true
this.$u.api
.queryMyQuestionWarehouseDetail(id) .queryMyQuestionWarehouseDetail(id)
.then((res) => {
this.detail = res || { questionWarehouse: {} }
this.relationId = res.questionWarehouse.id
this.queryQuestionWarehouseById(
res.questionWarehouse.questionWarehouseId
)
})
.catch((err) => { .catch((err) => {
console.log(err) console.log(err)
}) })
this.detail = res || { questionWarehouse: {} }
this.queryQuestionWarehouseById(res.questionWarehouse.questionWarehouseId)
}, },
handleSelect() { handleSelect() {
...@@ -308,6 +329,9 @@ export default { ...@@ -308,6 +329,9 @@ export default {
// this.show = true // this.show = true
this.$u.route({ this.$u.route({
url: 'pages/learn/detail', url: 'pages/learn/detail',
params: {
relationId: this.relationId,
},
}) })
} }
} else { } else {
...@@ -326,6 +350,9 @@ export default { ...@@ -326,6 +350,9 @@ export default {
this.$u.route({ this.$u.route({
url: 'pages/learn/' + str, url: 'pages/learn/' + str,
params: {
relationId: this.relationId,
},
}) })
}, },
handleClickItem(key) { handleClickItem(key) {
...@@ -382,6 +409,9 @@ export default { ...@@ -382,6 +409,9 @@ export default {
// this.show = true // this.show = true
this.$u.route({ this.$u.route({
url: 'pages/learn/detail', url: 'pages/learn/detail',
params: {
relationId: this.relationId,
},
}) })
} else { } else {
// 未选题库 // 未选题库
...@@ -406,6 +436,9 @@ export default { ...@@ -406,6 +436,9 @@ export default {
// this.show = true // this.show = true
this.$u.route({ this.$u.route({
url: 'pages/learn/detail', url: 'pages/learn/detail',
params: {
relationId: this.relationId,
},
}) })
} else { } else {
this.$u.route({ this.$u.route({
...@@ -473,10 +506,12 @@ export default { ...@@ -473,10 +506,12 @@ export default {
font-size: 40rpx; font-size: 40rpx;
display: flex; display: flex;
align-items: center; align-items: center;
.titleImage { .title-loading {
width: 40rpx; width: 240rpx;
height: 40rpx; height: 56rpx;
margin-right: 14rpx; display: flex;
align-items: center;
justify-content: center;
} }
.icon-view { .icon-view {
font-size: 24rpx; font-size: 24rpx;
......
...@@ -50,7 +50,9 @@ ...@@ -50,7 +50,9 @@
<script> <script>
export default { export default {
data() { data() {
return {} return {
relationId: 0, // 绑卡用
}
}, },
computed: { computed: {
...@@ -74,7 +76,11 @@ export default { ...@@ -74,7 +76,11 @@ export default {
} }
}, },
}, },
onLoad(e) {}, onLoad(e) {
if (e && e.relationId) {
this.relationId = e.relationId
}
},
methods: { methods: {
handleClick() { handleClick() {
wx.scanCode({ wx.scanCode({
...@@ -86,6 +92,7 @@ export default { ...@@ -86,6 +92,7 @@ export default {
url: 'pages/learn/boundTest', url: 'pages/learn/boundTest',
params: { params: {
code: res.result, code: res.result,
relationId: this.relationId,
}, },
}) })
} }
...@@ -96,6 +103,9 @@ export default { ...@@ -96,6 +103,9 @@ export default {
handleChange() { handleChange() {
this.$u.route({ this.$u.route({
url: 'pages/learn/manualBinding', url: 'pages/learn/manualBinding',
params: {
relationId: this.relationId,
},
}) })
}, },
}, },
......
...@@ -68,7 +68,9 @@ export default { ...@@ -68,7 +68,9 @@ export default {
this.param.cardNumber = code.slice(0, 15) this.param.cardNumber = code.slice(0, 15)
this.param.cardSecret = code.slice(15) this.param.cardSecret = code.slice(15)
} }
this.param.questionWarehouseId = this.questionWarehouseId if (e && e.relationId) {
this.param.questionWarehouseId = e.relationId
}
}, },
methods: { methods: {
handleClick() { handleClick() {
......
...@@ -91,6 +91,7 @@ import md5 from '@/common/md5.js' ...@@ -91,6 +91,7 @@ import md5 from '@/common/md5.js'
export default { export default {
data() { data() {
return { return {
relationId: 0, // 绑卡用
info: { info: {
title: '高处安装、维护、拆除作业人员题库', title: '高处安装、维护、拆除作业人员题库',
money: 80.0, money: 80.0,
...@@ -180,11 +181,18 @@ export default { ...@@ -180,11 +181,18 @@ export default {
] ]
}, },
}, },
onLoad(e) {}, onLoad(e) {
if (e && e.relationId) {
this.relationId = e.relationId
}
},
methods: { methods: {
handleClick() { handleClick() {
this.$u.route({ this.$u.route({
url: 'pages/learn/boundQuestions', url: 'pages/learn/boundQuestions',
params: {
relationId: this.relationId,
},
}) })
}, },
handleClickBuy() { handleClickBuy() {
......
...@@ -71,6 +71,7 @@ export default { ...@@ -71,6 +71,7 @@ export default {
password: '', password: '',
focus: true, focus: true,
loading: false, loading: false,
relationId: 0,
} }
}, },
...@@ -98,7 +99,11 @@ export default { ...@@ -98,7 +99,11 @@ export default {
return 'color:#9EA5BB;font-size:28rpx' return 'color:#9EA5BB;font-size:28rpx'
}, },
}, },
onLoad(e) {}, onLoad(e) {
if (e && e.relationId) {
this.relationId = e.relationId
}
},
methods: { methods: {
handleClick() { handleClick() {
this.loading = true this.loading = true
...@@ -106,7 +111,7 @@ export default { ...@@ -106,7 +111,7 @@ export default {
.bindCard({ .bindCard({
cardNumber: this.code, cardNumber: this.code,
cardSecret: this.password, cardSecret: this.password,
questionWarehouseId: this.questionWarehouseId, questionWarehouseId: this.relationId,
}) })
.then((res) => { .then((res) => {
this.$refs.uToast.show({ this.$refs.uToast.show({
......
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