dcCharging.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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. /deep/.u-circle-progress {
  389. position: relative;
  390. // min-width:220px;
  391. // min-height: 220px;
  392. }
  393. .u-progress-content {
  394. display: flex;
  395. align-items: center;
  396. justify-content: center;
  397. }
  398. .u-progress-dot {
  399. width: 16rpx;
  400. height: 16rpx;
  401. border-radius: 50%;
  402. background-color: #fb9126;
  403. }
  404. .u-progress-info {
  405. font-size: 22px;
  406. padding-left: 16rpx;
  407. letter-spacing: 2rpx;
  408. color: rgba(51, 51, 51, 100);
  409. }
  410. /deep/.u-progress-dot[data-v-05b104e0] {
  411. display: none;
  412. }
  413. /deep/.u-circle-progress[data-v-cab6fc66] {
  414. margin: 30px;
  415. }
  416. }
  417. .starting {
  418. height: 22px;
  419. color: rgba(0, 185, 98, 100);
  420. font-size: 16px;
  421. text-align: center;
  422. }
  423. .timer {
  424. height: 43px;
  425. color: rgba(51, 51, 51, 100);
  426. font-size: 36px;
  427. text-align: center;
  428. margin-top: 40px;
  429. }
  430. .charged {
  431. height: 20px;
  432. color: rgba(153, 153, 153, 100);
  433. font-size: 14px;
  434. text-align: center;
  435. margin-top: 4px;
  436. }
  437. .cost {
  438. // width: 50%;
  439. padding: 0 90px;
  440. margin-top: 16px;
  441. display: flex;
  442. justify-content: space-between;
  443. .cost-top {
  444. line-height: 33px;
  445. text-align: center;
  446. font-size: 24px;
  447. position: relative;
  448. .cost-font {
  449. position: absolute;
  450. top: 0;
  451. right: -25px;
  452. color: #ff6200;
  453. font-size: 24px
  454. }
  455. }
  456. .cost-bottom {
  457. line-height: 20px;
  458. color: #999999;
  459. text-align: center;
  460. }
  461. }
  462. .line {
  463. width: 0;
  464. height: 36px;
  465. border: 1px solid rgba(237, 237, 237, 100);
  466. margin-top: 10px;
  467. background-color: #ededed;
  468. }
  469. .power {
  470. display: flex;
  471. justify-content: space-around;
  472. padding: 0 55px;
  473. margin-top: 40px;
  474. .power-num {
  475. height: 27px;
  476. color: rgba(51, 51, 51, 100);
  477. font-size: 20px;
  478. text-align: center;
  479. }
  480. .power-text {
  481. height: 20px;
  482. color: rgba(153, 153, 153, 100);
  483. font-size: 14px;
  484. text-align: center;
  485. }
  486. }
  487. .info {
  488. display: flex;
  489. justify-content: space-between;
  490. margin: 0 40px;
  491. // height: 48px;
  492. line-height: 48px;
  493. background-color: rgba(255, 255, 255, 100);
  494. color: rgba(16, 16, 16, 100);
  495. border-bottom: 1px solid #ededed;
  496. .info-text {
  497. line-height: 23px;
  498. padding: 13px 0 12px;
  499. width: 200px;
  500. text-align: right;
  501. }
  502. }
  503. .bottom2 {
  504. padding: 12px 20px;
  505. background-color: #fff;
  506. position: fixed;
  507. bottom: 0;
  508. left: 0;
  509. right: 0;
  510. margin: auto;
  511. }
  512. .progress-bar2 {
  513. text-align: center;
  514. /deep/.u-circle-progress {
  515. // margin-left: 23.3% !important;
  516. position: relative;
  517. }
  518. .u-progress-content {
  519. display: flex;
  520. align-items: center;
  521. justify-content: center;
  522. }
  523. .u-progress-dot {
  524. width: 16rpx;
  525. height: 16rpx;
  526. border-radius: 50%;
  527. background-color: #fb9126;
  528. }
  529. .u-progress-info {
  530. display: block;
  531. font-size: 32px;
  532. padding-left: 16rpx;
  533. letter-spacing: 2rpx;
  534. color: rgba(51, 51, 51, 100);
  535. .progress-text {
  536. font-size: 14px;
  537. text-align: center;
  538. color: #666666;
  539. }
  540. }
  541. /deep/.u-progress-dot[data-v-05b104e0] {
  542. display: none;
  543. }
  544. /deep/.u-circle-progress[data-v-cab6fc66] {
  545. margin: 30px;
  546. }
  547. }
  548. .time-price {
  549. display: flex;
  550. justify-content: space-between;
  551. padding: 0 65px;
  552. .item-num {
  553. height: 33px;
  554. color: rgba(51, 51, 51, 100);
  555. font-size: 24px;
  556. text-align: center;
  557. }
  558. .item-text {
  559. eight: 20px;
  560. color: rgba(153, 153, 153, 100);
  561. font-size: 14px;
  562. text-align: center;
  563. }
  564. }
  565. .bottom {
  566. display: flex;
  567. width: 91.4%;
  568. padding: 12px 16px;
  569. position: fixed;
  570. bottom: 0;
  571. left: 0;
  572. right: 0;
  573. margin: auto;
  574. .u-size-default {
  575. border: 1px solid rgba(0, 185, 98, 100);
  576. color: #00b962;
  577. width: 44%;
  578. }
  579. }
  580. </style>