index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // pages/my/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. nvabarData: {
  9. showCapsule: 0, //是否显示左上角图标,消息中心 1表示显示 0表示不显示
  10. showBack: 1, //返回
  11. title: '我的申请', //导航栏 中间的标题
  12. // 此页面 页面内容距最顶部的距离
  13. height: app.globalData.height * 2 + 20,
  14. },
  15. messageList: [], // 列表
  16. skip: 1,
  17. limit: 20,
  18. total: 0,
  19. listshow: 1,
  20. // 是否到底
  21. hasMoreData: true
  22. },
  23. // 页面跳转
  24. // 判断id
  25. tompDetail: function (e) {
  26. wx.navigateTo({
  27. url: '/pages/myloanprojuctDetail/index?cneedid=' + e.currentTarget.dataset.cneedid + '&cpjlname=' + e.currentTarget.dataset.cpjlname + '&cpjlpho=' + e.currentTarget.dataset.cpjlpho// 希望跳转过去的页面
  28. })
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function () {
  34. if (wx.getStorageSync('user') == "") {
  35. wx.redirectTo({
  36. url: '/pages/login/index'
  37. })
  38. } else {
  39. var that = this;
  40. that.searchInfo('加载中')
  41. }
  42. },
  43. //列表查询
  44. searchInfo: function (message) {
  45. wx.showLoading({
  46. title: message,
  47. })
  48. var that = this;
  49. wx.request({
  50. url: app.globalData.publicUrl + 'api/financial/claimneed/littleqyclaim',
  51. method: 'post',
  52. data: {
  53. qyid: wx.getStorageSync('user')._id,
  54. skip: that.data.skip,
  55. limit: that.data.limit
  56. },
  57. header: {
  58. 'content-type': 'application/json', // 默认值
  59. },
  60. success(res) {
  61. console.log(res)
  62. if (res.data.errcode == '0') {
  63. if (res.data.res.length !== 0) {
  64. if (that.data.messageList.isEmpty) {
  65. that.setData({
  66. messageList: res.data.res,
  67. })
  68. console.log(messageList , "alkjkajdsskadsj")
  69. } else {
  70. that.setData({
  71. messageList: that.data.messageList.concat(res.data.res),
  72. total: res.data.total
  73. })
  74. console.log(that.data.messageList , "888888888888888888888")
  75. }
  76. } else {
  77. wx.showToast({
  78. title: "没有更多数据了",
  79. duration: 2000,
  80. icon: 'none',
  81. mask: true
  82. })
  83. }
  84. }
  85. },
  86. complete: function () {
  87. wx.hideLoading();
  88. wx.hideNavigationBarLoading() //完成停止加载
  89. wx.stopPullDownRefresh() //停止下拉刷新
  90. }
  91. })
  92. },
  93. /**
  94. * 生命周期函数--监听页面初次渲染完成
  95. */
  96. onReady: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面隐藏
  105. */
  106. onHide: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面卸载
  110. */
  111. onUnload: function () {
  112. },
  113. /**
  114. * 页面相关事件处理函数--监听用户下拉动作
  115. */
  116. onPullDownRefresh: function () {
  117. wx.showNavigationBarLoading() //在标题栏中显示加载
  118. this.data.skip = 1
  119. this.data.messageList = []
  120. this.searchInfo('正在刷新数据')
  121. },
  122. /**
  123. * 页面上拉触底事件的处理函数
  124. */
  125. onReachBottom: function () {
  126. const pageNum = this.data.skip;
  127. const _pagenum = Math.ceil(this.data.total / this.data.limit);
  128. if (pageNum < _pagenum) {
  129. this.setData({
  130. skip: pageNum + 1 //设置下一页
  131. })
  132. this.searchInfo('正在刷新数据'); //查询数据
  133. } else {
  134. wx.showToast({
  135. title: '没有更多数据',
  136. })
  137. }
  138. },
  139. /**
  140. * 用户点击右上角分享
  141. */
  142. onShareAppMessage: function () {
  143. }
  144. })