dcCharging.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  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="">
  21. <view class="info" >
  22. <view class="info-name">
  23. 充电时长
  24. </view>
  25. <view class="info-text">
  26. {{getPercent2()}}
  27. </view>
  28. </view>
  29. <view class="info" >
  30. <view class="info-name">
  31. 充电金额
  32. </view>
  33. <view class="info-text">
  34. {{chargingRecord.actualFee}}元
  35. </view>
  36. </view>
  37. <view class="info" >
  38. <view class="info-name">
  39. 优惠券
  40. </view>
  41. <view class="info-text" style="color:red">
  42. {{couponObj&&couponObj.status=='1'?couponObj.text:'未使用'}}
  43. </view>
  44. </view>
  45. <view class="info" v-if="chargingRecord.remark">
  46. <view class="info-name">
  47. 结束原因
  48. </view>
  49. <view class="info-text">
  50. {{chargingRecord.remark}}
  51. </view>
  52. </view>
  53. </view>
  54. <view
  55. style="
  56. margin-top: 20px;
  57. text-align: center;
  58. padding: 0 45px;
  59. padding-bottom: 40px;
  60. color:#9e9e9e;
  61. ">
  62. <span style="color: red;">*</span>实际充电金额与所选金额会略有出入,最终结算金额将以实际充入电量为准。
  63. </view>
  64. <view class="bottom">
  65. <u-button size="default" shape="circle" @click="gotoMain(0)" >返回首页</u-button>
  66. <u-button size="default" shape="circle" @click="gotoMain(1)">查看订单详情</u-button>
  67. </view>
  68. </view>
  69. <view style="background-color: #fff; padding-bottom: 60px;" v-else>
  70. <u-navbar title="充电详情">
  71. </u-navbar>
  72. <view class="iconfont tittle-font" @click="show = true">
  73. &#xe616;
  74. </view>
  75. <view class="progress-bar">
  76. <u-circle-progress width="440" active-color="green" :percent="percent?percent:percentValue" border-width="50">
  77. <view class="u-progress-content" v-if="chargingRecord.status==4">
  78. <text class='u-progress-info'>前方等待{{waitNum}}位</text>
  79. </view>
  80. <view class="u-progress-content" v-else-if="chargingGun.gunType==1">
  81. <text class='u-progress-info'>{{percent}}%</text>
  82. </view>
  83. <view class="u-progress-content" v-else-if="chargingGun.gunType==2">
  84. <text class='u-progress-info'>{{chargingRecord.statusText}}...</text>
  85. </view>
  86. <view class="bot"></view>
  87. </u-circle-progress>
  88. </view>
  89. <view class="starting" v-if="chargingGun.gunType==1">
  90. {{chargingRecord.statusText}}...
  91. </view>
  92. <view class="timer">
  93. {{timer}}
  94. </view>
  95. <view class="charged">
  96. 已充电{{chargingGun.kwh}}度
  97. </view>
  98. <view class="cost">
  99. <view class="">
  100. <view class="cost-top">
  101. {{chargingRecord.dueFee?chargingRecord.dueFee:0}}元
  102. </view>
  103. <view class="cost-bottom " >
  104. 实时费用
  105. </view>
  106. </view>
  107. <view class="line"></view>
  108. <view class="">
  109. <view class="cost-top">
  110. {{detail.balance}}元
  111. <view class="iconfont cost-font" @click="gotoUrl('pages/user/finance/recharge')" >&#xe633;</view>
  112. </view>
  113. <view class="cost-bottom">
  114. 账户余额
  115. </view>
  116. </view>
  117. </view>
  118. <view class="power">
  119. <view>
  120. <view class="power-num">
  121. {{chargingRecord.chargeVoltage?chargingRecord.chargeVoltage:0}}v
  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.chargingPower?chargingRecord.chargingPower/1000:0}}kW
  131. </view>
  132. <view class="power-text">
  133. 功率
  134. </view>
  135. </view>
  136. <view class="line"></view>
  137. <view>
  138. <view class="power-num">
  139. {{chargingRecord.chargeAmpere?chargingRecord.chargeAmpere:0}}A
  140. </view>
  141. <view class="power-text">
  142. 电流
  143. </view>
  144. </view>
  145. </view>
  146. <view class="info" >
  147. <view class="info-name">
  148. 优惠券
  149. </view>
  150. <view class="info-text" style="color:red">
  151. {{couponObj&&couponObj.useText?couponObj.useText:'未使用'}}
  152. </view>
  153. </view>
  154. <view class="info" v-if="chargingRecord.carNumber">
  155. <view class="info-name">
  156. 充电车辆
  157. </view>
  158. <view class="info-text">
  159. {{chargingRecord.carNumber}}
  160. </view>
  161. </view>
  162. <view class="info">
  163. <view class="info-name">
  164. 站点
  165. </view>
  166. <view class="info-text">
  167. {{chargingRecord.stationName}}
  168. </view>
  169. </view>
  170. <view class="info">
  171. <view class="info-name">
  172. 充电桩
  173. </view>
  174. <view class="info-text">
  175. {{chargingRecord.deviceName}}<br>
  176. {{chargingRecord.deviceNo}}
  177. </view>
  178. </view>
  179. <view class="info" v-if="false">
  180. <view class="info-name">
  181. 占位费说明
  182. </view>
  183. <view class="info-text">
  184. 停止充电后30分钟即开始收取占位费用,1元/分钟
  185. </view>
  186. </view>
  187. <view class="bottom2" >
  188. <u-button type="primary" @click="submit"
  189. :style="(chargingRecord.status==1||chargingRecord.status==4)?'background-color: #00b962':'background-color: #9be6c2;'"
  190. shape="circle" >结束充电</u-button>
  191. </view>
  192. <u-modal v-model="show" @confirm="confirmPhone"
  193. :confirm-text="confirmText" confirm-color="#606266"
  194. :show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title" :content="consumerPhone">
  195. </u-modal>
  196. <u-modal v-model="show2" @confirm="gotoGz"
  197. cancel-text="暂不关注" @cancel="cancelGz"
  198. confirm-text="前往关注"
  199. confirm-color="#53b56b"
  200. :show-cancel-button="true"
  201. ref="uModal2" :asyncClose="true"
  202. >
  203. <view style="padding: 15px;"
  204. >请关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,以便第一时间收到充电结束消息提醒</view>
  205. </u-modal>
  206. </view>
  207. </view>
  208. </template>
  209. <script>
  210. import * as API from '@/apis/chargeProcess.js'
  211. import * as API_weixin from '@/apis/weixin.js'
  212. import {
  213. secondsDistance,
  214. hourDistanceArr
  215. } from '@/utils'
  216. export default {
  217. data() {
  218. return {
  219. elderMode:false,
  220. timer:'',
  221. title: '联系客服',
  222. content: '0716-8123456',
  223. confirmText: '拨打电话',
  224. detail:{},
  225. percent: 0,
  226. percentValue: 0,
  227. consumerPhone: "",
  228. id: "",
  229. chargingGun: {},
  230. chargingRecord: {},
  231. couponObj:{},
  232. show: false,
  233. show2: false,
  234. isReady:true,
  235. waitNum:'',
  236. projectName:"",
  237. }
  238. },
  239. onLoad(op) {
  240. this.projectName=process.car.ProjectName;
  241. if (op.id) {
  242. this.id = op.id;
  243. this.init()
  244. this.getInfo()
  245. }
  246. var consumerPhone = this.carhelp.getConfig().consumerPhone
  247. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  248. if (consumerPhone) {
  249. this.consumerPhone = consumerPhone
  250. }
  251. },
  252. onUnload() {
  253. this.isReady=false;
  254. },
  255. onReady() {
  256. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  257. if(this.elderMode)
  258. this.theme('elder')
  259. else
  260. this.theme('standard')
  261. this.addpercent()
  262. },
  263. methods: {
  264. theme(type) {
  265. if(type == 'elder')
  266. {
  267. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  268. }
  269. else
  270. {
  271. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  272. }
  273. },
  274. cancelGz(){
  275. this.carhelp.setGzDate()
  276. },
  277. gotoGz(){
  278. this.carhelp.setGzDate()
  279. var url="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzg4Njc5ODEyMw==#wechat_redirect";
  280. window.location.href=url
  281. },
  282. gotoMain(i){
  283. if(i==0){
  284. uni.reLaunch({
  285. url:"/pages/index/index"
  286. })
  287. }
  288. if(i==1){
  289. uni.navigateTo({
  290. url:"/pages/record/details?id="+this.id
  291. })
  292. }
  293. },
  294. addpercent(){
  295. this.timer=this.getPercent()
  296. if(this.isReady){
  297. setTimeout(()=>{
  298. this.percentValue++;
  299. if(this.percentValue>=100){
  300. this.percentValue=0;
  301. }
  302. this.addpercent()
  303. },100)
  304. }
  305. },
  306. getPercent2() {
  307. var ms=this.chargingRecord.chargingMinute*60;
  308. var Hour = parseInt(Math.floor(ms / (60 * 60)));
  309. var Fen = parseInt(Math.floor(ms % (60 * 60) / 60));
  310. var S = parseInt(Math.floor(ms % (60) ));
  311. var obj = (Hour > 9 ? "" : "0") + Hour + ":" + (Fen > 9 ? "" : "0") + Fen+ ":" + (S > 9 ? "" : "0") + S
  312. return obj;
  313. },
  314. getPercent() {
  315. if(!this.chargingRecord.startTime){
  316. return '00:00:00'
  317. }
  318. var Hour=0;
  319. var Fen=0;
  320. var S=0;
  321. if (this.chargingRecord.status == 1) {
  322. var second = secondsDistance(this.chargingRecord.startTime);
  323. var ms=second;
  324. Hour = parseInt(Math.floor(ms / (60 * 60)));
  325. Fen = parseInt(Math.floor(ms % (60 * 60) / 60));
  326. S = parseInt(Math.floor(ms % (60) ));
  327. }
  328. var obj = (Hour > 9 ? "" : "0") + Hour + ":" + (Fen > 9 ? "" : "0") + Fen+ ":" + (S > 9 ? "" : "0") + S
  329. return obj;
  330. },
  331. init() {
  332. API.personalCenter().then((res) => {
  333. this.detail = res.data
  334. }).catch(error => {
  335. uni.showToast({
  336. title: error
  337. })
  338. })
  339. },
  340. checkSubscribe(){
  341. API_weixin.checkSubscribe({
  342. openId: this.carhelp.getOpenId()
  343. }).then((res) => {
  344. if(res.data=="0"){
  345. this.show2=true;
  346. }else{
  347. this.carhelp.setGzDate()
  348. }
  349. //setGzDate
  350. }).catch(error => {
  351. uni.showToast({
  352. title: error
  353. })
  354. })
  355. },
  356. confirmPhone() {
  357. this.show = false;
  358. uni.makePhoneCall({
  359. phoneNumber: this.consumerPhone //仅为示例
  360. });
  361. },
  362. getInfo() {
  363. // uni.showLoading({
  364. // title: "加载中",
  365. // mask: true,
  366. // })
  367. API.chargingDetail({
  368. id: this.id
  369. }).then((res) => {
  370. this.chargingRecord = res.data.chargingRecord
  371. //(this.chargingRecord)
  372. this.couponObj= res.data.coupon
  373. this.chargingGun = res.data.chargingGun
  374. this.waitNum=res.data.chargingRecord.waitNum;
  375. this.isReady = true;
  376. //直流
  377. if(this.chargingGun.gunType==1){
  378. if (this.chargingRecord.status == 1) {
  379. this.percent=this.chargingGun.soc
  380. // var second = secondsDistance(this.chargingRecord.startTime);
  381. // var percent = (second / 60) / this.chargingRecord.estimateMinute * 100;
  382. // //(this.percent)
  383. // var sum=this.chargingGun.chargeTimeSec/60+this.chargingGun.remainMin;
  384. // if(sum){
  385. // this.percent=this.chargingGun.chargeTimeSec/60/sum*100
  386. // }
  387. }
  388. }else if(this.chargingGun.gunType==2){
  389. //交流
  390. }
  391. if (this.chargingRecord.status == 1) {
  392. if(this.carhelp.getGzDate()&&!this.show2){
  393. this.checkSubscribe()
  394. }
  395. }
  396. if(this.isReady&&this.chargingRecord.status!=2){
  397. var time=500;
  398. if(this.chargingRecord.status==0){
  399. }else{
  400. time=3000;
  401. this.init();
  402. }
  403. setTimeout(()=>{
  404. this.getInfo();
  405. },time)
  406. }
  407. uni.hideLoading()
  408. }).catch(error => {
  409. uni.showToast({
  410. title: error
  411. })
  412. })
  413. },
  414. submit() {
  415. if(this.chargingRecord.status==1||this.chargingRecord.status==4){
  416. }else{
  417. return
  418. }
  419. uni.showModal({
  420. title: '提示',
  421. content: '确认结束充电?',
  422. success: res => {
  423. if (res.confirm) {
  424. //付钱 改为组件
  425. this.confirm()
  426. } else if (res.cancel) {
  427. //('用户点击取消');
  428. }
  429. }
  430. });
  431. },
  432. confirm() {
  433. ////(JSON.stringify(this.submitForm))
  434. uni.showLoading({
  435. title: "加载中",
  436. mask: true,
  437. })
  438. //this.submitForm.deviceNo = this.detail.deviceNo;
  439. API.stopCarCharging({
  440. chargingRecordId:this.chargingRecord.id
  441. }).then((res) => {
  442. this.getInfo()
  443. }).catch(error => {
  444. uni.showToast({
  445. title: error
  446. })
  447. })
  448. },
  449. }
  450. }
  451. </script>
  452. <style>
  453. page {
  454. background: #fff;
  455. padding-bottom: 50px;
  456. }
  457. </style>
  458. <style lang="scss" scoped>
  459. @import "@/_theme.scss";
  460. .tittle-font {
  461. @include themeify{
  462. font-size: themed('font-size7');
  463. }
  464. /* font-size: 24px;*/
  465. position: fixed;
  466. top: 12px;
  467. right: 16px;
  468. z-index: 99999;
  469. }
  470. .bot {
  471. width:100%;
  472. height:0;
  473. padding-top: 100%;
  474. border: 2px #00b962 dotted;
  475. border-radius:100%;
  476. box-sizing: border-box;
  477. position: absolute;
  478. top: 0px;
  479. left: 0px;
  480. right: 0px;
  481. margin: auto;
  482. }
  483. .progress-bar {
  484. text-align: center;
  485. margin-top: 20px;
  486. /deep/.u-circle-progress {
  487. position: relative;
  488. // min-width:220px;
  489. // min-height: 220px;
  490. }
  491. .u-progress-content {
  492. display: flex;
  493. align-items: center;
  494. justify-content: center;
  495. }
  496. .u-progress-dot {
  497. width: 16rpx;
  498. height: 16rpx;
  499. border-radius: 50%;
  500. background-color: #fb9126;
  501. }
  502. .u-progress-info {
  503. @include themeify{
  504. font-size: themed('font-size6');
  505. }
  506. /* font-size: 22px;*/
  507. padding-left: 16rpx;
  508. letter-spacing: 2rpx;
  509. color: rgba(51, 51, 51, 100);
  510. }
  511. /deep/.u-progress-dot[data-v-05b104e0] {
  512. display: none;
  513. }
  514. /deep/.u-circle-progress[data-v-cab6fc66] {
  515. margin: 30px;
  516. }
  517. }
  518. .starting {
  519. /* height: 22px;*/
  520. color: rgba(0, 185, 98, 100);
  521. @include themeify{
  522. font-size: themed('font-size3');
  523. height:themed('font-size6');
  524. }
  525. /* font-size: 16px;*/
  526. text-align: center;
  527. margin-top: 10px;
  528. }
  529. .timer {
  530. height: 43px;
  531. color: rgba(51, 51, 51, 100);
  532. @include themeify{
  533. font-size: themed('font-size13');
  534. }
  535. /* font-size: 36px;*/
  536. text-align: center;
  537. margin-top: 40px;
  538. }
  539. .charged {
  540. /* height: 20px;*/
  541. color: rgba(153, 153, 153, 100);
  542. @include themeify{
  543. font-size: themed('font-size2');
  544. height:themed('font-size5')
  545. }
  546. /* font-size: 14px;*/
  547. text-align: center;
  548. margin-top: 4px;
  549. }
  550. .cost {
  551. // width: 50%;
  552. padding: 0 50px;
  553. margin-top: 16px;
  554. margin: auto;
  555. width: 280px;
  556. display: flex;
  557. justify-content: space-between;
  558. .cost-top {
  559. line-height: 33px;
  560. text-align: center;
  561. @include themeify{
  562. font-size: themed('font-size7');
  563. }
  564. /* font-size: 24px;*/
  565. position: relative;
  566. .cost-font {
  567. position: absolute;
  568. top: 0;
  569. right: -25px;
  570. color: #ff6200;
  571. @include themeify{
  572. font-size: themed('font-size7');
  573. }
  574. /* font-size: 24px*/
  575. }
  576. }
  577. .cost-bottom {
  578. @include themeify{
  579. line-height: themed('font-size5');
  580. }
  581. /* line-height: 20px;*/
  582. color: #999999;
  583. text-align: center;
  584. }
  585. }
  586. .line {
  587. width: 0;
  588. height: 36px;
  589. border: 1px solid rgba(237, 237, 237, 100);
  590. margin-top: 10px;
  591. background-color: #ededed;
  592. }
  593. .power {
  594. display: flex;
  595. justify-content: space-around;
  596. padding: 0 55px;
  597. margin-top: 40px;
  598. .power-num {
  599. /* height: 27px;*/
  600. color: rgba(51, 51, 51, 100);
  601. @include themeify{
  602. font-size: themed('font-size5');
  603. height: themed('font-size9');
  604. }
  605. /* font-size: 20px;*/
  606. text-align: center;
  607. }
  608. .power-text {
  609. /* height: 20px;*/
  610. color: rgba(153, 153, 153, 100);
  611. @include themeify{
  612. font-size: themed('font-size2');
  613. height: themed('font-size5');
  614. }
  615. /* font-size: 14px;*/
  616. text-align: center;
  617. }
  618. }
  619. .info {
  620. display: flex;
  621. justify-content: space-between;
  622. margin: 0 40px;
  623. // height: 48px;
  624. line-height: 48px;
  625. background-color: rgba(255, 255, 255, 100);
  626. color: rgba(16, 16, 16, 100);
  627. border-bottom: 1px solid #ededed;
  628. .info-text {
  629. @include themeify{
  630. line-height: themed('font-size7');
  631. }
  632. /* line-height: 23px;*/
  633. padding: 13px 0 12px;
  634. //width: 200px;
  635. text-align: right;
  636. }
  637. }
  638. .bottom2 {
  639. padding: 12px 20px;
  640. background-color: #fff;
  641. position: fixed;
  642. bottom: 0;
  643. left: 0;
  644. right: 0;
  645. margin: auto;
  646. }
  647. .progress-bar2 {
  648. text-align: center;
  649. margin-top: 20px;
  650. /deep/.u-circle-progress {
  651. // margin-left: 23.3% !important;
  652. position: relative;
  653. }
  654. .u-progress-content {
  655. display: flex;
  656. align-items: center;
  657. justify-content: center;
  658. }
  659. .u-progress-dot {
  660. width: 16rpx;
  661. height: 16rpx;
  662. border-radius: 50%;
  663. background-color: #fb9126;
  664. }
  665. .u-progress-info {
  666. display: block;
  667. @include themeify{
  668. font-size: themed('font-size11');
  669. }
  670. /* font-size: 32px;*/
  671. padding-left: 16rpx;
  672. letter-spacing: 2rpx;
  673. color: rgba(51, 51, 51, 100);
  674. .progress-text {
  675. @include themeify{
  676. font-size: themed('font-size2');
  677. }
  678. /* font-size: 14px;*/
  679. text-align: center;
  680. color: #666666;
  681. }
  682. }
  683. /deep/.u-progress-dot[data-v-05b104e0] {
  684. display: none;
  685. }
  686. /deep/.u-circle-progress[data-v-cab6fc66] {
  687. margin: 30px;
  688. }
  689. }
  690. .time-price {
  691. display: flex;
  692. justify-content: space-between;
  693. padding: 0 65px;
  694. .item-num {
  695. /* height: 33px;*/
  696. color: rgba(51, 51, 51, 100);
  697. @include themeify{
  698. font-size: themed('font-size7');
  699. height:themed('font-size12')
  700. }
  701. /* font-size: 24px;*/
  702. text-align: center;
  703. }
  704. .item-text {
  705. eight: 20px;
  706. color: rgba(153, 153, 153, 100);
  707. @include themeify{
  708. font-size: themed('font-size2');
  709. }
  710. /* font-size: 14px;*/
  711. text-align: center;
  712. }
  713. }
  714. .bottom {
  715. background-color: #fff;
  716. display: flex;
  717. width: 91.4%;
  718. padding: 12px 16px;
  719. position: fixed;
  720. bottom: 0;
  721. left: 0;
  722. right: 0;
  723. margin: auto;
  724. .u-size-default {
  725. border: 1px solid rgba(0, 185, 98, 100);
  726. color: #00b962;
  727. width: 44%;
  728. }
  729. }
  730. </style>