maillist.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // pages/maillist.js
  2. import http from '../../base/httputil'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. /**
  10. * 控制上拉到底部时是否出现 "数据加载中..."
  11. */
  12. hidden: true,
  13. /**
  14. * 数据是否正在加载中,避免数据多次加载
  15. */
  16. loadingData: false,
  17. bookList: [],
  18. isRefresh: true,
  19. total: 0,
  20. pageNum: 1 // 页码
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (){
  26. this.loadData()
  27. },
  28. loadData(){
  29. let obj = new Object()
  30. obj.pageNum = this.data.pageNum
  31. obj.pageSize = 10
  32. obj.reasonable = false
  33. http.send_get("/system/AppPBookController/getPBookList", obj, this.getBookListSuccess)
  34. },
  35. getBookListSuccess(res) {
  36. console.log("@@@@", res)
  37. if (res.code == 200) {
  38. // 显示加载图标
  39. wx.showLoading({
  40. title: '玩命加载中',
  41. })
  42. var that = this
  43. if (res.data.rows.length == 0) {
  44. wx.showToast({
  45. title: '暂无更多数据',
  46. icon: "none"
  47. })
  48. }
  49. if (this.data.isRefresh) {
  50. this.setData({
  51. bookList: res.data.rows,
  52. total: res.data.total
  53. })
  54. // 隐藏导航栏加载框
  55. setTimeout(function () {
  56. that.setData({
  57. loadingData: false
  58. });
  59. wx.hideNavigationBarLoading();
  60. // 停止下拉动作
  61. wx.stopPullDownRefresh();
  62. wx.hideLoading()
  63. }, 1000)
  64. } else {
  65. this.setData({
  66. bookList: this.data.bookList.concat(res.data.rows)
  67. })
  68. // 隐藏加载框
  69. setTimeout(function () {
  70. that.setData({
  71. hidden: true,
  72. loadingData: false
  73. });
  74. wx.hideLoading();
  75. }, 1000)
  76. }
  77. } else {
  78. console.log("@@!", "请求失败")
  79. }
  80. },
  81. onPullDownRefresh: function () {
  82. // 显示顶部刷新图标
  83. wx.showNavigationBarLoading();
  84. var that = this;
  85. var loadingData = this.data.loadingData
  86. if (loadingData) {
  87. return;
  88. }
  89. that.setData({
  90. pageNum: 1,
  91. isRefresh: true
  92. })
  93. this.loadData()
  94. },
  95. /**
  96. * 页面上拉触底事件的处理函数
  97. */
  98. onReachBottom: function () {
  99. let that = this
  100. var loadingData = that.data.loadingData
  101. var hidden = that.data.hidden
  102. // 页数+1
  103. that.setData({
  104. pageNum: that.data.pageNum + 1,
  105. isRefresh: false
  106. })
  107. if (hidden) {
  108. that.setData({
  109. hidden: false
  110. });
  111. console.info(that.data.hidden);
  112. }
  113. if (loadingData) {
  114. return;
  115. }
  116. that.setData({
  117. loadingData: true
  118. });
  119. //console.log("@@@@"+Math.ceil(this.data.total/10))
  120. // if(Math.ceil(that.data.total/10)>=that.data.pageNum){
  121. that.loadData();
  122. // }else{
  123. // setTimeout(function () {
  124. // that.setData({
  125. // hidden: true,
  126. // });
  127. // }, 2000)
  128. // }
  129. },
  130. // 搜索结果跳页
  131. bindViewSearchEnd() {
  132. wx.navigateTo({
  133. url: '../maillist/serch/maillist_serch'
  134. })
  135. },
  136. Call(e){
  137. let phone = e.currentTarget.dataset.index
  138. wx.makePhoneCall({
  139. phoneNumber: phone.phonenumber
  140. })
  141. },
  142. /**
  143. * 生命周期函数--监听页面初次渲染完成
  144. */
  145. onReady() {
  146. },
  147. /**
  148. * 生命周期函数--监听页面显示
  149. */
  150. onShow() {
  151. },
  152. /**
  153. * 生命周期函数--监听页面隐藏
  154. */
  155. onHide() {
  156. },
  157. /**
  158. * 生命周期函数--监听页面卸载
  159. */
  160. onUnload() {
  161. },
  162. })