evaluationCourse.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //logs.js
  2. // const util = require('../../utils/util.js')
  3. // const app = require('../../utils/util.js');
  4. Page({
  5. data: {
  6. showSelect: false, //多选的问题
  7. manyi: [{
  8. id: 1,
  9. name: '不满意'
  10. }, {
  11. id: 2,
  12. name: '一般'
  13. }, {
  14. id: 3,
  15. name: '满意'
  16. }],
  17. checkboxArr: [{
  18. checked: false,
  19. id: "1",
  20. name: "通俗易懂",
  21. },
  22. {
  23. checked: false,
  24. id: "2",
  25. name: "准点时间",
  26. },
  27. {
  28. checked: false,
  29. id: "3",
  30. name: "礼貌友好",
  31. },
  32. {
  33. checked: false,
  34. id: "4",
  35. name: "携带工具",
  36. },
  37. {
  38. checked: false,
  39. id: "5",
  40. name: "认真",
  41. },
  42. {
  43. checked: false,
  44. id: "6",
  45. name: "很专心",
  46. },
  47. {
  48. checked: false,
  49. id: "7",
  50. name: "积极向上",
  51. },
  52. {
  53. checked: false,
  54. id: "8",
  55. name: "完成服务培训标准",
  56. },
  57. ],
  58. remarks: [],
  59. arr: [],
  60. },
  61. parameterTap(e) {
  62. var that = this
  63. var this_checked = e.currentTarget.dataset.id
  64. var parameterList = this.data.manyi
  65. for (var i = 0; i < parameterList.length; i++) {
  66. if (parameterList[i].id == this_checked) {
  67. parameterList[i].checked = true;
  68. } else {
  69. parameterList[i].checked = false;
  70. }
  71. }
  72. that.setData({
  73. manyi: parameterList
  74. })
  75. },
  76. // checkboxChange(e) {
  77. // console.log('checkbox发生change事件,携带value值为:', e.detail.value)
  78. // const items = this.data.checkboxArr
  79. // const values = e.detail.value
  80. // this.setData({
  81. // remarks: values
  82. // })
  83. // for (let i = 0, lenI = items.length; i < lenI; ++i) {
  84. // items[i].checked = false
  85. // for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  86. // if (items[i].name === values[j]) {
  87. // items[i].checked = true
  88. // this.setData({
  89. // showSelect:true
  90. // })
  91. // console.log(this.data.showSelect, "55555");
  92. // break
  93. // }
  94. // }
  95. // }
  96. // this.setData({
  97. // items
  98. // })
  99. // },
  100. checkboxChange: function (event) {
  101. console.log(event, "000000000000000000000");
  102. for (var i = 0; i < this.data.checkboxArr.length; i++) {
  103. if (event.currentTarget.id == this.data.checkboxArr[i].id) {
  104. if (this.data.checkboxArr[i].checked == true) {
  105. this.data.arr.pop(this.data.checkboxArr[i].name);
  106. console.log("8588888888888888");
  107. this.data.checkboxArr[i].checked = false;
  108. var checkboxArr = this.data.checkboxArr;
  109. this.setData({
  110. checkboxArr,
  111. remarks: this.data.arr
  112. })
  113. } else {
  114. this.data.arr.push(this.data.checkboxArr[i].name);
  115. this.data.checkboxArr[i].checked = true;
  116. var checkboxArr = this.data.checkboxArr;
  117. this.setData({
  118. checkboxArr,
  119. remarks: this.data.arr
  120. }),
  121. console.log(this.data.remarks, "333333333333333333");
  122. }
  123. }
  124. }
  125. },
  126. formSubmit(e) {
  127. console.log("提交评价");
  128. console.log(this.data.remarks);
  129. let pingjia = ''
  130. this.data.manyi.forEach(item => {
  131. if (item.checked) {
  132. pingjia = item.name;
  133. }
  134. })
  135. console.log(pingjia,"11111");
  136. },
  137. onLoad: function () {
  138. }
  139. })