Review.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // pages/Review.js
  2. var http = require('../../utils/http.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. current:1,
  9. pages:0,
  10. list:[]
  11. },
  12. // 获取列表
  13. getList(){
  14. http.request({
  15. url: "/p/prodComm/myCommList",
  16. method: "GET",
  17. data: {
  18. current: this.data.current,
  19. size: 10,
  20. },
  21. callBack: (res) => {
  22. if(res.records&&res.records.length){
  23. let list = []
  24. let img = ''
  25. res.records.map(e => {
  26. if(e.pic){
  27. img = e.pic.split(',')
  28. e.pic = img[0]
  29. }
  30. })
  31. if (this.data.current == 1) {
  32. this.setData({
  33. list: res.records,
  34. pages: res.pages,
  35. current: res.current
  36. });
  37. } else {
  38. list = this.data.list
  39. list.push(...res.records)
  40. this.setData({
  41. list
  42. })
  43. console.log(list.length,res.total);
  44. if (list.length >= res.total) {
  45. this.setData({
  46. isAll: true
  47. })
  48. }
  49. }
  50. }
  51. }
  52. })
  53. },
  54. /**
  55. * 评价图片预览
  56. */
  57. comPicPreView(e){
  58. var idx = e.currentTarget.dataset.idx
  59. var urls = []
  60. this.data.orderItemInfo.images.forEach(el => {
  61. urls.push(el.url)
  62. })
  63. wx.previewImage({
  64. current: urls[idx],
  65. urls: urls
  66. })
  67. },
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. onLoad(options) {
  72. this.getList()
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面显示
  81. */
  82. onShow() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload() {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh() {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom: function () {
  103. this.getNextPage()
  104. },
  105. // 触底加载下一页
  106. getNextPage() {
  107. console.log('getNextPage',this.data.current);
  108. if (this.data.pages > this.data.current) {
  109. this.setData({
  110. current: this.data.current + 1
  111. })
  112. this.getList()
  113. } else {
  114. this.setData({
  115. isAll: true
  116. })
  117. }
  118. },
  119. /**
  120. * 用户点击右上角分享
  121. */
  122. onShareAppMessage() {
  123. }
  124. })