stdBookMgr.vue 9.9 KB

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