答题模块

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

@ -1,7 +1,38 @@
<script>
import {config} from "./common/config";
export default {
onLaunch: function() {
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() {
console.log('App Show')

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

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

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