index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import $ from './../../utils/Tool'
  2. import router from './../../utils/router'
  3. import {formatMsgTime} from './../../utils/util'
  4. import {getFeedbackList} from '../../requests/api'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. dataList:[],
  11. page:0,
  12. tempType:{
  13. 1: "有点冷",
  14. 3: "有点热",
  15. 2: "太冷了",
  16. 4: "太热了",
  17. 5:"风太大",
  18. 10: "关闭设备",
  19. 11:"赞",
  20. 12:"开启设备"
  21. },
  22. type:null,
  23. allCount:0
  24. },
  25. goBack(){
  26. router.pop()
  27. },
  28. goHome(){
  29. $.store.set('goHome',true);
  30. router.toHome()
  31. },
  32. initDate(value){
  33. let date = new Date(value);
  34. let month = date.getMonth() + 1
  35. let day = date.getDate()
  36. let hour = date.getHours()
  37. let minute = date.getMinutes()
  38. hour = hour<10?`0${hour}`:hour;
  39. minute = minute<10?`0${minute}`:minute;
  40. return `${month}.${day} ${hour}:${minute}`
  41. },
  42. getDate(){
  43. this.setData({page:this.data.page+1},async ()=>{
  44. let data={
  45. "criteria": {
  46. "projectId": $.store.get('projectId'),
  47. "userId":$.store.get('userId')
  48. },
  49. page: this.data.page,
  50. size:30,
  51. "orders": [
  52. {
  53. "column": "createTime",
  54. "asc": false
  55. }
  56. ]
  57. }
  58. if(this.data.type==="space"){
  59. data.orders.push(
  60. {
  61. "column": "objectId",
  62. "asc": true
  63. })
  64. }
  65. wx.showLoading({
  66. title:"加载中"
  67. })
  68. await getFeedbackList(data).then(res=>{
  69. if(res.count){
  70. res.content.forEach(item=>{
  71. item.text=this.data.tempType[item.itemId] || '';
  72. if(!item.text){
  73. item.text = item.valueType==3?'设置全天温度计划':`调温至${item.value}°C`;
  74. }
  75. item.createTime = formatMsgTime(new Date(item.createTime)); //this.initDate
  76. })
  77. }
  78. res.content&&this.setData({dataList:this.data.dataList.concat(res.content)});
  79. // console.log(res);
  80. })
  81. wx.hideLoading()
  82. });
  83. },
  84. /**
  85. * 生命周期函数--监听页面加载
  86. */
  87. onLoad: function (options) {
  88. let {spaceFeedbackNum,type} = options;
  89. this.setData({allCount:Number(spaceFeedbackNum),type:type},()=>{
  90. this.getDate();
  91. })
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow: function () {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh() {
  102. this.setData({page:0,dataList:[]},async ()=>{
  103. await this.getDate();
  104. wx.stopPullDownRefresh();
  105. })
  106. },
  107. /**
  108. * 页面上拉触底事件的处理函数
  109. */
  110. onReachBottom: function () {
  111. if(this.data.dataList&&(this.data.dataList.length<this.data.allCount)){
  112. this.getDate();
  113. }
  114. },
  115. })