parent
1384db2c19
commit
158a86602f
@ -0,0 +1,11 @@
|
||||
//app.js
|
||||
App({
|
||||
onLaunch: function () {
|
||||
// 展示本地存储能力
|
||||
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
questions: []
|
||||
}
|
||||
})
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/test/test",
|
||||
"pages/result/result",
|
||||
"pages/wrongAnswer/wrongAnswer"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#99ffcc",
|
||||
"navigationBarTitleText": "小学五年级数学测试",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
/**app.wxss**/
|
||||
@import "weui.wxss";
|
||||
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 200rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
// pages/conn/conn.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
|
||||
bindtest: function () {
|
||||
wx.request({
|
||||
url: 'http://111.230.50.64:8080/WxMath/ServletTest',
|
||||
data: {
|
||||
|
||||
},
|
||||
method: 'GET',
|
||||
header: {
|
||||
'content-type': 'application/json' // 默认值
|
||||
},
|
||||
success: function (res) {
|
||||
console.log(res.data);
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(".....fail.....");
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,5 @@
|
||||
<!--pages/conn/conn.wxml-->
|
||||
<text>pages/conn/conn.wxml</text>
|
||||
<view>
|
||||
<button bindtap='bindtest'>test</button>
|
||||
</view>
|
@ -0,0 +1 @@
|
||||
/* pages/conn/conn.wxss */
|
@ -0,0 +1,76 @@
|
||||
//index.js
|
||||
//获取应用实例
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
motto: 'Hello World',
|
||||
userInfo: {},
|
||||
hasUserInfo: false,
|
||||
canIUse: wx.canIUse('button.open-type.getUserInfo')
|
||||
},
|
||||
//事件处理函数
|
||||
beginAnswer: function () {
|
||||
|
||||
wx.navigateTo({
|
||||
url: '../test/test'
|
||||
})
|
||||
},
|
||||
|
||||
onLoad: function () {
|
||||
/* 请求数据 */
|
||||
wx.request({
|
||||
url: '',
|
||||
data: {
|
||||
|
||||
},
|
||||
method: 'GET',
|
||||
header: {
|
||||
'content-type': 'application/json' // 默认值
|
||||
},
|
||||
success: function (res) {
|
||||
//var questionList = [];
|
||||
app.globalData.questions = res.data;
|
||||
console.log(res.data);
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(".....fail.....");
|
||||
}
|
||||
})
|
||||
|
||||
if (app.globalData.userInfo) {
|
||||
this.setData({
|
||||
userInfo: app.globalData.userInfo,
|
||||
hasUserInfo: true
|
||||
})
|
||||
} else if (this.data.canIUse){
|
||||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
||||
// 所以此处加入 callback 以防止这种情况
|
||||
app.userInfoReadyCallback = res => {
|
||||
this.setData({
|
||||
userInfo: res.userInfo,
|
||||
hasUserInfo: true
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// 在没有 open-type=getUserInfo 版本的兼容处理
|
||||
wx.getUserInfo({
|
||||
success: res => {
|
||||
app.globalData.userInfo = res.userInfo
|
||||
this.setData({
|
||||
userInfo: res.userInfo,
|
||||
hasUserInfo: true
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
getUserInfo: function(e) {
|
||||
console.log(e)
|
||||
app.globalData.userInfo = e.detail.userInfo
|
||||
this.setData({
|
||||
userInfo: e.detail.userInfo,
|
||||
hasUserInfo: true
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,5 @@
|
||||
<!--index.wxml-->
|
||||
<view class="begininfo">
|
||||
<view class='ep'></view>
|
||||
<button bindtap='beginAnswer'> 开始测试 </button>
|
||||
</view>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,111 @@
|
||||
// pages/result/result.js
|
||||
var app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
wrong: 0,
|
||||
wrongList: [],
|
||||
accuracy:0,
|
||||
mytrue:0,
|
||||
grade:0,
|
||||
answerArrays1:[],
|
||||
answerArrays2:[],
|
||||
answerArrays3:[]
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
// console.log(options.wrongList);
|
||||
// console.log(JSON.parse(options.wrongList));
|
||||
// console.log(typeof JSON.parse(options.wrongList));
|
||||
// console.log(options.answerArrays2);
|
||||
// console.log(options.answerArrays2.length);
|
||||
// console.log(typeof options.answerArrays2);
|
||||
//设置标题
|
||||
wx.setNavigationBarTitle({
|
||||
title: "测试结果"
|
||||
})
|
||||
this.setData({
|
||||
wrong: options.wrong - 0,
|
||||
wrongList: options.wrongList,
|
||||
answerArrays1: options.answerArrays1,
|
||||
answerArrays2: options.answerArrays2,
|
||||
answerArrays3: options.answerArrays3
|
||||
})
|
||||
this.setData({
|
||||
mytrue: 20 - this.data.wrong,
|
||||
})
|
||||
this.setData({
|
||||
accuracy: 5*this.data.mytrue,
|
||||
})
|
||||
this.setData({
|
||||
grade: this.data.mytrue*5
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
},
|
||||
reset: function(){
|
||||
wx.redirectTo({
|
||||
url: '../index/index',
|
||||
})
|
||||
},
|
||||
wrongAnswer:function(){
|
||||
|
||||
wx.redirectTo({
|
||||
url: '../wrongAnswer/wrongAnswer?wrongList=' + this.data.wrongList + '&answerArrays1=' + this.data.answerArrays1 + '&answerArrays2=' + this.data.answerArrays2 + '&answerArrays3=' + this.data.answerArrays3
|
||||
})
|
||||
}
|
||||
|
||||
})
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,19 @@
|
||||
<!--pages/result/result.wxml-->
|
||||
<view>
|
||||
<view class='result_title'>
|
||||
<view><text>恭喜您答题结束</text></view>
|
||||
</view>
|
||||
|
||||
<view class='result'>
|
||||
<view><text>本次测试总共20道题</text></view>
|
||||
<view><text>答对{{mytrue}}道题</text></view>
|
||||
<view><text>答错{{wrong}}道题</text></view>
|
||||
<view><text>正确率为{{accuracy}}%</text></view>
|
||||
<view><text>本次测试得{{grade}}分</text></view>
|
||||
</view>
|
||||
|
||||
<view class='mybutton'>
|
||||
<button bindtap='wrongAnswer' class='blbutton'>查看错题</button>
|
||||
<button bindtap='reset' class='brbutton'>返回首页</button>
|
||||
</view>
|
||||
</view>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,40 @@
|
||||
<!--pages/test/test.wxml-->
|
||||
|
||||
<view class="page" hover='true' hover-stay-time="20000">
|
||||
<view class='page__hd'>
|
||||
<view class="page__title">{{index+1}}、
|
||||
<view class='page_title_question'><image wx:if="{{questionImage!=''}}" src="{{questionImage}}" class='myimage' mode="widthFix"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="page__bd">
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
|
||||
<!-- 判断选项个数是3个还是4还是6个 -->
|
||||
<view wx:if="{{optionnumber == '3'}}">
|
||||
<view class="weui-cell " hover-class="weui-cell_active" bindtap='select' data-value="{{options[answerArrays1[index]]}}" data-option="{{index}}" wx:for="{{answerArrays1}}" wx:key="index">
|
||||
<icon type="{{icon[index]}}" size="23"></icon>
|
||||
<view>{{myoption[index]}}、<image src="{{options[answerArrays1[index]]}}" class='myoptionimage' mode="widthFix"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{optionnumber == '4'}}">
|
||||
<view class="weui-cell " hover-class="weui-cell_active" bindtap='select' data-value="{{options[answerArrays2[index]]}}" data-option="{{index}}" wx:for="{{answerArrays2}}" wx:key="index">
|
||||
|
||||
<icon type="{{icon[index]}}" size="23"></icon>
|
||||
<view class='myFloat'>{{myoption[index]}}、<image src="{{options[answerArrays2[index]]}}" class='myoptionimage' mode="widthFix"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else>
|
||||
<view class="weui-cell " hover-class="weui-cell_active" bindtap='select' data-value="{{options[answerArrays3[index]]}}" data-option="{{index}}" wx:for="{{answerArrays3}}" wx:key="index">
|
||||
|
||||
<icon type="{{icon[index]}}" size="23"></icon>
|
||||
<view>{{myoption[index]}}、<image src="{{options[answerArrays3[index]]}}" class='myoptionimage' mode="widthFix"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,138 @@
|
||||
var app = getApp()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data:{
|
||||
wrongList:[],
|
||||
answerArrays1: [],
|
||||
answerArrays2: [],
|
||||
answerArrays3: [],
|
||||
indexs:0,
|
||||
myoption: ["A", "B", "C", "D", "E", "F"],
|
||||
trueoption:[]
|
||||
},
|
||||
//判断正确选项乱序后的位置
|
||||
TrueOptionFunction:function(){
|
||||
var trueoptions = [];
|
||||
for(var i = 0;i < this.data.wrongList.length;i++){
|
||||
if (app.globalData.questions[this.data.wrongList[i].order].number == '3'){
|
||||
for(var j = 0;j < 3;j++){
|
||||
if(this.data.wrongList[i].trueOption == this.data.answerArrays1[j])
|
||||
{
|
||||
trueoptions.push(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (app.globalData.questions[this.data.wrongList[i].order].number == '4') {
|
||||
for (var j = 0; j < 4; j++) {
|
||||
if (this.data.wrongList[i].trueOption == this.data.answerArrays2[j]) {
|
||||
trueoptions.push(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var j = 0; j < 6; j++) {
|
||||
if (this.data.wrongList[i].trueOption == this.data.answerArrays3[j]) {
|
||||
trueoptions.push(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
trueoption: trueoptions
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
// console.log(JSON.parse(options.wrongList));
|
||||
// console.log(typeof JSON.parse(options.wrongList));
|
||||
//设置标题
|
||||
wx.setNavigationBarTitle({
|
||||
title: "错题集"
|
||||
})
|
||||
this.setData({
|
||||
wrongList:JSON.parse(options.wrongList),
|
||||
answerArrays1: JSON.parse(options.answerArrays1),
|
||||
answerArrays2: JSON.parse(options.answerArrays2),
|
||||
answerArrays3: JSON.parse(options.answerArrays3)
|
||||
})
|
||||
this.setData({
|
||||
wrongquestionImage: app.globalData.questions[this.data.wrongList[this.data.indexs].order].question,
|
||||
//wrongquestionDetail: app.globalData.questions[this.data.wrongList[this.data.indexs].order].question,
|
||||
wrongoptionnumber: app.globalData.questions[this.data.wrongList[this.data.indexs].order].number,
|
||||
wrongoptions: app.globalData.questions[this.data.wrongList[this.data.indexs].order].option
|
||||
})
|
||||
this.TrueOptionFunction();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
},
|
||||
next:function(){
|
||||
if(this.data.indexs < this.data.wrongList.length - 1){
|
||||
this.setData({
|
||||
indexs:this.data.indexs+1
|
||||
})
|
||||
this.setData({
|
||||
wrongquestionImage: app.globalData.questions[this.data.wrongList[this.data.indexs].order].question,
|
||||
//wrongquestionDetail: app.globalData.questions[this.data.wrongList[this.data.indexs].order].question,
|
||||
wrongoptionnumber: app.globalData.questions[this.data.wrongList[this.data.indexs].order].number,
|
||||
wrongoptions: app.globalData.questions[this.data.wrongList[this.data.indexs].order].option
|
||||
})
|
||||
}
|
||||
},
|
||||
goFirst:function(){
|
||||
wx.redirectTo({
|
||||
url: '../index/index'
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,48 @@
|
||||
<view class="page" hover='true' hover-stay-time="20000" >
|
||||
<view class='page__hd'>
|
||||
<view class="page__title">{{indexs+1}}、
|
||||
<view class='page_title_question'><image wx:if="{{wrongquestionImage!=''}}" src="{{wrongquestionImage}}" class='myimage' mode="widthFix"></image></view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="page__bd">
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
|
||||
<view wx:if="{{wrongoptionnumber == '3'}}">
|
||||
<view class="weui-cell " wx:for="{{answerArrays1}}" wx:key="index">
|
||||
|
||||
<view>{{myoption[index]}}、<image src="{{wrongoptions[answerArrays1[index]]}}" class='myoptionimage' mode="widthFix"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{wrongoptionnumber == '4'}}">
|
||||
<view class="weui-cell " wx:for="{{answerArrays2}}" wx:key="index">
|
||||
|
||||
<view>{{myoption[index]}}、<image src="{{wrongoptions[answerArrays2[index]]}}" class='myoptionimage' mode="widthFix"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else>
|
||||
<view class="weui-cell " wx:for="{{answerArrays3}}" wx:key="index">
|
||||
|
||||
<view>{{myoption[index]}}、<image src="{{wrongoptions[answerArrays3[index]]}}" class='myoptionimage' mode="widthFix"></image></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='page_ft'>
|
||||
<view>
|
||||
<view class='wronganswer'><text>您的答案为{{wrongList[indexs].wrongOption}}</text></view>
|
||||
<view class='trueanswer'><text>正确答案为{{myoption[trueoption[indexs]]}}</text></view>
|
||||
</view>
|
||||
|
||||
<view class='mybutton'>
|
||||
<button bindtap='goFirst' wx:if="{{indexs == wrongList.length-1}}">返回首页</button>
|
||||
<button bindtap='next' wx:else>下一题</button>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,38 @@
|
||||
{
|
||||
"description": "项目配置文件。",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
}
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "3.4.9",
|
||||
"appid": "wxcc2f96e8099af69a",
|
||||
"projectname": "z",
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "test",
|
||||
"pathName": "pages/index/index",
|
||||
"query": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 2
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
const formatTime = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
|
||||
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||||
}
|
||||
|
||||
const formatNumber = n => {
|
||||
n = n.toString()
|
||||
return n[1] ? n : '0' + n
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime
|
||||
}
|
Loading…
Reference in new issue