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