record.js 2.8 KB

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