details.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <view class="time-head">
  3. <ujp-navbar title="充电详情"></ujp-navbar>
  4. <view class="details-time">
  5. <view class="time">
  6. <view class="time1">
  7. <view class="time11">{{getday(chargeDetail.startTime?chargeDetail.startTime:chargeDetail.createTime)}}</view>
  8. <view class="time12">{{geth(chargeDetail.startTime?chargeDetail.startTime:chargeDetail.createTime)}}</view>
  9. </view>
  10. <view class="time2">
  11. <view class="time21">起</view>
  12. <view class="time22"></view>
  13. <view class="time21">止</view>
  14. </view>
  15. <view class="time1">
  16. <view class="time11">{{getday(chargeDetail.endTime)}}</view>
  17. <view class="time12">{{geth(chargeDetail.endTime)}}</view>
  18. </view>
  19. </view>
  20. <view class="oldTextjp18px" >
  21. <view class="details-row"><p>充电时长</p><span>{{chargeDetail.chargingMinute != null ? getPercent(chargeDetail.chargingMinute) : '0秒'}}</span></view>
  22. <view class="details-row"><p>充电度数</p><span>{{chargeDetail.electricQuantity != null ? chargeDetail.electricQuantity/10000 : '0.000'}}度</span></view>
  23. </view>
  24. </view>
  25. <view class="details" style="padding: 20rpx;" v-show="electricRecordListBl">
  26. <view id="pieEcharts" style="min-height:240px;">
  27. </view>
  28. <view style="color:#9e9e9e;margin-top: 4px;">注:充电时间每5分钟获取一次数据</view>
  29. </view>
  30. <view class="details">
  31. <view class="details-title">
  32. <h4 class="oldTextjp20px" oldstyle="font-size: 20px;">费用信息</h4>
  33. </view>
  34. <view class="oldTextjp18px" oldstyle="font-size: 18px;">
  35. <view class="details-row"><p>订单总额</p><span>{{chargeDetail.actualFee != null ? chargeDetail.actualFee.toFixed(2) : '0.00'}}元</span></view>
  36. <view class="details-row"><p>电费</p><span>{{chargeDetail.totalElecMoney != null ? chargeDetail.totalElecMoney.toFixed(2) : '0.00'}}元</span></view>
  37. <view class="details-row" ><p>服务费</p><span>{{chargeDetail.totalServiceMoney != null ? chargeDetail.totalServiceMoney.toFixed(2) : '0.00'}}元</span></view>
  38. <view class="details-row" v-if="chargeDetail.serviceDiscountRatio&&chargeDetail.serviceDiscountRatio!=100" ><p>折前服务费</p><span>{{(chargeDetail.dueServiceMoney?chargeDetail.dueServiceMoney:0).toFixed(2)}}元</span></view>
  39. <view class="details-row" v-if="chargeDetail.serviceDiscountRatio&&chargeDetail.serviceDiscountRatio!=100" ><p>服务费折扣</p><span>{{chargeDetail.serviceDiscountRatio/10}}折</span></view>
  40. <!-- <view class="details-row" v-if="chargeDetail.discountAmount" ><p>服务费</p><span>{{chargeDetail.totalServiceMoney != null ? (chargeDetail.totalServiceMoney*100-chargeDetail.discountAmount*100)/100 : '0.00'}}元({{chargeDetail.totalServiceMoney}}-{{chargeDetail.discountAmount}})</span></view>
  41. -->
  42. <view class="details-row"><p>优惠券抵扣</p><span style="color:red">{{userCouponObj? userCouponObj.useText : '未使用'}}</span></view>
  43. <view class="details-row" v-if="chargeDetail.discountAmount" ><p>实际减免</p><span >-{{chargeDetail.discountAmount.toFixed(2)}}元</span></view>
  44. <view class="details-row" v-if="chargeDetail.userCardId"><p>会员活动</p><span >充电服务费月卡</span></view>
  45. <!--
  46. <view class="details-row"><p>开始时间</p><span>{{chargeDetail.startTime}}</span></view>
  47. <view class="details-row"><p>结束时间</p><span>{{chargeDetail.endTime}}</span></view>
  48. --> </view>
  49. </view>
  50. <view class="details">
  51. <view class="details-title">
  52. <h4 class="oldTextjp20px" >更多信息</h4>
  53. </view>
  54. <view class="oldTextjp18px" >
  55. <view class="details-row"><p>结束原因</p><span>{{chargeDetail.remark}}</span></view>
  56. <view class="details-row"><p>订单状态</p><span>{{chargeDetail.statusText}}</span></view>
  57. <view class="details-row" v-if="false"><p>更新时间</p><span>{{chargeDetail.updateTime}}</span></view>
  58. <view class="details-row" ><p>充电站点</p><span>{{chargeDetail.stationName}}</span></view>
  59. <view class="details-row"><p>充电桩编号</p><span>{{chargeDetail.deviceName}}</span></view>
  60. <view class="details-row"><p>充电车辆</p><span>{{chargeDetail.carNumber}}</span></view>
  61. </view>
  62. </view>
  63. <view class="" style="padding: 0px 20px;">
  64. <u-button class="detailsBtn-btn oldTextjp18px" oldstyle="font-size: 16px;" type="success" shape="circle" @click="toHome">返回主页</u-button>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import * as API from '@/apis/index.js'
  70. import * as echarts from "echarts";
  71. export default {
  72. data() {
  73. return {
  74. id: '',
  75. myChart:null,
  76. electricRecordList:[],
  77. chargeDetail: {},
  78. userCouponObj:{},
  79. electricRecordListBl:true,
  80. elderStatus: false,
  81. }
  82. },
  83. onLoad(op) {
  84. if(op.id) {
  85. this.id = op.id;
  86. this.getchargingDetail();
  87. }
  88. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  89. this.elderStatus = true;
  90. } else {
  91. this.elderStatus = false;
  92. }
  93. },
  94. methods: {
  95. getday(time){
  96. if(time){
  97. return time.substring(5,10).replace('-','月')+'日'
  98. }else
  99. return''
  100. },
  101. geth(time){
  102. if(time){
  103. return time.substring(11,16)
  104. }else
  105. return''
  106. },
  107. getPercent(estimateMinute) {
  108. var value="";
  109. var ms =estimateMinute
  110. if (ms > 0) {
  111. var Hour = parseInt(Math.floor(ms / 60 ));
  112. var Fen = parseInt(Math.floor(ms % 60 ));
  113. // value = Hour + "小时" + Fen+"分钟"
  114. if(Hour){
  115. value += Hour + "小时"
  116. }
  117. if(Fen){
  118. value += Fen+"分钟"
  119. }
  120. }else{
  121. value="0分钟"
  122. }
  123. return value;
  124. },
  125. toHome() {
  126. uni.navigateTo({
  127. url: '/pages/index/index'
  128. })
  129. },
  130. getPie(data){
  131. if (!this.myChart) {
  132. this.myChart = echarts.init(document.getElementById('pieEcharts'));
  133. // this.myChart.on("dataZoom", (res) => {
  134. // showkey = "";
  135. // this.headitemby = "";
  136. // });
  137. }
  138. var timeList=[]
  139. var seriesList1=[]
  140. var seriesList2=[]
  141. var seriesList3=[]
  142. //var sz2 = ['soc', 'power', 'ampere', 'voltage','temperature'];
  143. console.log(data)
  144. var dataInterval=[0,10,20,30,40,50,60,70,80,90,100]
  145. for(var i in data){
  146. var item=data[i]
  147. timeList.push(this.geth(item.recordTime));
  148. seriesList1.push(item.soc?item.soc:'')
  149. seriesList2.push(item.power?(item.power/1000).toFixed(1):'')
  150. //seriesList3.push(item.temperature?item.temperature:0)
  151. seriesList3.push(item.temperature?item.temperature:'')
  152. }
  153. var spaceNum=5
  154. let maxA = Math.max(...seriesList2); // 最大值A
  155. let maxint = Math.ceil(maxA / spaceNum); //最大平均值(向上取整)= 最大值A / 间隔数
  156. let maxB = maxint * spaceNum; // 最大值B = 最大平均值 * 间隔数 (注:最大值B>最大值A)
  157. var max= Math.max(maxB, 10); // 为了防止maxB数据为0时,Y轴不显示,给个默认最大值10
  158. var interval=max/spaceNum;
  159. const colors = ['#ea9832', '#429fc8', '#b13331'];
  160. var option = {
  161. color: colors,
  162. tooltip: {
  163. formatter: (value) => {
  164. console.log(value)
  165. var name = value[0].axisValue;
  166. var style = "float: right;margin-left: 3px;"
  167. var text1 = ""
  168. var ulist=['%','kW','℃','','','']
  169. for (var i in value) {
  170. var u = ulist[i];
  171. if(value[i].data==''){
  172. continue
  173. }
  174. text1 += "<p>" + value[i].marker + value[i].seriesName + '<span style="' + style +
  175. '">' + value[i].data + u + '</span></p>';
  176. }
  177. return `<p>${name}</p>` + text1
  178. },
  179. trigger: 'axis',
  180. },
  181. grid: {
  182. left: '8%',
  183. right: '10%',
  184. bottom: '10%',
  185. // containLabel: true
  186. },
  187. legend: {
  188. data: ['SOC', '功率', '温度']
  189. },
  190. xAxis: [
  191. {
  192. type: 'category',
  193. axisTick: {
  194. alignWithLabel: true
  195. },
  196. splitNumber: 2,
  197. // prettier-ignore
  198. data:timeList
  199. }
  200. ],
  201. yAxis: [
  202. {
  203. type: 'value',
  204. name: '℃/SOC',
  205. //data: [0,10,20,30,40,50,60,70,80,90,100],
  206. max:100,
  207. min:0,
  208. minInterval:10,
  209. position: 'right',
  210. alignTicks: true,
  211. axisLine: {
  212. show: true,
  213. lineStyle: {
  214. color: colors[0]
  215. }
  216. },
  217. axisLabel: {
  218. formatter: '{value}'
  219. }
  220. },
  221. {
  222. type: 'value',
  223. name: 'kW',
  224. position: 'left',
  225. alignTicks: true,
  226. interval:interval,
  227. max:max,
  228. min:0,
  229. axisLine: {
  230. show: true,
  231. lineStyle: {
  232. color: colors[1]
  233. }
  234. },
  235. axisLabel: {
  236. formatter: '{value}'
  237. }
  238. }
  239. ],
  240. series: [
  241. {
  242. name: 'SOC',
  243. type: 'line',
  244. symbolSize:3,
  245. data: seriesList1
  246. },
  247. {
  248. name: '功率',
  249. type: 'line',
  250. symbolSize:3,
  251. yAxisIndex: 1,
  252. data: seriesList2
  253. },
  254. {
  255. name: '温度',
  256. type: 'line',
  257. symbolSize:3,
  258. yAxisIndex: 0,
  259. data: seriesList3
  260. }
  261. ]
  262. };
  263. console.log(option)
  264. this.myChart.setOption(option);
  265. },
  266. getchargingDetail() {
  267. uni.showLoading({
  268. title: "加载中",
  269. mask: true,
  270. })
  271. API.chargingDetail(this.id).then((res) => {
  272. uni.hideLoading();
  273. this.chargeDetail = res.data.chargingRecord;
  274. this.userCouponObj = res.data.userCoupon;
  275. this.electricRecordList=res.data.electricRecordList
  276. if(res.data.electricRecordList&&res.data.electricRecordList.length){
  277. this.getPie(res.data.electricRecordList);
  278. }else{
  279. this.electricRecordListBl=false
  280. }
  281. }).catch(error => {
  282. uni.showToast({
  283. title: error,
  284. icon: "none"
  285. })
  286. })
  287. }
  288. }
  289. }
  290. </script>
  291. <style>
  292. page{
  293. background-color: #F7F7F7;
  294. }
  295. </style>
  296. <style lang="scss" scoped>
  297. .time-head{
  298. background: linear-gradient(
  299. 180deg, rgba(0,185,98,1) 0%,rgba(246,248,248,1) 240px);
  300. padding-bottom: 20px;
  301. }
  302. .details-time{
  303. background: linear-gradient(180deg, #b7ebcf 0%,rgba(255,255,255,1) 33%);
  304. .time{
  305. display: flex;
  306. justify-content: space-between;
  307. border-bottom: 1px solid #E8E8E8;
  308. padding-bottom: 20rpx;
  309. .time1{
  310. .time11{
  311. font-size: 28rpx;
  312. margin-bottom: 4rpx;
  313. }
  314. .time12{
  315. font-size: 48rpx;
  316. color: #101010;
  317. font-weight: bold;
  318. text-align: center;
  319. }
  320. }
  321. .time2{
  322. color: #B8B8B8;
  323. align-items: center;
  324. display: flex;
  325. justify-content: space-between;
  326. .time21{
  327. border: 1px solid #B8B8B8;
  328. border-radius: 100rpx;
  329. line-height: 46rpx;
  330. height: 48rpx;
  331. width: 48rpx;
  332. text-align: center;
  333. }
  334. .time22{
  335. width:200rpx;
  336. border-top: 1px solid #CFCFCF ;
  337. }
  338. }
  339. }
  340. }
  341. .oldTextClassF{
  342. .oldTextjp18px{
  343. font-size: 36rpx !important;
  344. }
  345. .oldTextjp20px{
  346. font-size: 40rpx !important;
  347. }
  348. }
  349. .detailsBtn{
  350. margin: 16px;
  351. .detailsBtn-btn{
  352. border-color:#00B962!important;
  353. border-radius: 8px!important;
  354. background: none!important;
  355. color:#00B962!important;
  356. }
  357. }
  358. .details-title{
  359. margin-bottom: 16px;
  360. h4{
  361. font-weight: bold;
  362. font-size: 16px;
  363. position: relative;
  364. padding-left:10px;
  365. &::after{
  366. content: '';
  367. position: absolute;
  368. height: 12px;
  369. width: 4px;
  370. background-color: #27B148;
  371. left: 0;
  372. top:5px;
  373. }
  374. }
  375. }
  376. .details-row{
  377. display: flex;
  378. justify-content: space-between;
  379. align-items: center;
  380. margin-top: 10px;
  381. p{
  382. color:#333;
  383. width: 180rpx;
  384. min-width: 80px;
  385. }
  386. span{
  387. color:#101010;
  388. font-weight: bold;
  389. }
  390. }
  391. .details,.details-time{
  392. margin: 32rpx;
  393. padding: 40rpx;
  394. background-color: #fff;
  395. border-radius: 8px;
  396. box-shadow: 0px 2px 6px 0px #00b96226;
  397. border: 1px solid rgba(255, 255, 255, 1);
  398. .details-head{
  399. display: flex;
  400. align-items: center;
  401. justify-content: center;
  402. h4{
  403. font-size: 18px;
  404. font-weight: normal;
  405. margin-left: 4px;
  406. }
  407. }
  408. .details-price{
  409. margin-top: 28px;
  410. display: flex;
  411. align-items: flex-end;
  412. justify-content: center;
  413. h3{
  414. font-size: 36px;
  415. color:#FF6200;
  416. line-height: 36px;
  417. margin: 0 4px;
  418. font-weight: normal;
  419. }
  420. span{
  421. font-size: 20px;
  422. color:#FF6200;
  423. }
  424. }
  425. .details-main{
  426. text-align: center;
  427. margin-bottom: 20px;
  428. p{
  429. color:#777;
  430. margin-top: 4px;
  431. }
  432. }
  433. }
  434. </style>