Commit c8c12230 authored by 李俊赕's avatar 李俊赕

small-css

parent 52c021f7
......@@ -19,19 +19,18 @@
<view class="topicView">
<text class="topicText">{{currentItem.question.content}}</text>
</view>
<view class="itemBackView" v-for="(item,ikey) in currentItem.answerList":key="ikey">
<view class="itemBackView" v-for="(item,ikey) in currentItem.answerList" :key="ikey">
<view class="itemView">
<view class="itemIndexView">
<text class="itemIndexText">A</text>
</view>
<text :class="item.isSelect ? 'itemText selectedColor' : 'itemText defaultColor' "
@click="itemClick(item,ikey)">哒哒所大所大所大所大所大所大所大所大所大所大所大所大所大所大所大所多撒大大所大撒多</text>
<!--view>{{item.content}}</view-->
<view class="itemIndexView">
<text class="itemIndexText">A</text>
</view>
</view>
<text :class="item.isSelect ? 'itemText selectedColor' : 'itemText defaultColor' " @click="itemClick(item,ikey)">哒哒所大所大所大所大所大所大所大所大所大所大所大所大所大所大所大所多撒大大所大撒多</text>
<!--view>{{item.content}}</view-->
</view>
</view>
<!--view class="itemView" v-for="(item,ikey) in currentItem.answerList":key="ikey">
<text :class="item.isSelect ? 'itemText selectedColor' : 'itemText defaultColor' "
@click="itemClick(item,ikey)">{{item.content}}</text>
......@@ -39,366 +38,364 @@
<view class="answerBottomView">
<image class="timeIcon" src="" mode=""></image>
<text class="timeText">{{currentTime}}</text>
<view :class="isSelect ? 'nextBtn selectedColor' : 'nextBtn defaultColor' "
@click="nextClick()">
<view :class="isSelect ? 'nextBtn selectedColor' : 'nextBtn defaultColor' " @click="nextClick()">
<text class="bottomTitle">{{bottomTitle}}</text>
</view>
</view>
</view>
</template>
</view>
</template>
<script>
import globalData from '@/common/base_url.js'
const systemApiUrl = globalData.systemUrl.apiUrl
export default {
data() {
return {
examId:2,
userExamId:0,
userAnswerIds:'',
isStart:true,
currentNumber:1,
currentItem:null,
isSelect:false,
currentTime:30,
progress:'',
bottomTitle:'下一题',
isStop:false,
examId: 2,
userExamId: 0,
userAnswerIds: '',
isStart: true,
currentNumber: 1,
currentItem: null,
isSelect: false,
currentTime: 30,
progress: '',
bottomTitle: '下一题',
isStop: false,
}
},
onLoad(e) {
this.getUserExamInfo()
},
methods: {
//开始考试 点击
startClick: function () {
startClick: function() {
this.isStart = true
//this.getData()
//this.applyExam()
this.getUserExamInfo()
},
//获取考试信息
getUserExamInfo: function () {
getUserExamInfo: function() {
uni.showLoading({
title:'请稍候'
title: '请稍候'
})
let that = this
uni.request({
url:systemApiUrl
+'/wxh-worker-rest/rest/exam'
+'/serviceRule/userExamInfo/'
+getApp().globalData.token
+'?examId='+this.examId,
url: systemApiUrl +
'/wxh-worker-rest/rest/exam' +
'/serviceRule/userExamInfo/' +
getApp().globalData.token +
'?examId=' + this.examId,
method: 'POST',
data: {
//examId:this.examId,
//examId:this.examId,
},
header:{
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: (res) => {
uni.hideLoading()
if(!res.data){
return
if (!res.data) {
return
}
if(res.data.code==401 || res.data.code==403 ){
if (res.data.code == 401 || res.data.code == 403) {
uni.navigateTo({
url:'/pages/login/wxlogin'
url: '/pages/login/wxlogin'
})
return
}
if(res.data.code==200){
if (res.data.code == 200) {
//examStatus 用户考试状态 0考试中 1考试完成 2未参与
if(res.data.data.examStatus == 2){
if (res.data.data.examStatus == 2) {
that.applyExam()
}
if(res.data.data.examStatus == 0
||res.data.data.examStatus == 1){
if (res.data.data.examStatus == 0 ||
res.data.data.examStatus == 1) {
that.userExamId = res.data.data.id
that.getNext()
}
// console.log('code=200')
// console.log('code=200')
//this.handleList(res)
}else{
} else {
uni.showToast({
icon:'none',
title:res.data.message
icon: 'none',
title: res.data.message
})
}
},
fail: (e) => {
uni.hideLoading()
uni.showToast({
icon:'none',
title:'获取考试信息失败'
icon: 'none',
title: '获取考试信息失败'
})
// console.log('获取下单列表 失败')
// console.log(e)
// console.log('获取下单列表 失败')
// console.log(e)
}
})
},
//申请考试
applyExam: function () {
applyExam: function() {
uni.showLoading({
title:'请稍候'
title: '请稍候'
})
let that = this
uni.request({
url: systemApiUrl
+'/wxh-worker-rest/rest/exam'
+'/serviceRule/'
+getApp().globalData.token
+'?examId=' + this.examId,
url: systemApiUrl +
'/wxh-worker-rest/rest/exam' +
'/serviceRule/' +
getApp().globalData.token +
'?examId=' + this.examId,
method: 'POST',
data: {
//examId:this.examId,
//examId:this.examId,
},
header:{
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: (res) => {
uni.hideLoading()
console.log('申请考试 成功')
console.log(res)
if(res.statusCode==401){
if (res.statusCode == 401) {
uni.navigateTo({
url:'/pages/login/wxlogin'
url: '/pages/login/wxlogin'
})
return
}
if(res.data.code==200){
if(res.data.data.userExamId){
if (res.data.code == 200) {
if (res.data.data.userExamId) {
that.userExamId = res.data.data.userExamId
that.getNext()
}
// console.log('code=200')
// console.log('code=200')
//this.handleList(res)
}else{
} else {
uni.showToast({
icon:'none',
title:res.data.message
icon: 'none',
title: res.data.message
})
}
},
fail: (e) => {
uni.hideLoading()
uni.showToast({
icon:'none',
title:'申请考试 失败'
icon: 'none',
title: '申请考试 失败'
})
// console.log('获取下单列表 失败')
// console.log(e)
// console.log('获取下单列表 失败')
// console.log(e)
}
})
},
//获取下一题
getNext: function () {
getNext: function() {
var questionId = ''
if(this.currentItem
&&this.currentItem.question
&&this.currentItem.question.id){
if (this.currentItem &&
this.currentItem.question &&
this.currentItem.question.id) {
questionId = this.currentItem.question.id
}
uni.showLoading({
title:'请稍候'
title: '请稍候'
})
let that = this
uni.request({
url: systemApiUrl
+'/wxh-worker-rest/rest/exam'
+'/serviceRule/next/'
+getApp().globalData.token
+'?userExamId='+this.userExamId
+'&questionId='+questionId
+'&userAnswerIds='+this.userAnswerIds,
url: systemApiUrl +
'/wxh-worker-rest/rest/exam' +
'/serviceRule/next/' +
getApp().globalData.token +
'?userExamId=' + this.userExamId +
'&questionId=' + questionId +
'&userAnswerIds=' + this.userAnswerIds,
method: 'POST',
data: {
// userExamId:this.userExamId,
// questionId:this.currentItem.question.id,
// userAnswerIds:this.userAnswerIds,
// userExamId:this.userExamId,
// questionId:this.currentItem.question.id,
// userAnswerIds:this.userAnswerIds,
},
header:{
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: (res) => {
uni.hideLoading()
console.log('获取下一题 成功')
console.log(res)
if(res.statusCode==401){
if (res.statusCode == 401) {
uni.navigateTo({
url:'/pages/login/wxlogin'
url: '/pages/login/wxlogin'
})
return
}
if(res.data.code==200){
if (res.data.code == 200) {
that.currentItem = res.data.data
that.progress = res.data.data.progress
if(res.data.data.answerList){
if (res.data.data.answerList) {
that.handleData()
that.currentTime = 30
//that.startCounting()
}else{
} else {
that.isSelect = true
that.bottomTitle = '完成考试,现在签约'
}
// console.log('code=200')
// console.log('code=200')
//this.handleList(res)
}else{
} else {
uni.showToast({
icon:'none',
title:res.data.message
icon: 'none',
title: res.data.message
})
}
},
fail: (e) => {
uni.hideLoading()
uni.showToast({
icon:'none',
title:'获取下一题 失败'
icon: 'none',
title: '获取下一题 失败'
})
// console.log('获取下单列表 失败')
// console.log(e)
// console.log('获取下单列表 失败')
// console.log(e)
}
})
},
handleData: function () {
handleData: function() {
this.currentItem.answerList.forEach(item => {
item.isSelect = false
})
console.log(this.currentItem)
},
startCounting : function () {
if(this.isStop){
startCounting: function() {
if (this.isStop) {
return
}
this.currentTime = this.currentTime - 1
if(this.currentTime > 0){
if (this.currentTime > 0) {
setTimeout(this.startCounting, 1000);
}else{
} else {
this.currentTime = 30
this.nextClick()
}
},
itemClick: function (currentItem , ikey) {
itemClick: function(currentItem, ikey) {
this.isSelect = true
//answerType 题目类型,1单选,2多选,3简答,
for (let i = 0; i < this.currentItem.answerList.length; i++) {
var item = this.currentItem.answerList[i]
if(this.currentItem.answerType == 2){//多选
if(ikey == i){
if (this.currentItem.answerType == 2) { //多选
if (ikey == i) {
item.isSelect = !item.isSelect
}
}else{//单选/简答
if(ikey == i){
} else { //单选/简答
if (ikey == i) {
item.isSelect = !item.isSelect
}else{
} else {
item.isSelect = false
}
}
}
var isSelect = false
this.currentItem.answerList.forEach(item => {
if(item.isSelect){
if (item.isSelect) {
isSelect = true
}
})
//有选答案
this.isSelect = isSelect
},
//下一题
nextClick: function () {
nextClick: function() {
console.log(this.bottomTitle)
if(this.bottomTitle == '完成考试,现在签约'){
if (this.bottomTitle == '完成考试,现在签约') {
uni.navigateTo({
url:'/pages/settle/prompt'
url: '/pages/settle/prompt'
})
return
}
this.currentNumber = this.currentNumber + 1
//this.getData()
this.handleAnswer()
//this.getNext()
},
//所选答案
handleAnswer: function () {
handleAnswer: function() {
/*
userAnswerIds
本题回答。
......@@ -406,50 +403,49 @@
简答题时直接存问题答案。
如果是第一次答题,不需要传。
*/
// var idList = []
// idList.push(item.id)
this.currentItem.answerList.forEach(item => {
// if(this.currentItem.answerType == 2){//多选}
if(item.isSelect){
//this.userAnswerIds = item.id + ',' + this.userAnswerIds
///*
if(this.userAnswerIds.length == 0){
this.userAnswerIds = item.id
}else{ // if(this.userAnswerIds.length == 1)
this.userAnswerIds = item.id + ',' + this.userAnswerIds
}
//*/
}
})
console.log('所选答案:')
console.log(this.userAnswerIds)
this.getNext()
// var idList = []
// idList.push(item.id)
this.currentItem.answerList.forEach(item => {
// if(this.currentItem.answerType == 2){//多选}
if (item.isSelect) {
//this.userAnswerIds = item.id + ',' + this.userAnswerIds
///*
if (this.userAnswerIds.length == 0) {
this.userAnswerIds = item.id
} else { // if(this.userAnswerIds.length == 1)
this.userAnswerIds = item.id + ',' + this.userAnswerIds
}
//*/
}
})
console.log('所选答案:')
console.log(this.userAnswerIds)
this.getNext()
},
}
}
</script>
<style>
.backView{
.backView {
background-color: #FFFFFF;
position: absolute;
top: 0;
......@@ -458,42 +454,42 @@
display: flex;
flex-direction: column;
}
.noticeView{
.noticeView {
margin-top: 100rpx;
width: 100%;
display: flex;
}
.noticeText{
.noticeText {
font-size: 32rpx;
color: #555555;
padding-left: 40rpx;
padding-right: 40rpx;
}
.numberView{
.numberView {
margin-top: 40rpx;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.numberText{
.numberText {
color: #333333;
font-size: 28rpx;
font-weight: bold;
}
.topicView{
.topicView {
margin-top: 60rpx;
width: 100%;
display: flex;
align-items: center;
}
.topicText{
.topicText {
color: #333333;
font-size: 36rpx;
padding-left: 28rpx;
......@@ -502,49 +498,54 @@
line-height: 48rpx;
font-weight: bold;
}
.itemBackView{
background-color: #4CD964;
margin-top: 40rpx;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.itemView{
background-color: #FFFFFF;
width: 690rpx;
display: flex;
flex-direction: row;
align-items: center;
border-radius: 12rpx;
}
.itemIndexView{
background-color: #D02B2B;
margin-left: 30rpx;
width: 40rpx;
height: 40rpx;
border-radius: 8rpx;
display: flex;
align-items: center;
justify-content: center;
}
.itemIndexText{
font-size: 28rpx;
}
.itemText{
margin-left: 20rpx;
font-size: 28rpx;
padding-top: 40rpx;
padding-bottom: 40rpx;
padding-right: 40rpx;
}
.bottomView{
.itemBackView {
background-color: #4CD964;
margin-top: 40rpx;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.itemView {
background-color: #FFFFFF;
width: 690rpx;
display: flex;
flex-direction: row;
align-items: center;
border-radius: 12rpx;
}
.itemIndexView {
background-color: #D02B2B;
margin-left: 30rpx;
width: 40rpx;
height: 40rpx;
border-radius: 8rpx;
display: flex;
align-items: center;
justify-content: center;
}
.itemIndexText {
width: 40rpx;
height: 40rpx;
display: block;
line-height: 40rpx;
text-align: center;
font-size: 28rpx;
}
.itemText {
margin-left: 20rpx;
font-size: 28rpx;
padding-top: 40rpx;
padding-bottom: 40rpx;
padding-right: 40rpx;
}
.bottomView {
background-color: #FFFFFF;
width: 100%;
height: 140rpx;
......@@ -554,8 +555,8 @@
position: fixed;
bottom: 0;
}
.bottomBtn{
.bottomBtn {
background-color: #007AFF;
width: 60%;
height: 80rpx;
......@@ -564,13 +565,13 @@
align-items: center;
justify-content: center;
}
.bottomTitle{
.bottomTitle {
font-size: 32rpx;
color: #FFFFFF;
}
.answerBottomView{
.answerBottomView {
background-color: #FFFFFF;
width: 100%;
height: 140rpx;
......@@ -580,22 +581,22 @@
position: fixed;
bottom: 0;
}
.timeIcon{
.timeIcon {
background-color: #999999;
margin-left: 80rpx;
width: 80rpx;
height: 80rpx;
border-radius: 40rpx;
}
.timeText{
.timeText {
margin-left: 20rpx;
font-size: 32rpx;
color: #999999;
}
.nextBtn{
.nextBtn {
width: 400rpx;
height: 80rpx;
border-radius: 40rpx;
......@@ -604,17 +605,16 @@
align-items: center;
justify-content: center;
}
.defaultColor{
.defaultColor {
background-color: #999999;
}
.selectedColor{
.selectedColor {
background-color: #007AFF;
}
.bottom-padding{
.bottom-padding {
padding-bottom: 180rpx;
}
</style>
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