show.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="container">
  3. <view class="show-item">
  4. <view class="show-elec-label">
  5. <view class="show-item-logol">
  6. <image class="show-item-logo-left" src="/static/image/show.png"></image>
  7. </view>
  8. <view class="show-item-label">能耗走势图</view>
  9. </view>
  10. <view class="charts-box">
  11. <qiun-data-charts type="demotype" :chartData="chartData" />
  12. </view>
  13. <view class="select-show">
  14. <button class="first-button">月</button>
  15. </view>
  16. </view>
  17. <view class="show-item-date">
  18. <view class="show-elec-label">
  19. <view class="show-item-logol">
  20. <image class="show-item-logo-left" src="/static/image/record.png"></image>
  21. </view>
  22. <view class="show-item-label show-label">缴费记录</view>
  23. </view>
  24. <view class="select-date">
  25. <picker mode="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
  26. <view class="uni-input">
  27. <text class="uni-input-label">{{date}}</text>
  28. <text class="iconfont icon-arrow-down"></text>
  29. </view>
  30. </picker>
  31. <view class="uni-list">
  32. <view class="item-list" v-for="(item, i) in list" :key="i">
  33. <view class="item-list-left">
  34. <text class="item-list-txt">{{item.name}}</text>
  35. <text class="item-list-txt">{{item.tdate}} {{item.time}}</text>
  36. </view>
  37. <text class="item-list-txt show-money">{{item.money}}</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. chartData: {
  49. categories: [],
  50. series: [{
  51. data: [],
  52. }],
  53. },
  54. date: this.$getDate({
  55. format: true
  56. }),
  57. startDate: this.$getDate('start_date'),
  58. endDate: this.$getDate('end_date'),
  59. all_data: '', //所有数据
  60. list: [], //消费列表
  61. code: '',
  62. ceshi: 'code',
  63. stu_number: 0, //用户卡号
  64. }
  65. },
  66. onLoad() {
  67. // 获取学号
  68. this.stu_number = this.$store.state.stu_number
  69. this.get_xiaofeijilu()
  70. this.get_chongzhijilu()
  71. },
  72. methods: {
  73. /**
  74. * 获取选择日期
  75. * @param {Object} e
  76. */
  77. bindDateChange: function(e) {
  78. this.date = e.detail.value
  79. this.get_chongzhijilu()
  80. },
  81. /**
  82. * 获取充值记录
  83. */
  84. async get_chongzhijilu() {
  85. console.log(this.$store.state.stu_number);
  86. const res = await this.$myRequest({
  87. host: this.ceshi,
  88. url: '/HotWaters/elqueyRecordEle.action',
  89. method: 'POST',
  90. header: {
  91. 'content-type': 'application/x-www-form-urlencoded'
  92. },
  93. data: {
  94. 'stu_number': this.$store.state.stu_number,
  95. 're_time': this.date
  96. }
  97. })
  98. console.log(res);
  99. if (res.data.mess == '未查到记录') {
  100. uni.showToast({
  101. title: '该月无充值记录',
  102. icon: 'success'
  103. });
  104. }
  105. // this.list = this.all_data.data[0].xiaofei
  106. },
  107. async get_xiaofeijilu() {
  108. const res = await this.$myRequest({
  109. host: this.ceshi,
  110. url: '/HotWaters/buildgetMonthBill.action',
  111. method: 'POST',
  112. header: {
  113. 'content-type': 'application/x-www-form-urlencoded'
  114. },
  115. data: {
  116. 'roomSelect': this.$store.state.building.roomSelect
  117. }
  118. })
  119. console.log(res);
  120. let tmparr_date_time = []
  121. let tmparr_use_elec = []
  122. for (var i = 0; i < res.data.date_time.length; i++) {
  123. tmparr_date_time.push(res.data.date_time[i])
  124. }
  125. for (var i = 0; i < res.data.use_elc.length; i++) {
  126. tmparr_use_elec.push(res.data.use_elc[i])
  127. }
  128. let chrt_data = {
  129. categories: [],
  130. series: [{
  131. data: [],
  132. }],
  133. }
  134. chrt_data.categories = tmparr_date_time
  135. chrt_data.series[0].data = tmparr_use_elec
  136. console.log(chrt_data);
  137. setTimeout(() => {
  138. this.chartData = chrt_data;
  139. }, 30)
  140. }
  141. }
  142. }
  143. </script>
  144. <style>
  145. @import url("show.css");
  146. </style>