Commit cec01ecd authored by Facius's avatar Facius

feat: 接口

parent fb334a21
...@@ -10,12 +10,17 @@ let learnApiFun = function(vm) { ...@@ -10,12 +10,17 @@ let learnApiFun = function(vm) {
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 = {}) =>
await vm.$u.get(
'/rest/question/query/getQuestionWarehouse/' + subjectId,
params
)
const learnApi = { const learnApi = {
getQuestion, getQuestion,
getQuestionTotal, getQuestionTotal,
answer, answer,
subjectList, subjectList,
getQuestionWarehouse,
} }
return learnApi return learnApi
} }
......
<template> <template>
<!-- 体验资格结束弹窗 --> <!-- 体验资格结束弹窗 -->
<u-popup <u-popup
border-radius="24"
v-model="visible" v-model="visible"
mode="center" mode="center"
safe-area-inset-bottom safe-area-inset-bottom
width="690rpx" width="690rpx"
:mask-close-able="flase" :mask-close-able="flase"
close-icon-color="#FFFFFF" close-icon-color="#FFFFFF"
height="86%"
> >
<view class="pop-view"> <view class="pop-view">
<image mode="widthFix" class="image-view" :src="backgroundImage"></image> <image mode="widthFix" class="image-view" :src="backgroundImage"></image>
...@@ -96,7 +96,7 @@ export default { ...@@ -96,7 +96,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.pop-view { .pop-view {
margin-top: 80rpx; // margin-top: 80rpx;
padding: 48rpx 24rpx; padding: 48rpx 24rpx;
position: relative; position: relative;
text-align: center; text-align: center;
...@@ -124,7 +124,7 @@ export default { ...@@ -124,7 +124,7 @@ export default {
z-index: -1; z-index: -1;
} }
.pop-content { .pop-content {
margin-bottom: 60rpx; margin-bottom: 150rpx;
font-size: 36rpx; font-size: 36rpx;
font-weight: bold; font-weight: bold;
color: #191c27; color: #191c27;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="u-flex top"> <view class="u-flex top">
<view class="u-flex avatar"> <view class="u-flex avatar">
<view class="avatar-list" v-for="(item, index) in avatars" :key="index"> <view class="avatar-list" v-for="(item, index) in avatars" :key="index">
<image :src="item" mode="scaleToFill" /> <image :src="item" mode="aspectFill" />
</view> </view>
</view> </view>
<view class="notice"> <view class="notice">
...@@ -117,6 +117,9 @@ export default { ...@@ -117,6 +117,9 @@ export default {
'习题"练习' '习题"练习'
) )
}, },
defaultUrl() {
return process.uniEnv.qn_base_url + 'heads/'
},
}, },
created() { created() {
this.initData() this.initData()
...@@ -124,18 +127,22 @@ export default { ...@@ -124,18 +127,22 @@ export default {
}, },
methods: { methods: {
initData() { initData() {
// this.avatars = [ var a0 = this.$u.random(0, 49)
// process.uniEnv.qn_base_url + 'touxiang' + this.$u.random(0, 49) + '.png', var a1 = this.$u.random(0, 49)
// process.uniEnv.qn_base_url + 'touxiang' + this.$u.random(0, 49) + '.png', var a2 = this.$u.random(0, 49)
// process.uniEnv.qn_base_url + 'touxiang' + this.$u.random(0, 49) + '.png', var a3 = this.$u.random(0, 49)
// process.uniEnv.qn_base_url + 'touxiang' + this.$u.random(0, 49) + '.png',
// ]
this.avatars = [ this.avatars = [
process.uniEnv.qn_base_url + 'xunzhang.png', this.defaultUrl + a0 > 9 ? 'a' : 'a0' + a0 + '.png',
process.uniEnv.qn_base_url + 'xunzhang.png', this.defaultUrl + a1 > 9 ? 'a' : 'a0' + a1 + '.png',
process.uniEnv.qn_base_url + 'xunzhang.png', this.defaultUrl + a2 > 9 ? 'a' : 'a0' + a2 + '.png',
process.uniEnv.qn_base_url + 'xunzhang.png', this.defaultUrl + a3 > 9 ? 'a' : 'a0' + a3 + '.png',
] ]
// this.avatars = [
// this.defaultUrl + 'xunzhang.png',
// this.defaultUrl + 'xunzhang.png',
// this.defaultUrl + 'xunzhang.png',
// this.defaultUrl + 'xunzhang.png',
// ]
this.list = [this.noticeText] this.list = [this.noticeText]
setInterval(() => { setInterval(() => {
this.produceTime += this.duration this.produceTime += this.duration
...@@ -154,9 +161,12 @@ export default { ...@@ -154,9 +161,12 @@ export default {
}, },
produceData() { produceData() {
var array = this.avatars.slice(1) var array = this.avatars.slice(1)
console.log(array.length) var a0 = this.$u.random(0, 49)
// this.avatars = [...array, process.uniEnv.qn_base_url + 'touxiang' + this.$u.random(0, 49) + '.png'] this.avatars = [
this.avatars = [...array, process.uniEnv.qn_base_url + 'xunzhang.png'] ...array,
this.defaultUrl + a0 > 9 ? 'a' : 'a0' + a0 + '.png',
]
// this.avatars = [...array, this.defaultUrl + 'xunzhang.png']
console.log(this.avatars.length) console.log(this.avatars.length)
this.list = [this.noticeText] this.list = [this.noticeText]
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
:custom-style="customStyleSave" :custom-style="customStyleSave"
shape="circle" shape="circle"
type="primary" type="primary"
:loading="loading"
@click="handleClickSure" @click="handleClickSure"
> >
{{ buttonText }} {{ buttonText }}
...@@ -62,7 +63,9 @@ export default { ...@@ -62,7 +63,9 @@ export default {
}, },
}, },
data() { data() {
return {} return {
loading: false,
}
}, },
computed: { computed: {
customStyleCancel() { customStyleCancel() {
...@@ -85,6 +88,11 @@ export default { ...@@ -85,6 +88,11 @@ export default {
} }
}, },
}, },
watch: {
visible() {
this.loading = false
},
},
methods: { methods: {
changeVisibleValue(val) { changeVisibleValue(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
...@@ -94,6 +102,7 @@ export default { ...@@ -94,6 +102,7 @@ export default {
this.$emit('cancel') this.$emit('cancel')
}, },
handleClickSure() { handleClickSure() {
this.loading = true
this.$emit('submit') this.$emit('submit')
}, },
}, },
......
<template> <template>
<view class="question-bank-cell"> <view class="question-bank-cell">
<view class="label-normal"> <view class="label-normal">
<view>{{ info.name }}</view> <view>{{ info.label }}</view>
<view class="label-text"> <view class="label-text">
共 共
<text class="label-blue">{{ info.quantity }}</text <text class="label-blue">{{ info.number }}</text
>道精编试题,通过率 >道精编试题,通过率
<text class="label-blue">{{ info.pass }}</text> <text class="label-blue">{{ $u.random(95, 99) }}%</text>
</view> </view>
</view> </view>
<u-button <u-button
......
...@@ -19,7 +19,11 @@ ...@@ -19,7 +19,11 @@
</view> </view>
<view class="add-exam-content"> <view class="add-exam-content">
<view class="label-content"> <view class="label-content">
<view v-for="(label, index) in list" :key="index" class="label-item"> <view
v-for="(label, index) in category.list"
:key="index"
class="label-item"
>
<QuestionBankCell <QuestionBankCell
:info="label" :info="label"
type="add" type="add"
...@@ -27,12 +31,8 @@ ...@@ -27,12 +31,8 @@
></QuestionBankCell> ></QuestionBankCell>
</view> </view>
</view> </view>
<!-- 标签加载中 -->
<view class="tag-loading-view" v-if="loading">
<u-loading mode="flower"></u-loading>
</view>
<!-- 无数据 --> <!-- 无数据 -->
<view class="tag-loading-view" v-else-if="list.length <= 0" <view class="tag-loading-view" v-if="category.list.length <= 0"
>暂无数据</view >暂无数据</view
> >
</view> </view>
...@@ -50,8 +50,6 @@ export default { ...@@ -50,8 +50,6 @@ export default {
}, },
data() { data() {
return { return {
list: [], // 题库列表
loading: true,
selected: {}, selected: {},
} }
}, },
...@@ -75,37 +73,16 @@ export default { ...@@ -75,37 +73,16 @@ export default {
}, },
onLoad(e) { onLoad(e) {
this.getPageInfo() this.getPageInfo()
this.loadList() // 获取题库列表
}, },
methods: { methods: {
// 点击了添加按钮 // 点击了添加按钮
handleClick(index) { handleClick(index) {
this.selected[key3] = this.list[index] this.selected[key3] = this.category.list[index]
this.setPageInfo(this.selected) this.setPageInfo(this.selected)
this.$u.route({ this.$u.route({
url: 'pages/learn/examSetting', url: 'pages/learn/examSetting',
}) })
}, },
// 获取题库列表
loadList() {
// async loadList() {
// this.loading = true;
// let res = await this.$u.api.fileLabel({categoryId: this.category.id});
// this.loading = false
// if (res && res.code == 200) {
// this.list = res.data || [];
for (var i = 0; i < 10; i++) {
// 测试模拟多条数据
this.list.push({
name: '登高架设作业',
quantity: '80000',
pass: '98%',
id: i,
})
}
// }
},
// 本页数据设置,用于其他页面访问本页数据 // 本页数据设置,用于其他页面访问本页数据
setPageInfo(info) { setPageInfo(info) {
var pages = getCurrentPages() var pages = getCurrentPages()
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
></u-navbar> ></u-navbar>
<view> <view>
<view class="title-view"> <view class="title-view">
<text>{{ category.name }}</text> <text>{{ category.label }}</text>
</view> </view>
</view> </view>
<view class="exam-type"> <view class="exam-type">
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
> >
<view v-for="(value, key) in selected" :key="key" class="pop-content"> <view v-for="(value, key) in selected" :key="key" class="pop-content">
<view :class="['pop-content-text', { last: key == thirdKey }]">{{ <view :class="['pop-content-text', { last: key == thirdKey }]">{{
value.name value.label
}}</view> }}</view>
<u-icon v-if="key != thirdKey" name="arrow-downward"></u-icon> <u-icon v-if="key != thirdKey" name="arrow-downward"></u-icon>
</view> </view>
...@@ -141,7 +141,7 @@ export default { ...@@ -141,7 +141,7 @@ export default {
} }
}, },
buttonDisabled() { buttonDisabled() {
return !(this.selectedProvince.label && this.selectedType) return !(this.selectedProvince.label && this.selectedTypeId)
}, },
selectedType() { selectedType() {
for (var item of this.types) { for (var item of this.types) {
...@@ -154,6 +154,14 @@ export default { ...@@ -154,6 +154,14 @@ export default {
thirdKey() { thirdKey() {
return key3 return key3
}, },
selectedTypeId() {
for (var item of this.types) {
if (item.selected == true) {
return item.id
}
}
return null
},
}, },
onLoad(e) { onLoad(e) {
this.getPageInfo() this.getPageInfo()
...@@ -190,8 +198,21 @@ export default { ...@@ -190,8 +198,21 @@ export default {
handleClickSure() { handleClickSure() {
this.showPop = true this.showPop = true
}, },
handleClickSubmit() { async handleClickSubmit() {
if (this.buttonDisabled) return if (this.buttonDisabled) return
let param = {
provinceId: this.selectedProvince.value,
type: this.selectedTypeId,
}
let res = await this.$u.api.getQuestionWarehouse(this.category.id, param)
this.setPageInfo(res)
this.showPop = false
uni.switchTab({
url: '/pages/index/index',
})
console.log(res)
return
var selected = { var selected = {
key: 0, key: 0,
name: 'abc', name: 'abc',
......
...@@ -78,6 +78,7 @@ export default { ...@@ -78,6 +78,7 @@ export default {
tapLoading: true, tapLoading: true,
scrollId: '', scrollId: '',
minHeight: 0, minHeight: 0,
result: [],
} }
}, },
computed: { computed: {
...@@ -113,6 +114,9 @@ export default { ...@@ -113,6 +114,9 @@ export default {
} else { } else {
// 选中二级标签 // 选中二级标签
this.selected[key1] = this.labels[key1][0][index] this.selected[key1] = this.labels[key1][0][index]
this.selected[key2].list = this.result.filter((item) => {
return item.parentId == label.id
})
this.setPageInfo(this.selected) this.setPageInfo(this.selected)
this.$u.route({ this.$u.route({
url: 'pages/learn/addExam', url: 'pages/learn/addExam',
...@@ -126,6 +130,7 @@ export default { ...@@ -126,6 +130,7 @@ export default {
let param = {} let param = {}
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
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