dcCharging.vue 14 KB

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