historical.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.userOrderistView(res.data)
  38. }
  39. this.data.lock = false
  40. }).catch(_ => {
  41. console.log(_)
  42. this.data.lock = false
  43. })
  44. },
  45. userOrderistView: 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 beginTime = v.coupon.couponBeginTimestamp
  63. let endTime = v.coupon.couponEndTimestamp
  64. v.coupon.couponBeginTimestamp = parseTime(beginTime, "{y}.{m}.{d}")
  65. v.coupon.couponEndTimestamp = parseTime(endTime, "{y}.{m}.{d}")
  66. })
  67. this.data.couponList = this.data.couponList.concat(...data)
  68. this.setData({
  69. mobileTop:getMobileCache(),
  70. couponList: this.data.couponList
  71. })
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload: function () {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh: function () {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom: function () {
  102. },
  103. getCompletion(e) {
  104. const url = "../order/orderCompletion?id=" + e.currentTarget.dataset.id
  105. wx.redirectTo({
  106. url
  107. })
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage: function () {
  113. }
  114. })