ordersList.js 1.6 KB

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