微信小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

index.js 2.4 KiB

3 yıl önce
3 yıl önce
3 yıl önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import * as UTIL from '../../utils/util.js';
  2. import * as API from '../../utils/API.js';
  3. Page({
  4. data: {
  5. //顶部胶囊按钮位置信息rect
  6. CustomMenuButton: null,
  7. wrokScrollHeight:0,
  8. userInfoObj:{} //用户信息
  9. },
  10. onLoad: function (options) {
  11. //获取用户信息
  12. this.getUserInfo()
  13. //获取滚动条高度
  14. this.computeBarLocation();
  15. },
  16. //跳转收入登记
  17. swichInCome:function(e){
  18. console.log(e.currentTarget.dataset.current);
  19. // let cur = e.currentTarget.dataset.current;
  20. // if (this.data.currentTaB == cur) {
  21. // return false;
  22. // }else{
  23. // wx.navigateTo({
  24. // url: '../inCome/index?id=' + id,
  25. // })
  26. // }
  27. wx.navigateTo({
  28. url: '../inCome/inCome?',
  29. })
  30. },
  31. //跳转支出申请
  32. swichPayment:function(e){
  33. console.log(e.currentTarget.dataset.current);
  34. // let cur = e.currentTarget.dataset.current;
  35. // if (this.data.currentTaB == cur) {
  36. // return false;
  37. // }else{
  38. // wx.navigateTo({
  39. // url: '../inCome/index?id=' + id,
  40. // })
  41. // }
  42. wx.navigateTo({
  43. url: '../apply/index?',
  44. })
  45. },
  46. /* 计算bar 高度*/
  47. computeBarLocation() {
  48. var that = this;
  49. let CustomMenuButton = wx.getMenuButtonBoundingClientRect();
  50. let CustomWidows = wx.getSystemInfoSync();
  51. // 根据文档,先创建一个SelectorQuery对象实例
  52. let query = wx.createSelectorQuery().in(this);
  53. query.select('.top_title').boundingClientRect();
  54. query.select('.information_header').boundingClientRect();
  55. query.select('.navList_main').boundingClientRect();
  56. query.select('.child_function').boundingClientRect();
  57. query.select('.work_plan').boundingClientRect();
  58. query.exec((res) => {
  59. let wrokScrollHeight = CustomWidows.windowHeight;
  60. res.forEach((v)=>{
  61. wrokScrollHeight = wrokScrollHeight - v.height;
  62. })
  63. wrokScrollHeight = wrokScrollHeight-CustomMenuButton.top-CustomMenuButton.bottom -15;
  64. that.setData({
  65. wrokScrollHeight: wrokScrollHeight,
  66. });
  67. })
  68. that.setData({
  69. CustomMenuButton: CustomMenuButton,
  70. });
  71. },
  72. /* 获取用户信息*/
  73. getUserInfo(){
  74. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  75. success: (res) => {
  76. if (res.code == API.SUCCESS_CODE) {
  77. this.setData({userInfoObj:res.user})
  78. }
  79. }
  80. })
  81. }
  82. })