allocated.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. Page({
  2. data: {
  3. date: '',
  4. items: [],
  5. itemsId:[1,2],
  6. yuIndex:0,
  7. arr:[]
  8. },
  9. bindDateChange:function(e){
  10. console.log(e)
  11. this.setData({date:e.detail.value})
  12. this.methods(this.data.date,this.data.itemsId)
  13. },
  14. getNowFormatDate:function() {
  15. var date = new Date();
  16. var seperator1 = "-";
  17. var year = date.getFullYear();
  18. var month = date.getMonth() + 1;
  19. var strDate = date.getDate();
  20. if (month >= 1 && month <= 9) {
  21. month = "0" + month;
  22. }
  23. if (strDate >= 0 && strDate <= 9) {
  24. strDate = "0" + strDate;
  25. }
  26. var currentdate = year + seperator1 + month + seperator1 + strDate;
  27. console.log(currentdate)
  28. this.setData({date:currentdate})
  29. return currentdate;
  30. },
  31. onLoad: function (options) {
  32. this.getNowFormatDate()
  33. var items = wx.getStorageSync('items');
  34. var arr = [{'id':"",name:'全部'}];
  35. for(var i=0;i<items.length;i++){
  36. var obj = {}
  37. obj.name = items[i].name;
  38. obj.id = items[i].id;
  39. console.log(obj)
  40. arr = arr.concat(obj)
  41. }
  42. this.setData({
  43. items:arr
  44. });
  45. this.methods(this.data.date,this.data.itemsId)
  46. },
  47. yutang:function(e){
  48. console.log(e)
  49. var index= e.currentTarget.dataset.index
  50. this.setData({yuIndex:index})
  51. if(index==0){
  52. this.setData({itemsId:[1,2]})
  53. }else if(index==1){
  54. this.setData({itemsId:[this.data.items[index].id]})
  55. }else if(index==2){
  56. this.setData({itemsId:[this.data.items[index].id]})
  57. }
  58. this.methods(this.data.date,this.data.itemsId)
  59. },
  60. methods:function(time,arr){
  61. var that = this;
  62. wx.request({
  63. url: 'https://yutang.web.ximengnaikang.com/api/admin/byDateGetNos?date='+time+'&sate='+arr,
  64. method: 'GET',
  65. header: {
  66. 'content-type': 'application/x-www-form-urlencoded',
  67. 'Authorization':wx.getStorageSync('token')
  68. },
  69. success: function (res) {
  70. console.log(res)
  71. if(res.data.code==200){
  72. that.setData({arr:res.data.data})
  73. }
  74. }
  75. })
  76. },
  77. onReady: function () {
  78. },
  79. onShow: function () {
  80. },
  81. onHide: function () {
  82. },
  83. onUnload: function () {
  84. },
  85. onPullDownRefresh: function () {
  86. },
  87. onReachBottom: function () {
  88. console.log('没有更多了~')
  89. },
  90. onShareAppMessage: function () {
  91. }
  92. })