details.vue 14 KB

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