show.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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: '', // 学号
  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_nenghaojilu()
  110. // 缴费记录
  111. this.get_jiaofeijilu()
  112. },
  113. /**
  114. * 获取缴费记录
  115. */
  116. async get_jiaofeijilu() {
  117. // console.log(this.stu_number);
  118. if (this.stu_number != '') {
  119. const res = await this.$myRequest({
  120. host: this.ceshi,
  121. url: '/HotWaters/elqueyRecordEle.action',
  122. method: 'POST',
  123. header: {
  124. 'content-type': 'application/x-www-form-urlencoded'
  125. },
  126. data: {
  127. 'stu_number': this.stu_number,
  128. 're_time': this.date
  129. }
  130. })
  131. // console.log(res);
  132. if (res.data.mess == '未查到记录') {
  133. if (this.changeDate) {
  134. uni.showToast({
  135. title: '该月无缴费记录',
  136. icon: 'success',
  137. success: (res) => {
  138. this.changeDate = false
  139. }
  140. });
  141. }
  142. } else {
  143. // 充值绑定显示到界面
  144. for (var i = 0; i < res.data.data.length; i++) {
  145. this.list.push(res.data.data[i])
  146. }
  147. }
  148. } else {
  149. uni.showToast({
  150. title: '学号为空',
  151. icon: 'success'
  152. });
  153. }
  154. },
  155. /**
  156. * 能耗记录
  157. */
  158. async get_nenghaojilu() {
  159. if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
  160. const res = await this.$myRequest({
  161. host: this.ceshi,
  162. url: '/HotWaters/buildgetMonthBill.action',
  163. method: 'POST',
  164. header: {
  165. 'content-type': 'application/x-www-form-urlencoded'
  166. },
  167. data: {
  168. 'roomSelect': this.roomSelect
  169. }
  170. })
  171. // console.log(res);
  172. if (res.data.mess == '未查询到数据') {
  173. return
  174. }
  175. let chrt_data = {
  176. categories: [],
  177. series: [{
  178. data: [],
  179. }],
  180. }
  181. for (var i = 0; i < res.data.date_time.length; i++) {
  182. chrt_data.categories.push(res.data.date_time[i])
  183. chrt_data.series[0].data.push(res.data.use_elc[i])
  184. }
  185. // console.log(chrt_data);
  186. setTimeout(() => {
  187. this.chartData = chrt_data;
  188. }, 1000)
  189. } else {
  190. uni.showToast({
  191. title: '宿舍号为空',
  192. icon: 'success'
  193. });
  194. }
  195. }
  196. }
  197. }
  198. </script>
  199. <style>
  200. @import url("show.css");
  201. </style>