visitListInfo.js 2.2 KB

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