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