visitList.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // pages/visitList/visitList.js
  2. const app = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. arr: []
  9. },
  10. go(e) {
  11. console.log(e.currentTarget.dataset.item)
  12. wx.navigateTo({
  13. url: '/pages/visitListInfo/visitListInfo?id=' + e.currentTarget.dataset.item
  14. })
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. wx.showLoading({
  21. title: '加载中',
  22. })
  23. console.log(options)
  24. wx.request({
  25. url: app.globalData.publicUrl + '/wxinfo/visitByNumber',
  26. method: "GET",
  27. data: {
  28. number: options.id
  29. },
  30. success: res => {
  31. console.log(res)
  32. if (res.data.code == 0) {
  33. console.log('我查到15条信息了', res)
  34. let arr = res.data.data
  35. arr.forEach(item => {
  36. item.visitTime = this.formatDate(item.visitTime);
  37. })
  38. this.setData({
  39. arr
  40. })
  41. } else {
  42. wx.showModal({
  43. showCancel: false,
  44. content: res.data.message,
  45. })
  46. }
  47. },
  48. complete: () => {
  49. wx.hideLoading()
  50. }
  51. });
  52. },
  53. formatTen(num) {
  54. return num > 9 ? num + "" : "0" + num;
  55. },
  56. formatDate(date) {
  57. var date = new Date(date);
  58. var year = date.getFullYear();
  59. var month = date.getMonth() + 1;
  60. var day = date.getDate();
  61. var hour = date.getHours();
  62. var minute = date.getMinutes();
  63. var second = date.getSeconds();
  64. return (
  65. year +
  66. "-" +
  67. this.formatTen(month) +
  68. "-" +
  69. this.formatTen(day) +
  70. " " +
  71. this.formatTen(hour) +
  72. ":" +
  73. this.formatTen(minute) +
  74. ":" +
  75. this.formatTen(second)
  76. );
  77. },
  78. /**
  79. * 生命周期函数--监听页面初次渲染完成
  80. */
  81. onReady: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function () {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function () {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function () {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })