stdBookMgr.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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" :ontouch="true" :canvas2d="false"
  26. 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", "0.00", "0.00", "0.00", "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: '../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() {
  145. if (this.id_card == '') {
  146. uni.showToast({
  147. icon: 'none',
  148. title: '身份证号为空,请进行授权',
  149. duration: 3000
  150. });
  151. return
  152. }
  153. let res = await this.$myRequest({
  154. host: this.ceshi,
  155. url: '/airManage/consumequeryOwnPage.action',
  156. method: 'POST',
  157. header: {
  158. 'content-type': 'application/x-www-form-urlencoded'
  159. },
  160. data: {
  161. page: 1,
  162. rows: 90,
  163. sfzh: this.id_card,
  164. con_month: this.selYearMonth
  165. }
  166. })
  167. // console.log(res.data);
  168. let data = res.data
  169. if (typeof data.rows !== 'undefined' && data.rows === '') {
  170. uni.showToast({
  171. title: '暂无消费数据',
  172. duration: 1500
  173. })
  174. // 清空列表
  175. this.consumeRecords = []
  176. return
  177. }
  178. if (data.code === 200) {
  179. if (typeof data.rows === 'undefined' || data.rows === '') {
  180. uni.showToast({
  181. title: '暂无消费数据',
  182. duration: 1500
  183. })
  184. // 清空列表
  185. this.consumeRecords = []
  186. return
  187. }
  188. let tmpRecord = []
  189. for (var i = 0; i < data.rows.length; i++) {
  190. tmpRecord.push({
  191. loudong: data.rows[i].build + '-' + data.rows[i].floors + '-' + data.rows[i].dom
  192. .split('-')[1],
  193. startTime: data.rows[i].time,
  194. endTime: data.rows[i].end_time,
  195. amount: data.rows[i].account
  196. })
  197. }
  198. this.consumeRecords = tmpRecord
  199. } else if (typeof data.code === 'undefined') {
  200. uni.showToast({
  201. title: data.message,
  202. duration: 1500
  203. })
  204. } else {
  205. uni.showToast({
  206. title: '暂无数据',
  207. duration: 1500
  208. })
  209. }
  210. },
  211. /**
  212. * 按获取消费走势图数据
  213. */
  214. async getRechargeRecord() {
  215. let res = await this.$myRequest({
  216. host: this.ceshi,
  217. url: '/airManage/consumequeryOwnConTong.action',
  218. method: 'POST',
  219. header: {
  220. 'content-type': 'application/x-www-form-urlencoded'
  221. },
  222. data: {
  223. // sfzh: '360313110'
  224. sfzh: this.id_card
  225. }
  226. })
  227. // console.log(res.data);
  228. let _this = this
  229. if (typeof res.data === 'undefined') {
  230. uni.showToast({
  231. title: '暂无走势图数据',
  232. duration: 1500
  233. });
  234. setTimeout(() => {
  235. _this.chartData = _this.chartDataInit
  236. }, 1000);
  237. return
  238. }
  239. let tmpdata = res.data
  240. if (tmpdata.code === 200) {
  241. if (typeof tmpdata.data === 'undefined' || tmpdata.data.length === 0) {
  242. uni.showToast({
  243. title: '暂无走势图数据',
  244. duration: 1500
  245. });
  246. setTimeout(() => {
  247. _this.chartData = _this.chartDataInit
  248. }, 1000);
  249. return
  250. }
  251. let chrt_data = {
  252. categories: [],
  253. series: []
  254. }
  255. let elc_max = -1.0
  256. let dt = ''
  257. let temp = 0
  258. let data = []
  259. for (var i = 0; i < tmpdata.data.length; i++) {
  260. dt = tmpdata.data[i].month
  261. chrt_data.categories.push(parseInt(dt.substr(dt.indexOf('-') + 1, dt.length)) + '月')
  262. temp = tmpdata.data[i].num
  263. temp = temp.toFixed(2)
  264. data.push(temp)
  265. if (parseFloat(temp) > parseFloat(elc_max)) {
  266. elc_max = temp
  267. }
  268. }
  269. let items = {
  270. name: '金额',
  271. data: data
  272. }
  273. chrt_data.series.push(items)
  274. let m = parseFloat(Math.abs(elc_max))
  275. // console.log(chrt_data);
  276. if (elc_max == 0.0) {
  277. setTimeout(() => {
  278. this.chartOpts.yAxis.data[0].max = parseInt(10)
  279. this.chartData = chrt_data;
  280. }, 1000);
  281. } else {
  282. setTimeout(() => {
  283. this.chartOpts.yAxis.data[0].max = parseInt(m + 5)
  284. this.chartData = chrt_data;
  285. }, 1000);
  286. }
  287. } else {
  288. uni.showToast({
  289. title: '数据异常',
  290. duration: 1500
  291. })
  292. }
  293. },
  294. /**
  295. * 转换年月格式
  296. */
  297. get_year_month() {
  298. this.selYearMonth = this.years[this.selYearIndex].substring(0, 4) + '-' +
  299. this.months[this.selMonthindex].substring(0, 2)
  300. // 查询当月消费
  301. this.getRecord()
  302. },
  303. /**
  304. * 选择年份
  305. * @param {Object} e
  306. */
  307. bindYearPickerChange(e) {
  308. // console.log(e);
  309. this.selYearIndex = e.target.value
  310. this.get_year_month()
  311. },
  312. /**
  313. * 选择月份
  314. * @param {Object} e
  315. */
  316. bindMonthPickerChange(e) {
  317. // console.log(e);
  318. this.selMonthindex = e.target.value
  319. this.get_year_month()
  320. },
  321. /**
  322. * 滚动到顶部提示
  323. */
  324. scroll_to_upper() {
  325. uni.showToast({
  326. title: '到顶了!',
  327. icon: 'none',
  328. duration: 500
  329. })
  330. },
  331. /**
  332. * 滚动到底部提示
  333. */
  334. scroll_to_lower() {
  335. uni.showToast({
  336. title: '到底了!',
  337. icon: 'none',
  338. duration: 500
  339. })
  340. },
  341. /**
  342. * 计算屏幕的高度
  343. */
  344. calc_screen_height() {
  345. uni.getSystemInfo({
  346. success: res => {
  347. let h = ((res.screenHeight * (750 / res.windowWidth)) - 820) //将px 转换rpx
  348. this.screenHeight = Math.floor(h) + 'rpx'
  349. }
  350. });
  351. }
  352. }
  353. }
  354. </script>
  355. <style lang="scss" scoped>
  356. .container {
  357. display: flex;
  358. flex-direction: column;
  359. font-size: 28rpx;
  360. font-family: "Microsoft YaHei-3970(82674968)";
  361. width: 730rpx;
  362. padding: 10rpx;
  363. .line {
  364. height: 20rpx;
  365. }
  366. .picker-box {
  367. display: flex;
  368. justify-content: space-between;
  369. width: 375rpx;
  370. .picker-input {
  371. display: flex;
  372. justify-content: space-around;
  373. align-items: center;
  374. border: 2rpx solid #CCCCCC;
  375. border-radius: 6rpx;
  376. .txt-picker {
  377. display: flex;
  378. justify-content: space-around;
  379. align-items: center;
  380. width: 175rpx;
  381. height: 60rpx;
  382. }
  383. }
  384. }
  385. .show-charts {
  386. display: flex;
  387. flex-direction: column;
  388. .show-label {
  389. display: flex;
  390. align-items: center;
  391. image {
  392. width: 30rpx;
  393. height: 30rpx;
  394. margin: 0 10rpx 0;
  395. }
  396. .show-txt-label {
  397. font-size: 32upx;
  398. }
  399. }
  400. }
  401. .xfjl {
  402. display: flex;
  403. flex-direction: column;
  404. .xfjl-title {
  405. display: flex;
  406. align-items: center;
  407. image {
  408. width: 30rpx;
  409. height: 30rpx;
  410. margin: 0 10rpx 0;
  411. }
  412. .show-txt-label {
  413. font-size: 32upx;
  414. }
  415. }
  416. .items {
  417. display: flex;
  418. flex-direction: column;
  419. .item {
  420. display: flex;
  421. justify-content: space-between;
  422. align-items: center;
  423. height: 120rpx;
  424. margin: 10rpx;
  425. padding: 15rpx 0;
  426. border-bottom: 1px solid #CCCCCC;
  427. .item-left {
  428. display: flex;
  429. align-items: center;
  430. image {
  431. width: 90rpx;
  432. height: 90rpx;
  433. margin: 0 20rpx 0 0;
  434. }
  435. .item-desc {
  436. display: flex;
  437. flex-direction: column;
  438. justify-content: space-between;
  439. .item-title {
  440. font-size: 32upx;
  441. font-weight: bold;
  442. }
  443. .item-time {
  444. font-size: 24upx;
  445. color: #c8cdd8;
  446. }
  447. }
  448. }
  449. .item-right {
  450. font-size: 36upx;
  451. font-weight: bold;
  452. color: #4456fb;
  453. }
  454. }
  455. }
  456. }
  457. }
  458. </style>