show.vue 6.1 KB

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