couponHistory.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // pages/couponHistory/couponHistory.js
  2. import {
  3. get,
  4. post
  5. } from '../../utils/http'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. list: []
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad(options) {
  17. this.getCouponLog()
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady() {
  23. },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow() {
  28. },
  29. /**
  30. * 生命周期函数--监听页面隐藏
  31. */
  32. onHide() {
  33. },
  34. /**
  35. * 生命周期函数--监听页面卸载
  36. */
  37. onUnload() {
  38. },
  39. /**
  40. * 页面相关事件处理函数--监听用户下拉动作
  41. */
  42. onPullDownRefresh() {
  43. },
  44. /**
  45. * 页面上拉触底事件的处理函数
  46. */
  47. onReachBottom() {
  48. },
  49. /**
  50. * 用户点击右上角分享
  51. */
  52. onShareAppMessage() {
  53. },
  54. getCouponLog() {
  55. get('/v2/api/user/coupon/log', {}, res => {
  56. res.data.list.map(item=>{
  57. console.log(typeof(item.start_time),11111);
  58. if(typeof(item.start_time)=='string'){
  59. console.log(1);
  60. return
  61. }
  62. var date = new Date(item.start_time * 1000);
  63. let year = date.getFullYear()
  64. let month = date.getMonth()+1<10?'0'+date.getMonth():date.getMonth()
  65. let data = date.getDate()<10?'0'+date.getDate():date.getDate()
  66. let hours= date.getHours()<10?'0'+date.getHours():date.getHours()
  67. let minutes = date.getMinutes()<10?'0'+date.getMinutes():date.getMinutes()
  68. item.start_time = `${year}.${month}.${data} ${hours}:${minutes}`
  69. })
  70. this.setData({
  71. list: res.data.list
  72. })
  73. })
  74. },
  75. again(e){
  76. console.log(e);
  77. let item = e.currentTarget.dataset.item
  78. let storeId = wx.getStorageSync('store_id')
  79. wx.navigateTo({
  80. url: `/pages/projectDetail/projectDetail?source=project&id=${item.project_id}&store_id=${storeId}`,
  81. })
  82. }
  83. })