childMatch.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // pages/childMatch/childMatch.js
  2. import httpRequestApi from '../../utils/APIRequest';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. photoBoxList: [],
  9. hiddenFlag: true,
  10. page: 1,
  11. totalSize: 0
  12. },
  13. //点击跳转到相册
  14. album: ({ currentTarget }) => {
  15. console.log(currentTarget)
  16. wx.navigateTo({
  17. url: `/pages/access/access?id=${currentTarget.id}`
  18. })
  19. },
  20. //萌娃相册的搜素
  21. focus: function ({detail}) {
  22. if (detail.value) {
  23. httpRequestApi.getPhotoBoxList({
  24. name: detail.value
  25. }).success((res) => {
  26. console.log('萌娃相册搜索结果', res)
  27. this.setData({
  28. photoBoxList: res.data.data.list
  29. })
  30. if(res.data.data.list.length == 0) {
  31. this.setData({
  32. hiddenFlag: false
  33. })
  34. }else {
  35. this.setData({
  36. hiddenFlag: true
  37. })
  38. }
  39. })
  40. }else {
  41. this.getPhotoBoxList(1, 7);
  42. this.setData({
  43. hiddenFlag: true
  44. })
  45. }
  46. },
  47. /**
  48. * 生命周期函数--监听页面加载
  49. */
  50. onLoad: function (options) {
  51. if(options.share && !wx.getStorageSync('uid')) {
  52. wx.reLaunch({
  53. url: '/pages/index/index?ind=0'
  54. })
  55. return false;
  56. }
  57. this.getPhotoBoxList(1, 7);
  58. },
  59. getPhotoBoxList(pageNo, pageSize) {
  60. httpRequestApi.getPhotoBoxList({
  61. pageNo,
  62. pageSize
  63. }).success((res) => {
  64. this.setData({
  65. photoBoxList: res.data.data.list,
  66. totalSize: res.data.data.totalSize
  67. })
  68. wx.hideLoading();
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function () {
  80. this.getPhotoBoxList(1, 7);
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload: function () {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh: function () {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom: function () {
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage: function () {
  106. return {
  107. title: '七彩童年',
  108. path: `pages/childMatch/childMatch?share=true`,
  109. success: function (res) {
  110. // 转发成功
  111. console.log("转发成功:" + JSON.stringify(res));
  112. // var shareTickets = res.shareTickets;
  113. // if (shareTickets.length == 0) {
  114. // return false;
  115. // }
  116. // //可以获取群组信息
  117. // wx.getShareInfo({
  118. // shareTicket: shareTickets[0],
  119. // success: function (res) {
  120. // console.log(res)
  121. // }
  122. // })
  123. },
  124. fail: function (res) {
  125. // 转发失败
  126. console.log("转发失败:" + JSON.stringify(res));
  127. }
  128. }
  129. },
  130. /*上拉加载更多*/
  131. onBottom: function (e) {
  132. if(this.data.totalSize <= 10 * this.data.page){
  133. return false;
  134. }
  135. wx.showLoading({
  136. title: '加载中。。。。。。',
  137. })
  138. setTimeout( () => {
  139. this.data.page++;
  140. this.setData({
  141. page: this.data.page++
  142. })
  143. this.getPhotoBoxList(1, 10 * this.data.page);
  144. },2000)
  145. }
  146. })