138 lines
2.9 KiB
JavaScript
138 lines
2.9 KiB
JavaScript
|
|
// pages/QA/QA.js
|
||
|
|
Page({
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
questions: [],
|
||
|
|
showQuestions: [],
|
||
|
|
},
|
||
|
|
chooseYes(e) {
|
||
|
|
var departmentname = e.currentTarget.dataset.departmentname
|
||
|
|
wx.navigateTo({
|
||
|
|
url: '/pages/QAresult/Qaresult?departmentname=' + departmentname,
|
||
|
|
})
|
||
|
|
// console.log()
|
||
|
|
},
|
||
|
|
chooseNo(e) {
|
||
|
|
var tempList = this.data.showQuestions;
|
||
|
|
let a = tempList[tempList.length-1]
|
||
|
|
if(a.isLaseted=="1"){
|
||
|
|
var departmentname = e.currentTarget.dataset.departmentname
|
||
|
|
wx.navigateTo({
|
||
|
|
url: '/pages/QAresult/Qaresult?departmentname=' + departmentname,
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
for (var i = 0; i < tempList.length; i++) {
|
||
|
|
tempList[i]['isChoose'] = '1'
|
||
|
|
}
|
||
|
|
var tempData = this.data.questions.slice(tempList.length, tempList.length + 1)
|
||
|
|
console.log(tempData)
|
||
|
|
if (this.data.questions.length - tempList.length == 1) { //最后一个
|
||
|
|
console.log(tempData[0])
|
||
|
|
tempData[0]['isChoose'] = "0"
|
||
|
|
tempData[0]['isLaseted'] = "1"
|
||
|
|
} else {
|
||
|
|
tempData[0]['isChoose'] = '0';
|
||
|
|
tempData[0]['isLaseted'] = '0';
|
||
|
|
}
|
||
|
|
tempList.push(tempData[0])
|
||
|
|
console.log(tempList)
|
||
|
|
this.setData({
|
||
|
|
showQuestions: tempList
|
||
|
|
})
|
||
|
|
console.log("选择了否")
|
||
|
|
},
|
||
|
|
getQuestions(childid) {
|
||
|
|
// var childid = e.currentTarget.dataset.childid
|
||
|
|
wx.request({
|
||
|
|
url: 'https://fy.btlsoln.com:8443/IntelligentGuidance/getQuestions',
|
||
|
|
method: "GET",
|
||
|
|
data: {
|
||
|
|
childId: childid,
|
||
|
|
},
|
||
|
|
success: res => {
|
||
|
|
this.setData({
|
||
|
|
questions: JSON.parse(res.data.data)
|
||
|
|
})
|
||
|
|
var temp = this.data.questions.slice(0, 1)
|
||
|
|
if (this.data.questions.length == 1) {
|
||
|
|
// 新增是否被选择过的状态,新增最后一个数组的状态
|
||
|
|
temp[0]['isChoose'] = "0"
|
||
|
|
temp[0]['isLaseted'] = "1"
|
||
|
|
console.log(temp)
|
||
|
|
} else {
|
||
|
|
temp[0]['isChoose'] = "0"
|
||
|
|
temp[0]['isLaseted'] = "0"
|
||
|
|
}
|
||
|
|
console.log(temp[0])
|
||
|
|
this.setData({
|
||
|
|
showQuestions: temp
|
||
|
|
})
|
||
|
|
console.log(this.data.showQuestions)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad(options) {
|
||
|
|
var childid = options.childid
|
||
|
|
// console.log(options.childid)
|
||
|
|
this.getQuestions(childid)
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
|
*/
|
||
|
|
onReady() {
|
||
|
|
wx.setNavigationBarTitle({
|
||
|
|
title: '自测分诊'
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面显示
|
||
|
|
*/
|
||
|
|
onShow() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面隐藏
|
||
|
|
*/
|
||
|
|
onHide() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面卸载
|
||
|
|
*/
|
||
|
|
onUnload() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
|
*/
|
||
|
|
onPullDownRefresh() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面上拉触底事件的处理函数
|
||
|
|
*/
|
||
|
|
onReachBottom() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 用户点击右上角分享
|
||
|
|
*/
|
||
|
|
onShareAppMessage() {
|
||
|
|
|
||
|
|
}
|
||
|
|
})
|