searchRecords.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // pages/searchRecords/searchRecords.js
  2. const api = require('../../api/index')
  3. const app = getApp()
  4. import { $startWuxRefresher, $stopWuxRefresher,$stopWuxLoader} from '../../miniprogram_npm/wux-weapp/index'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. tableData:[],
  11. queryParams:{
  12. current:1,
  13. size:10
  14. },
  15. total:0,
  16. loading:false,
  17. imgHttp:app.globalData.imghttp,
  18. scrollTop: 0,
  19. menu:[
  20. {
  21. label:'删除',
  22. method:'del',
  23. icon:''
  24. },
  25. ]
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad(options) {
  31. this.init()
  32. },
  33. /**
  34. * 生命周期函数--监听页面初次渲染完成
  35. */
  36. onReady() {
  37. },
  38. /**
  39. * 生命周期函数--监听页面显示
  40. */
  41. onShow() {
  42. },
  43. /**
  44. * 页面功能
  45. */
  46. //初始化加载
  47. init(){
  48. var params = {
  49. current:1,
  50. size:10
  51. }
  52. this.setData(
  53. {
  54. queryParams:params,
  55. total:0,
  56. tableData:[]
  57. }
  58. )
  59. this.getSearchRecords()
  60. },
  61. //下拉
  62. onPulling() {
  63. console.log('onPulling')
  64. },
  65. //下拉刷新
  66. onRefresh() {
  67. console.log('onRefresh')
  68. this.init()
  69. },
  70. //查看图片
  71. previewImage(e) {
  72. const { current,imglist } = e.currentTarget.dataset
  73. var imgs = []
  74. for(var i =0;i<imglist.length;i++){
  75. imgs.push(this.data.imgHttp + imglist[i].guid)
  76. }
  77. current = this.data.imgHttp + current
  78. wx.previewImage({
  79. current,
  80. urls:imgs,
  81. })
  82. },
  83. //菜单点击
  84. clickMenu(e){
  85. console.log(e)
  86. var data = e.detail
  87. this[data.method](data.data,data.index)
  88. },
  89. del(data,index){
  90. },
  91. //获取检索记录
  92. getSearchRecords(){
  93. wx.showLoading({
  94. title: '加载中',
  95. })
  96. api.querySearchRecords(this.data.queryParams).then(res=>{
  97. if(res.code == 200){
  98. console.log(res)
  99. var data = this.data.tableData
  100. data = data.concat(res.data.data)
  101. this.setData(
  102. {
  103. tableData:data,
  104. total:res.data.total
  105. }
  106. )
  107. }
  108. })
  109. },
  110. //加载更多
  111. loadMore(){
  112. var current = this.data.queryParams.current
  113. this.setData(
  114. {
  115. ['queryParams.current']:current+1
  116. }
  117. )
  118. this.getSearchRecords()
  119. },
  120. /**
  121. * 生命周期函数--监听页面隐藏
  122. */
  123. onHide() {
  124. },
  125. /**
  126. * 生命周期函数--监听页面卸载
  127. */
  128. onUnload() {
  129. },
  130. /**
  131. * 页面相关事件处理函数--监听用户下拉动作
  132. */
  133. onPullDownRefresh() {
  134. },
  135. /**
  136. * 页面上拉触底事件的处理函数
  137. */
  138. onReachBottom() {
  139. },
  140. /**
  141. * 用户点击右上角分享
  142. */
  143. onShareAppMessage() {
  144. }
  145. })