index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <view class="body">
  3. <!-- <view class="topLine" :style="{height: topBar+'px'}"></view> -->
  4. <view class="nav row_align_center" id="nav">
  5. <li class="li_4" style="color: #fff;z-index: 999;" :class="['iconfont icon-zuojiantou back']" @click="gotoBack()"></li>
  6. </view>
  7. <view class="top_head">
  8. <view class="text_des">
  9. <text class="month_num">{{ nowTime.month }}</text>
  10. <text class="month_text">月</text>
  11. <text class="month_year">{{ nowTime.year }}</text>
  12. <text class="point">.</text>
  13. <text class="title">财务报告</text>
  14. </view>
  15. <view class="top_desc">
  16. <view class="text-gray">结余</view>
  17. <view class="remaining">{{ myWallet.remaining }}</view>
  18. <view class="row head_block">
  19. <view class="flex_1">
  20. <text class="text-gray">支出</text>
  21. <text class="text_green">{{ myWallet.expend }}</text>
  22. </view>
  23. <view class="flex_1">
  24. <text class="text-gray">收入</text>
  25. <text class="income">{{ myWallet.income }}</text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="main">
  31. <view class="row_block">
  32. <view class="the_title" style="justify-content: space-between;">
  33. <view class="left_title">
  34. <view class="title_icon"></view>
  35. <text class="margin_stand-samll font-big wide">历史趋势</text>
  36. </view>
  37. <view class="right_btn">
  38. <view v-for="(item, index) in historyBtn" :key="index" :class="item.state ? 'active_btn' : ''"
  39. @click="changeHistoryBtn(item.type)">{{ item.name }}</view>
  40. </view>
  41. </view>
  42. <view class="charts-box" style="height: 200px;">
  43. <qiun-data-charts type="line" canvasId="finance_a" :canvas2d="isCanvas2d" :reshow="delayload"
  44. :opts="{ xAxis: { itemCount: 12, disableGrid: true }, yAxis: { disableGrid: true, data: [{ disabled: true }] } }"
  45. :chartData="historyData" />
  46. </view>
  47. </view>
  48. <view class="row_block">
  49. <view class="the_title">
  50. <view class="title_icon"></view>
  51. <text class="margin_stand-samll font-big wide">钱都去哪了</text>
  52. </view>
  53. <view v-if="delayload" class="charts-box">
  54. <qiun-data-charts type="ring" canvasId="finance_b" :canvas2d="isCanvas2d" :reshow="delayload"
  55. :opts="{ padding: [15, 0, 4, 0], legend: { position: 'bottom' }, title: { name: expendCount }, subtitle: { name: '支出', fontSize: '20' } }"
  56. :chartData="expendDetail" />
  57. </view>
  58. <view class="the_title">
  59. <text class="margin_stand-samll font-middle wide">支出单笔最贵</text>
  60. </view>
  61. <view class="extend_rank">
  62. <view class="rank_item" v-for="(item, index) in extendRank" :key="index">
  63. <image :src="getImage(index)" mode="widthFix"></image>
  64. <text class="name">{{ item.name }}</text>
  65. <text class="desc">{{ item.desc }}</text>
  66. <text class="text_green money">{{ item.money }}</text>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="row_block">
  71. <view class="the_title">
  72. <view class="title_icon"></view>
  73. <text class="margin_stand-samll font-big wide">{{ nowTime.month }}月明细</text>
  74. </view>
  75. <view class="detail_list">
  76. <view v-for="(item, index) in detail_list" :key="index" class="detail_item">
  77. <view>
  78. <view class="font-middle">{{ item.date }}</view>
  79. <view class="font-small">{{ item.time }}</view>
  80. </view>
  81. <view class="icon">
  82. <li class="li_2" :class="['iconfont', item.type == 'income' ? 'icon-income' : 'icon-expend']"></li>
  83. </view>
  84. <view class="right_content">
  85. <view class="money">{{ item.type == 'income' ? '+' : '-' }}{{ item.money }}</view>
  86. <view class="text-gray font-middle">{{ item.desc }}</view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="end_block">
  92. <view class="the_title" style="margin-bottom: 40rpx;">
  93. <view class="title_icon"></view>
  94. <text class="margin_stand-samll font-big wide">我的支出水平</text>
  95. </view>
  96. <view class="level_bar">
  97. <view v-for="(item, index) in extend_level_bar" :key="index" :style="{ width: item.width }"
  98. :class="item.state ? 'text_green font-middle' : ''">{{ item.name }}</view>
  99. </view>
  100. <view class="level_bar">
  101. <view v-for="(item, index) in extend_level_bar" :key="index" :style="{ width: item.width }"
  102. :class="item.state ? 'active_bar' : 'default_bar'"></view>
  103. </view>
  104. <view class="level_bar">
  105. <view v-for="(item, index) in extend_level_bar" :key="index" :style="{ width: item.width }"
  106. :class="item.state ? 'text_green font-middle' : ''">{{ item.range }}</view>
  107. </view>
  108. <view class="extend_message">
  109. <li style="color: #ccc;" :class="['iconfont icon-message']"></li>
  110. <view>
  111. “ 我的支出水平已超过
  112. <text>{{ extend_morethan }}</text>
  113. 的乡镇居民。 ”
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </template>
  120. <script>
  121. import ProgressBar from "../../components/progress-bar/progress-bar.vue"
  122. import dataOne from '../../static/json/finance/1.json';
  123. import expendDetail from '../../static/json/finance/2.json';
  124. import Config from '../../static/js/config'
  125. import Common from '../../static/js/common'
  126. let _now = new Date();
  127. let now_time = {};
  128. now_time.year = _now.getFullYear()
  129. now_time.month = _now.getMonth() + 1
  130. now_time.day = _now.getDay()
  131. export default {
  132. components: {
  133. ProgressBar
  134. },
  135. data() {
  136. return {
  137. info: '大便超人', //用户数据
  138. scrollHeight: "600px", //数据展示体高度
  139. isCanvas2d: Config.ISCANVAS2D,
  140. historyData: {},
  141. dataOne,
  142. expendDetail,
  143. expendCount: 0,
  144. delayload: false,
  145. nowTime: {
  146. year: now_time.year,
  147. month: now_time.month,
  148. day: now_time.day
  149. },
  150. historyBtn: [{
  151. name: "支出",
  152. state: 1,
  153. type: "expend"
  154. },
  155. {
  156. name: "收入",
  157. state: 0,
  158. type: "income"
  159. },
  160. {
  161. name: "结余",
  162. state: 0,
  163. type: "remaining"
  164. },
  165. ],
  166. myWallet: {
  167. remaining: 3000.34,
  168. expend: 5240.32,
  169. income: 8240.66
  170. },
  171. extendRank: [{
  172. name: "腐败聚会",
  173. desc: now_time.month + "月6日12:34-跨界空间轰趴",
  174. money: "422.12"
  175. },
  176. {
  177. name: "沐浴按摩",
  178. desc: now_time.month + "月12日21:34-乔杉沐浴城",
  179. money: "318.00"
  180. },
  181. {
  182. name: "食品酒水",
  183. desc: now_time.month + "月1日21:34-school酒馆",
  184. money: "289.50"
  185. },
  186. ],
  187. extend_level_bar: [
  188. { name: "低消费", range: "<2000元", width: "20%" },
  189. { name: "中间消费", range: "2000-5000元", width: "35%" },
  190. { name: "较高消费", range: "5000-8000元", width: "25%", state: 1 },
  191. { name: "高消费", range: ">8000元", width: "20%" },
  192. ],
  193. extend_morethan: "68%",
  194. detail_list: [
  195. { date: now_time.month + "-01", time: "11:01", "type": "extend", money: "10.00", desc: "银行卡转出" },
  196. { date: now_time.month + "-01", time: "13:45", "type": "income", money: "18.00", desc: "银行卡收入" },
  197. { date: now_time.month + "-02", time: "06:21", "type": "extend", money: "123.45", desc: "信用卡转出" },
  198. { date: now_time.month + "-03", time: "07:38", "type": "income", money: "23.00", desc: "银行卡收入" },
  199. { date: now_time.month + "-08", time: "16:28", "type": "extend", money: "23.56", desc: "信用卡转出" },
  200. { date: now_time.month + "-09", time: "15:25", "type": "income", money: "850.12", desc: "银行卡收入" },
  201. { date: now_time.month + "-09", time: "18:52", "type": "income", money: "1.88", desc: "银行卡收入" },
  202. { date: now_time.month + "-11", time: "21:12", "type": "extend", money: "220.21", desc: "银行卡转出" },
  203. { date: now_time.month + "-12", time: "13:08", "type": "income", money: "32.28", desc: "银行卡收入" },
  204. { date: now_time.month + "-12", time: "12:41", "type": "extend", money: "122.12", desc: "信用卡转出" },
  205. { date: now_time.month + "-13", time: "17:21", "type": "income", money: "10.00", desc: "银行卡收入" },
  206. ]
  207. };
  208. },
  209. watch: {
  210. "historyBtn": {
  211. deep: true,
  212. handler: function (newVal, oldVal) {
  213. this.filterHistoryData();
  214. }
  215. }
  216. },
  217. methods: {
  218. async getData() {
  219. uni.showLoading();
  220. this.filterHistoryData();
  221. for (let i = 0; i < this.expendDetail.series.length; i++) {
  222. this.expendDetail.series[i].format = "pieDemo"
  223. }
  224. let length = this.expendDetail.series[0].data.length
  225. for (let i = 0; i < length; i++) {
  226. this.expendCount += this.expendDetail.series[0].data[i].value
  227. }
  228. await setTimeout(() => {
  229. this.delayload = true;
  230. uni.hideLoading();
  231. }, 1000)
  232. },
  233. changeHistoryBtn(type) {
  234. for (let i = 0; i < this.historyBtn.length; i++) {
  235. if (this.historyBtn[i].type == type) {
  236. this.historyBtn[i].state = 1
  237. } else {
  238. this.historyBtn[i].state = 0
  239. }
  240. }
  241. },
  242. filterHistoryData() {
  243. let type = this.historyBtn.filter(x => x.state == 1)[0].type;
  244. switch (type) {
  245. case "expend":
  246. this.historyData = this.dataOne.expend;
  247. break;
  248. case "income":
  249. this.historyData = this.dataOne.income;
  250. break;
  251. case "remaining":
  252. this.historyData = this.dataOne.remaining;
  253. break;
  254. }
  255. },
  256. gotoBack() {
  257. Common.navigateBack("/index/index");
  258. },
  259. getImage(index) {
  260. switch (index) {
  261. case 0:
  262. return "https://s1.ax1x.com/2023/03/31/ppRYrfP.png";
  263. break;
  264. case 1:
  265. return "https://s1.ax1x.com/2023/03/31/ppRYySf.png";
  266. break;
  267. case 2:
  268. return "https://s1.ax1x.com/2023/03/31/ppRY6l8.png";
  269. break;
  270. }
  271. }
  272. },
  273. onReady() {
  274. //#ifndef H5
  275. uni.showShareMenu();
  276. //#endif
  277. this.getData()
  278. }
  279. }
  280. </script>
  281. <style scoped lang="scss">
  282. .body {
  283. height: 100%;
  284. background-color: #560594;
  285. margin: 0;
  286. padding-bottom: 20rpx;
  287. .li_4 {
  288. list-style-type: none;
  289. }
  290. .nav {
  291. position: fixed;
  292. top: 50rpx;
  293. left: 20rpx;
  294. }
  295. .text_green {
  296. color: #4ECDB6;
  297. }
  298. .main {
  299. width: 100%;
  300. padding: 0 10rpx;
  301. box-sizing: border-box;
  302. margin-top: 20rpx;
  303. .detail_list {
  304. height: 700rpx;
  305. overflow: auto;
  306. color: #9E9E9E;
  307. .detail_item {
  308. display: flex;
  309. margin: 20rpx 0;
  310. align-items: center;
  311. .icon {
  312. width: 30%;
  313. text-align: center;
  314. .li_2 {
  315. font-size: 80rpx;
  316. }
  317. }
  318. .right_content {
  319. width: 50%;
  320. text-align: center;
  321. }
  322. .icon-income {
  323. color: #4AABF9;
  324. }
  325. .icon-expend {
  326. color: #E45521;
  327. }
  328. .money {
  329. color: #000;
  330. }
  331. }
  332. }
  333. .extend_message {
  334. margin-top: 20rpx;
  335. color: #ccc;
  336. display: flex;
  337. text {
  338. color: #ff9900;
  339. }
  340. }
  341. .level_bar {
  342. width: 100%;
  343. height: 40rpx;
  344. border-radius: 40rpx;
  345. overflow: hidden;
  346. display: flex;
  347. color: #ccc;
  348. font-size: 20rpx;
  349. text-align: right;
  350. line-height: 40rpx;
  351. view {
  352. border-right: 2rpx solid #fff;
  353. position: relative;
  354. }
  355. .name {
  356. position: absolute;
  357. top: -30rpx;
  358. right: -40rpx;
  359. }
  360. .range {
  361. position: absolute;
  362. bottom: 30rpx;
  363. right: -40rpx;
  364. }
  365. .default_bar {
  366. background-color: #A0DFCD;
  367. }
  368. .active_bar {
  369. background-color: #02AE7A;
  370. }
  371. }
  372. .right_btn {
  373. float: right;
  374. display: flex;
  375. color: #ccc;
  376. font-size: 22rpx;
  377. view {
  378. line-height: 50rpx;
  379. height: 50rpx;
  380. margin: 0 20rpx;
  381. }
  382. .active_btn {
  383. padding: 0rpx 20rpx;
  384. border: 1px solid #ccc;
  385. border-radius: 40rpx;
  386. }
  387. }
  388. .end_block {
  389. width: 100%;
  390. box-sizing: border-box;
  391. background-color: #fff;
  392. border-radius: 12rpx;
  393. position: relative;
  394. padding: 20rpx;
  395. }
  396. .row_block {
  397. width: 100%;
  398. box-sizing: border-box;
  399. background-color: #fff;
  400. border-radius: 12rpx;
  401. position: relative;
  402. padding: 20rpx;
  403. &::after {
  404. content: "";
  405. height: 0px;
  406. width: 92%;
  407. position: absolute;
  408. transform: translateX(-50%);
  409. left: 50%;
  410. bottom: 0;
  411. border-top: 1px dashed #ccc;
  412. }
  413. }
  414. .the_title {
  415. display: flex;
  416. align-items: center;
  417. .left_title {
  418. display: flex;
  419. align-items: center;
  420. }
  421. .title_icon {
  422. background-color: #7E7E7E;
  423. height: 40rpx;
  424. width: 10rpx;
  425. border-radius: 10rpx;
  426. margin-right: 20rpx;
  427. font-size: 16px;
  428. font-weight: 600;
  429. }
  430. }
  431. .extend_rank {
  432. width: 100%;
  433. background-color: #F5F5F5;
  434. box-sizing: border-box;
  435. padding: 10rpx;
  436. .rank_item {
  437. width: 100%;
  438. margin: 20rpx 0;
  439. box-sizing: border-box;
  440. display: flex;
  441. font-size: 26rpx;
  442. justify-content: space-between;
  443. align-items: center;
  444. image {
  445. width: 10%;
  446. }
  447. text {
  448. text-overflow: ellipsis;
  449. overflow: hidden;
  450. white-space: nowrap;
  451. display: block;
  452. }
  453. .name {
  454. margin: 0 10rpx;
  455. color: #7D7D7D;
  456. width: 20%;
  457. }
  458. .desc {
  459. width: 50%;
  460. color: #ccc;
  461. }
  462. .money {
  463. width: 20%;
  464. text-align: right;
  465. }
  466. }
  467. }
  468. }
  469. .top_head {
  470. height: 435rpx;
  471. width: 100%;
  472. padding: 110rpx 10rpx 0rpx 10rpx;
  473. background: url("https://img1.qunarzz.com/travel/d3/1704/db/34de73c353d44db5.jpg_r_640x426x70_53f464ca.jpg") no-repeat center 0px;
  474. background-size: 100% 100%;
  475. box-sizing: border-box;
  476. .top_desc {
  477. width: 100%;
  478. border-radius: 20rpx;
  479. background-color: #fff;
  480. margin-top: 20rpx;
  481. padding: 20rpx;
  482. box-sizing: border-box;
  483. .text-gray {
  484. font-size: 28rpx;
  485. color: #ccc;
  486. margin-right: 10rpx;
  487. }
  488. .remaining {
  489. font-size: 46rpx;
  490. }
  491. .flex_1 {
  492. flex: 1;
  493. }
  494. .head_block {
  495. margin-top: 20rpx;
  496. .income {
  497. color: #E34B5E;
  498. }
  499. }
  500. }
  501. .text_des {
  502. height: 100rpx;
  503. color: #fff;
  504. font-weight: 900;
  505. position: relative;
  506. margin-left: 60rpx;
  507. text {
  508. display: inline-block;
  509. height: 100%;
  510. }
  511. .month_num {
  512. font-size: 90rpx;
  513. }
  514. .month_text {
  515. font-size: 56rpx;
  516. }
  517. .month_year {
  518. font-size: 22rpx;
  519. position: absolute;
  520. left: 60rpx;
  521. top: 20rpx;
  522. }
  523. .point {
  524. font-size: 40rpx;
  525. }
  526. .title {
  527. font-size: 40rpx;
  528. }
  529. }
  530. }
  531. }
  532. </style>