stdBookMgr.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="container">
  3. <view class="line"></view>
  4. <view class="picker-box">
  5. <picker @change="bindYearPickerChange" :value="selYearIndex" :range="years" class="picker-input">
  6. <view class="txt-picker">
  7. <view>{{years[selYearIndex]}}</view>
  8. <uni-icons type="bottom" size="22"></uni-icons>
  9. </view>
  10. </picker>
  11. <picker @change="bindMonthPickerChange" :value="selMonthindex" :range="months" class="picker-input">
  12. <view class="txt-picker">
  13. <view>{{months[selMonthindex]}}</view>
  14. <uni-icons type="bottom" size="22"></uni-icons>
  15. </view>
  16. </picker>
  17. </view>
  18. <view class="line"></view>
  19. <view class="show-charts">
  20. <view class="show-label">
  21. <image class="show-logo-left" src="../static/images/dt.png"></image>
  22. <view class="show-txt-label">消费走势图</view>
  23. </view>
  24. <view class="charts-box">
  25. <qiun-data-charts type="line" :chartData="chartData" :opts="chartOpts" :ontouch="true"
  26. tooltipFormat="tooltipDemo1" />
  27. </view>
  28. </view>
  29. <view class="line"></view>
  30. <view class="xfjl">
  31. <view class="xfjl-title">
  32. <image class="show-logo-left" src="../static/images/xfjl.png"></image>
  33. <view class="show-txt-label">消费记录</view>
  34. </view>
  35. <scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
  36. @scrolltolower="scroll_to_lower">
  37. <view class="items" v-for="(item, index) in consumeRecords" :key="index">
  38. <view class="item">
  39. <view class="item-left">
  40. <image src="../static/images/item-icon.png" mode=""></image>
  41. <view class="item-desc">
  42. <view class="item-title">{{item.loudong}}</view>
  43. <view class="item-time">开始时间:{{item.startTime}}</view>
  44. <view class="item-time">结束时间:{{item.endTime}}</view>
  45. </view>
  46. </view>
  47. <view class="item-right">{{item.amount.toFixed(2)}}</view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. screenHeight: 0,
  59. ceshi: 'code',
  60. years: ['2021年', '2022年'], // 候选年份
  61. months: ['全部', '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], // 候选月份
  62. selYearIndex: 0, // 选择的年份
  63. selMonthindex: 0, // 选择的月份
  64. chartData: {
  65. categories: [],
  66. series: []
  67. },
  68. chartOpts: {
  69. color: ["#1890FF", "#91CB74", "#FAC858"],
  70. padding: [15, 10, 0, 15],
  71. legend: {},
  72. xAxis: {
  73. disableGrid: true
  74. },
  75. yAxis: {
  76. data: [{
  77. max: 0
  78. }]
  79. },
  80. extra: {
  81. line: {
  82. type: "curve",
  83. width: 2
  84. }
  85. }
  86. },
  87. consumeRecords: [{
  88. loudong: '科技楼-5F-101',
  89. startTime: '2022-03-12 12:12:15',
  90. endTime: '2022-03-12 13:12:15',
  91. amount: -20.0
  92. },
  93. {
  94. loudong: '科技楼-5F-101',
  95. startTime: '2022-03-12 12:12:15',
  96. endTime: '2022-03-12 13:12:15',
  97. amount: -20.0
  98. },
  99. {
  100. loudong: '科技楼-5F-101',
  101. startTime: '2022-03-12 12:12:15',
  102. endTime: '2022-03-12 13:12:15',
  103. amount: -20.0
  104. },
  105. {
  106. loudong: '科技楼-5F-101',
  107. startTime: '2022-03-12 12:12:15',
  108. endTime: '2022-03-12 13:12:15',
  109. amount: -20.0
  110. },
  111. {
  112. loudong: '科技楼-5F-101',
  113. startTime: '2022-03-12 12:12:15',
  114. endTime: '2022-03-12 13:12:15',
  115. amount: -20.0
  116. }
  117. ]
  118. }
  119. },
  120. onLoad() {
  121. this.get_xiaofiezoushi()
  122. },
  123. onShow() {
  124. // 从新计算高度
  125. // setTimeout(() => {
  126. this.calc_screen_height()
  127. // }, 1500)
  128. },
  129. methods: {
  130. /**
  131. * 滚动到顶部提示
  132. */
  133. scroll_to_upper() {
  134. uni.showToast({
  135. title: '到顶了!',
  136. icon: 'none',
  137. duration: 500
  138. })
  139. },
  140. /**
  141. * 滚动到底部提示
  142. */
  143. scroll_to_lower() {
  144. uni.showToast({
  145. title: '到底了!',
  146. icon: 'none',
  147. duration: 500
  148. })
  149. },
  150. /**
  151. * 选择年份
  152. * @param {Object} e
  153. */
  154. bindYearPickerChange(e) {
  155. // console.log(e);
  156. this.selYearIndex = e.target.value
  157. console.log(this.years[this.selYearIndex]);
  158. },
  159. /**
  160. * 选择月份
  161. * @param {Object} e
  162. */
  163. bindMonthPickerChange(e) {
  164. // console.log(e);
  165. this.selMonthindex = e.target.value
  166. console.log(this.months[this.selMonthindex]);
  167. },
  168. /**
  169. * 按月、年获取消费记录
  170. */
  171. async get_xiaofiezoushi() {
  172. // console.log(this.roomSelect);
  173. var reg = /[\u4e00-\u9fa5]/g;
  174. var str = '墨轩湖校区1-302';
  175. var dom = str.replace(reg, "");
  176. if (dom != '' && typeof(dom) != 'undefined') {
  177. let res = null;
  178. res = await this.$myRequest({
  179. host: this.ceshi,
  180. // url: '/HotWaters/elqueryDayPower.action',
  181. url: '/HotWaters/elMonthlist.action',
  182. method: 'POST',
  183. header: {
  184. 'content-type': 'application/x-www-form-urlencoded'
  185. },
  186. data: {
  187. 'dom': dom,
  188. 'page': 1,
  189. 'rows': 12
  190. }
  191. })
  192. // console.log(res.data.rows);
  193. // console.log(res.data);
  194. if (res.data.rows.length == 0) {
  195. return
  196. }
  197. if (typeof res.data.rows === 'undefined') {
  198. uni.showToast({
  199. title: '加载数据异常',
  200. duration: 1500
  201. })
  202. return
  203. }
  204. let chrt_data = {
  205. categories: [],
  206. series: [],
  207. }
  208. let elc_max = -1.0
  209. let dt = ''
  210. let temp = 0
  211. let data = []
  212. for (var i = 0; i < res.data.rows.length; i++) {
  213. dt = res.data.rows[i].dataTime
  214. chrt_data.categories.push(parseInt(dt.substr(dt.indexOf('-') + 1, dt.length)) + '月')
  215. temp = res.data.rows[i].totalMoney
  216. temp = temp.toFixed(2)
  217. data.push(temp)
  218. if (parseFloat(temp) > parseFloat(elc_max)) {
  219. elc_max = temp
  220. }
  221. }
  222. let items = {
  223. name: '金额',
  224. data: data
  225. }
  226. chrt_data.series.push(items)
  227. let m = parseFloat(Math.abs(elc_max))
  228. // console.log(chrt_data);
  229. if (elc_max == 0.0) {
  230. setTimeout(() => {
  231. this.chartOpts.yAxis.data[0].max = parseInt(10)
  232. this.chartData = chrt_data;
  233. }, 1000);
  234. } else {
  235. setTimeout(() => {
  236. this.chartOpts.yAxis.data[0].max = parseInt(m + 5)
  237. this.chartData = chrt_data;
  238. }, 1000);
  239. }
  240. } else {
  241. uni.showToast({
  242. title: '宿舍号为空',
  243. icon: 'success'
  244. });
  245. }
  246. },
  247. /**
  248. * 计算屏幕的高度
  249. */
  250. calc_screen_height() {
  251. uni.getSystemInfo({
  252. success: res => {
  253. let h = ((res.screenHeight * (750 / res.windowWidth)) - 820) //将px 转换rpx
  254. this.screenHeight = Math.floor(h) + 'rpx'
  255. }
  256. });
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss">
  262. .container {
  263. display: flex;
  264. flex-direction: column;
  265. font-size: 28rpx;
  266. font-family: "Microsoft YaHei-3970(82674968)";
  267. width: 730rpx;
  268. padding: 10rpx;
  269. .line {
  270. height: 20rpx;
  271. }
  272. .picker-box {
  273. display: flex;
  274. justify-content: space-between;
  275. width: 375rpx;
  276. .picker-input {
  277. display: flex;
  278. justify-content: space-around;
  279. align-items: center;
  280. border: 2rpx solid #CCCCCC;
  281. border-radius: 6rpx;
  282. .txt-picker {
  283. display: flex;
  284. justify-content: space-around;
  285. align-items: center;
  286. width: 175rpx;
  287. height: 60rpx;
  288. }
  289. }
  290. }
  291. .show-charts {
  292. display: flex;
  293. flex-direction: column;
  294. .show-label {
  295. display: flex;
  296. align-items: center;
  297. image {
  298. width: 30rpx;
  299. height: 30rpx;
  300. margin: 0 10rpx 0;
  301. }
  302. .show-txt-label {
  303. font-size: 32upx;
  304. }
  305. }
  306. }
  307. .xfjl {
  308. display: flex;
  309. flex-direction: column;
  310. .xfjl-title {
  311. display: flex;
  312. align-items: center;
  313. image {
  314. width: 30rpx;
  315. height: 30rpx;
  316. margin: 0 10rpx 0;
  317. }
  318. .show-txt-label {
  319. font-size: 32upx;
  320. }
  321. }
  322. .items {
  323. display: flex;
  324. flex-direction: column;
  325. .item {
  326. display: flex;
  327. justify-content: space-between;
  328. align-items: center;
  329. height: 120rpx;
  330. margin: 10rpx;
  331. padding: 15rpx 0;
  332. border-bottom: 1px solid #CCCCCC;
  333. .item-left {
  334. display: flex;
  335. align-items: center;
  336. image {
  337. width: 90rpx;
  338. height: 90rpx;
  339. margin: 0 20rpx 0 0;
  340. }
  341. .item-desc {
  342. display: flex;
  343. flex-direction: column;
  344. justify-content: space-between;
  345. .item-title {
  346. font-size: 32upx;
  347. font-weight: bold;
  348. }
  349. .item-time {
  350. font-size: 24upx;
  351. color: #c8cdd8;
  352. }
  353. }
  354. }
  355. .item-right {
  356. font-size: 36upx;
  357. font-weight: bold;
  358. color: #4456fb;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>