index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. isLogin:false
  19. },
  20. onShow:function(){
  21. if (typeof this.getTabBar === 'function' &&
  22. this.getTabBar()) {
  23. this.getTabBar().setData({
  24. current: 0 // 根据tab的索引值设置
  25. })
  26. }
  27. },
  28. /**
  29. * 用户点击右上角分享
  30. */
  31. onShareAppMessage: function () {
  32. },
  33. onLoad: function () {
  34. this.getStatis();
  35. this.setData({
  36. userInfo: app.globalData.userInfo,
  37. isLogin:app.globalData.isLogin
  38. })
  39. setTimeout(()=>{
  40. this.setData({
  41. animation:true
  42. })
  43. },600)
  44. },
  45. change(e) {
  46. this.setData({
  47. currentTab: e.detail.index
  48. })
  49. if(e.detail.index==0){
  50. this.setData({['searchParams.timeType']: "oldDay"})
  51. }else if(e.detail.index==1){
  52. this.setData({['searchParams.timeType']: "day"})
  53. }else if(e.detail.index==2){
  54. this.setData({['searchParams.timeType'] : "month"})
  55. }
  56. this.getStatis()
  57. },
  58. toRouter(e){
  59. if(app.globalData.isLogin){
  60. wx.navigateTo({
  61. url: e.currentTarget.dataset.url,
  62. })
  63. }else{
  64. wx.reLaunch({
  65. url: '/pages/login/index',
  66. })
  67. }
  68. },
  69. tip(){
  70. utils.toast('功能暂未开放')
  71. },
  72. getStatis(){
  73. let that = this;
  74. if(app.globalData.isLogin){
  75. utils.request(utils.api.indexSalesOrderApp, this.data.searchParams, "GET", false, true,app.globalData.token).then((res)=>{
  76. if (res.code == 200) {
  77. that.setData({
  78. statisData:res.result
  79. })
  80. }else{
  81. util.toast(res.message);
  82. }
  83. }).catch((res) => {})
  84. }
  85. }
  86. })