historical.js 2.7 KB

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