sfxq.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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.totalPower}}</view>
  21. <view class="description">用量(吨)</view>
  22. </view>
  23. <view class="item">
  24. <view class="num">{{sameMonthData.totalMoney}}</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. totalMoney: 0.00.toFixed(2),
  67. totalPower: 0.00.toFixed(2),
  68. zongStart: 0.00.toFixed(2)
  69. },
  70. moneyPer: 2.1.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);
  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/cwaterqueryNow.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 totalMoney = res.data.data[0].totalMoney
  162. let totalPower = res.data.data[0].totalPower
  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.totalMoney = totalMoney.toFixed(2)
  169. this.sameMonthData.totalPower = totalPower.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. uni.showToast({
  184. icon: 'none',
  185. title: '每月账单开发中...',
  186. mask: true,
  187. duration: 3000
  188. })
  189. return
  190. var reg = /[\u4e00-\u9fa5]/g;
  191. var str = this.roomSelect;
  192. this.dom = str.replace(reg, "");
  193. let res = await this.$myRequest({
  194. host: this.ceshi,
  195. url: '/HotWaters/cwaterMonthlist.action',
  196. method: 'POST',
  197. header: {
  198. 'content-type': 'application/x-www-form-urlencoded'
  199. },
  200. data: {
  201. 'dom': this.dom,
  202. 'page': 1,
  203. 'rows': 12
  204. }
  205. })
  206. // console.log(res.data)
  207. if (res.data.rows.length == 0) {
  208. return
  209. }
  210. if (typeof res.data.rows === 'undefined') {
  211. uni.showToast({
  212. title: '加载数据异常',
  213. duration: 1500
  214. })
  215. return
  216. } else {
  217. for (let i = 0; i < res.data.rows.length; i++) {
  218. let dataTime = res.data.rows[i].dataTime
  219. let zongStart = res.data.rows[i].zongStart
  220. let zongEnd = res.data.rows[i].zongEnd
  221. let totalPower = res.data.rows[i].totalPower
  222. let totalMoney = res.data.rows[i].totalMoney
  223. zongStart = zongStart.toFixed(2)
  224. zongEnd = zongEnd.toFixed(2)
  225. totalPower = totalPower.toFixed(2)
  226. totalMoney = totalMoney.toFixed(2)
  227. if (this.moneyPer <= 0.00) {
  228. if (totalPower > 0.00 && totalMoney > 0.00) {
  229. let moneyPer = totalMoney / totalPower
  230. this.moneyPer = moneyPer.toFixed(2)
  231. if (this.moneyPer <= 0.00) {
  232. this.moneyPer = 0.61
  233. }
  234. }
  235. }
  236. totalMoney = '¥' + totalMoney
  237. this.tableData.push({
  238. dataTime,
  239. zongStart,
  240. zongEnd,
  241. totalPower,
  242. totalMoney
  243. })
  244. }
  245. }
  246. }
  247. }
  248. }
  249. </script>
  250. <style scoped lang="scss">
  251. .container {
  252. display: flex;
  253. flex-direction: column;
  254. font-size: 29upx;
  255. font-family: "Microsoft YaHei";
  256. .line {
  257. height: 10rpx;
  258. background-color: #f5f5f5;
  259. }
  260. .same-month {
  261. display: flex;
  262. flex-direction: column;
  263. padding: 20rpx 30rpx;
  264. .title {
  265. display: flex;
  266. align-items: center;
  267. margin-bottom: 30rpx;
  268. .vertical-line {
  269. display: inline-block;
  270. margin-right: 20rpx;
  271. width: 10rpx;
  272. height: 45rpx;
  273. background-color: #0282F8;
  274. }
  275. .title-txt {
  276. display: flex;
  277. flex-direction: row;
  278. align-items: flex-end;
  279. color: #C1C1C1;
  280. .caption {
  281. color: #2b2b2b;
  282. font-size: 40upx;
  283. }
  284. .hah {
  285. display: flex;
  286. margin: 0 10rpx;
  287. }
  288. }
  289. }
  290. .content-details {
  291. display: flex;
  292. justify-content: space-around;
  293. .item {
  294. display: flex;
  295. flex-direction: column;
  296. align-items: center;
  297. .num {
  298. font-size: 40upx;
  299. }
  300. .description {
  301. color: #9a9a9a;
  302. }
  303. }
  304. /deep/ .uni-table {
  305. .uni-table-th {
  306. padding: 6px 8px;
  307. font-size: 26upx;
  308. white-space: nowrap;
  309. text-align: center;
  310. background-color: #E5F2FE;
  311. color: #39393A;
  312. }
  313. .uni-table-td {
  314. padding: 3px 5px;
  315. font-size: 26upx;
  316. white-space: nowrap;
  317. text-align: center;
  318. }
  319. }
  320. }
  321. .txt-color {
  322. margin: 20rpx 0;
  323. color: #C1C1C1;
  324. }
  325. }
  326. }
  327. </style>