show.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.user_name}}</text>
  35. <text class="item-list-txt">{{item.re_time}}</text>
  36. </view>
  37. <text class="item-list-txt show-money">{{item.account}}</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. // 充值记录
  70. this.get_chongzhijilu()
  71. // 消费记录
  72. this.get_xiaofeijilu()
  73. },
  74. methods: {
  75. /**
  76. * 获取选择日期
  77. * @param {Object} e
  78. */
  79. bindDateChange: function(e) {
  80. this.date = e.detail.value
  81. // 充值记录
  82. this.get_chongzhijilu()
  83. },
  84. /**
  85. * 获取充值记录
  86. */
  87. async get_chongzhijilu() {
  88. // console.log(this.$store.state.stu_number);
  89. if (this.$store.state.stu_number != '') {
  90. const res = await this.$myRequest({
  91. host: this.ceshi,
  92. url: '/HotWaters/elqueyRecordEle.action',
  93. method: 'POST',
  94. header: {
  95. 'content-type': 'application/x-www-form-urlencoded'
  96. },
  97. data: {
  98. 'stu_number': this.$store.state.stu_number,
  99. 're_time': this.date
  100. }
  101. })
  102. // console.log(res);
  103. if (res.data.mess == '未查到记录') {
  104. uni.showToast({
  105. title: '该月无缴费记录',
  106. icon: 'success'
  107. });
  108. } else {
  109. // 充值绑定显示到界面
  110. for (var i = 0; i < res.data.data.length; i++) {
  111. this.list.push(res.data.data[i])
  112. }
  113. }
  114. } else {
  115. uni.showToast({
  116. title: '学号为空',
  117. icon: 'success'
  118. });
  119. }
  120. },
  121. /**
  122. * 缴费记录
  123. */
  124. async get_xiaofeijilu() {
  125. if (this.$store.state.building.roomSelect != '') {
  126. const res = await this.$myRequest({
  127. host: this.ceshi,
  128. url: '/HotWaters/buildgetMonthBill.action',
  129. method: 'POST',
  130. header: {
  131. 'content-type': 'application/x-www-form-urlencoded'
  132. },
  133. data: {
  134. 'roomSelect': this.$store.state.building.roomSelect
  135. }
  136. })
  137. // console.log(res);
  138. if (res.data.mess == '未查询到数据') {
  139. return
  140. }
  141. let chrt_data = {
  142. categories: [],
  143. series: [{
  144. data: [],
  145. }],
  146. }
  147. for (var i = 0; i < res.data.date_time.length; i++) {
  148. chrt_data.categories.push(res.data.date_time[i])
  149. chrt_data.series[0].data.push(res.data.use_elc[i])
  150. }
  151. // console.log(chrt_data);
  152. setTimeout(() => {
  153. this.chartData = chrt_data;
  154. }, 1000)
  155. } else {
  156. uni.showToast({
  157. title: '宿舍号为空',
  158. icon: 'success'
  159. });
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style>
  166. @import url("show.css");
  167. </style>