sfxq.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. const eventChannel = this.getOpenerEventChannel();
  81. // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
  82. let _this = this;
  83. eventChannel.on('params', function(data) {
  84. // console.log(data)
  85. // 获取学号
  86. _this.stu_number = data.data.card_number
  87. _this.roomSelect = data.data.roomSelect
  88. })
  89. if (this.stu_number == '' || this.roomSelect == '' || typeof(this.stu_number) == 'undefined' || typeof(this
  90. .roomSelect) == 'undefined') {
  91. // 获取学号
  92. this.stu_number = this.$store.state.userInfo.card_number
  93. this.roomSelect = this.$store.state.building.roomSelect
  94. if (this.stu_number == '' || this.roomSelect == '' || typeof(this.stu_number) == 'undefined' || typeof(
  95. this
  96. .roomSelect) == 'undefined') {
  97. const userinfo = uni.getStorageSync('userinfo_storage_key')
  98. if (userinfo) {
  99. this.stu_number = userinfo.card_number
  100. this.roomSelect = userinfo.campus + userinfo.dorm_number
  101. } else {
  102. uni.redirectTo({
  103. url: '../index/index'
  104. })
  105. uni.showToast({
  106. icon: 'none',
  107. title: '学号或宿舍号为空,请授权',
  108. duration: 1500
  109. })
  110. return
  111. }
  112. }
  113. }
  114. // console.log(this.stu_number);
  115. // console.log(this.roomSelect);
  116. // 判断是否选择了宿舍号
  117. if (this.haveSelectRoom()) {
  118. uni.showToast({
  119. title: '宿舍号为空',
  120. icon: 'success'
  121. })
  122. }
  123. } catch (e) {
  124. console.log(e);
  125. }
  126. },
  127. methods: {
  128. /**
  129. * 判断是否选择了宿舍号
  130. */
  131. haveSelectRoom() {
  132. if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
  133. // 当月详情
  134. try {
  135. this.get_sameMonthDetails()
  136. } catch (e) {
  137. uni.showToast({
  138. title: '当月详情异常'
  139. })
  140. }
  141. // 每月账单
  142. try {
  143. this.get_history()
  144. } catch (e) {
  145. uni.showToast({
  146. title: '每月账单异常'
  147. })
  148. }
  149. return false
  150. } else {
  151. return true
  152. }
  153. },
  154. /**
  155. * 当月详情
  156. */
  157. async get_sameMonthDetails() {
  158. let res = await this.$myRequest({
  159. host: this.ceshi,
  160. url: '/HotWaters/cwaterqueryNow.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.data)
  170. if (res.data.mess === '返回成功') {
  171. if (res.data.data.length == 0) {
  172. return
  173. }
  174. let zongEnd = res.data.data[0].zongEnd
  175. let totalMoney = res.data.data[0].totalMoney
  176. let totalPower = res.data.data[0].totalPower
  177. let zongStart = res.data.data[0].zongStart
  178. let dataTime = res.data.data[0].dataTime
  179. let dt = dataTime.split('-')
  180. this.sameMonthData.dataTime = dt[0] + '年' + parseInt(dt[1]) + '月'
  181. this.sameMonthData.zongEnd = zongEnd.toFixed(2)
  182. this.sameMonthData.totalMoney = totalMoney.toFixed(2)
  183. this.sameMonthData.totalPower = totalPower.toFixed(2)
  184. this.sameMonthData.zongStart = zongStart.toFixed(2)
  185. } else {
  186. uni.showToast({
  187. title: '加载数据异常',
  188. duration: 1500
  189. })
  190. return
  191. }
  192. },
  193. /**
  194. * 每月账单
  195. */
  196. async get_history() {
  197. var reg = /[\u4e00-\u9fa5]/g;
  198. var str = this.roomSelect;
  199. this.dom = str.replace(reg, "");
  200. let res = await this.$myRequest({
  201. host: this.ceshi,
  202. url: '/HotWaters/cwaterMonthlist.action',
  203. method: 'POST',
  204. header: {
  205. 'content-type': 'application/x-www-form-urlencoded'
  206. },
  207. data: {
  208. 'dom': this.dom,
  209. 'page': 1,
  210. 'rows': 12
  211. }
  212. })
  213. // console.log(res.data)
  214. if (res.data.rows.length == 0) {
  215. return
  216. }
  217. if (typeof res.data.rows === 'undefined') {
  218. uni.showToast({
  219. title: '加载数据异常',
  220. duration: 1500
  221. })
  222. return
  223. } else {
  224. for (let i = 0; i < res.data.rows.length; i++) {
  225. let dataTime = res.data.rows[i].dataTime
  226. let zongStart = res.data.rows[i].zongStart
  227. let zongEnd = res.data.rows[i].zongEnd
  228. let totalPower = res.data.rows[i].totalPower
  229. let totalMoney = res.data.rows[i].totalMoney
  230. zongStart = zongStart.toFixed(2)
  231. zongEnd = zongEnd.toFixed(2)
  232. totalPower = totalPower.toFixed(2)
  233. totalMoney = totalMoney.toFixed(2)
  234. if (this.moneyPer <= 0.00) {
  235. if (totalPower > 0.00 && totalMoney > 0.00) {
  236. let moneyPer = totalMoney / totalPower
  237. this.moneyPer = moneyPer.toFixed(2)
  238. if (this.moneyPer <= 0.00) {
  239. this.moneyPer = 0.61
  240. }
  241. }
  242. }
  243. totalMoney = '¥' + totalMoney
  244. this.tableData.push({
  245. dataTime,
  246. zongStart,
  247. zongEnd,
  248. totalPower,
  249. totalMoney
  250. })
  251. }
  252. }
  253. }
  254. }
  255. }
  256. </script>
  257. <style scoped lang="scss">
  258. .container {
  259. display: flex;
  260. flex-direction: column;
  261. font-size: 29upx;
  262. font-family: "Microsoft YaHei";
  263. .line {
  264. height: 10rpx;
  265. background-color: #f5f5f5;
  266. }
  267. .same-month {
  268. display: flex;
  269. flex-direction: column;
  270. padding: 20rpx 30rpx;
  271. .title {
  272. display: flex;
  273. align-items: center;
  274. margin-bottom: 30rpx;
  275. .vertical-line {
  276. display: inline-block;
  277. margin-right: 20rpx;
  278. width: 10rpx;
  279. height: 45rpx;
  280. background-color: #0282F8;
  281. }
  282. .title-txt {
  283. display: flex;
  284. flex-direction: row;
  285. align-items: flex-end;
  286. color: #C1C1C1;
  287. .caption {
  288. color: #2b2b2b;
  289. font-size: 40upx;
  290. }
  291. .hah {
  292. display: flex;
  293. margin: 0 10rpx;
  294. }
  295. }
  296. }
  297. .content-details {
  298. display: flex;
  299. justify-content: space-around;
  300. .item {
  301. display: flex;
  302. flex-direction: column;
  303. align-items: center;
  304. .num {
  305. font-size: 40upx;
  306. }
  307. .description {
  308. color: #9a9a9a;
  309. }
  310. }
  311. /deep/ .uni-table {
  312. .uni-table-th {
  313. padding: 6px 8px;
  314. font-size: 26upx;
  315. white-space: nowrap;
  316. text-align: center;
  317. background-color: #E5F2FE;
  318. color: #39393A;
  319. }
  320. .uni-table-td {
  321. padding: 3px 5px;
  322. font-size: 26upx;
  323. white-space: nowrap;
  324. text-align: center;
  325. }
  326. }
  327. }
  328. .txt-color {
  329. margin: 20rpx 0;
  330. color: #C1C1C1;
  331. }
  332. }
  333. }
  334. </style>