Index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false">
  3. <view class="div container">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="近30天销售走势" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="charts-box">
  14. <qiun-data-charts
  15. type="line"
  16. :chartData="chartData"
  17. :opts="opts"
  18. background="none"
  19. />
  20. </view>
  21. </view>
  22. </seller-base>
  23. </template>
  24. <script>
  25. import {getFontSize} from '@/util/common'
  26. import TitleHeader from '../../TitleHeader'
  27. import SellerBase from '../SellerBase'
  28. import { getStatisticsGeneral } from '../../../api/sellerStatistics'
  29. export default {
  30. name: 'StatisticsGeneral',
  31. components:{
  32. TitleHeader,
  33. SellerBase,
  34. },
  35. data(){
  36. return {
  37. navHeight: 0,
  38. chartData:{
  39. categories:[],
  40. series:[],
  41. },
  42. opts:{
  43. xAxis: {
  44. labelCount: 5,
  45. }
  46. }
  47. }
  48. },
  49. created () {
  50. this.getStatisticsGeneral()
  51. },
  52. computed:{
  53. fontSize(){
  54. return getFontSize()
  55. },
  56. },
  57. mounted(){
  58. // #ifdef MP-WEIXIN
  59. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  60. // #endif
  61. },
  62. beforeDestroy () {
  63. },
  64. methods:{
  65. goBack(){uni.navigateBack({delta:1})},
  66. // 最近30天销售数据
  67. getStatisticsGeneral () {
  68. getStatisticsGeneral().then(res => {
  69. if (res) {
  70. var stattoday_json = JSON.parse(res.result.stattoday_json)// 字符串转JSON格式
  71. this.chartData={
  72. categories:stattoday_json.xAxis.categories,
  73. series:stattoday_json.series
  74. }
  75. }
  76. }).catch(error=>{
  77. uni.showToast({icon:'none',title: error.message})
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style scoped lang="scss">
  84. /* 请根据需求修改图表容器尺寸,如果父容器没有高度图表则会显示异常 */
  85. .charts-box{
  86. width: 100%;
  87. height:300px;
  88. }
  89. </style>