dcCharging.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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"
  167. :confirm-text="confirmText" confirm-color="#606266"
  168. :show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title" :content="consumerPhone">
  169. </u-modal>
  170. <u-modal v-model="show2" @confirm="gotoGz"
  171. cancel-text="暂不关注" @cancel="cancelGz"
  172. confirm-text="前往关注"
  173. confirm-color="#53b56b"
  174. :show-cancel-button="true"
  175. ref="uModal2" :asyncClose="true"
  176. >
  177. <view style="padding: 15px;"
  178. >请关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,以便第一时间收到充电结束消息提醒</view>
  179. </u-modal>
  180. </view>
  181. </view>
  182. </template>
  183. <script>
  184. import * as API from '@/apis/chargeProcess.js'
  185. import * as API_weixin from '@/apis/weixin.js'
  186. import {
  187. secondsDistance,
  188. hourDistanceArr
  189. } from '@/utils'
  190. export default {
  191. data() {
  192. return {
  193. timer:'',
  194. title: '联系客服',
  195. content: '0716-8123456',
  196. confirmText: '拨打电话',
  197. detail:{},
  198. percent: 0,
  199. percentValue: 0,
  200. consumerPhone: "",
  201. id: "",
  202. chargingGun: {},
  203. chargingRecord: {},
  204. show: false,
  205. show2: false,
  206. isReady:true,
  207. waitNum:'',
  208. projectName:"",
  209. }
  210. },
  211. onLoad(op) {
  212. this.projectName=process.car.ProjectName;
  213. if (op.id) {
  214. this.id = op.id;
  215. this.init()
  216. this.getInfo()
  217. }
  218. var consumerPhone = this.carhelp.getConfig().consumerPhone
  219. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  220. if (consumerPhone) {
  221. this.consumerPhone = consumerPhone
  222. }
  223. },
  224. onUnload() {
  225. this.isReady=false;
  226. },
  227. onReady() {
  228. this.addpercent()
  229. },
  230. methods: {
  231. cancelGz(){
  232. this.carhelp.setGzDate()
  233. },
  234. gotoGz(){
  235. this.carhelp.setGzDate()
  236. var url="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzg4Njc5ODEyMw==#wechat_redirect";
  237. window.location.href=url
  238. },
  239. gotoMain(i){
  240. if(i==0){
  241. uni.reLaunch({
  242. url:"/pages/index/index"
  243. })
  244. }
  245. if(i==1){
  246. uni.redirectTo({
  247. url:"/pages/record/details?id="+this.id
  248. })
  249. }
  250. },
  251. addpercent(){
  252. this.timer=this.getPercent()
  253. if(this.isReady){
  254. setTimeout(()=>{
  255. this.percentValue++;
  256. if(this.percentValue>=100){
  257. this.percentValue=0;
  258. }
  259. this.addpercent()
  260. },100)
  261. }
  262. },
  263. getPercent2() {
  264. var ms=this.chargingRecord.chargingMinute*60;
  265. var Hour = parseInt(Math.floor(ms / (60 * 60)));
  266. var Fen = parseInt(Math.floor(ms % (60 * 60) / 60));
  267. var S = parseInt(Math.floor(ms % (60) ));
  268. var obj = (Hour > 9 ? "" : "0") + Hour + ":" + (Fen > 9 ? "" : "0") + Fen+ ":" + (S > 9 ? "" : "0") + S
  269. return obj;
  270. },
  271. getPercent() {
  272. var Hour=0;
  273. var Fen=0;
  274. var S=0;
  275. if (this.chargingRecord.status == 1) {
  276. var second = secondsDistance(this.chargingRecord.startTime);
  277. var ms=second;
  278. Hour = parseInt(Math.floor(ms / (60 * 60)));
  279. Fen = parseInt(Math.floor(ms % (60 * 60) / 60));
  280. S = parseInt(Math.floor(ms % (60) ));
  281. }
  282. var obj = (Hour > 9 ? "" : "0") + Hour + ":" + (Fen > 9 ? "" : "0") + Fen+ ":" + (S > 9 ? "" : "0") + S
  283. return obj;
  284. },
  285. init() {
  286. API.personalCenter().then((res) => {
  287. this.detail = res.data
  288. }).catch(error => {
  289. uni.showToast({
  290. title: error
  291. })
  292. })
  293. },
  294. checkSubscribe(){
  295. API_weixin.checkSubscribe({
  296. openId: this.carhelp.getOpenId()
  297. }).then((res) => {
  298. if(res.data=="0"){
  299. this.show2=true;
  300. }else{
  301. this.carhelp.setGzDate()
  302. }
  303. //setGzDate
  304. }).catch(error => {
  305. uni.showToast({
  306. title: error
  307. })
  308. })
  309. },
  310. confirmPhone() {
  311. this.show = false;
  312. uni.makePhoneCall({
  313. phoneNumber: this.consumerPhone //仅为示例
  314. });
  315. },
  316. getInfo() {
  317. // uni.showLoading({
  318. // title: "加载中",
  319. // mask: true,
  320. // })
  321. API.chargingDetail({
  322. id: this.id
  323. }).then((res) => {
  324. this.chargingRecord = res.data.chargingRecord
  325. this.chargingGun = res.data.chargingGun
  326. this.waitNum=res.data.chargingRecord.waitNum;
  327. this.isReady = true;
  328. //直流
  329. if(this.chargingGun.gunType==1){
  330. if (this.chargingRecord.status == 1) {
  331. this.percent=this.chargingGun.soc
  332. // var second = secondsDistance(this.chargingRecord.startTime);
  333. // var percent = (second / 60) / this.chargingRecord.estimateMinute * 100;
  334. // console.log(this.percent)
  335. // var sum=this.chargingGun.chargeTimeSec/60+this.chargingGun.remainMin;
  336. // if(sum){
  337. // this.percent=this.chargingGun.chargeTimeSec/60/sum*100
  338. // }
  339. }
  340. }else if(this.chargingGun.gunType==2){
  341. //交流
  342. }
  343. if (this.chargingRecord.status == 1) {
  344. if(this.carhelp.getGzDate()&&!this.show2){
  345. this.checkSubscribe()
  346. }
  347. }
  348. if(this.isReady&&this.chargingRecord.status!=2){
  349. var time=500;
  350. if(this.chargingRecord.status==0){
  351. }else{
  352. time=3000;
  353. this.init();
  354. }
  355. setTimeout(()=>{
  356. this.getInfo();
  357. },time)
  358. }
  359. uni.hideLoading()
  360. }).catch(error => {
  361. uni.showToast({
  362. title: error
  363. })
  364. })
  365. },
  366. submit() {
  367. if(this.chargingRecord.status!=1){
  368. return
  369. }
  370. uni.showModal({
  371. title: '提示',
  372. content: '确认结束充电?',
  373. success: res => {
  374. if (res.confirm) {
  375. //付钱 改为组件
  376. this.confirm()
  377. } else if (res.cancel) {
  378. console.log('用户点击取消');
  379. }
  380. }
  381. });
  382. },
  383. confirm() {
  384. //console.log(JSON.stringify(this.submitForm))
  385. uni.showLoading({
  386. title: "加载中",
  387. mask: true,
  388. })
  389. //this.submitForm.deviceNo = this.detail.deviceNo;
  390. API.stopCarCharging({
  391. chargingRecordId:this.chargingRecord.id
  392. }).then((res) => {
  393. this.getInfo()
  394. }).catch(error => {
  395. uni.showToast({
  396. title: error
  397. })
  398. })
  399. },
  400. }
  401. }
  402. </script>
  403. <style>
  404. page {
  405. background: #fff;
  406. padding-bottom: 50px;
  407. }
  408. </style>
  409. <style lang="scss" scoped>
  410. .tittle-font {
  411. font-size: 24px;
  412. position: fixed;
  413. top: 12px;
  414. right: 16px;
  415. z-index: 99999;
  416. }
  417. .bot {
  418. width:100%;
  419. height:0;
  420. padding-top: 100%;
  421. border: 2px #00b962 dotted;
  422. border-radius:100%;
  423. box-sizing: border-box;
  424. position: absolute;
  425. top: 0px;
  426. left: 0px;
  427. right: 0px;
  428. margin: auto;
  429. }
  430. .progress-bar {
  431. text-align: center;
  432. margin-top: 20px;
  433. /deep/.u-circle-progress {
  434. position: relative;
  435. // min-width:220px;
  436. // min-height: 220px;
  437. }
  438. .u-progress-content {
  439. display: flex;
  440. align-items: center;
  441. justify-content: center;
  442. }
  443. .u-progress-dot {
  444. width: 16rpx;
  445. height: 16rpx;
  446. border-radius: 50%;
  447. background-color: #fb9126;
  448. }
  449. .u-progress-info {
  450. font-size: 22px;
  451. padding-left: 16rpx;
  452. letter-spacing: 2rpx;
  453. color: rgba(51, 51, 51, 100);
  454. }
  455. /deep/.u-progress-dot[data-v-05b104e0] {
  456. display: none;
  457. }
  458. /deep/.u-circle-progress[data-v-cab6fc66] {
  459. margin: 30px;
  460. }
  461. }
  462. .starting {
  463. height: 22px;
  464. color: rgba(0, 185, 98, 100);
  465. font-size: 16px;
  466. text-align: center;
  467. margin-top: 10px;
  468. }
  469. .timer {
  470. height: 43px;
  471. color: rgba(51, 51, 51, 100);
  472. font-size: 36px;
  473. text-align: center;
  474. margin-top: 40px;
  475. }
  476. .charged {
  477. height: 20px;
  478. color: rgba(153, 153, 153, 100);
  479. font-size: 14px;
  480. text-align: center;
  481. margin-top: 4px;
  482. }
  483. .cost {
  484. // width: 50%;
  485. padding: 0 90px;
  486. margin-top: 16px;
  487. display: flex;
  488. justify-content: space-between;
  489. .cost-top {
  490. line-height: 33px;
  491. text-align: center;
  492. font-size: 24px;
  493. position: relative;
  494. .cost-font {
  495. position: absolute;
  496. top: 0;
  497. right: -25px;
  498. color: #ff6200;
  499. font-size: 24px
  500. }
  501. }
  502. .cost-bottom {
  503. line-height: 20px;
  504. color: #999999;
  505. text-align: center;
  506. }
  507. }
  508. .line {
  509. width: 0;
  510. height: 36px;
  511. border: 1px solid rgba(237, 237, 237, 100);
  512. margin-top: 10px;
  513. background-color: #ededed;
  514. }
  515. .power {
  516. display: flex;
  517. justify-content: space-around;
  518. padding: 0 55px;
  519. margin-top: 40px;
  520. .power-num {
  521. height: 27px;
  522. color: rgba(51, 51, 51, 100);
  523. font-size: 20px;
  524. text-align: center;
  525. }
  526. .power-text {
  527. height: 20px;
  528. color: rgba(153, 153, 153, 100);
  529. font-size: 14px;
  530. text-align: center;
  531. }
  532. }
  533. .info {
  534. display: flex;
  535. justify-content: space-between;
  536. margin: 0 40px;
  537. // height: 48px;
  538. line-height: 48px;
  539. background-color: rgba(255, 255, 255, 100);
  540. color: rgba(16, 16, 16, 100);
  541. border-bottom: 1px solid #ededed;
  542. .info-text {
  543. line-height: 23px;
  544. padding: 13px 0 12px;
  545. width: 200px;
  546. text-align: right;
  547. }
  548. }
  549. .bottom2 {
  550. padding: 12px 20px;
  551. background-color: #fff;
  552. position: fixed;
  553. bottom: 0;
  554. left: 0;
  555. right: 0;
  556. margin: auto;
  557. }
  558. .progress-bar2 {
  559. text-align: center;
  560. margin-top: 20px;
  561. /deep/.u-circle-progress {
  562. // margin-left: 23.3% !important;
  563. position: relative;
  564. }
  565. .u-progress-content {
  566. display: flex;
  567. align-items: center;
  568. justify-content: center;
  569. }
  570. .u-progress-dot {
  571. width: 16rpx;
  572. height: 16rpx;
  573. border-radius: 50%;
  574. background-color: #fb9126;
  575. }
  576. .u-progress-info {
  577. display: block;
  578. font-size: 32px;
  579. padding-left: 16rpx;
  580. letter-spacing: 2rpx;
  581. color: rgba(51, 51, 51, 100);
  582. .progress-text {
  583. font-size: 14px;
  584. text-align: center;
  585. color: #666666;
  586. }
  587. }
  588. /deep/.u-progress-dot[data-v-05b104e0] {
  589. display: none;
  590. }
  591. /deep/.u-circle-progress[data-v-cab6fc66] {
  592. margin: 30px;
  593. }
  594. }
  595. .time-price {
  596. display: flex;
  597. justify-content: space-between;
  598. padding: 0 65px;
  599. .item-num {
  600. height: 33px;
  601. color: rgba(51, 51, 51, 100);
  602. font-size: 24px;
  603. text-align: center;
  604. }
  605. .item-text {
  606. eight: 20px;
  607. color: rgba(153, 153, 153, 100);
  608. font-size: 14px;
  609. text-align: center;
  610. }
  611. }
  612. .bottom {
  613. display: flex;
  614. width: 91.4%;
  615. padding: 12px 16px;
  616. position: fixed;
  617. bottom: 0;
  618. left: 0;
  619. right: 0;
  620. margin: auto;
  621. .u-size-default {
  622. border: 1px solid rgba(0, 185, 98, 100);
  623. color: #00b962;
  624. width: 44%;
  625. }
  626. }
  627. </style>