record.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // pages/signIn/record/record.js
  2. import SignIn from '../../../api/signIn'
  3. import { parseTime } from '../../../utils/util'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. page: 1,
  10. pageSize: 10,
  11. lock: false,
  12. noResult: false,
  13. noMore: false,
  14. isLogin: false,
  15. hidden1: false,
  16. hidden2: false,
  17. mobileTop: 'TONY WU',
  18. couponNum: 0,
  19. productNum: 0,
  20. activityId: 1,
  21. couponList: []
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. this.getUserAwardCouponList();
  28. },
  29. getUserAwardCouponList: function() {
  30. SignIn.getUserAwardCouponList({
  31. page: this.data.page,
  32. pageSize: this.data.pageSize,
  33. mobile: "16602120168",
  34. activityId: this.data.activityId
  35. }).then(res => {
  36. if (res.code == 200) {
  37. this.userCouponListView(res.data)
  38. }
  39. this.data.lock = false
  40. }).catch(_ => {
  41. console.log(_)
  42. this.data.lock = false
  43. })
  44. },
  45. userCouponListView: 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. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage: function () {
  107. }
  108. })