maillist.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.nickName = ""
  31. obj.pageNum = this.data.pageNum
  32. obj.pageSize = 10
  33. obj.reasonable = false
  34. http.send_get("/system/AppPBookController/getPBookList", obj, this.getBookListSuccess)
  35. },
  36. getBookListSuccess(res) {
  37. console.log("@@@@", res)
  38. if (res.code == 200) {
  39. // 显示加载图标
  40. wx.showLoading({
  41. title: '玩命加载中',
  42. })
  43. var that = this
  44. if (res.data.rows.length == 0) {
  45. wx.showToast({
  46. title: '暂无更多数据',
  47. icon: "none"
  48. })
  49. }
  50. if (this.data.isRefresh) {
  51. this.setData({
  52. bookList: res.data.rows,
  53. total: res.data.total
  54. })
  55. // 隐藏导航栏加载框
  56. setTimeout(function () {
  57. that.setData({
  58. loadingData: false
  59. });
  60. wx.hideNavigationBarLoading();
  61. // 停止下拉动作
  62. wx.stopPullDownRefresh();
  63. wx.hideLoading()
  64. }, 1000)
  65. } else {
  66. this.setData({
  67. bookList: this.data.bookList.concat(res.data.rows)
  68. })
  69. // 隐藏加载框
  70. setTimeout(function () {
  71. that.setData({
  72. hidden: true,
  73. loadingData: false
  74. });
  75. wx.hideLoading();
  76. }, 1000)
  77. }
  78. } else {
  79. console.log("@@!", "请求失败")
  80. }
  81. },
  82. onPullDownRefresh: function () {
  83. // 显示顶部刷新图标
  84. wx.showNavigationBarLoading();
  85. var that = this;
  86. var loadingData = this.data.loadingData
  87. if (loadingData) {
  88. return;
  89. }
  90. that.setData({
  91. pageNum: 1,
  92. isRefresh: true
  93. })
  94. this.loadData()
  95. },
  96. /**
  97. * 页面上拉触底事件的处理函数
  98. */
  99. onReachBottom: function () {
  100. let that = this
  101. var loadingData = that.data.loadingData
  102. var hidden = that.data.hidden
  103. // 页数+1
  104. that.setData({
  105. pageNum: that.data.pageNum + 1,
  106. isRefresh: false
  107. })
  108. if (hidden) {
  109. that.setData({
  110. hidden: false
  111. });
  112. console.info(that.data.hidden);
  113. }
  114. if (loadingData) {
  115. return;
  116. }
  117. that.setData({
  118. loadingData: true
  119. });
  120. //console.log("@@@@"+Math.ceil(this.data.total/10))
  121. // if(Math.ceil(that.data.total/10)>=that.data.pageNum){
  122. that.loadData();
  123. // }else{
  124. // setTimeout(function () {
  125. // that.setData({
  126. // hidden: true,
  127. // });
  128. // }, 2000)
  129. // }
  130. },
  131. // 搜索结果跳页
  132. bindViewSearchEnd() {
  133. wx.navigateTo({
  134. url: '../maillist/serch/maillist_serch'
  135. })
  136. },
  137. Call(e){
  138. let phone = e.currentTarget.dataset.index
  139. if(phone.phonenumber!=""){
  140. wx.makePhoneCall({
  141. phoneNumber: phone.phonenumber
  142. })
  143. }else{
  144. wx.showToast({
  145. title: '该联系人暂无电话',
  146. icon:'error'
  147. })
  148. }
  149. },
  150. /**
  151. * 生命周期函数--监听页面初次渲染完成
  152. */
  153. onReady() {
  154. },
  155. /**
  156. * 生命周期函数--监听页面显示
  157. */
  158. onShow() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面隐藏
  162. */
  163. onHide() {
  164. },
  165. /**
  166. * 生命周期函数--监听页面卸载
  167. */
  168. onUnload() {
  169. },
  170. })