show.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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" tooltipFormat="tooltipDemo1" />
  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: '', // 学号
  64. roomSelect: '', // 选择的宿舍号
  65. changeDate: false // 是否是手动选择日期
  66. }
  67. },
  68. onLoad() {
  69. try {
  70. // 获取学号
  71. this.stu_number = this.$store.state.userInfo.card_number
  72. this.roomSelect = this.$store.state.building.roomSelect
  73. if (this.stu_number == '' || this.roomSelect == '' || typeof(this.stu_number) == 'undefined' || typeof(this
  74. .roomSelect) == 'undefined') {
  75. const userinfo = uni.getStorageSync('userinfo_storage_key')
  76. if (userinfo) {
  77. this.stu_number = userinfo.card_number
  78. this.roomSelect = userinfo.campus + userinfo.dorm_number
  79. } else {
  80. uni.redirectTo({
  81. url: '../index/index'
  82. })
  83. uni.showToast({
  84. icon: 'none',
  85. title: '学号或宿舍号为空,请授权',
  86. duration: 3000
  87. })
  88. return
  89. }
  90. }
  91. // console.log(this.stu_number);
  92. // console.log(this.roomSelect);
  93. // 能耗记录
  94. this.get_nenghaojilu()
  95. // 缴费记录
  96. this.get_jiaofeijilu()
  97. } catch (e) {
  98. console.log(e);
  99. }
  100. },
  101. methods: {
  102. /**
  103. * 获取选择日期
  104. */
  105. bindDateChange: function(e) {
  106. this.date = e.detail.value
  107. this.changeDate = true
  108. // 缴费记录
  109. this.get_jiaofeijilu()
  110. },
  111. /**
  112. * 获取缴费记录
  113. */
  114. async get_jiaofeijilu() {
  115. // console.log(this.stu_number);
  116. if (this.stu_number != '') {
  117. const res = await this.$myRequest({
  118. host: this.ceshi,
  119. url: '/HotWaters/elqueyRecordEle.action',
  120. method: 'POST',
  121. header: {
  122. 'content-type': 'application/x-www-form-urlencoded'
  123. },
  124. data: {
  125. 'stu_number': this.stu_number,
  126. 're_time': this.date
  127. }
  128. })
  129. // console.log(res);
  130. if (res.data.mess == '未查到记录') {
  131. if (this.changeDate) {
  132. uni.showToast({
  133. title: '该月无缴费记录',
  134. icon: 'success',
  135. success: (res) => {
  136. this.changeDate = false
  137. }
  138. });
  139. }
  140. } else {
  141. // 充值绑定显示到界面
  142. for (var i = 0; i < res.data.data.length; i++) {
  143. this.list.push(res.data.data[i])
  144. }
  145. }
  146. } else {
  147. uni.showToast({
  148. title: '学号为空',
  149. icon: 'success'
  150. });
  151. }
  152. },
  153. /**
  154. * 能耗记录
  155. */
  156. async get_nenghaojilu() {
  157. if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
  158. const res = await this.$myRequest({
  159. host: this.ceshi,
  160. url: '/HotWaters/buildgetMonthBill.action',
  161. method: 'POST',
  162. header: {
  163. 'content-type': 'application/x-www-form-urlencoded'
  164. },
  165. data: {
  166. 'roomSelect': this.roomSelect
  167. }
  168. })
  169. // console.log(res);
  170. if (res.data.mess == '未查询到数据') {
  171. return
  172. }
  173. let chrt_data = {
  174. categories: [],
  175. series: [{
  176. data: [],
  177. }],
  178. }
  179. for (var i = 0; i < res.data.date_time.length; i++) {
  180. chrt_data.categories.push(res.data.date_time[i])
  181. chrt_data.series[0].data.push(res.data.use_elc[i])
  182. }
  183. // console.log(chrt_data);
  184. setTimeout(() => {
  185. this.chartData = chrt_data;
  186. }, 1000)
  187. } else {
  188. uni.showToast({
  189. title: '宿舍号为空',
  190. icon: 'success'
  191. });
  192. }
  193. }
  194. }
  195. }
  196. </script>
  197. <style>
  198. @import url("show.css");
  199. </style>