Commit e2e85b81 authored by Facius's avatar Facius

improvement: 首页加载中

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