小程序看题模式

This commit is contained in:
caoqianming 2020-11-18 14:42:20 +08:00
parent e15ed90ae1
commit b075c6adad
7 changed files with 123 additions and 74 deletions

View File

@ -16,13 +16,27 @@ Page({
answerP: false, answerP: false,
page:1, page:1,
domain:getApp().globalData.mediahost, domain:getApp().globalData.mediahost,
moShi:'背题模式',
},
changeM: function () {
var that = this
if(that.data.moShi=='看题模式'){
that.setData({
moShi:'背题模式',
})
that.showOptions()
}else{
that.setData({
moShi: '看题模式',
})
}
}, },
radioChange: function(e) { radioChange: function(e) {
var that = this var that = this
that.data.tm_current['user_answer'] = e.detail.value that.data.tm_current['user_answer'] = e.detail.value
that.data.tms[that.data.tm_index] = that.data.tm_current that.data.tms[that.data.tm_index] = that.data.tm_current
that.showAnswer() that.showAnswer()
if (that.data.ydtms.indexOf(that.data.tm_current.id) == -1) { if (that.data.moShi=='背题模式' && that.data.ydtms.indexOf(that.data.tm_current.id) == -1) {
that.data.ydtms.push(that.data.tm_current.id) that.data.ydtms.push(that.data.tm_current.id)
} }
}, },
@ -30,7 +44,7 @@ Page({
var that = this var that = this
that.data.tm_current['user_answer'] = e.detail.value that.data.tm_current['user_answer'] = e.detail.value
that.data.tms[that.data.tm_index] = that.data.tm_current that.data.tms[that.data.tm_index] = that.data.tm_current
if (that.data.ydtms.indexOf(that.data.tm_current.id) == -1) { if (that.data.moShi=='背题模式' && that.data.ydtms.indexOf(that.data.tm_current.id) == -1) {
that.data.ydtms.push(that.data.tm_current.id) that.data.ydtms.push(that.data.tm_current.id)
} }
}, },
@ -156,6 +170,14 @@ Page({
if (tm_current.user_answer) { if (tm_current.user_answer) {
that.showAnswer() that.showAnswer()
} }
else{
that.setData({
isright:false
})
}
if (that.data.moShi=='看题模式' && that.data.ydtms.indexOf(that.data.tm_current.id) == -1) {
that.data.ydtms.push(that.data.tm_current.id)
}
} }
}, },
@ -230,15 +252,19 @@ Page({
let option = {} let option = {}
option.key = key option.key = key
option.value = tm_current.options[key].toString() option.value = tm_current.options[key].toString()
option.checked = false
option.right = false
if(option.key == tm_current.right||tm_current.right.indexOf(option.key)!=-1){
option.right = true
}
if (tm_current.user_answer) { if (tm_current.user_answer) {
if (key == tm_current.user_answer || tm_current.user_answer.indexOf(key) != -1) { if (key == tm_current.user_answer || tm_current.user_answer.indexOf(key) != -1) {
option.checked = true option.checked = true
} }
} else {
option.checked = false
} }
options.push(option) options.push(option)
} }
console.log(options)
this.setData({ this.setData({
options: options options: options
}) })

View File

@ -1,5 +1,11 @@
<view class="head"> <view class="head">
题量: {{tm_index+1}}/{{tmtotal}} <view style="width:50%">
<span style="margin-left:10px">题量: {{tm_index+1}}/{{tmtotal}}</span>
</view>
<view style="width:50%;text-align:right" bindtap="changeM">
<span style="margin-right:10px"><span style="font-weight:bold;">{{moShi}}</span>
(点击切换)</span>
</view>
</view> </view>
<scroll-view scroll-y="true" style="height: {{scrollHeight}}px;"> <scroll-view scroll-y="true" style="height: {{scrollHeight}}px;">
<view class="weui-article"> <view class="weui-article">
@ -14,9 +20,15 @@
<view class="weui-cells weui-cells_radio"> <view class="weui-cells weui-cells_radio">
<radio-group class="radio-group" bindchange="radioChange" wx:if="{{(tm_current.type=='单选' ||tm_current.type=='判断')}}"> <radio-group class="radio-group" bindchange="radioChange" wx:if="{{(tm_current.type=='单选' ||tm_current.type=='判断')}}">
<label class="weui-cell weui-cell_active weui-check__label" wx:for="{{options}}" wx:key="key"> <label class="weui-cell weui-cell_active weui-check__label" wx:for="{{options}}" wx:key="key">
<view class="weui-cell__bd"> <view class="weui-cell__bd" >
<view style="font-weight:bold;color:green" wx:if="{{ moShi == '看题模式' && item.right}}">
<view style="float:left;width:10%">{{item.key}}:</view> <view style="float:left;width:10%">{{item.key}}:</view>
<view style="float:left;width:90%"><parser html="{{item.value}}" domain="{{domain}}" selectable /></view> <view style="float:left;width:90%"><parser html="{{item.value}}" domain="{{domain}}" selectable /></view>
</view>
<view wx:else>
<view style="float:left;width:10%">{{item.key}}:</view>
<view style="float:left;width:90%"><parser html="{{item.value}}" domain="{{domain}}" selectable /></view>
</view>
</view> </view>
<view class="weui-cell__ft"> <view class="weui-cell__ft">
<radio class="weui-check" value="{{item.key}}" checked="{{item.checked}}" /> <radio class="weui-check" value="{{item.key}}" checked="{{item.checked}}" />
@ -30,8 +42,14 @@
<label class="weui-cell weui-cell_active weui-check__label" wx:for="{{options}}" wx:key="key"> <label class="weui-cell weui-cell_active weui-check__label" wx:for="{{options}}" wx:key="key">
<view class="weui-cell__bd" > <view class="weui-cell__bd" >
<view style="font-weight:bold;color:green" wx:if="{{ moShi == '看题模式' && item.right}}">
<view style="float:left;width:10%">{{item.key}}:</view> <view style="float:left;width:10%">{{item.key}}:</view>
<view style="float:left;width:90%"><parser html="{{item.value}}" domain="{{domain}}" selectable /></view> <view style="float:left;width:90%"><parser html="{{item.value}}" domain="{{domain}}" selectable /></view>
</view>
<view wx:else>
<view style="float:left;width:10%">{{item.key}}:</view>
<view style="float:left;width:90%"><parser html="{{item.value}}" domain="{{domain}}" selectable /></view>
</view>
</view> </view>
<view class="weui-cell__hd"> <view class="weui-cell__hd">
<checkbox class="weui-check" value="{{item.key}}" checked="{{item.checked}}"/> <checkbox class="weui-check" value="{{item.key}}" checked="{{item.checked}}"/>
@ -40,10 +58,10 @@
</label> </label>
</checkbox-group> </checkbox-group>
</view> </view>
<view class="weui-article" wx:if="{{answerP}}"> <view class="weui-article" wx:if="{{answerP||moShi=='看题模式'}}">
<view class="weui-article__h2" wx:if="{{isright}}" style="color:green;font-weight:bold">回答正确!</view> <view class="weui-article__h2" wx:if="{{isright}}" style="color:green;font-weight:bold">回答正确!</view>
<view class="weui-article__h2" wx:else style="color:red;font-weight:bold">回答有误!</view> <view class="weui-article__h2" wx:else style="color:red;font-weight:bold">回答有误!</view>
<view class="weui-article__h2">正确答案是{{tm_current.right}},你的答案是{{tm_current.user_answer}}</view> <view class="weui-article__h2">正确答案是 {{tm_current.right}},你的答案是 {{tm_current.user_answer}}</view>
<view class="weui-article__title"> <view class="weui-article__title">
<span style="color:blue">解析: </span> <span style="color:blue">解析: </span>
<span wx:if="{{tm_current.resolution}}">{{tm_current.resolution}}</span> <span wx:if="{{tm_current.resolution}}">{{tm_current.resolution}}</span>

View File

@ -3,7 +3,9 @@
height:30px; height:30px;
color:#fff; color:#fff;
background-color: cornflowerblue; background-color: cornflowerblue;
text-align: center; text-align: left;
display:flex;
flex-direction: row;
} }
.btns{ .btns{
height:40px; height:40px;

View File

@ -140,6 +140,7 @@ Page({
wx.openDocument({ wx.openDocument({
filePath, filePath,
fileType: filetype, fileType: filetype,
showMenu: true,
success(res) { success(res) {
wx.hideLoading() wx.hideLoading()
console.log('打开文档成功') console.log('打开文档成功')

View File

@ -72,6 +72,7 @@ Page({
wx.openDocument({ wx.openDocument({
filePath, filePath,
fileType: filetype, fileType: filetype,
showMenu: true,
success(res) { success(res) {
wx.hideLoading() wx.hideLoading()
console.log('打开文档成功') console.log('打开文档成功')
@ -88,7 +89,7 @@ Page({
api.request('/cms/material/','get', {name:'个人防护用品检测申请单'}).then(res=>{ api.request('/cms/material/','get', {name:'个人防护用品检测申请单'}).then(res=>{
var res1 = res.data var res1 = res.data
if(res1.count){ if(res1.count){
var fileurl = getApp().globalData.host + res1[0].path var fileurl = getApp().globalData.host + res1.results[0].path
wx.showLoading({ wx.showLoading({
title: '正在下载...', title: '正在下载...',
}) })
@ -127,6 +128,7 @@ Page({
wx.openDocument({ wx.openDocument({
filePath, filePath,
fileType: filetype, fileType: filetype,
showMenu: true,
success(res) { success(res) {
wx.hideLoading() wx.hideLoading()
console.log('打开文档成功') console.log('打开文档成功')

View File

@ -1,7 +1,7 @@
<view > <view >
<view class="weui-form__text-area" style="margin-top:20px;padding: 0 18px;"> <view class="weui-form__text-area" style="margin-top:20px;padding: 0 18px;">
<h2 class="weui-form__title">个人防护用品检测(铅当量)</h2> <h2 class="weui-form__title">个人防护用品检测(铅当量)</h2>
<view class="weui-form__desc">中科辐射学堂和国家建材工业安防工程产品质量监督检验中心推出个人防护用品合格检测,限每个核技术利用单位在10月31日之前免费检测一套个人防护用品,如有需要请提交您的申请。</view> <view class="weui-form__desc">中科辐射学堂和国家建材工业安防工程产品质量监督检验中心推出个人防护用品合格检测,免费检测一套个人防护用品,如有需要请提交您的申请。</view>
</view> </view>
<view style="text-align:center"> <view style="text-align:center">
<button class="mini-btn" type="default" size="mini" bindtap="tap1">介绍和案例</button> <button class="mini-btn" type="default" size="mini" bindtap="tap1">介绍和案例</button>

View File

@ -1,65 +1,65 @@
{ {
"description": "项目配置文件", "description": "项目配置文件",
"packOptions": { "packOptions": {
"ignore": [] "ignore": []
}, },
"setting": { "setting": {
"urlCheck": false, "urlCheck": false,
"es6": true, "es6": true,
"enhance": true, "enhance": true,
"postcss": true, "postcss": true,
"preloadBackgroundData": false, "preloadBackgroundData": false,
"minified": true, "minified": true,
"newFeature": true, "newFeature": true,
"coverView": true, "coverView": true,
"nodeModules": true, "nodeModules": true,
"autoAudits": false, "autoAudits": false,
"showShadowRootInWxmlPanel": true, "showShadowRootInWxmlPanel": true,
"scopeDataCheck": false, "scopeDataCheck": false,
"uglifyFileName": false, "uglifyFileName": false,
"checkInvalidKey": true, "checkInvalidKey": true,
"checkSiteMap": true, "checkSiteMap": true,
"uploadWithSourceMap": true, "uploadWithSourceMap": true,
"compileHotReLoad": false, "babelSetting": {
"useMultiFrameRuntime": false, "ignore": [],
"useApiHook": true, "disablePlugins": [],
"babelSetting": { "outputPath": ""
"ignore": [], },
"disablePlugins": [], "useCompilerModule": false,
"outputPath": "" "userConfirmedUseCompilerModuleSwitch": false,
}, "compileHotReLoad": false,
"useIsolateContext": true, "useMultiFrameRuntime": false,
"useCompilerModule": true, "useApiHook": true,
"userConfirmedUseCompilerModuleSwitch": false, "useIsolateContext": true,
"packNpmManually": false, "packNpmManually": false,
"packNpmRelationList": [] "packNpmRelationList": []
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.10.3", "libVersion": "2.10.3",
"appid": "wxf1e9471c93f05ad6", "appid": "wxf1e9471c93f05ad6",
"projectname": "test_mini", "projectname": "test_mini",
"debugOptions": { "debugOptions": {
"hidedInDevtools": [] "hidedInDevtools": []
}, },
"isGameTourist": false, "isGameTourist": false,
"simulatorType": "wechat", "simulatorType": "wechat",
"simulatorPluginLibVersion": {}, "simulatorPluginLibVersion": {},
"condition": { "condition": {
"search": { "search": {
"current": -1, "current": -1,
"list": [] "list": []
}, },
"conversation": { "conversation": {
"current": -1, "current": -1,
"list": [] "list": []
}, },
"game": { "game": {
"currentL": -1, "currentL": -1,
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": -1, "current": -1,
"list": [] "list": []
} }
} }
} }