list.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const app = getApp()
  2. import * as echarts from '../../../commpents/ec-canvas/echarts'
  3. Page({
  4. data: {
  5. frameStyle: { useTop: true, name: '付费情况', leftArrow: true, useBar: false },
  6. // xdata: []
  7. },
  8. // 返回
  9. back(e) {
  10. wx.navigateBack({ delta: 1 })
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. },
  17. // 监听用户是否登录
  18. watchLogin: async function () {
  19. const that = this;
  20. wx.getStorage({
  21. key: 'user',
  22. success: async res => {
  23. that.setData({ ec: { onInit: that.initChart } })
  24. that.data.xdata = [
  25. { value: 2, name: '1月' },
  26. { value: 10, name: '2月' },
  27. { value: 19, name: '3月' },
  28. { value: 20, name: '4月' },
  29. { value: 70, name: '5月' },
  30. { value: 9, name: '6月' },
  31. { value: 12, name: '7月' },
  32. { value: 41, name: '8月' },
  33. { value: 31, name: '9月' },
  34. { value: 13, name: '10月' },
  35. { value: 16, name: '11月' },
  36. { value: 10, name: '12月' }
  37. ];
  38. },
  39. fail: async res => {
  40. wx.redirectTo({ url: '/pages/index/index' })
  41. }
  42. })
  43. },
  44. // 饼图
  45. initChart(canvas, width, height, dpr) {
  46. let that = this;
  47. var xdata = that.data.xdata;
  48. const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr });
  49. canvas.setChart(chart);
  50. if (xdata) {
  51. var option = {
  52. tooltip: { trigger: 'item' },
  53. legend: {
  54. orient: 'vertical',
  55. height: 40,
  56. padding: 50
  57. },
  58. series: [
  59. {
  60. name: '课时费',
  61. type: 'pie',
  62. radius: '50%',
  63. data: xdata,
  64. emphasis: {
  65. itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' }
  66. }
  67. }
  68. ]
  69. };
  70. chart.setOption(option, true);
  71. return chart;
  72. }
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady: function () { },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. const that = this;
  83. // 监听用户是否登录
  84. that.watchLogin();
  85. },
  86. /**
  87. * 页面上拉触底事件的处理函数
  88. */
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload: function () {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh: function () {
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage: function (res) {
  108. },
  109. })