index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view>
  3. <u-navbar :is-back="false" :border-bottom="false" :background="background">
  4. <view class="navbar-tit">{{title}}</view>
  5. </u-navbar>
  6. <view class="statisticsData" v-if="!iswuye">
  7. <view class="statisticsData-item">
  8. <view class="statisticsData-head" @click="gotoUrl('pagesFinance/detailed/index')">
  9. <p>今日充电收益(元)</p>
  10. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="24"></u-icon>
  11. </view>
  12. <view class="statisticsData-main">
  13. <h2>{{indexData.todayAmount}}</h2>
  14. </view>
  15. <view class="statisticsData-foot">
  16. <p>昨日收益</p>
  17. <h4>{{indexData.yesterdayAmount}}</h4>
  18. </view>
  19. </view>
  20. <view class="statisticsData-item">
  21. <view class="statisticsData-head">
  22. <p>今日充电单量(笔)</p>
  23. </view>
  24. <view class="statisticsData-main">
  25. <h2>{{indexData.todayNum}}</h2>
  26. </view>
  27. <view class="statisticsData-foot">
  28. <p>累计收益</p>
  29. <h4>{{indexData.withdrawnAmount}}</h4>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="statisticsData" v-if="iswuye">
  34. <view class="statisticsData-item">
  35. <view class="statisticsData-head" @click="gotoUrl('pagesFinance/detailed/index')" >
  36. <p>今日充电电费(元)</p>
  37. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="24"></u-icon>
  38. </view>
  39. <view class="statisticsData-main">
  40. <h2>{{indexData.todayCost}}</h2>
  41. </view>
  42. <view class="statisticsData-foot">
  43. <p>昨日电费</p>
  44. <h4>{{indexData.yesterdayCost}}</h4>
  45. </view>
  46. </view>
  47. <view class="statisticsData-item">
  48. <view class="statisticsData-head">
  49. <p>今日充电度数(kW/h)</p>
  50. </view>
  51. <view class="statisticsData-main">
  52. <h2>{{indexData.todayElectricity/10000}}</h2>
  53. </view>
  54. <view class="statisticsData-foot">
  55. <p>累计收益</p>
  56. <h4>{{indexData.withdrawnAmount}}</h4>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="statisticsChart">
  61. <view class="statisticsChart-head">
  62. <h4 v-if="!iswuye">充电桩收益占比</h4>
  63. <h4 v-if="iswuye">充电桩电费占比</h4>
  64. <view class="statisticsChart-time">
  65. <u-calendar v-model="showdate" mode="range" @change="changedate"></u-calendar>
  66. <p @click="showdate = true">{{startTime}} 至 {{endTime}}</p>
  67. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="36"></u-icon>
  68. </view>
  69. </view>
  70. <view class="statisticsChart-main">
  71. <u-subsection :list="subsection" @change="changesub" :current="current" button-color="#2E7Dff"
  72. active-color="#fff"></u-subsection>
  73. <view id="pieEcharts" style="min-height:250px;">
  74. </view>
  75. </view>
  76. </view>
  77. <Tabbar :current="0"></Tabbar>
  78. <!-- <u-tabbar v-model="current" :list="tabbarList" active-color="#185ac6"></u-tabbar>
  79. --> </view>
  80. </template>
  81. <script>
  82. import Tabbar from '@/components/TabbarFinance.vue'
  83. import * as API from '@/apis/finance.js'
  84. import * as echarts from "echarts";
  85. import {
  86. beforeTimeStamp,
  87. currentTimeStamp,
  88. parseUnixTime
  89. } from '@/utils'
  90. export default {
  91. data() {
  92. return {
  93. title:"",
  94. showdate: false,
  95. startTime: "",
  96. indexData:{},
  97. endTime: "",
  98. myChart: null,
  99. subsection: [{
  100. name: '金额'
  101. },
  102. {
  103. name: '单量'
  104. }
  105. ],
  106. tabbarList: [{
  107. iconPath: "bar-chart-box-fill",
  108. selectedIconPath: "bar-chart-box-fill",
  109. text: '统计',
  110. count: 0,
  111. isDot: true,
  112. customIcon: true,
  113. },
  114. {
  115. iconPath: "article-fill",
  116. selectedIconPath: "article-fill",
  117. text: '明细',
  118. midButton: true,
  119. customIcon: true,
  120. },
  121. {
  122. iconPath: "account-pin-box-fill",
  123. selectedIconPath: "account-pin-box-fill",
  124. text: '我的',
  125. count: 0,
  126. isDot: false,
  127. customIcon: true,
  128. },
  129. ],
  130. current: 0,
  131. background: {
  132. background: 'none'
  133. },
  134. iswuye:false,
  135. }
  136. },
  137. onLoad() {
  138. this.title="收益统计"
  139. var obj=this.carhelp.getPersonInfoPlus("merchantUser");
  140. if(obj&&obj.role){
  141. var role=obj.role;
  142. if(role.id=="4"){
  143. this.title="电费统计"
  144. this.iswuye=true;
  145. }
  146. }
  147. },
  148. components: {
  149. Tabbar
  150. },
  151. onReady() {
  152. this.startTime = parseUnixTime(beforeTimeStamp(7), '{y}-{m}-{d}')
  153. this.endTime = parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}')
  154. this.getData()
  155. },
  156. methods: {
  157. getData(){
  158. uni.showLoading({
  159. title: "加载中",
  160. mask: true,
  161. })
  162. //this.form.pageIndex=this.pageIndex
  163. API.spIncomeStatistics(this.iswuye,{
  164. startDate:this.startTime,
  165. endDate:this.endTime
  166. }).then((res) => {
  167. this.indexData = res.data
  168. this.getPie()
  169. uni.hideLoading()
  170. }).catch(error => {
  171. uni.showToast({
  172. title: error
  173. })
  174. })
  175. },
  176. changesub(e){
  177. console.log(e)
  178. this.current=e
  179. this.getPie()
  180. },
  181. changedate(e) {
  182. this.startTime = e.startDate
  183. this.endTime = e.endDate
  184. this.getData()
  185. },
  186. getPie() {
  187. var list=this.indexData.pieChart;
  188. var getData=[];
  189. list.forEach(item=>{
  190. var value=(this.iswuye?(item.electricity/10000):item.amountNums)
  191. getData.push({
  192. value: this.current?value:item.amount,
  193. name: item.deviceName
  194. })
  195. })
  196. if (!this.myChart) {
  197. this.myChart = echarts.init(document.getElementById('pieEcharts'));
  198. }
  199. // 指定图表的配置项和数据
  200. var option = {
  201. tooltip: {
  202. trigger: 'item'
  203. },
  204. legend: {
  205. bottom: '0%',
  206. left: 'center'
  207. },
  208. series: [{
  209. //name: 'Access From',
  210. type: 'pie',
  211. radius: '50%',
  212. data: getData,
  213. emphasis: {
  214. itemStyle: {
  215. shadowBlur: 10,
  216. shadowOffsetX: 0,
  217. shadowColor: 'rgba(0, 0, 0, 0.5)'
  218. }
  219. },
  220. itemStyle:{
  221. normal:{
  222. color:function(colors){
  223. var list = [
  224. '#fc8251',
  225. '#5470c6',
  226. '#91cd77',
  227. '#ef6567',
  228. '#f9c956',
  229. '#75bedc',
  230. '#fc8251',
  231. '#5470c6',
  232. '#91cd77',
  233. '#ef6567',
  234. '#f9c956',
  235. '#75bedc'
  236. ]
  237. return list[colors.dataIndex]
  238. }
  239. }
  240. }
  241. }]
  242. };
  243. // 使用刚指定的配置项和数据显示图表。
  244. this.myChart.setOption(option);
  245. }
  246. }
  247. }
  248. </script>
  249. <style>
  250. page {
  251. background: url(../../assets/img/index_header_bg.png) no-repeat top center #f7f7f7;
  252. background-size: 100%;
  253. }
  254. </style>
  255. <style lang="scss" scoped>
  256. .navbar-tit {
  257. color: #fff;
  258. font-size: 20px;
  259. padding-left: 15px;
  260. }
  261. .statisticsData {
  262. background-color: #fff;
  263. margin: 16px;
  264. padding: 16px;
  265. border-radius: 8px;
  266. display: flex;
  267. margin-top: 80px;
  268. }
  269. .statisticsData-item {
  270. flex: 1;
  271. .statisticsData-head {
  272. display: flex;
  273. align-items: center;
  274. p {
  275. color: #637AA2;
  276. font-size: 12px;
  277. }
  278. }
  279. .statisticsData-main {
  280. margin-top: 4px;
  281. font-size: 20px;
  282. }
  283. .statisticsData-foot {
  284. display: flex;
  285. align-items: center;
  286. margin-top: 16px;
  287. p {
  288. color: #637AA2;
  289. }
  290. h4 {
  291. margin-left: 8px;
  292. }
  293. }
  294. }
  295. .statisticsChart {
  296. margin: 16px;
  297. .statisticsChart-head {
  298. margin-bottom: 5px;
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. h4 {
  303. font-weight: normal;
  304. font-size: 16px;
  305. position: relative;
  306. padding-left: 10px;
  307. &::after {
  308. content: '';
  309. position: absolute;
  310. height: 12px;
  311. width: 4px;
  312. background-color: #4E8DF6;
  313. left: 0;
  314. top: 5px;
  315. }
  316. }
  317. .statisticsChart-time {
  318. display: flex;
  319. align-items: center;
  320. p {
  321. color: #666;
  322. }
  323. }
  324. }
  325. .statisticsChart-main {
  326. background-color: #fff;
  327. padding: 16px;
  328. border-radius: 8px;
  329. }
  330. }
  331. </style>