monitoringNum.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. isShow:null,
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function (options) {
  13. var list = JSON.parse(options.list);
  14. this.setData({
  15. list,
  16. listCopy:JSON.stringify(list)
  17. })
  18. },
  19. sort(e){
  20. var that = this;
  21. var type = e.currentTarget.dataset.type;
  22. var list = this.data.list;
  23. var isShow = this.data.isShow;
  24. if(isShow == null){
  25. list.sort((a,b)=>b[type] - a[type]) // 升序
  26. isShow = true
  27. }else if(isShow == true){
  28. list.sort((a,b)=>a[type] - b[type]) // 降序
  29. isShow = false
  30. }else if(isShow == false){ // 恢复
  31. list = JSON.parse(that.data.listCopy);
  32. isShow = null
  33. }
  34. this.setData({
  35. type,
  36. isShow,
  37. list,
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面隐藏
  52. */
  53. onHide: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面卸载
  57. */
  58. onUnload: function () {
  59. },
  60. /**
  61. * 页面相关事件处理函数--监听用户下拉动作
  62. */
  63. onPullDownRefresh: function () {
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom: function () {
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage: function () {
  74. }
  75. })