stdBookMgr.vue 10 KB

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