stdBookMgr.vue 11 KB

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