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

small-css

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