index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // orderRecord/index.js
  2. var app = getApp();
  3. var util = require("../utils/util.js");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. appAssetsUrl: app.appAssetsUrl,
  10. params: {
  11. page: 1,
  12. limit: 10,
  13. },
  14. total: {
  15. total: 0,
  16. currPage: 0,
  17. totalPage: 0,
  18. },
  19. noMore: false,
  20. listData: [],
  21. member: {},
  22. nodata: util.nodata(),
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. // this.PushVipInfo();
  29. this.loadList();
  30. },
  31. /**
  32. * 生命周期函数--监听页面初次渲染完成
  33. */
  34. onReady: function () {},
  35. /**
  36. * 生命周期函数--监听页面显示
  37. */
  38. onShow: function () {},
  39. /**
  40. * 生命周期函数--监听页面隐藏
  41. */
  42. onHide: function () {},
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload: function () {},
  47. /**
  48. * 页面相关事件处理函数--监听用户下拉动作
  49. */
  50. onPullDownRefresh: function () {},
  51. /**
  52. * 页面上拉触底事件的处理函数
  53. */
  54. onReachBottom: function () {
  55. this.setData({
  56. params: {
  57. page: ++this.data.params.page,
  58. limit: 10,
  59. },
  60. });
  61. this.loadList();
  62. },
  63. /**
  64. * 用户点击右上角分享
  65. */
  66. onShareAppMessage: function () {},
  67. //查询会员信息
  68. PushVipInfo() {
  69. let that = this;
  70. let id = util.getUserId();
  71. if (id) {
  72. app._post_form(
  73. "member/apiSelectMeberInfo",
  74. "application/json",
  75. { id },
  76. function (res) {
  77. if (res.code === 0) {
  78. that.setData({
  79. member: res.member,
  80. });
  81. }
  82. }
  83. );
  84. }
  85. },
  86. loadList() {
  87. if (this.data.total.total > 0) {
  88. if (this.data.total.currPage == this.data.total.totalPage) {
  89. wx.showToast({
  90. title: "没有更多哦~",
  91. icon: "none",
  92. });
  93. return false;
  94. }
  95. }
  96. wx.showLoading({
  97. title: "努力加载中...",
  98. });
  99. app._get(
  100. "order/orderPage",
  101. {
  102. ...this.data.params,
  103. memberId: util.getUserId(),
  104. },
  105. (res) => {
  106. if (res.code === 0) {
  107. this.setData({
  108. listData: [...this.data.listData, ...res.page.list],
  109. total: {
  110. total: res.page.totalCount,
  111. currPage: res.page.currPage,
  112. totalPage: res.page.totalPage,
  113. },
  114. });
  115. wx.hideLoading();
  116. }
  117. },
  118. (err) => {
  119. console.log(err, 111)
  120. wx.showToast({
  121. icon: 'error',
  122. title: '服务端异常',
  123. })
  124. },
  125. (complete) => {}
  126. );
  127. },
  128. });