index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const utils = require('../../utils/util')
  2. const app = getApp()
  3. Page({
  4. data: {
  5. userInfo:{},
  6. currentTab: 0,
  7. tabs: [{
  8. name: "昨日"
  9. }, {
  10. name: "今日"
  11. }, {
  12. name: "本月"
  13. }],
  14. statisData:{},
  15. searchParams: {
  16. timeType:"oldDay",
  17. }
  18. },
  19. onShow:function(){
  20. if (typeof this.getTabBar === 'function' &&
  21. this.getTabBar()) {
  22. this.getTabBar().setData({
  23. current: 0 // 根据tab的索引值设置
  24. })
  25. }
  26. },
  27. /**
  28. * 用户点击右上角分享
  29. */
  30. onShareAppMessage: function () {
  31. },
  32. onLoad: function () {
  33. this.getStatis();
  34. this.setData({
  35. userInfo: app.globalData.userInfo
  36. })
  37. setTimeout(()=>{
  38. this.setData({
  39. animation:true
  40. })
  41. },600)
  42. },
  43. change(e) {
  44. this.setData({
  45. currentTab: e.detail.index
  46. })
  47. if(e.detail.index==0){
  48. this.setData({['searchParams.timeType']: "oldDay"})
  49. }else if(e.detail.index==1){
  50. this.setData({['searchParams.timeType']: "day"})
  51. }else if(e.detail.index==2){
  52. this.setData({['searchParams.timeType'] : "month"})
  53. }
  54. this.getStatis()
  55. },
  56. toRouter(e){
  57. console.log(e)
  58. wx.navigateTo({
  59. url: e.currentTarget.dataset.url,
  60. })
  61. },
  62. tip(){
  63. utils.toast('功能暂未开放')
  64. },
  65. getStatis(){
  66. let that = this;
  67. utils.request(utils.api.indexSalesOrderApp, this.data.searchParams, "GET", false, true,app.globalData.token).then((res)=>{
  68. if (res.code == 200) {
  69. that.setData({
  70. statisData:res.result
  71. })
  72. }else{
  73. util.toast(res.message);
  74. }
  75. }).catch((res) => {})
  76. }
  77. })