//logs.js // const util = require('../../utils/util.js') // const app = require('../../utils/util.js'); Page({ data: { showSelect: false, //多选的问题 manyi: [{ id: 1, name: '不满意' }, { id: 2, name: '一般' }, { id: 3, name: '满意' }], checkboxArr: [{ checked: false, id: "1", name: "通俗易懂", }, { checked: false, id: "2", name: "准点时间", }, { checked: false, id: "3", name: "礼貌友好", }, { checked: false, id: "4", name: "携带工具", }, { checked: false, id: "5", name: "认真", }, { checked: false, id: "6", name: "很专心", }, { checked: false, id: "7", name: "积极向上", }, { checked: false, id: "8", name: "完成服务培训标准", }, ], remarks: [], arr: [], }, parameterTap(e) { let that = this let this_checked = e.currentTarget.dataset.id let parameterList = this.data.manyi for (let i = 0; i < parameterList.length; i++) { if (parameterList[i].id == this_checked) { parameterList[i].checked = true; } else { parameterList[i].checked = false; } } that.setData({ manyi: parameterList }) }, // checkboxChange(e) { // console.log('checkbox发生change事件,携带value值为:', e.detail.value) // const items = this.data.checkboxArr // const values = e.detail.value // this.setData({ // remarks: values // }) // for (let i = 0, lenI = items.length; i < lenI; ++i) { // items[i].checked = false // for (let j = 0, lenJ = values.length; j < lenJ; ++j) { // if (items[i].name === values[j]) { // items[i].checked = true // this.setData({ // showSelect:true // }) // console.log(this.data.showSelect, "55555"); // break // } // } // } // this.setData({ // items // }) // }, checkboxChange: function (event) { console.log(event, "000000000000000000000"); for (let i = 0; i < this.data.checkboxArr.length; i++) { if (event.currentTarget.id == this.data.checkboxArr[i].id) { if (this.data.checkboxArr[i].checked == true) { this.data.arr.pop(this.data.checkboxArr[i].name); console.log("8588888888888888"); this.data.checkboxArr[i].checked = false; let checkboxArr = this.data.checkboxArr; this.setData({ checkboxArr, remarks: this.data.arr }) } else { this.data.arr.push(this.data.checkboxArr[i].name); this.data.checkboxArr[i].checked = true; let checkboxArr = this.data.checkboxArr; this.setData({ checkboxArr, remarks: this.data.arr }), console.log(this.data.remarks, "333333333333333333"); } } } }, formSubmit(e) { console.log("提交评价"); console.log(this.data.remarks); let pingjia = '' this.data.manyi.forEach(item => { if (item.checked) { pingjia = item.name; } }) console.log(pingjia,"11111"); }, onLoad: function () { } })