stdBookMgr.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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 canvasId="canvasAirId" type="line" :chartData="chartData" :opts="chartOpts"
  26. :ontouch="true" :canvas2d="false" id="chartsAir" />
  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. ceshi: 'air',
  59. id_card: '', // 身份证号
  60. screenHeight: 0,
  61. years: this.$getDate('get_year'), // 候选年份
  62. months: ['全部', '01月', '02月', '03月', '04月', '05月', '06月', '07月', '08月', '09月', '10月', '11月', '12月'], // 候选月份
  63. selYearIndex: 0, // 选择的年份index
  64. selMonthindex: this.$getDate('get_month'), // 选择的月份index
  65. selYearMonth: '', // 选择的年份、月份
  66. chartData: {
  67. categories: [],
  68. series: []
  69. },
  70. chartDataInit: { // 如果 chartData 没有数据,解决一直打转的问题
  71. "categories": ["无数据"],
  72. "series": [{
  73. "name": "金额",
  74. "data": ["0.00"]
  75. }]
  76. },
  77. chartOpts: {
  78. color: ["#1890FF", "#91CB74", "#FAC858"],
  79. padding: [15, 10, 0, 15],
  80. legend: {},
  81. xAxis: {
  82. disableGrid: true
  83. },
  84. yAxis: {
  85. data: [{
  86. max: 0
  87. }]
  88. },
  89. extra: {
  90. line: {
  91. type: "curve",
  92. width: 2
  93. }
  94. }
  95. },
  96. consumeRecords: []
  97. }
  98. },
  99. onLoad() {
  100. // 获取基本信息
  101. this.get_base_info()
  102. // 获取年月格式
  103. this.get_year_month()
  104. },
  105. onShow() {
  106. // 从新计算高度
  107. setTimeout(() => {
  108. this.calc_screen_height()
  109. }, 1000)
  110. },
  111. mounted() {
  112. // 走势图数据
  113. this.getRechargeRecord()
  114. },
  115. methods: {
  116. /**
  117. * 获取身份证号
  118. */
  119. get_base_info() {
  120. try {
  121. if (this.id_card == '' || typeof(this.id_card) == 'undefined') {
  122. const userinfo = uni.getStorageSync('userinfo_storage_key')
  123. if (userinfo) {
  124. this.id_card = userinfo.id_card
  125. } else {
  126. uni.navigateTo({
  127. url: '../../pages/index/index?from=' + options.from
  128. })
  129. uni.showToast({
  130. icon: 'none',
  131. title: '身份证号为空,请进行授权',
  132. duration: 3000
  133. });
  134. return
  135. }
  136. }
  137. } catch (e) {
  138. console.log('获取基本信息:' + e.message);
  139. }
  140. },
  141. /**
  142. * 查询当月消费
  143. */
  144. async getRecord(param) {
  145. if (this.id_card == '') {
  146. uni.showToast({
  147. icon: 'none',
  148. title: '身份证号为空,请进行授权',
  149. duration: 3000
  150. });
  151. return
  152. }
  153. let pYear = this.years[this.selYearIndex].substring(0, 4);
  154. let pData = '';
  155. if (param === '全部') {
  156. pData = {
  157. page: 1,
  158. rows: 90,
  159. sfzh: this.id_card,
  160. con_year: pYear
  161. };
  162. } else {
  163. pData = {
  164. page: 1,
  165. rows: 90,
  166. sfzh: this.id_card,
  167. con_year: pYear,
  168. con_month: this.selYearMonth
  169. };
  170. }
  171. let res = await this.$myRequest({
  172. host: this.ceshi,
  173. url: '/airManage/consumequeryOwnPage.action',
  174. method: 'POST',
  175. header: {
  176. 'content-type': 'application/x-www-form-urlencoded'
  177. },
  178. data: pData
  179. })
  180. // console.log(res.data);
  181. let data = res.data
  182. if (typeof data.rows !== 'undefined' && data.rows === '') {
  183. uni.showToast({
  184. title: '暂无消费数据',
  185. duration: 1500
  186. })
  187. // 清空列表
  188. this.consumeRecords = []
  189. return
  190. }
  191. if (data.code === 200) {
  192. if (typeof data.rows === 'undefined' || data.rows === '') {
  193. uni.showToast({
  194. title: '暂无消费数据',
  195. duration: 1500
  196. })
  197. // 清空列表
  198. this.consumeRecords = []
  199. return
  200. }
  201. let tmpRecord = []
  202. for (var i = 0; i < data.rows.length; i++) {
  203. tmpRecord.push({
  204. loudong: data.rows[i].build + '-' + data.rows[i].floors + '-' + data.rows[i].dom
  205. .split('-')[1],
  206. startTime: data.rows[i].time,
  207. endTime: data.rows[i].end_time,
  208. amount: data.rows[i].account
  209. })
  210. }
  211. this.consumeRecords = tmpRecord
  212. } else if (typeof data.code === 'undefined') {
  213. uni.showToast({
  214. title: data.message,
  215. duration: 1500
  216. })
  217. } else {
  218. uni.showToast({
  219. title: '暂无数据',
  220. duration: 1500
  221. })
  222. }
  223. },
  224. /**
  225. * 获取消费走势图数据
  226. */
  227. async getRechargeRecord() {
  228. let pYear = this.years[this.selYearIndex].substring(0, 4);
  229. let pMonth = '';
  230. if (this.selMonthindex == 0) {
  231. pMonth = this.months[this.selMonthindex].substring(0, 2);
  232. } else {
  233. pMonth = pYear + '-' + this.months[this.selMonthindex].substring(0, 2);
  234. }
  235. let res = await this.$myRequest({
  236. host: this.ceshi,
  237. url: '/airManage/consumequeryOwnConTong.action',
  238. method: 'POST',
  239. header: {
  240. 'content-type': 'application/x-www-form-urlencoded'
  241. },
  242. data: {
  243. // sfzh: '421182199112100031'
  244. sfzh: this.id_card,
  245. con_year: pYear,
  246. con_month: pMonth
  247. }
  248. })
  249. // console.log(res.data);
  250. let _this = this
  251. if (typeof res.data === 'undefined') {
  252. uni.showToast({
  253. title: '暂无走势图数据',
  254. duration: 1500
  255. });
  256. setTimeout(() => {
  257. _this.chartData = _this.chartDataInit
  258. }, 1000);
  259. return
  260. }
  261. let tmpdata = res.data
  262. if (tmpdata.code === 200) {
  263. if (typeof tmpdata.data === 'undefined' || tmpdata.data.length === 0) {
  264. uni.showToast({
  265. title: '暂无走势图数据',
  266. duration: 1500
  267. });
  268. setTimeout(() => {
  269. _this.chartData = _this.chartDataInit
  270. }, 1000);
  271. return;
  272. }
  273. let chrt_data = {
  274. categories: [],
  275. series: []
  276. };
  277. let elc_max = -1.0;
  278. let dt = '';
  279. let temp = 0;
  280. let data = [];
  281. if (this.selMonthindex == 0) {
  282. let echartData = tmpdata.data.sort((a, b) => a.month.localeCompare(b.month));
  283. for (var i = 0; i < echartData.length; i++) {
  284. dt = echartData[i].month;
  285. chrt_data.categories.push(parseInt(dt.substr(dt.lastIndexOf('-') + 1, dt.length)) + '月');
  286. temp = echartData[i].num;
  287. temp = temp.toFixed(2);
  288. data.push(temp);
  289. if (parseFloat(temp) > parseFloat(elc_max)) {
  290. elc_max = temp;
  291. }
  292. }
  293. } else {
  294. let echartData = tmpdata.data.sort((a, b) => a.day.localeCompare(b.day));
  295. for (var i = 0; i < echartData.length; i++) {
  296. dt = echartData[i].day;
  297. chrt_data.categories.push(parseInt(dt.substr(dt.lastIndexOf('-') + 1, dt.length)) + '日');
  298. temp = echartData[i].num;
  299. temp = temp.toFixed(2);
  300. data.push(temp);
  301. if (parseFloat(temp) > parseFloat(elc_max)) {
  302. elc_max = temp;
  303. }
  304. }
  305. }
  306. let items = {
  307. name: '金额',
  308. data: data
  309. };
  310. chrt_data.series.push(items);
  311. let m = parseFloat(Math.abs(elc_max));
  312. // console.log(chrt_data);
  313. if (elc_max == 0.0) {
  314. setTimeout(() => {
  315. this.chartOpts.yAxis.data[0].max = parseInt(10);
  316. this.chartData = chrt_data;
  317. }, 1000);
  318. } else {
  319. setTimeout(() => {
  320. this.chartOpts.yAxis.data[0].max = parseInt(m + 5);
  321. this.chartData = chrt_data;
  322. }, 1000);
  323. }
  324. } else if (tmpdata.code === 205) {
  325. setTimeout(() => {
  326. _this.chartData = _this.chartDataInit
  327. }, 1000);
  328. uni.showToast({
  329. title: tmpdata.message,
  330. duration: 1500
  331. })
  332. } else {
  333. uni.showToast({
  334. title: '数据异常',
  335. duration: 1500
  336. })
  337. }
  338. },
  339. /**
  340. * 转换年月格式
  341. */
  342. get_year_month() {
  343. // 走势图数据
  344. this.getRechargeRecord();
  345. this.selYearMonth = this.years[this.selYearIndex].substring(0, 4) + '-' +
  346. this.months[this.selMonthindex].substring(0, 2);
  347. if (this.selMonthindex == 0) {
  348. // 全部,显示1-12月的数据
  349. this.getRecord('全部');
  350. } else {
  351. // 查询当月消费
  352. this.getRecord('按月');
  353. }
  354. },
  355. /**
  356. * 选择年份
  357. * @param {Object} e
  358. */
  359. bindYearPickerChange(e) {
  360. // console.log(e);
  361. this.selYearIndex = e.target.value
  362. this.get_year_month()
  363. },
  364. /**
  365. * 选择月份
  366. * @param {Object} e
  367. */
  368. bindMonthPickerChange(e) {
  369. // console.log(e);
  370. this.selMonthindex = e.target.value
  371. this.get_year_month()
  372. },
  373. /**
  374. * 滚动到顶部提示
  375. */
  376. scroll_to_upper() {
  377. uni.showToast({
  378. title: '到顶了!',
  379. icon: 'none',
  380. duration: 500
  381. })
  382. },
  383. /**
  384. * 滚动到底部提示
  385. */
  386. scroll_to_lower() {
  387. uni.showToast({
  388. title: '到底了!',
  389. icon: 'none',
  390. duration: 500
  391. })
  392. },
  393. /**
  394. * 计算屏幕的高度
  395. */
  396. calc_screen_height() {
  397. uni.getSystemInfo({
  398. success: res => {
  399. let h = ((res.screenHeight * (750 / res.windowWidth)) - 820) //将px 转换rpx
  400. this.screenHeight = Math.floor(h) + 'rpx'
  401. }
  402. });
  403. }
  404. }
  405. }
  406. </script>
  407. <style lang="scss" scoped>
  408. .container {
  409. display: flex;
  410. flex-direction: column;
  411. font-size: 28rpx;
  412. font-family: "Microsoft YaHei-3970(82674968)";
  413. width: 730rpx;
  414. padding: 10rpx;
  415. .line {
  416. height: 20rpx;
  417. }
  418. .picker-box {
  419. display: flex;
  420. justify-content: space-between;
  421. width: 375rpx;
  422. .picker-input {
  423. display: flex;
  424. justify-content: space-around;
  425. align-items: center;
  426. border: 2rpx solid #CCCCCC;
  427. border-radius: 6rpx;
  428. .txt-picker {
  429. display: flex;
  430. justify-content: space-around;
  431. align-items: center;
  432. width: 175rpx;
  433. height: 60rpx;
  434. }
  435. }
  436. }
  437. .show-charts {
  438. display: flex;
  439. flex-direction: column;
  440. .show-label {
  441. display: flex;
  442. align-items: center;
  443. image {
  444. width: 30rpx;
  445. height: 30rpx;
  446. margin: 0 10rpx 0;
  447. }
  448. .show-txt-label {
  449. font-size: 32upx;
  450. }
  451. }
  452. }
  453. .xfjl {
  454. display: flex;
  455. flex-direction: column;
  456. .xfjl-title {
  457. display: flex;
  458. align-items: center;
  459. image {
  460. width: 30rpx;
  461. height: 30rpx;
  462. margin: 0 10rpx 0;
  463. }
  464. .show-txt-label {
  465. font-size: 32upx;
  466. }
  467. }
  468. .items {
  469. display: flex;
  470. flex-direction: column;
  471. .item {
  472. display: flex;
  473. justify-content: space-between;
  474. align-items: center;
  475. height: 120rpx;
  476. margin: 10rpx;
  477. padding: 15rpx 0;
  478. border-bottom: 1px solid #CCCCCC;
  479. .item-left {
  480. display: flex;
  481. align-items: center;
  482. image {
  483. width: 90rpx;
  484. height: 90rpx;
  485. margin: 0 20rpx 0 0;
  486. }
  487. .item-desc {
  488. display: flex;
  489. flex-direction: column;
  490. justify-content: space-between;
  491. .item-title {
  492. font-size: 32upx;
  493. font-weight: bold;
  494. }
  495. .item-time {
  496. font-size: 24upx;
  497. color: #c8cdd8;
  498. }
  499. }
  500. }
  501. .item-right {
  502. font-size: 36upx;
  503. font-weight: bold;
  504. color: #4456fb;
  505. }
  506. }
  507. }
  508. }
  509. }
  510. </style>