stdBookMgr.vue 11 KB

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