show.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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" :opts="chartOpts"
  12. tooltipFormat="tooltipDemo1" />
  13. </view>
  14. <view class="select-show">
  15. <button class="first-button">月</button>
  16. </view>
  17. </view>
  18. <view class="show-item-date">
  19. <view class="show-elec-label">
  20. <view class="show-item-logol">
  21. <image class="show-item-logo-left" src="/static/image/record.png"></image>
  22. </view>
  23. <view class="show-item-label show-label">缴费记录</view>
  24. </view>
  25. <view class="select-date">
  26. <picker mode="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
  27. <view class="uni-input">
  28. <text class="uni-input-label">{{date}}</text>
  29. <text class="iconfont icon-arrow-down"></text>
  30. </view>
  31. </picker>
  32. <view class="uni-list">
  33. <view class="item-list" v-for="(item, i) in list" :key="i">
  34. <view class="item-list-left">
  35. <text class="item-list-txt">{{item.user_name}}</text>
  36. <text class="item-list-txt">{{item.re_time}}</text>
  37. </view>
  38. <text class="item-list-txt show-money">{{item.account}}</text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. chartData: {
  50. categories: [],
  51. series: [{
  52. data: [],
  53. }]
  54. },
  55. chartOpts: {
  56. yAxis: {
  57. data: [{
  58. max: 0
  59. }]
  60. }
  61. },
  62. date: this.$getDate({
  63. format: true
  64. }),
  65. startDate: this.$getDate('start_date'),
  66. endDate: this.$getDate('end_date'),
  67. all_data: '', // 所有数据
  68. list: [], // 消费列表
  69. code: '',
  70. ceshi: 'code',
  71. stu_number: '', // 学号
  72. roomSelect: '', // 选择的宿舍号
  73. changeDate: false // 是否是手动选择日期
  74. }
  75. },
  76. onLoad() {
  77. try {
  78. // 获取学号
  79. this.stu_number = this.$store.state.userInfo.card_number
  80. this.roomSelect = this.$store.state.building.roomSelect
  81. if (this.stu_number == '' || this.roomSelect == '' || typeof(this.stu_number) == 'undefined' || typeof(this
  82. .roomSelect) == 'undefined') {
  83. const userinfo = uni.getStorageSync('userinfo_storage_key')
  84. if (userinfo) {
  85. this.stu_number = userinfo.card_number
  86. this.roomSelect = userinfo.campus + userinfo.dorm_number
  87. } else {
  88. uni.redirectTo({
  89. url: '../index/index'
  90. })
  91. uni.showToast({
  92. icon: 'none',
  93. title: '学号或宿舍号为空,请授权',
  94. duration: 3000
  95. })
  96. return
  97. }
  98. }
  99. // console.log(this.stu_number);
  100. // console.log(this.roomSelect);
  101. // 能耗记录
  102. this.get_nenghaojilu()
  103. // 缴费记录
  104. this.get_jiaofeijilu()
  105. } catch (e) {
  106. console.log(e);
  107. }
  108. },
  109. methods: {
  110. /**
  111. * 获取选择日期
  112. */
  113. bindDateChange: function(e) {
  114. this.date = e.detail.value
  115. this.changeDate = true
  116. // 缴费记录
  117. this.get_jiaofeijilu()
  118. },
  119. /**
  120. * 获取缴费记录
  121. */
  122. async get_jiaofeijilu() {
  123. // console.log(this.stu_number);
  124. if (this.stu_number != '') {
  125. const res = await this.$myRequest({
  126. host: this.ceshi,
  127. url: '/HotWaters/elqueyRecordEle.action',
  128. method: 'POST',
  129. header: {
  130. 'content-type': 'application/x-www-form-urlencoded'
  131. },
  132. data: {
  133. 'stu_number': this.stu_number,
  134. 're_time': this.date
  135. }
  136. })
  137. // console.log(res);
  138. if (res.data.mess == '未查到记录') {
  139. if (this.changeDate) {
  140. uni.showToast({
  141. title: '该月无缴费记录',
  142. icon: 'success',
  143. success: (res) => {
  144. this.changeDate = false
  145. }
  146. });
  147. }
  148. } else {
  149. // 充值绑定显示到界面
  150. for (var i = 0; i < res.data.data.length; i++) {
  151. this.list.push(res.data.data[i])
  152. }
  153. }
  154. } else {
  155. uni.showToast({
  156. title: '学号为空',
  157. icon: 'success'
  158. });
  159. }
  160. },
  161. /**
  162. * 能耗记录
  163. */
  164. async get_nenghaojilu() {
  165. if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
  166. const res = await this.$myRequest({
  167. host: this.ceshi,
  168. url: '/HotWaters/buildgetMonthBill.action',
  169. method: 'POST',
  170. header: {
  171. 'content-type': 'application/x-www-form-urlencoded'
  172. },
  173. data: {
  174. 'roomSelect': this.roomSelect
  175. }
  176. })
  177. // console.log(res);
  178. if (res.data.mess == '未查询到数据') {
  179. return
  180. }
  181. let chrt_data = {
  182. categories: [],
  183. series: [{
  184. data: [],
  185. }],
  186. }
  187. let elc_max = 0.0
  188. for (var i = 0; i < res.data.date_time.length; i++) {
  189. chrt_data.categories.push(res.data.date_time[i])
  190. chrt_data.series[0].data.push(res.data.use_elc[i])
  191. if (parseFloat(res.data.use_elc[i]) > parseFloat(elc_max)) {
  192. elc_max = res.data.use_elc[i]
  193. }
  194. }
  195. let m = parseFloat(Math.abs(elc_max))
  196. // console.log(chrt_data);
  197. setTimeout(() => {
  198. this.chartOpts.yAxis.data[0].max = parseInt(m + (m / 4.0))
  199. this.chartData = chrt_data;
  200. }, 1000);
  201. } else {
  202. uni.showToast({
  203. title: '宿舍号为空',
  204. icon: 'success'
  205. });
  206. }
  207. }
  208. }
  209. }
  210. </script>
  211. <style>
  212. @import url("show.css");
  213. </style>