1 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7ca8137d"],{"0a1d":function(t,e,n){"use strict";n.d(e,"d",(function(){return c})),n.d(e,"f",(function(){return s})),n.d(e,"e",(function(){return a})),n.d(e,"a",(function(){return o})),n.d(e,"c",(function(){return r})),n.d(e,"b",(function(){return u})),n.d(e,"g",(function(){return h})),n.d(e,"h",(function(){return f}));var i=n("9550");function c(t){return Object(i["a"])({url:"courses",method:"get",params:t})}function s(t){return Object(i["a"])({url:"coursess",method:"get",params:t})}function a(t){return Object(i["a"])({url:"coursess/".concat(t),method:"get"})}function o(t){return Object(i["a"])({url:"check/".concat(t),method:"get"})}function r(t){return Object(i["a"])({url:"checks",method:"get",params:t})}function u(t){return Object(i["a"])({url:"checks/".concat(t),method:"get"})}function h(t){return Object(i["a"])({url:"checks",method:"post",data:t})}function f(t){return Object(i["a"])({url:"check/".concat(t),method:"put"})}},"0baa":function(t,e,n){"use strict";n.r(e);n("ca0b"),n("d4e8"),n("933e"),n("fa76");var i=function(){var t=this,e=t._self._c;return e("div",{staticClass:"check"},[e("div",{staticClass:"checking"},[e("div",{staticClass:"top-nav-bar"},[e("span",{staticStyle:{"margin-right":"10px"}},[t._v("进度: "+t._s(t.active+1)+" / "+t._s(t.info.total))]),e("van-progress",{staticStyle:{flex:"1","margin-right":"10px"},attrs:{percentage:t.info.total?100*(t.active+1)/t.info.total:0,"show-pivot":!1}}),e("span",{staticStyle:{"margin-right":"5px"}},[t._v("用时:")]),e("van-count-down",{attrs:{time:1==t.info.state?1e3*(t.info.updated_at-t.info.created_at):t.now-1e3*t.info.created_at,"auto-start":!1}})],1),t.checks[t.active]?e("div",{staticClass:"checking-main"},[0==t.checks[t.active].type?[e("span",{staticClass:"check-title"},[t._v(t._s(t.checks[t.active].content))]),t._l(JSON.parse(t.checks[t.active].options),(function(n,i){return e("van-button",{key:i,staticClass:"check-option",attrs:{round:"",icon:i+1==t.checks[t.active].right?"success":i+1==t.checks[t.active].answer?0==t.info.state?"certificate":"cross":null,type:i+1==t.checks[t.active].answer?0==t.info.state?"info":i+1==t.checks[t.active].right?"primary":"danger":"default",block:""},on:{click:function(e){0==t.info.state&&t.select(i)}}},[t._v(t._s(n))])}))]:t._e(),1==t.checks[t.active].type?[e("span",{staticClass:"check-title"},[t._l(t.contentParse(t.checks[t.active].content),(function(n,i){return["text"==n.type?e("span",{key:i},[t._v(t._s(n.text))]):t._e(),"input"==n.type?[0==t.info.state?e("input",{directives:[{name:"model",rawName:"v-model",value:t.inputs[t.contentParse(t.checks[t.active].content).slice(0,i).filter((function(t){return"input"==t.type})).length],expression:"\n inputs[\n contentParse(checks[active].content)\n .slice(0, index)\n .filter((p) => p.type == 'input').length\n ]\n "}],key:i,staticClass:"answer-input",style:{width:n.long+"em"},attrs:{type:"text"},domProps:{value:t.inputs[t.contentParse(t.checks[t.active].content).slice(0,i).filter((function(t){return"input"==t.type})).length]},on:{change:function(e){t.inputs=t.inputs},input:function(e){e.target.composing||t.$set(t.inputs,t.contentParse(t.checks[t.active].content).slice(0,i).filter((function(t){return"input"==t.type})).length,e.target.value)}}}):e("span",{key:i,staticClass:"answer-input",style:{color:t.inputs[t.contentParse(t.checks[t.active].content).slice(0,i).filter((function(t){return"input"==t.type})).length]==t.jsonArray(t.checks[t.active].right)[t.contentParse(t.checks[t.active].content).slice(0,i).filter((function(t){return"input"==t.type})).length]?"#07c160":"#ee0a24"}},[t._v(t._s(t.inputs[t.contentParse(t.checks[t.active].content).slice(0,i).filter((function(t){return"input"==t.type})).length]))])]:t._e()]}))],2)]:t._e()],2):t._e(),t.checks[t.active]?e("div",{staticClass:"bottom-nav-bar"},[e("van-button",{attrs:{type:"default",icon:"arrow-left",disabled:0==t.active},on:{click:function(e){t.active--,t.updateActive()}}},[t._v("上一题")]),e("van-button",{directives:[{name:"show",rawName:"v-show",value:0==t.info.state,expression:"info.state == 0"}],staticStyle:{padding:"0 30px"},attrs:{type:"info",icon:"certificate",disabled:0==t.checks[t.active].type?0!=t.checks.filter((function(t){return""==t.answer})).length:0!=t.checks.filter((function(e,n){return n!=t.active&&""==e.answer})).length||t.inputs.filter((function(t){return t})).length!=t.contentParse(t.checks[t.active].content).filter((function(t){return"input"==t.type})).length},on:{click:t.handleSubmit}},[t._v("交卷")]),e("van-button",{attrs:{type:"default",icon:"arrow",disabled:t.active+1==t.checks.length||(0==t.checks[t.active].type?""==t.checks[t.active].answer:t.inputs.filter((function(t){return t})).length!=t.contentParse(t.checks[t.active].content).filter((function(t){return"input"==t.type})).length)},on:{click:t.next}},[t._v("下一题")])],1):t._e()])])},c=[],s=(n("844d"),n("7bb1"),n("c751"),n("a210"),n("6aff"),n("2a9b"),n("0a1d")),a={data:function(){return{id:0,info:{},checks:[],active:0,now:(new Date).getTime(),timer:null,inputs:[]}},created:function(){var t=this;this.id=this.$route.params&&this.$route.params.id,this.timer=setInterval((function(){t.now=(new Date).getTime()}),1e3)},mounted:function(){this.loadCheckInfo()},destroyed:function(){clearInterval(this.timer)},methods:{jsonArray:function(t){if("string"===typeof t)try{return JSON.parse(t)}catch(e){return[]}return t instanceof Array?t:[]},updateActive:function(){1!=this.checks[this.active].type||(this.inputs=this.jsonArray(this.checks[this.active].answer))},contentParse:function(t){var e=[];while(""!=t){var n=t.indexOf("_");if(-1==n)e.push({type:"text",text:t}),t="";else{for(n>0&&(e.push({type:"text",text:t.slice(0,n)}),t=t.slice(n)),n=0;n<t.length;n++)if("_"!=t[n])break;n>0&&(e.push({type:"input",long:n}),t=t.slice(n))}}return e},loadCheckInfo:function(){var t=this;this.$store.commit("loading/showLoading"),Object(s["b"])(this.id).then((function(e){t.checks=e.data.checks,t.info=e.data.info;var n=t.checks.findIndex((function(t){return 0==t.answer}));0==t.info.state&&0==t.active&&(t.active=n<0?t.checks.length-1:n),2==t.info.state&&t.$router.go(-1),t.updateActive(),t.$store.commit("loading/hideLoading")})).catch((function(){t.$store.commit("loading/hideLoading")}))},select:function(t){var e=this;this.$store.commit("loading/showLoading"),Object(s["g"])({checks_id:this.checks[this.active].id,answer:(t+1).toString()}).then((function(t){e.active<e.checks.length-1&&e.active++,e.loadCheckInfo()})).catch((function(){e.$store.commit("loading/hideLoading")}))},next:function(){var t=this;if(0!=this.info.state||0==this.checks[this.active].type)return this.active++,void this.updateActive();this.$store.commit("loading/showLoading"),Object(s["g"])({checks_id:this.checks[this.active].id,answer:JSON.stringify(this.inputs).toString()}).then((function(e){t.active<t.checks.length-1&&t.active++,t.loadCheckInfo()})).catch((function(){t.$store.commit("loading/hideLoading")}))},handleSubmit:function(){var t=this;0!=this.checks[this.active].type?(this.$store.commit("loading/showLoading"),Object(s["g"])({checks_id:this.checks[this.active].id,answer:JSON.stringify(this.inputs).toString()}).then((function(e){t.submit()})).catch((function(){t.$store.commit("loading/hideLoading")}))):this.submit()},submit:function(){var t=this;this.$store.commit("loading/showLoading"),Object(s["h"])(this.info.id).then((function(e){t.active=0,t.loadCheckInfo()})).catch((function(){t.$store.commit("loading/hideLoading")}))}}},o=a,r=(n("4456"),n("e607")),u=Object(r["a"])(o,i,c,!1,null,"60eba33f",null);e["default"]=u.exports},4456:function(t,e,n){"use strict";n("b357")},b357:function(t,e,n){},c751:function(t,e,n){"use strict";var i=n("b323"),c=n("be37").findIndex,s=n("6fe3"),a="findIndex",o=!0;a in[]&&Array(1)[a]((function(){o=!1})),i({target:"Array",proto:!0,forced:o},{findIndex:function(t){return c(this,t,arguments.length>1?arguments[1]:void 0)}}),s(a)}}]);
|