"use strict";const t=require("../../common/vendor.js"),c=require("../../api/index.js"),h={data(){return{isChecked:!0,isShake:!1,scaleDetail:{},questionList:[],currentQuestion:{},currentAnswerList:[],currentIndex:0,userAnswerList:[],resultId:"",isLoading:!1,isDisbale:!1,maxLength:0,userInfo:{}}},computed:{percentage(){return this.currentIndex/this.maxLength*652+"rpx"}},created(){this.loadData(),this.userInfo=t.index.getStorageSync("user")},methods:{loadData(){this.$request.get({url:"scaleInfo/20210820143117",loadingTip:"加载中...",data:{}}).then(e=>{this.questionList=JSON.parse(JSON.stringify(e.data)),this.maxLength=this.questionList.length,this.currentQuestion=this.questionList[this.currentIndex],this.currentAnswerList=this.getAnswerItem(this.currentQuestion.checkItems)})},nextHandle(e){this.isDisbale||(this.isDisbale=!0,this.userAnswerList[this.currentIndex]=JSON.parse(JSON.stringify(this.currentQuestion)),this.userAnswerList[this.currentIndex].checkItems=e,this.currentIndex>=this.questionList.length-1?this.isDisbale=!1:setTimeout(()=>{this.currentIndex++,this.currentQuestion=this.questionList[this.currentIndex],this.currentAnswerList=this.getAnswerItem(this.currentQuestion.checkItems),this.isDisbale=!1},150))},prevHandle(){setTimeout(()=>{this.currentIndex--,this.currentQuestion=this.questionList[this.currentIndex],this.currentAnswerList=this.getAnswerItem(this.currentQuestion.checkItems)},300)},submitResult(){let e=this;if(e.isLoading)return;e.isLoading=!0;let u={testPlanId:"",scale_result:e.userAnswerList,userId:t.index.getStorageSync("setUerInfo").user.id};t.index.showLoading({title:"测试结果生成中"}),e.$request.post({url:`${c.getResult}/20210820143117`,loadingTip:"加载中...",data:u}).then(i=>{e.isLoading=!1,e.resultId=i.data,t.index.hideLoading(),e.getQueryPromotionBySubjectId()}).catch(()=>{e.isLoading=!1,t.index.showToast({icon:"none",title:"提交失败"}),t.index.hideLoading()})},async getQueryPromotionBySubjectId(){let e=this,u=c.queryPromotionBySubjectId+"/20210820143117";await e.$request.get({url:u,loadingTip:"加载中...",data:{}}).then(i=>{var s;console.log("量表支付信息",i.data);let a=i.data;if(a.price==0)t.index.navigateTo({url:`/newScale/EQtest/testResult?resultId=${e.resultId}&messageShare=1`});else{let r={productId:"20210820143117",userId:(s=e.userInfo)==null?void 0:s.id,resultId:e.resultId,description:a.name,total:a.price,sceneType:t.index.getSystemInfoSync().platform=="android"?"Android":"iOS"};t.index.setStorageSync("orderInfo",r),t.index.navigateTo({url:"/newScale/EQtest/paymentPage"})}})},checkActive(e){return this.userAnswerList[this.currentIndex]&&this.userAnswerList[this.currentIndex].checkItems==e?"active":""},getAnswerItem(e){return e.split(";")}}};function o(e,u,i,a,s,r){return{a:r.percentage,b:t.t(s.currentIndex+1),c:t.t(s.maxLength),d:t.t(s.currentQuestion.answer),e:t.f(s.currentAnswerList,(n,d,g)=>({a:t.t(n),b:t.n(`answer${d+1}`),c:t.n(r.checkActive(n)),d:t.o(I=>r.nextHandle(n))})),f:s.currentIndex>0,g:t.o((...n)=>r.prevHandle&&r.prevHandle(...n)),h:s.currentIndex>=s.maxLength-1,i:t.o((...n)=>r.submitResult&&r.submitResult(...n))}}const l=t._export_sfc(h,[["render",o],["__scopeId","data-v-a0c71dc4"],["__file","E:/psy_web_share/newScale/EQtest/testPage.vue"]]);tt.createPage(l);