dfxq.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="container">
  3. <view class="line"></view>
  4. <view class="same-month">
  5. <view class="title">
  6. <view class="vertical-line"></view>
  7. <view class="title-txt"><text class="caption">当月详情</text><text
  8. class="hah">/</text>时间更新到{{sameMonthData.dataTime}}</view>
  9. </view>
  10. <view class="content-details">
  11. <view class="item">
  12. <view class="num">{{sameMonthData.zongStart}}</view>
  13. <view class="description">起码(度)</view>
  14. </view>
  15. <view class="item">
  16. <view class="num">{{sameMonthData.zongEnd}}</view>
  17. <view class="description">止码(度)</view>
  18. </view>
  19. <view class="item">
  20. <view class="num">{{sameMonthData.zongPower}}</view>
  21. <view class="description">用量(度)</view>
  22. </view>
  23. <view class="item">
  24. <view class="num">{{sameMonthData.zongMoney}}</view>
  25. <view class="description">消费(元)</view>
  26. </view>
  27. </view>
  28. <view class="txt-color">(注:电费标准:{{moneyPer}}元/度)</view>
  29. </view>
  30. <view class="line"></view>
  31. <view class="same-month">
  32. <view class="title">
  33. <view class="vertical-line"></view>
  34. <view class="title-txt"><text class="caption">每月账单</text></view>
  35. </view>
  36. <view class="content-details">
  37. <uni-table :border="true" :stripe="true" emptyText="暂无更多数据">
  38. <!-- 表头行 -->
  39. <uni-tr>
  40. <uni-th width="66" align="center">时间</uni-th>
  41. <uni-th width="64" align="center">起码(度)</uni-th>
  42. <uni-th width="64" align="center">止码(度)</uni-th>
  43. <uni-th width="64" align="center">用量(度)</uni-th>
  44. <uni-th width="64" align="center">消费</uni-th>
  45. </uni-tr>
  46. <!-- 表格数据行 -->
  47. <uni-tr v-for="(item, index) in tableData" :key="index">
  48. <uni-td align="center">{{item.dataTime}}</uni-td>
  49. <uni-td align="center">{{item.zongStart}}</uni-td>
  50. <uni-td align="center">{{item.zongEnd}}</uni-td>
  51. <uni-td align="center">{{item.totalPower}}</uni-td>
  52. <uni-td align="center">{{item.totalMoney}}</uni-td>
  53. </uni-tr>
  54. </uni-table>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. sameMonthData: {
  64. dataTime: '',
  65. zongEnd: 0.00.toFixed(2),
  66. zongMoney: 0.00.toFixed(2),
  67. zongPower: 0.00.toFixed(2),
  68. zongStart: 0.00.toFixed(2)
  69. },
  70. moneyPer: 0.62.toFixed(2),
  71. tableData: [],
  72. ceshi: 'code',
  73. stu_number: '', // 学号
  74. roomSelect: '', // 选择的宿舍号
  75. dom: ''
  76. }
  77. },
  78. onLoad() {
  79. try {
  80. // 获取学号
  81. this.stu_number = this.$store.state.userInfo.card_number
  82. this.roomSelect = this.$store.state.building.roomSelect
  83. if (this.stu_number == '' || this.roomSelect == '' || typeof(this.stu_number) == 'undefined' || typeof(this
  84. .roomSelect) == 'undefined') {
  85. const userinfo = uni.getStorageSync('userinfo_storage_key')
  86. if (userinfo) {
  87. this.stu_number = userinfo.card_number
  88. this.roomSelect = userinfo.campus + userinfo.dorm_number
  89. } else {
  90. uni.redirectTo({
  91. url: '../index/index'
  92. })
  93. uni.showToast({
  94. icon: 'none',
  95. title: '学号或宿舍号为空,请授权',
  96. duration: 1500
  97. })
  98. return
  99. }
  100. }
  101. // console.log(this.stu_number);
  102. // console.log(this.roomSelect);
  103. // 判断是否选择了宿舍号
  104. if (this.haveSelectRoom()) {
  105. uni.showToast({
  106. title: '宿舍号为空',
  107. icon: 'success'
  108. })
  109. }
  110. } catch (e) {
  111. console.log(e.message)
  112. }
  113. },
  114. methods: {
  115. /**
  116. * 判断是否选择了宿舍号
  117. */
  118. haveSelectRoom() {
  119. if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
  120. // 当月详情
  121. try {
  122. this.get_sameMonthDetails()
  123. } catch (e) {
  124. uni.showToast({
  125. title: '当月详情'
  126. })
  127. }
  128. // 每月账单
  129. try {
  130. this.get_history()
  131. } catch (e) {
  132. uni.showToast({
  133. title: '每月账单异常'
  134. })
  135. }
  136. } else {
  137. return true
  138. }
  139. },
  140. /**
  141. * 当月详情
  142. */
  143. async get_sameMonthDetails() {
  144. let res = await this.$myRequest({
  145. host: this.ceshi,
  146. url: '/HotWaters/elnowElc.action',
  147. method: 'POST',
  148. header: {
  149. 'content-type': 'application/x-www-form-urlencoded'
  150. },
  151. data: {
  152. 'roomSelect': this.roomSelect
  153. }
  154. })
  155. // console.log(res.data)
  156. if (res.data.data.length == 0) {
  157. return
  158. }
  159. if (res.data.mess === '返回成功') {
  160. let zongEnd = res.data.data[0].zongEnd
  161. let zongMoney = res.data.data[0].zongMoney
  162. let zongPower = res.data.data[0].zongPower
  163. let zongStart = res.data.data[0].zongStart
  164. let dataTime = res.data.data[0].dataTime
  165. let dt = dataTime.split('-')
  166. this.sameMonthData.dataTime = dt[0] + '年' + parseInt(dt[1]) + '月'
  167. this.sameMonthData.zongEnd = zongEnd.toFixed(2)
  168. this.sameMonthData.zongMoney = zongMoney.toFixed(2)
  169. this.sameMonthData.zongPower = zongPower.toFixed(2)
  170. this.sameMonthData.zongStart = zongStart.toFixed(2)
  171. } else {
  172. uni.showToast({
  173. title: '加载数据异常',
  174. duration: 1500
  175. })
  176. return
  177. }
  178. },
  179. /**
  180. * 每月账单
  181. */
  182. async get_history() {
  183. var reg = /[\u4e00-\u9fa5]/g;
  184. var str = this.roomSelect;
  185. this.dom = str.replace(reg, "");
  186. let res = await this.$myRequest({
  187. host: this.ceshi,
  188. url: '/HotWaters/elMonthlist.action',
  189. method: 'POST',
  190. header: {
  191. 'content-type': 'application/x-www-form-urlencoded'
  192. },
  193. data: {
  194. 'dom': this.dom,
  195. 'page': 1,
  196. 'rows': 12
  197. }
  198. })
  199. // console.log(res.data)
  200. if (res.data.rows.length == 0) {
  201. return
  202. }
  203. if (typeof res.data.rows === 'undefined') {
  204. uni.showToast({
  205. title: '加载数据异常',
  206. duration: 1500
  207. })
  208. return
  209. } else {
  210. for (let i = 0; i < res.data.rows.length; i++) {
  211. let dataTime = res.data.rows[i].dataTime
  212. let zongStart = res.data.rows[i].zongStart
  213. let zongEnd = res.data.rows[i].zongEnd
  214. let totalPower = res.data.rows[i].totalPower
  215. let totalMoney = res.data.rows[i].totalMoney
  216. zongStart = zongStart.toFixed(2)
  217. zongEnd = zongEnd.toFixed(2)
  218. totalPower = totalPower.toFixed(2)
  219. totalMoney = totalMoney.toFixed(2)
  220. if (this.moneyPer <= 0.00) {
  221. if (totalPower > 0.00 && totalMoney > 0.00) {
  222. let moneyPer = totalMoney / totalPower
  223. this.moneyPer = moneyPer.toFixed(2)
  224. if (this.moneyPer <= 0.00) {
  225. this.moneyPer = 0.61
  226. }
  227. }
  228. }
  229. totalMoney = '¥' + totalMoney
  230. this.tableData.push({
  231. dataTime,
  232. zongStart,
  233. zongEnd,
  234. totalPower,
  235. totalMoney
  236. })
  237. }
  238. }
  239. }
  240. }
  241. }
  242. </script>
  243. <style scoped lang="scss">
  244. .container {
  245. display: flex;
  246. flex-direction: column;
  247. font-size: 29upx;
  248. font-family: "Microsoft YaHei";
  249. .line {
  250. height: 10rpx;
  251. background-color: #f5f5f5;
  252. }
  253. .same-month {
  254. display: flex;
  255. flex-direction: column;
  256. padding: 20rpx 30rpx;
  257. .title {
  258. display: flex;
  259. align-items: center;
  260. margin-bottom: 30rpx;
  261. .vertical-line {
  262. display: inline-block;
  263. margin-right: 20rpx;
  264. width: 10rpx;
  265. height: 45rpx;
  266. background-color: #0282F8;
  267. }
  268. .title-txt {
  269. display: flex;
  270. flex-direction: row;
  271. align-items: flex-end;
  272. color: #C1C1C1;
  273. .caption {
  274. color: #2b2b2b;
  275. font-size: 40upx;
  276. }
  277. .hah {
  278. display: flex;
  279. margin: 0 10rpx;
  280. }
  281. }
  282. }
  283. .content-details {
  284. display: flex;
  285. justify-content: space-around;
  286. .item {
  287. display: flex;
  288. flex-direction: column;
  289. align-items: center;
  290. .num {
  291. font-size: 40upx;
  292. }
  293. .description {
  294. color: #9a9a9a;
  295. }
  296. }
  297. /deep/ .uni-table {
  298. .uni-table-th {
  299. padding: 6px 8px;
  300. font-size: 26upx;
  301. white-space: nowrap;
  302. text-align: center;
  303. background-color: #E5F2FE;
  304. color: #5b5b5d;
  305. }
  306. .uni-table-td {
  307. padding: 3px 5px;
  308. font-size: 26upx;
  309. white-space: nowrap;
  310. text-align: center;
  311. color: #000000;
  312. }
  313. }
  314. }
  315. .txt-color {
  316. margin: 20rpx 0;
  317. color: #C1C1C1;
  318. }
  319. }
  320. }
  321. </style>