order.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // pages/order/order.js
  2. const app = getApp()
  3. const link = app.globalData.url
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. page:1,
  10. pageSize:10,
  11. openId:"",
  12. // count:0,
  13. // pageIndex:""
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. //获取产品
  20. var that = this;
  21. that.page = 1
  22. that.pageSize = 18
  23. that.openId = wx.getStorageSync('openId')
  24. wx.request( {
  25. url: link + "/v1/user/order/list",
  26. header: {
  27. "Content-Type": "application/json"
  28. },
  29. method: "POST",
  30. data: { openId: that.openId,pageIndex:that.page,pageSize: that.pageSize},
  31. complete: function( res ) {
  32. console.log(res)
  33. if( res == null || res.data == null ) {
  34. console.error( '网络请求失败' );
  35. return;
  36. }
  37. console.log(res.data.data.rows)
  38. //that.count = res.data.data.count
  39. that.setData({
  40. goodsList: res.data.data.rows,
  41. })
  42. }
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload: function () {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function () {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom: function () {
  74. //获取数据
  75. var that = this;
  76. that.page +=1
  77. wx.request( {
  78. url: link + "/v1/user/order/list",
  79. header: {
  80. "Content-Type": "application/json"
  81. },
  82. method: "POST",
  83. data: { openId: that.openId,pageIndex:that.page,pageSize: that.pageSize},
  84. complete: function( res ) {
  85. wx.hideLoading();
  86. console.log(res)
  87. if (res.data.data.rows.length <= 0){
  88. //提示页码到了
  89. that.setData({
  90. lType:"end"
  91. })
  92. return
  93. }
  94. for (var i = 0; i < res.data.data.rows.length; i++) {
  95. that.data.goodsList.push( res.data.data.rows[i]);
  96. }
  97. that.setData({
  98. goodsList: that.data.goodsList,
  99. })
  100. console.log(res.data.data.goods_search_response)
  101. if( res == null || res.data == null ) {
  102. console.error( '网络请求失败' );
  103. return;
  104. }
  105. }
  106. })
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })