index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. var isAll = false
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. // 主体高度
  11. infoHeight: '',
  12. frameStyle: { useTop: true, name: '已上传图片', leftArrow: true, useBar: false },
  13. list: [
  14. {
  15. id: '1', name: '朝阳沟第三节力气大赛', time: '2020.11.12', shop1: '/image/shop1.png', shop2: '/image/shop2.png', shop3: '/image/shop3.png',
  16. },
  17. {
  18. id: '1', name: '朝阳沟第三节力气大赛', time: '2020.11.12', shop1: '/image/shop1.png', shop2: '/image/shop2.png', shop3: '/image/shop3.png',
  19. }
  20. ],
  21. },
  22. back: function () {
  23. wx.navigateBack({ url: '/pages/me/index' })
  24. },
  25. //提交
  26. formSubmit: function (e) {
  27. console.log('form发生了submit事件,携带数据为:', e.detail.value)
  28. },
  29. //实现全选的点击事件,首先要定义一个全局变量isAll=false,让复选框默认为不勾选状态
  30. checkq: function () {
  31. var list = this.data.list;
  32. console.log(list);
  33. isAll = !isAll;
  34. if (isAll) {
  35. for (var i = 0; i < list.length; i++) {
  36. var item = list[i];
  37. item.isCheck = true
  38. list.splice(i, 1, item)
  39. }
  40. } else {
  41. for (var i = 0; i < list.length; i++) {
  42. var item = list[i];
  43. item.isCheck = false
  44. list.splice(i, 1, item)
  45. }
  46. }
  47. this.setData({
  48. list: list
  49. })
  50. },
  51. //点击减号删除
  52. delList: function () {
  53. var list = this.data.list;
  54. list.pop(); //实质是删除lists数组内容,使for循环少一次
  55. this.setData({
  56. list: list,
  57. })
  58. },
  59. //删除图片
  60. deleteImg: function (e) {
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function (options) {
  66. // 计算高度
  67. this.searchHeight()
  68. },
  69. // 计算高度
  70. searchHeight: function () {
  71. let frameStyle = this.data.frameStyle;
  72. let client = app.globalData.client;
  73. // 减去状态栏
  74. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  75. // 是否减去底部菜单
  76. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  77. if (infoHeight) this.setData({ infoHeight: infoHeight })
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload: function () {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh: function () {
  103. },
  104. /**
  105. * 页面上拉触底事件的处理函数
  106. */
  107. onReachBottom: function () {
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage: function () {
  113. }
  114. })