stdBookMgr.vue 11 KB

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