fourth.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. Page({
  2. /**
  3. * 页面的初始数据
  4. */
  5. data: {
  6. allowNext:false,
  7. itemList:[],
  8. productList:[
  9. {title:'漆面膜',is_choose:false,product:[
  10. {title:'待施工单',is_choose:false},{title:'第一单',is_choose:false}
  11. ]},
  12. {title:'漆面膜',is_choose:false,product:[
  13. {title:'待施工单',is_choose:false},{title:'第一单',is_choose:false}
  14. ]},
  15. {title:'改色膜',is_choose:false,product:[ {title:'常规单',is_choose:false},{title:'售后单',is_choose:false},{title:'前装单',is_choose:false},{title:'赠送单',is_choose:false},{title:'待施工单',is_choose:false},{title:'第二单',is_choose:false}]},
  16. {title:'天窗冰甲',is_choose:false,product:[ {title:'常规单',is_choose:false},{title:'售后单',is_choose:false},{title:'前装单',is_choose:false},{title:'赠送单',is_choose:false},{title:'待施工单',is_choose:false},{title:'第三单',is_choose:false}]}
  17. ],
  18. },
  19. handleChooseItem(item){
  20. let data = this.data.itemList;
  21. data.forEach((v,idx)=>{
  22. if(idx===(item.target.dataset.index)*1){
  23. v.is_choose = !v.is_choose;
  24. }else{
  25. v.is_choose = false;
  26. }
  27. })
  28. if(data.every(v=>(!v.is_choose))){
  29. this.setData({
  30. allowNext:false
  31. })
  32. }else{
  33. this.setData({
  34. allowNext:true
  35. })
  36. }
  37. this.setData({
  38. itemList:data
  39. })
  40. },
  41. handleChoose(item){
  42. let data = this.data.productList;
  43. data.forEach((v,idx)=>{
  44. v.product.forEach(el=>{
  45. el.is_choose = false;
  46. })
  47. if(idx===(item.target.dataset.index)*1){
  48. v.is_choose = !v.is_choose;
  49. }else{
  50. v.is_choose = false;
  51. }
  52. })
  53. this.setData({
  54. allowNext:false,
  55. productList:data,
  56. itemList:data[(item.target.dataset.index)*1].is_choose?data[(item.target.dataset.index)*1].product:[],
  57. })
  58. },
  59. handleNext(){
  60. wx.navigateTo({
  61. url: '../fifth/fifth',
  62. })
  63. },
  64. handleReturn(){
  65. wx.navigateBack({
  66. delta:1
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面加载
  71. */
  72. onLoad(option) {
  73. const eventChannel = this.getOpenerEventChannel()
  74. // 监听 acceptDataFromOpenerPage 事件,获取上一页面通过 eventChannel 传送到当前页面的数据
  75. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  76. console.log(data)
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide() {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload() {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh() {
  103. },
  104. /**
  105. * 页面上拉触底事件的处理函数
  106. */
  107. onReachBottom() {
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage() {
  113. }
  114. })