historical.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // pages/welfareMall/historical/historical.js
  2. import WelfareMall from '../../../api/welfareMall'
  3. import { parseTime } from '../../../utils/util'
  4. import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. page: 1,
  11. pageSize: 10,
  12. lock: false,
  13. noResult: false,
  14. noMore: false,
  15. mobileTop: 'TONY WU',
  16. orderList: []
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.getOrderList();
  23. },
  24. // 订单数据
  25. getOrderList: function() {
  26. WelfareMall.getOrderList({
  27. page: this.data.page,
  28. pageSize: this.data.pageSize,
  29. mobile: getMobileCache(),
  30. }).then(res => {
  31. if (res.code == 200) {
  32. this.userOrderListView(res.data)
  33. }
  34. this.data.lock = false
  35. }).catch(_ => {
  36. console.log(_)
  37. this.data.lock = false
  38. })
  39. },
  40. userOrderListView: function(data) {
  41. if (!Array.isArray(data) || data.length == 0) {
  42. console.log("订单列表数据为空");
  43. if (this.data.page == 1) {
  44. this.setData({
  45. mobileTop:getMobileCache(),
  46. noResult: true
  47. })
  48. } else {
  49. this.setData({
  50. mobileTop:getMobileCache(),
  51. noMore: true
  52. })
  53. }
  54. return
  55. }
  56. // data.forEach(v => {
  57. // let payeTime = v.payedAt
  58. // v.payedAt = parseTime(payeTime, "{y}.{m}.{d} {h}:{i}:{s}")
  59. // })
  60. this.data.orderList = this.data.orderList.concat(...data)
  61. this.setData({
  62. mobileTop:getMobileCache(),
  63. orderList: this.data.orderList
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面隐藏
  78. */
  79. onHide: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function () {
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh: function () {
  90. },
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom: function () {
  95. if (this.data.lock || this.data.noMore) {
  96. return
  97. }
  98. this.data.lock = true
  99. this.data.page++
  100. this.getOrderList();
  101. },
  102. getCompletion(e) {
  103. const url = "../order/orderCompletion?ordersn=" + e.currentTarget.dataset.ordersn
  104. wx.navigateTo({
  105. url
  106. })
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })