record-index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // components/record-index/record-index.js
  2. Component({
  3. properties: {
  4. id: {
  5. type: String,
  6. value: ''
  7. }
  8. },
  9. data: {
  10. loading: true,
  11. error: false,
  12. charts: [],
  13. rect: {
  14. width: 0,
  15. height: 0
  16. }
  17. },
  18. lifetimes: {
  19. attached() {
  20. this.init();
  21. }
  22. },
  23. methods: {
  24. async init() {
  25. try {
  26. const systemInfo = wx.getSystemInfoSync();
  27. const rect = {
  28. width: systemInfo.windowWidth,
  29. height: 300
  30. };
  31. this.setData({ rect });
  32. await this.loadCharts();
  33. } catch (error) {
  34. console.error('Failed to initialize record-index:', error);
  35. this.setData({ error: true, loading: false });
  36. }
  37. },
  38. async loadCharts() {
  39. try {
  40. // TODO: Implement your chart data loading logic here
  41. // This should be similar to what you have in the page version
  42. this.setData({ loading: false });
  43. } catch (error) {
  44. console.error('Failed to load charts:', error);
  45. this.setData({ error: true, loading: false });
  46. }
  47. }
  48. }
  49. });