search.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // pages/search/search.js
  2. const $api = require('../../utils/api.js').API;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. index1:-1,
  9. index2: -1,
  10. index3: -1,
  11. arr1:[],
  12. arr2: [],
  13. arr3: [],
  14. form:{
  15. name: '',
  16. zq: "",
  17. cw: "",
  18. df:'',
  19. page_size:20
  20. },
  21. list:[],
  22. page:1,
  23. total:0,
  24. show:0
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. this.setData({
  31. id: options.id,
  32. })
  33. $api.getEnumList().then(res=>{
  34. var zq = res.data.data.zq, cw = res.data.data.cw,
  35. df = res.data.data.df;
  36. zq.unshift('周期')
  37. cw.unshift('仓位')
  38. df.unshift('打法')
  39. this.setData({
  40. arr1:zq,
  41. arr2:cw,
  42. arr3:df
  43. })
  44. })
  45. this.getData(options.match_id?options.match_id:null);
  46. },
  47. next: function () {
  48. if (this.data.list.length < this.data.total) {
  49. const page = this.data.page + 1
  50. this.setData({
  51. page: page
  52. })
  53. this.getData()
  54. }
  55. },
  56. getData(match_id) {
  57. wx.showLoading({
  58. title: '正在加载',
  59. })
  60. var list = this.data.list
  61. var form=this.data.form;
  62. form.page = this.data.page;
  63. form.match_id = match_id;
  64. $api.getPlayerList(form).then(res => {
  65. wx.hideLoading()
  66. res.data.data.list.forEach(item => {
  67. list.push(item)
  68. })
  69. this.setData({
  70. list: list,
  71. total: res.data.data.total,
  72. show: 1
  73. })
  74. })
  75. },
  76. bindDateChange(e){
  77. var i = e.target.dataset.id, item = e.target.dataset.item;
  78. var form = this.data.form, val = e.detail.value;
  79. if(i == 1){
  80. if(val>0){
  81. form[item] = this.data.arr1[val]
  82. }else{
  83. form[item] = ''
  84. }
  85. this.setData({
  86. index1: val,
  87. form: form
  88. })
  89. }
  90. if (i == 2) {
  91. if (val > 0) {
  92. form[item] = this.data.arr2[val]
  93. } else {
  94. form[item] = ''
  95. }
  96. this.setData({
  97. index2: val,
  98. form: form
  99. })
  100. }
  101. if (i == 3) {
  102. if (val > 0) {
  103. form[item] = this.data.arr3[val]
  104. } else {
  105. form[item] = ''
  106. }
  107. this.setData({
  108. index3: val,
  109. form: form
  110. })
  111. }
  112. this.search()
  113. },
  114. inputChange(e){
  115. var form = this.data.form, val = e.detail.value;
  116. form.name=val;
  117. this.setData({
  118. form: form,
  119. })
  120. },
  121. search(){
  122. this.setData({
  123. page: 1,
  124. total: 0,
  125. list:[],
  126. show:0
  127. })
  128. this.getData()
  129. },
  130. /**
  131. * 生命周期函数--监听页面初次渲染完成
  132. */
  133. onReady: function () {
  134. },
  135. /**
  136. * 生命周期函数--监听页面显示
  137. */
  138. onShow: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面隐藏
  142. */
  143. onHide: function () {
  144. },
  145. /**
  146. * 生命周期函数--监听页面卸载
  147. */
  148. onUnload: function () {
  149. },
  150. /**
  151. * 页面相关事件处理函数--监听用户下拉动作
  152. */
  153. onPullDownRefresh: function () {
  154. },
  155. /**
  156. * 页面上拉触底事件的处理函数
  157. */
  158. onReachBottom: function () {
  159. },
  160. /**
  161. * 用户点击右上角分享
  162. */
  163. onShareAppMessage: function () {
  164. }
  165. })