index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '创建比赛', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. value: [],
  13. list: [],
  14. // 原数据
  15. levelArray: [
  16. ['淘汰制', '循环制'],
  17. ['单败淘汰', '双败淘汰', '交叉淘汰'],
  18. ['单循环', '双循环', '四循环']
  19. ],
  20. date: '2018-01-01',//默认起始时间
  21. date2: '2018-01-24',//默认结束时间
  22. singledate: '2018-09-01',
  23. time: '12:01',
  24. szList: [],
  25. },
  26. // 确定选择
  27. szChange: function (e) {
  28. const that = this;
  29. let value = e.detail.value;
  30. let list = that.data.list;
  31. let data = []
  32. for (let [index, val] of value.entries()) {
  33. if (list[index][val]) data.push(list[index][val])
  34. else data.push(list[index][0])
  35. }
  36. //存值
  37. let sz = [...that.data.szList, { type: data[0], name: data[1] }]
  38. that.setData({ szList: sz })
  39. that.setData({ value: data })
  40. that.search();
  41. },
  42. // 列值改变时
  43. columnChange: function (e) {
  44. const that = this;
  45. let array = that.data.levelArray;
  46. let list = that.data.list;
  47. if (e.detail.column == '0') list[1] = array[parseInt(e.detail.value) + 1];
  48. that.setData({ list: list });
  49. },
  50. //删除
  51. toDel: function (e) {
  52. const that=this;
  53. let list=that.data.szList;
  54. let value =e.currentTarget.dataset.index;
  55. let data=list.filter((i,index)=>index!=value)
  56. this.setData({szList:data})
  57. },
  58. search: function () {
  59. const that = this;
  60. let data = that.data.levelArray;
  61. that.setData({ list: [data[0], data[1]] })
  62. },
  63. bindDateChange3: function (e) {
  64. console.log('picker发送选择改变,携带值为', e.detail.value)
  65. this.setData({
  66. singledate: e.detail.value
  67. })
  68. },
  69. bindTimeChange: function (e) {
  70. console.log('picker发送选择改变,携带值为', e.detail.value)
  71. this.setData({
  72. time: e.detail.value
  73. })
  74. },
  75. // 时间段选择
  76. bindDateChange(e) {
  77. let that = this;
  78. console.log(e.detail.value)
  79. that.setData({
  80. date: e.detail.value,
  81. })
  82. },
  83. bindDateChange2(e) {
  84. let that = this;
  85. that.setData({
  86. date2: e.detail.value,
  87. })
  88. },
  89. back: function () {
  90. wx.navigateBack({ url: '/pages/home/index' })
  91. },
  92. /**
  93. * 生命周期函数--监听页面加载
  94. */
  95. onLoad: function (options) {
  96. // 计算高度
  97. this.searchHeight()
  98. const that = this;
  99. // 初始化数据
  100. console.log(that.data.value);
  101. that.search();
  102. },
  103. // 计算高度
  104. searchHeight: function () {
  105. let frameStyle = this.data.frameStyle;
  106. let client = app.globalData.client;
  107. // 减去状态栏
  108. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  109. // 是否减去底部菜单
  110. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  111. if (infoHeight) this.setData({ infoHeight: infoHeight })
  112. },
  113. /**
  114. * 生命周期函数--监听页面初次渲染完成
  115. */
  116. onReady: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面显示
  120. */
  121. onShow: function () {
  122. },
  123. /**
  124. * 生命周期函数--监听页面隐藏
  125. */
  126. onHide: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面卸载
  130. */
  131. onUnload: function () {
  132. },
  133. /**
  134. * 页面相关事件处理函数--监听用户下拉动作
  135. */
  136. onPullDownRefresh: function () {
  137. },
  138. /**
  139. * 页面上拉触底事件的处理函数
  140. */
  141. onReachBottom: function () {
  142. },
  143. /**
  144. * 用户点击右上角分享
  145. */
  146. onShareAppMessage: function () {
  147. }
  148. })