accendant.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // pages/ucenter/myworksheet/accendant.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. items: []
  8. },
  9. checkboxChange(e) {
  10. //console.log('checkbox发生change事件,携带value值为:', e.detail.value);
  11. let accendants = [];
  12. e.detail.value.forEach((item,index) => {
  13. this.data.items.forEach((item1,index1)=>{
  14. if(item1.userId == item){
  15. accendants.push(item1.userName);
  16. }
  17. });
  18. });
  19. let pages = getCurrentPages();
  20. let prevPage = pages[pages.length - 2]; //上一个页面
  21. let worksheetinfo = prevPage.data.worksheetinfo;
  22. worksheetinfo.accendant = accendants.join(",");
  23. prevPage.setData({
  24. accendantids: e.detail.value,
  25. worksheetinfo
  26. });
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. let { chargstationid, accendant} = options;
  33. let accendants = accendant.split(",");
  34. //console.log(chargstationid);
  35. let that = this;
  36. wx.request({
  37. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/getuserstation',
  38. data: chargstationid,
  39. method: 'POST',
  40. success(res) {
  41. //console.log(res);
  42. let {
  43. data: items
  44. } = res;
  45. items.forEach((item, index) => {
  46. if (accendants.indexOf(item.userName) != -1){
  47. item.checked= true;
  48. }
  49. });
  50. that.setData({
  51. items
  52. });
  53. }
  54. });
  55. },
  56. /**
  57. * 生命周期函数--监听页面初次渲染完成
  58. */
  59. onReady: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面显示
  63. */
  64. onShow: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面隐藏
  68. */
  69. onHide: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面卸载
  73. */
  74. onUnload: function () {
  75. },
  76. /**
  77. * 页面相关事件处理函数--监听用户下拉动作
  78. */
  79. onPullDownRefresh: function () {
  80. },
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. onReachBottom: function () {
  85. },
  86. /**
  87. * 用户点击右上角分享
  88. */
  89. onShareAppMessage: function () {
  90. }
  91. })