const app = require('../../utils/util.js');
const tools = require('../../utils/tools.js');
Page({
  data: {
    gridArr: [],
  },
  chengji(sessionKey, answersId) {
    wx.request({
      url: app.globalData.publicUrl + '/wx/answer/detail',
      method: "post",
      data: {
        sessionKey,
        answersId
      },
      success: (res) => {
        if (res.data.code == 0) {
          console.log(res,"000000")
         
         let gridArr =  res.data.list.map(item=>{
            let json = {};
            if( item.correctAnswer){
               json.correctAnswer = item.correctAnswer.split("||").join('')
            }
            if( item.currentAnswer){
              json.currentAnswer = item.currentAnswer.split("||").join('')
           }
            json.score = item.score;
            json.questStem =  item.questStem;
            json.answerScore =  item.answerScore;
            return json;
          })
          this.setData({
            gridArr: gridArr
          })
        }
      }
    })
  },
  async onLoad(options) {
    let answersId = options.answersId;
    const sessionKey = await tools.checkSessionAndLogin();
    this.chengji(sessionKey, answersId);
  },
})