dcCharging.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <view>
  3. <view v-if="chargingRecord.status==2">
  4. <u-navbar title="充电结束">
  5. </u-navbar>
  6. <view class="progress-bar2">
  7. <u-circle-progress width="400" active-color="green" duration='20' :percent="100" border-width="20">
  8. <view class="u-progress-content">
  9. <text class='u-progress-info' v-if="chargingGun.gunType==1">
  10. <p style="text-align: center;">{{chargingRecord.endSoc}}%</p>
  11. <p class="progress-text">当前电量</p>
  12. </text>
  13. <text class='u-progress-info' v-if="chargingGun.gunType==2">
  14. <p style="text-align: center;">{{chargingRecord.electricQuantity/10000}}</p>
  15. <p class="progress-text">已充电量(度)</p>
  16. </text>
  17. </view>
  18. </u-circle-progress>
  19. </view>
  20. <view class="time-price">
  21. <view class="item">
  22. <view class="item-num">
  23. {{getPercent2()}}
  24. </view>
  25. <view class="item-text">
  26. 充电时长
  27. </view>
  28. </view>
  29. <view class="item">
  30. <view class="item-num">
  31. {{chargingRecord.actualFee}}元
  32. </view>
  33. <view class="item-text">
  34. 充电金额
  35. </view>
  36. </view>
  37. </view>
  38. <view
  39. v-if="chargingRecord.remark"
  40. style="
  41. margin-top: 20px;
  42. text-align: center;
  43. ">
  44. 结束原因:{{chargingRecord.remark}}
  45. </view>
  46. <view
  47. style="
  48. margin-top: 20px;
  49. text-align: center;
  50. padding: 0 65px;
  51. color:#9e9e9e;
  52. ">
  53. <span style="color: red;">*</span>实际充电金额与所选金额会略有出入,最终结算金额将以实际充入电量为准。
  54. </view>
  55. <view class="bottom">
  56. <u-button size="default" shape="circle" @click="gotoMain(0)" >返回首页</u-button>
  57. <u-button size="default" shape="circle" @click="gotoMain(1)">查看订单详情</u-button>
  58. </view>
  59. </view>
  60. <view style="background-color: #fff; padding-bottom: 60px;" v-else>
  61. <u-navbar title="充电详情">
  62. </u-navbar>
  63. <view class="iconfont tittle-font" @click="show = true">
  64. &#xe616;
  65. </view>
  66. <view class="progress-bar">
  67. <u-circle-progress width="440" active-color="green" :percent="percent?percent:percentValue" border-width="50">
  68. <view class="u-progress-content" v-if="chargingRecord.status==4">
  69. <text class='u-progress-info'>前方等待{{waitNum}}位</text>
  70. </view>
  71. <view class="u-progress-content" v-else-if="chargingGun.gunType==1">
  72. <text class='u-progress-info'>{{percent}}%</text>
  73. </view>
  74. <view class="u-progress-content" v-else-if="chargingGun.gunType==2">
  75. <text class='u-progress-info'>{{chargingRecord.statusText}}...</text>
  76. </view>
  77. <view class="bot"></view>
  78. </u-circle-progress>
  79. </view>
  80. <view class="starting" v-if="chargingGun.gunType==1">
  81. {{chargingRecord.statusText}}...
  82. </view>
  83. <view class="timer">
  84. {{timer}}
  85. </view>
  86. <view class="charged">
  87. 已充电{{chargingGun.kwh}}度
  88. </view>
  89. <view class="cost">
  90. <view class="">
  91. <view class="cost-top">
  92. {{chargingRecord.dueFee?chargingRecord.dueFee:0}}元
  93. </view>
  94. <view class="cost-bottom">
  95. 实时费用
  96. </view>
  97. </view>
  98. <view class="line"></view>
  99. <view class="">
  100. <view class="cost-top">
  101. {{detail.balance}}元
  102. <view class="iconfont cost-font" @click="gotoUrl('pages/user/finance/recharge')" >&#xe633;</view>
  103. </view>
  104. <view class="cost-bottom">
  105. 账户余额
  106. </view>
  107. </view>
  108. </view>
  109. <view class="power">
  110. <view>
  111. <view class="power-num">
  112. {{chargingRecord.chargeVoltage?chargingRecord.chargeVoltage:0}}v
  113. </view>
  114. <view class="power-text">
  115. 电压
  116. </view>
  117. </view>
  118. <view class="line"></view>
  119. <view>
  120. <view class="power-num">
  121. {{chargingRecord.chargingPower?chargingRecord.chargingPower/1000:0}}kW
  122. </view>
  123. <view class="power-text">
  124. 功率
  125. </view>
  126. </view>
  127. <view class="line"></view>
  128. <view>
  129. <view class="power-num">
  130. {{chargingRecord.chargeAmpere?chargingRecord.chargeAmpere:0}}A
  131. </view>
  132. <view class="power-text">
  133. 电流
  134. </view>
  135. </view>
  136. </view>
  137. <view class="info">
  138. <view class="info-name">
  139. 充电车辆
  140. </view>
  141. <view class="info-text">
  142. {{chargingRecord.carNumber}}
  143. </view>
  144. </view>
  145. <view class="info">
  146. <view class="info-name">
  147. 站点
  148. </view>
  149. <view class="info-text">
  150. {{chargingRecord.stationName}} / {{chargingRecord.deviceNo}}
  151. </view>
  152. </view>
  153. <view class="info" v-if="false">
  154. <view class="info-name">
  155. 占位费说明
  156. </view>
  157. <view class="info-text">
  158. 停止充电后30分钟即开始收取占位费用,1元/分钟
  159. </view>
  160. </view>
  161. <view class="bottom2" >
  162. <u-button type="primary" @click="submit"
  163. :style="chargingRecord.status==1?'background-color: #00b962':'background-color: #9be6c2;'"
  164. shape="circle" >结束充电</u-button>
  165. </view>
  166. <u-modal v-model="show" @confirm="confirmPhone" :confirm-text="confirmText" confirm-color="#606266"
  167. :show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title" :content="consumerPhone">
  168. </u-modal>
  169. </view>
  170. </view>
  171. </template>
  172. <script>
  173. import * as API from '@/apis/chargeProcess.js'
  174. import {
  175. secondsDistance,
  176. hourDistanceArr
  177. } from '@/utils'
  178. export default {
  179. data() {
  180. return {
  181. timer:'',
  182. title: '联系客服',
  183. content: '0716-8123456',
  184. confirmText: '拨打电话',
  185. detail:{},
  186. percent: 0,
  187. percentValue: 0,
  188. consumerPhone: "",
  189. id: "",
  190. chargingGun: {},
  191. chargingRecord: {},
  192. show: false,
  193. isReady:true,
  194. waitNum:'',
  195. }
  196. },
  197. onLoad(op) {
  198. if (op.id) {
  199. this.id = op.id;
  200. this.init()
  201. this.getInfo()
  202. }
  203. var consumerPhone = this.carhelp.getConfig().consumerPhone
  204. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  205. if (consumerPhone) {
  206. this.consumerPhone = consumerPhone
  207. }
  208. },
  209. onUnload() {
  210. this.isReady=false;
  211. },
  212. onReady() {
  213. this.addpercent()
  214. },
  215. methods: {
  216. gotoMain(i){
  217. if(i==0){
  218. uni.reLaunch({
  219. url:"/pages/index/index"
  220. })
  221. }
  222. if(i==1){
  223. uni.redirectTo({
  224. url:"/pages/record/details?id="+this.id
  225. })
  226. }
  227. },
  228. addpercent(){
  229. this.timer=this.getPercent()
  230. if(this.isReady){
  231. setTimeout(()=>{
  232. this.percentValue++;
  233. if(this.percentValue>=100){
  234. this.percentValue=0;
  235. }
  236. this.addpercent()
  237. },100)
  238. }
  239. },
  240. getPercent2() {
  241. var ms=this.chargingRecord.chargingMinute*60;
  242. var Hour = parseInt(Math.floor(ms / (60 * 60)));
  243. var Fen = parseInt(Math.floor(ms % (60 * 60) / 60));
  244. var S = parseInt(Math.floor(ms % (60) ));
  245. var obj = (Hour > 9 ? "" : "0") + Hour + ":" + (Fen > 9 ? "" : "0") + Fen+ ":" + (S > 9 ? "" : "0") + S
  246. return obj;
  247. },
  248. getPercent() {
  249. var Hour=0;
  250. var Fen=0;
  251. var S=0;
  252. if (this.chargingRecord.status == 1) {
  253. var second = secondsDistance(this.chargingRecord.startTime);
  254. var ms=second;
  255. Hour = parseInt(Math.floor(ms / (60 * 60)));
  256. Fen = parseInt(Math.floor(ms % (60 * 60) / 60));
  257. S = parseInt(Math.floor(ms % (60) ));
  258. }
  259. var obj = (Hour > 9 ? "" : "0") + Hour + ":" + (Fen > 9 ? "" : "0") + Fen+ ":" + (S > 9 ? "" : "0") + S
  260. return obj;
  261. },
  262. init() {
  263. API.personalCenter().then((res) => {
  264. this.detail = res.data
  265. }).catch(error => {
  266. uni.showToast({
  267. title: error
  268. })
  269. })
  270. },
  271. confirmPhone() {
  272. this.show = false;
  273. uni.makePhoneCall({
  274. phoneNumber: this.consumerPhone //仅为示例
  275. });
  276. },
  277. getInfo() {
  278. // uni.showLoading({
  279. // title: "加载中",
  280. // mask: true,
  281. // })
  282. API.chargingDetail({
  283. id: this.id
  284. }).then((res) => {
  285. this.chargingRecord = res.data.chargingRecord
  286. this.chargingGun = res.data.chargingGun
  287. this.waitNum=res.data.chargingRecord.waitNum;
  288. this.isReady = true;
  289. //直流
  290. if(this.chargingGun.gunType==1){
  291. if (this.chargingRecord.status == 1) {
  292. this.percent=this.chargingGun.soc
  293. // var second = secondsDistance(this.chargingRecord.startTime);
  294. // var percent = (second / 60) / this.chargingRecord.estimateMinute * 100;
  295. // console.log(this.percent)
  296. // var sum=this.chargingGun.chargeTimeSec/60+this.chargingGun.remainMin;
  297. // if(sum){
  298. // this.percent=this.chargingGun.chargeTimeSec/60/sum*100
  299. // }
  300. }
  301. }else if(this.chargingGun.gunType==2){
  302. //交流
  303. }
  304. if(this.isReady&&this.chargingRecord.status!=2){
  305. var time=500;
  306. if(this.chargingRecord.status==0){
  307. }else{
  308. time=3000;
  309. this.init();
  310. }
  311. setTimeout(()=>{
  312. this.getInfo();
  313. },time)
  314. }
  315. uni.hideLoading()
  316. }).catch(error => {
  317. uni.showToast({
  318. title: error
  319. })
  320. })
  321. },
  322. submit() {
  323. if(this.chargingRecord.status!=1){
  324. return
  325. }
  326. uni.showModal({
  327. title: '提示',
  328. content: '确认结束充电?',
  329. success: res => {
  330. if (res.confirm) {
  331. //付钱 改为组件
  332. this.confirm()
  333. } else if (res.cancel) {
  334. console.log('用户点击取消');
  335. }
  336. }
  337. });
  338. },
  339. confirm() {
  340. //console.log(JSON.stringify(this.submitForm))
  341. uni.showLoading({
  342. title: "加载中",
  343. mask: true,
  344. })
  345. //this.submitForm.deviceNo = this.detail.deviceNo;
  346. API.stopCarCharging({
  347. chargingRecordId:this.chargingRecord.id
  348. }).then((res) => {
  349. this.getInfo()
  350. }).catch(error => {
  351. uni.showToast({
  352. title: error
  353. })
  354. })
  355. },
  356. }
  357. }
  358. </script>
  359. <style>
  360. page {
  361. background: #fff;
  362. padding-bottom: 50px;
  363. }
  364. </style>
  365. <style lang="scss" scoped>
  366. .tittle-font {
  367. font-size: 24px;
  368. position: fixed;
  369. top: 12px;
  370. right: 16px;
  371. z-index: 99999;
  372. }
  373. .bot {
  374. width:100%;
  375. height:0;
  376. padding-top: 100%;
  377. border: 2px #00b962 dotted;
  378. border-radius:100%;
  379. box-sizing: border-box;
  380. position: absolute;
  381. top: 0px;
  382. left: 0px;
  383. right: 0px;
  384. margin: auto;
  385. }
  386. .progress-bar {
  387. text-align: center;
  388. margin-top: 20px;
  389. /deep/.u-circle-progress {
  390. position: relative;
  391. // min-width:220px;
  392. // min-height: 220px;
  393. }
  394. .u-progress-content {
  395. display: flex;
  396. align-items: center;
  397. justify-content: center;
  398. }
  399. .u-progress-dot {
  400. width: 16rpx;
  401. height: 16rpx;
  402. border-radius: 50%;
  403. background-color: #fb9126;
  404. }
  405. .u-progress-info {
  406. font-size: 22px;
  407. padding-left: 16rpx;
  408. letter-spacing: 2rpx;
  409. color: rgba(51, 51, 51, 100);
  410. }
  411. /deep/.u-progress-dot[data-v-05b104e0] {
  412. display: none;
  413. }
  414. /deep/.u-circle-progress[data-v-cab6fc66] {
  415. margin: 30px;
  416. }
  417. }
  418. .starting {
  419. height: 22px;
  420. color: rgba(0, 185, 98, 100);
  421. font-size: 16px;
  422. text-align: center;
  423. margin-top: 10px;
  424. }
  425. .timer {
  426. height: 43px;
  427. color: rgba(51, 51, 51, 100);
  428. font-size: 36px;
  429. text-align: center;
  430. margin-top: 40px;
  431. }
  432. .charged {
  433. height: 20px;
  434. color: rgba(153, 153, 153, 100);
  435. font-size: 14px;
  436. text-align: center;
  437. margin-top: 4px;
  438. }
  439. .cost {
  440. // width: 50%;
  441. padding: 0 90px;
  442. margin-top: 16px;
  443. display: flex;
  444. justify-content: space-between;
  445. .cost-top {
  446. line-height: 33px;
  447. text-align: center;
  448. font-size: 24px;
  449. position: relative;
  450. .cost-font {
  451. position: absolute;
  452. top: 0;
  453. right: -25px;
  454. color: #ff6200;
  455. font-size: 24px
  456. }
  457. }
  458. .cost-bottom {
  459. line-height: 20px;
  460. color: #999999;
  461. text-align: center;
  462. }
  463. }
  464. .line {
  465. width: 0;
  466. height: 36px;
  467. border: 1px solid rgba(237, 237, 237, 100);
  468. margin-top: 10px;
  469. background-color: #ededed;
  470. }
  471. .power {
  472. display: flex;
  473. justify-content: space-around;
  474. padding: 0 55px;
  475. margin-top: 40px;
  476. .power-num {
  477. height: 27px;
  478. color: rgba(51, 51, 51, 100);
  479. font-size: 20px;
  480. text-align: center;
  481. }
  482. .power-text {
  483. height: 20px;
  484. color: rgba(153, 153, 153, 100);
  485. font-size: 14px;
  486. text-align: center;
  487. }
  488. }
  489. .info {
  490. display: flex;
  491. justify-content: space-between;
  492. margin: 0 40px;
  493. // height: 48px;
  494. line-height: 48px;
  495. background-color: rgba(255, 255, 255, 100);
  496. color: rgba(16, 16, 16, 100);
  497. border-bottom: 1px solid #ededed;
  498. .info-text {
  499. line-height: 23px;
  500. padding: 13px 0 12px;
  501. width: 200px;
  502. text-align: right;
  503. }
  504. }
  505. .bottom2 {
  506. padding: 12px 20px;
  507. background-color: #fff;
  508. position: fixed;
  509. bottom: 0;
  510. left: 0;
  511. right: 0;
  512. margin: auto;
  513. }
  514. .progress-bar2 {
  515. text-align: center;
  516. margin-top: 20px;
  517. /deep/.u-circle-progress {
  518. // margin-left: 23.3% !important;
  519. position: relative;
  520. }
  521. .u-progress-content {
  522. display: flex;
  523. align-items: center;
  524. justify-content: center;
  525. }
  526. .u-progress-dot {
  527. width: 16rpx;
  528. height: 16rpx;
  529. border-radius: 50%;
  530. background-color: #fb9126;
  531. }
  532. .u-progress-info {
  533. display: block;
  534. font-size: 32px;
  535. padding-left: 16rpx;
  536. letter-spacing: 2rpx;
  537. color: rgba(51, 51, 51, 100);
  538. .progress-text {
  539. font-size: 14px;
  540. text-align: center;
  541. color: #666666;
  542. }
  543. }
  544. /deep/.u-progress-dot[data-v-05b104e0] {
  545. display: none;
  546. }
  547. /deep/.u-circle-progress[data-v-cab6fc66] {
  548. margin: 30px;
  549. }
  550. }
  551. .time-price {
  552. display: flex;
  553. justify-content: space-between;
  554. padding: 0 65px;
  555. .item-num {
  556. height: 33px;
  557. color: rgba(51, 51, 51, 100);
  558. font-size: 24px;
  559. text-align: center;
  560. }
  561. .item-text {
  562. eight: 20px;
  563. color: rgba(153, 153, 153, 100);
  564. font-size: 14px;
  565. text-align: center;
  566. }
  567. }
  568. .bottom {
  569. display: flex;
  570. width: 91.4%;
  571. padding: 12px 16px;
  572. position: fixed;
  573. bottom: 0;
  574. left: 0;
  575. right: 0;
  576. margin: auto;
  577. .u-size-default {
  578. border: 1px solid rgba(0, 185, 98, 100);
  579. color: #00b962;
  580. width: 44%;
  581. }
  582. }
  583. </style>