答题模块

master
橙橙楊 5 years ago committed by luffy
parent 601610d187
commit b275e76499
  1. 33
      src/App.vue
  2. 5
      src/manifest.json
  3. 51
      src/pages/waste_sorting/query.vue
  4. 44
      src/pages/waste_sorting/question.vue

@ -1,7 +1,38 @@
<script> <script>
export default { import {config} from "./common/config";
export default {
onLaunch: function() { onLaunch: function() {
console.log('App Launch') console.log('App Launch')
uni.showLoading({
title:"检测服务端中"
})
let test=false
uni.request({
url:config.server+'/api/test.php',
success:function (res) {
console.info(res)
if(res.data==="ok"){
uni.showToast({
title:"连接服务端成功"
})
}
},fail:function (res) {
console.error(res)
uni.showModal({
title:"错误提示",
content:"服务端连接失败,请检查服务端地址"+config.server+"是否正确",
showCancel:false
})
},
complete:function () {
uni.hideLoading()
test=true
}
})
}, },
onShow: function() { onShow: function() {
console.log('App Show') console.log('App Show')

@ -71,5 +71,8 @@
}, },
"mp-qq" : { "mp-qq" : {
"usingComponents" : true "usingComponents" : true
} },
"networkTimeout": {
"request":5000
}
} }

@ -87,7 +87,12 @@
if (json_res["status"]) { if (json_res["status"]) {
console.info("查询成功") console.info("查询成功")
if (json_res["result"].length === 0) { if (json_res["result"].length === 0) {
console.info("没有匹配结果") let str="没有匹配结果"
console.info(str)
uni.showToast({
title:str,
duration:3000
})
} else { } else {
that.show_info = true that.show_info = true
that.query_result = json_res["result"] that.query_result = json_res["result"]
@ -105,7 +110,7 @@
},else:function (err) { },else:function (err) {
console.error(err) console.error(err)
uni.showToast({ uni.showToast({
title:"参数解析异常", title:"参数解析异常,请联系管理员",
duration:3000 duration:3000
}) })
} }
@ -142,9 +147,10 @@
if (json_res["result"].length === 0) { if (json_res["result"].length === 0) {
let str = "照片解析成功,但是没有垃圾分类信息" let str = "照片解析成功,但是没有垃圾分类信息"
console.info(str) console.info(str)
uni.showToast({ uni.showModal({
title:str, title:"错误提示",
duration:3000 content:str,
showCancel:false
}) })
}else{ }else{
that.show_info=true that.show_info=true
@ -153,25 +159,28 @@
} else { } else {
let str = "照片解析失败" let str = "照片解析失败"
console.info(str) console.info(str)
uni.showToast({ uni.showModal({
title:str, title:"错误提示",
duration:3000 content:str,
showCancel:false
}) })
} }
} else { } else {
let str = "照片解析失败" let str = "照片解析失败"
console.info(str) console.info(str)
uni.showToast({ uni.showModal({
title:str, title:"错误提示",
duration:3000 content:str,
showCancel:false
}) })
} }
}, },
fail: function (err) { fail: function (err) {
console.error(err) console.error(err)
uni.showToast({ uni.showModal({
title: "照片解析失败,多次出现此异常请联系管理员", title:"错误提示",
duration:3000 content: "照片解析失败,多次出现此异常请联系管理员",
showCancel:false
}) })
}, },
complete: function (res) { complete: function (res) {
@ -181,18 +190,20 @@
}, },
fail: function (err) { fail: function (err) {
console.error(err) console.error(err)
uni.showToast({ uni.showModal({
title: "照片保存失败,多次出现此异常请联系管理员", title:"错误提示",
duration:3000 content: "照片保存失败,多次出现此异常请联系管理员",
showCancel:false
}) })
} }
}) })
}, },
fail: function (err) { fail: function (err) {
console.error(err) console.error(err)
uni.showToast({ uni.showModal({
title: "授权摄像头权限失败,请刷新页面重新授权,多次出现此异常请联系管理员", title:"错误提示",
duration:3000 content: "授权摄像头权限失败,请刷新页面重新授权,多次出现此异常请联系管理员",
showCancel:false
}) })
} }
}) })

@ -1,6 +1,6 @@
<template> <template>
<view> <view>
<view class="uni-padding-wrap uni-common-mt" v-if="isLoad"> <view class="uni-padding-wrap" v-if="isLoad">
<view v-for="(question,q_index) in questions" :key="q_index" class="question uni-flex uni-column"> <view v-for="(question,q_index) in questions" :key="q_index" class="question uni-flex uni-column">
<text class="title uni-center">{{question.question_title}}</text> <text class="title uni-center">{{question.question_title}}</text>
@ -14,7 +14,7 @@
</radio-group> </radio-group>
</view> </view>
<view class="uni-flex uni-row button-group question"> <view class="uni-flex uni-row button-group question" v-if="questions.length>0">
<view class="flex-item"> <view class="flex-item">
<button type="primary" @click="submit">提交答卷</button> <button type="primary" @click="submit">提交答卷</button>
</view> </view>
@ -22,6 +22,11 @@
<button type="primary" class="reset" @click="reset">重置答卷</button> <button type="primary" class="reset" @click="reset">重置答卷</button>
</view> </view>
</view> </view>
<view class="uni-flex vertical-center" :style="{height: height+'px'}" v-else>
<view class="weui-btn-area" :style="{width:width+'px'}">
<button class="weui-btn" type="default" @click="openConfirm">错误提示</button>
</view>
</view>
</view> </view>
</view> </view>
</template> </template>
@ -36,10 +41,20 @@
title: "垃圾百科测验", title: "垃圾百科测验",
questions:[], questions:[],
isLoad:false, isLoad:false,
show_answer:false show_answer:false,
height:0,
width:0
} }
}, },
methods:{ methods:{
openConfirm:function(){
let that=this
uni.showModal({
title:"错误提示",
content:that.err_msg,
showCancel:false
})
},
reset:function () { reset:function () {
this.show_answer=false this.show_answer=false
uni.reLaunch({ uni.reLaunch({
@ -105,8 +120,16 @@
uni.showLoading({ uni.showLoading({
title:"加载试题中" title:"加载试题中"
}) })
let url=getInterface(config.interface.create_question)
let that=this let that=this
uni.getSystemInfo({
success:function (res) {
console.info(res)
that.height=res.windowHeight
that.width=res.windowWidth
}
})
let url=getInterface(config.interface.create_question)
console.info("创建试题接口:"+url); console.info("创建试题接口:"+url);
uni.request({ uni.request({
url:url, url:url,
@ -114,6 +137,13 @@
console.info(res.data) console.info(res.data)
if(res.data.status) { if(res.data.status) {
that.questions = res.data.result; that.questions = res.data.result;
}else{
that.err_msg=res.data.msg
uni.showModal({
title:"错误提示",
content:that.err_msg,
showCancel:false
})
} }
}, },
fail:function (err) { fail:function (err) {
@ -146,7 +176,6 @@
justify-content: center; justify-content: center;
} }
.true{ .true{
/*background-color: #75807f;*/
background-color: lightgrey; background-color: lightgrey;
} }
.true_font{ .true_font{
@ -156,4 +185,9 @@
.false{ .false{
color: red; color: red;
} }
/* 水平垂直居中*/
.vertical-center{
align-items: center;
justify-content:center;
}
</style> </style>
Loading…
Cancel
Save