charging.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. <template>
  2. <div class="main-page">
  3. <!-- #ifndef MP-ALIPAY -->
  4. <u-navbar
  5. :border-bottom="false"
  6. :title="statusOptions[orderInfo.status]"
  7. back-icon-color="#fff"
  8. title-color="#fff"
  9. class="header-only-back"
  10. :back-icon-name="pagesLength == 1 ? 'home' : 'arrow-left'"
  11. :background="{ background: 'tranparent' }"
  12. :custom-back="back"
  13. ></u-navbar>
  14. <!-- #endif -->
  15. <view class="product-container" :style="{ height: productRefHeight }">
  16. <scroll-view scroll-anchoring enableBackToTop="true" scroll-y class="scroll-page" :scroll-top="tabScrollTop">
  17. <!-- 枪未开放,或有故障 -->
  18. <view v-if="orderInfo.status == 0 || orderInfo.status == 255">
  19. <view style="margin-top:200rpx;padding:30rpx 20rpx;display: flex;color:#fff;">
  20. <image style="width: 80rpx; height: 80rpx;margin-right:20rpx;" src="/static/index/connector.png" mode="scaleToFill" />
  21. <view style="flex:1">
  22. <view style="font-size:32rpx;">无法使用,请尝试其他充电枪</view>
  23. <view style="font-size:24rpx;">枪编号 {{ routerVal.id }}</view>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 枪被其他用户充电中 -->
  28. <view v-if="orderInfo.status == 5">
  29. <view style="margin-top:200rpx;padding:30rpx 20rpx;display: flex;color:#fff;">
  30. <image style="width: 80rpx; height: 80rpx;margin-right:20rpx;" src="/static/index/connector.png" mode="scaleToFill" />
  31. <view style="flex:1">
  32. <view style="font-size:32rpx;">已经有人在充电了哦,请使用其他枪</view>
  33. <view style="font-size:24rpx;">枪编号 {{ routerVal.id }}</view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 未插枪,空闲状态 -->
  38. <view v-if="orderInfo.status == 1">
  39. <view style="margin-top:200rpx;padding:30rpx 20rpx;display: flex;color:#fff;">
  40. <image style="width: 80rpx; height: 80rpx;margin-right:20rpx;" src="/static/index/connector.png" mode="scaleToFill" />
  41. <view style="flex:1">
  42. <view style="font-size:32rpx;">请先插枪</view>
  43. <view style="font-size:24rpx;">枪编号 {{ routerVal.id }}</view>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 已插枪 -->
  48. <view v-if="orderInfo.status == 2">
  49. <view style="margin-top:200rpx;padding:30rpx 20rpx;display: flex;color:#fff;">
  50. <image style="width: 80rpx; height: 80rpx;margin-right:20rpx;" src="/static/index/connector.png" mode="scaleToFill" />
  51. <view style="flex:1">
  52. <view style="font-size:32rpx;">已插枪</view>
  53. <view style="font-size:24rpx;">枪编号 {{ routerVal.id }}</view>
  54. </view>
  55. </view>
  56. <!-- 基本信息 -->
  57. <view class="card-box" style="padding:30rpx 20rpx;">
  58. <view class="card-row">
  59. <view class="lable">站点名称</view>
  60. <view class="content">{{ equipmentInfo.stationName }}</view>
  61. </view>
  62. <view class="card-row">
  63. <view class="lable">设备编号</view>
  64. <view class="content">{{ equipmentInfo.equipmentId }}</view>
  65. </view>
  66. <view class="card-row">
  67. <view class="lable">终端类型</view>
  68. <view class="content">{{ equipmentInfo.type == 1 ? '快充' : '慢充' }}</view>
  69. </view>
  70. <view class="card-row">
  71. <view class="lable">功率</view>
  72. <view class="content">{{ equipmentInfo.power }}kW</view>
  73. </view>
  74. </view>
  75. <!-- 充电与停车费 -->
  76. <view class="card-box">
  77. <view class="card-flex set-image" @click="shutMask">
  78. <u-image width="40rpx" height="40rpx" src="/static/index/electric.png"></u-image>
  79. <u-image width="40rpx" height="40rpx" src="/static/index/car-parking.png"></u-image>
  80. <view class="card-title">充电与停车费</view>
  81. <view class="card-content">¥{{ curnetPrice.price | unitPrice }}/度</view>
  82. <view class="card-bottom">
  83. <u-icon name="more-dot-fill"></u-icon>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 预充金额 -->
  88. <view class="card-box">
  89. <view class="card-flex">
  90. <view class="card-title charge-amount">
  91. 预充金额
  92. <u-row gutter="16">
  93. <u-col span="3" v-for="(a, aIndex) in chargeMaxAmount" :key="a">
  94. <view :class="['radio-button', { isActive: aIndex == chargeAmountIndex }]" v-if="aIndex < 2" @click="radioChange(aIndex)">{{ a }}元</view>
  95. <view :class="['radio-button', { isActive: aIndex == chargeAmountIndex }]" v-if="aIndex == 2" @click="radioChange(aIndex)">充满</view>
  96. <!-- #ifdef MP-ALIPAY -->
  97. <view :class="['amount-input', { isActive: aIndex == chargeAmountIndex }]" v-if="aIndex == 3" @click="radioChange(aIndex)">
  98. <input
  99. @input="chargeMaxAmountChange($event)"
  100. type="number"
  101. placeholder="其他金额"
  102. placeholder-style="font-size: 28rpx"
  103. :value="chargeMaxAmount[3]"
  104. />
  105. </view>
  106. <!-- #endif -->
  107. <!-- #ifndef MP-ALIPAY -->
  108. <input
  109. :class="['radio-button', { isActive: aIndex == chargeAmountIndex }]"
  110. v-if="aIndex == 3"
  111. @input="chargeMaxAmountChange($event)"
  112. @click="radioChange(aIndex)"
  113. type="number"
  114. placeholder="其他金额"
  115. :value="chargeMaxAmount[3]"
  116. />
  117. <!-- #endif -->
  118. </u-col>
  119. </u-row>
  120. <view class="card-row" style="margin-bottom: -20rpx;">
  121. <view class="small">充电过程中,可随时停止充电,费用按实际充电量收取。</view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <!-- 充电中 -->
  128. <view v-if="orderInfo.status == 3">
  129. <view style="margin-top:200rpx;">
  130. <view style="margin-top:150rpx;padding:30rpx 20rpx;display: flex;color:#fff;">
  131. <u-circle-progress active-color="#0089c9" bg-color="transparent" width="80" :percent="equipmentInfo.soc" :show="orderInfo.status == 3"></u-circle-progress>
  132. <view style="flex:1">
  133. <view style="font-size:32rpx;">充电中</view>
  134. <view style="font-size:24rpx;">{{Number(equipmentInfo.soc)}}%</view>
  135. </view>
  136. </view>
  137. <!-- 基本信息 -->
  138. <view class="card-box" style="padding:30rpx 20rpx;">
  139. <view class="card-row">
  140. <view class="lable">站点名称</view>
  141. <view class="content">{{ equipmentInfo.stationName }}</view>
  142. </view>
  143. <view class="card-row">
  144. <view class="lable">充电枪编号</view>
  145. <view class="content">{{ equipmentInfo.connectorId }}</view>
  146. </view>
  147. </view>
  148. <!-- 充电参数,只在枪对应的订单状态是2 充电中时,才显示 -->
  149. <view class="card-box" style="padding:30rpx 20rpx;" v-if="equipmentInfo.status == 2">
  150. <view class="card-title">充电详情</view>
  151. <view class="card-row">
  152. <view class="lable">充电电量</view>
  153. <view class="content">{{ equipmentInfo.totalPower }}度</view>
  154. </view>
  155. <view class="card-row">
  156. <view class="lable">充电时长</view>
  157. <view class="content">{{ chargeDurStr }}</view>
  158. </view>
  159. <view class="card-row">
  160. <view class="lable">充电金额</view>
  161. <view class="content">¥{{ equipmentInfo.totalMoney }}</view>
  162. </view>
  163. </view>
  164. <!-- 参数 -->
  165. <view
  166. class="card-swapper"
  167. v-if="equipmentInfo.status == 1 || equipmentInfo.status == 3 || (equipmentInfo.status == 4 && equipmentInfo.orderStatus == 10)"
  168. >
  169. <u-row gutter="8">
  170. <u-col span="12">
  171. <view class="label">
  172. <view class="number">
  173. <u-loading mode="circle" size="64" color="#00d591"></u-loading>
  174. </view>
  175. <view class="label" v-if="equipmentInfo.status == 1">启动中...</view>
  176. <view class="label" v-if="equipmentInfo.status == 3">停止中...</view>
  177. </view>
  178. </u-col>
  179. </u-row>
  180. </view>
  181. </view>
  182. <u-modal
  183. show-cancel-button
  184. v-model="endChargeShow"
  185. @confirm="endCharge"
  186. :confirm-color="lightColor"
  187. :async-close="true"
  188. :content="'确定要结束充电么?'"
  189. ></u-modal>
  190. </view>
  191. <!-- 充电结束,占位中 -->
  192. <view v-if="orderInfo.status == 98">
  193. <view style="margin-top:200rpx;padding:30rpx 20rpx;display: flex;color:#fff;">
  194. <image style="width: 80rpx; height: 80rpx;margin-right:20rpx;" src="/static/index/connector.png" mode="scaleToFill" />
  195. <view style="flex:1">
  196. <view style="font-size:32rpx;">充电结束,请拔枪</view>
  197. </view>
  198. </view>
  199. </view>
  200. <!-- 结算订单 -->
  201. <view v-if="orderInfo.status == 99">
  202. <view style="margin-top:150rpx;padding:30rpx 20rpx;display: flex;color:#fff;">
  203. <image style="width: 80rpx; height: 80rpx;margin:0 20rpx;" src="/static/index/order-wait.png" mode="scaleToFill" />
  204. <view style="flex:1">
  205. <view style="font-size:32rpx;">充电详情</view>
  206. <view style="font-size:24rpx;">订单已支付</view>
  207. </view>
  208. </view>
  209. <!-- 基本信息 -->
  210. <view class="card-box" style="padding:30rpx 20rpx;">
  211. <view class="card-row">
  212. <view class="lable">站点名称</view>
  213. <view class="content">{{ equipmentInfo.stationName }}</view>
  214. </view>
  215. <view class="card-row">
  216. <view class="lable">充电枪编号</view>
  217. <view class="content">{{ equipmentInfo.connectorId }}</view>
  218. </view>
  219. </view>
  220. <view class="card-box" style="padding:30rpx 20rpx;">
  221. <view class="card-title">充电详情</view>
  222. <view class="card-row">
  223. <view class="lable">充电开始时间</view>
  224. <view class="content">{{ equipmentInfo.startTime }}</view>
  225. </view>
  226. <view class="card-row">
  227. <view class="lable">充电结束时间</view>
  228. <view class="content">{{ equipmentInfo.endTime }}</view>
  229. </view>
  230. <view class="card-row">
  231. <view class="lable">充电时长</view>
  232. <view class="content">{{ chargeDurStr }}</view>
  233. </view>
  234. <view class="card-row">
  235. <view class="lable">充电量</view>
  236. <view class="content">{{ equipmentInfo.totalPower }}度</view>
  237. </view>
  238. </view>
  239. <view class="card-box" style="padding:30rpx 20rpx;">
  240. <view class="card-title">费用详情</view>
  241. <view class="card-row">
  242. <view class="lable">充电费</view>
  243. <view class="content">¥{{ equipmentInfo.totalElecMoney | unitPrice }}</view>
  244. </view>
  245. <view class="card-row">
  246. <view class="lable">服务费</view>
  247. <view class="content">¥{{ equipmentInfo.totalServiceMoney | unitPrice }}</view>
  248. </view>
  249. <view class="card-row">
  250. <view class="lable">订单总额</view>
  251. <view class="content">
  252. ¥{{ (equipmentInfo.totalMoney) |
  253. unitPrice }}
  254. </view>
  255. </view>
  256. <view class="card-row">
  257. <view class="lable"></view>
  258. <view class="content">
  259. 实际支付
  260. <text class="actual-pay">
  261. ¥{{ equipmentInfo.totalMoney |
  262. unitPrice }}
  263. </text>
  264. </view>
  265. </view>
  266. </view>
  267. <view class="card-box" style="padding:30rpx 20rpx;">
  268. <view class="card-title">支付详情</view>
  269. <view class="card-row">
  270. <view class="lable">订单号</view>
  271. <view class="content">{{ equipmentInfo.startChargeSeq }}</view>
  272. </view>
  273. </view>
  274. </view>
  275. <view style="height:40rpx;text-align:center;padding-top:10rpx;" v-if="orderInfo.status == 2 || orderInfo.status == 99"></view>
  276. </scroll-view>
  277. <view class="page-bottom">
  278. <view class="icon-btn">
  279. <view class="icon-btn-item" @click="linkMsgDetail()">
  280. <u-icon size="34" name="kefu-ermai"></u-icon>
  281. <view class="icon-btn-name">客服</view>
  282. </view>
  283. </view>
  284. <!-- 正常结算页面 -->
  285. <view class="detail-btn">
  286. <view class="button" @click="charge()" v-if="orderInfo.status == 2">启动充电</view>
  287. <view class="button" @click="endChargeShow = true" v-if="orderInfo.status == 3">结束充电</view>
  288. <view class="button" @click="back()" v-if="orderInfo.status == 99">完成</view>
  289. </view>
  290. </view>
  291. </view>
  292. <!-- 规格-模态层弹窗 -->
  293. <view v-if="orderInfo.status == 2">
  294. <!-- 价格弹窗 -->
  295. <u-popup
  296. v-model="priceShow"
  297. :height="setup.height"
  298. :mode="setup.mode"
  299. :border-radius="setup.radius"
  300. @close="priceShow = false"
  301. :mask-close-able="setup.close"
  302. closeable
  303. >
  304. <view class="price-title">费用</view>
  305. <scroll-view class="scroll_mask" :scroll-y="true">
  306. <!-- 价格 -->
  307. <PriceCom :stationData="stationInfo" :currentTimeIndex="curnetPrice.currentTimeIndex" />
  308. <!-- 空白 -->
  309. <view style="height:80rpx;"></view>
  310. </scroll-view>
  311. </u-popup>
  312. </view>
  313. <u-top-tips ref="uTips" :navbar-height="statusBarHeight"></u-top-tips>
  314. </div>
  315. </template>
  316. <script>
  317. /************接口API***************/
  318. import { getConnector, getStation } from "@/api/station.js";
  319. import { startCharge, stopCharge, getOrderDetail, setOrderNofity } from "@/api/order.js";
  320. import Foundation from "@/utils/Foundation.js";
  321. import { serviceCall } from "@/utils/tools.js";
  322. import config from "@/config/config";
  323. /************组件***************/
  324. import PriceCom from "./components/-price"; //价格组件
  325. import Progress from "@/components/progress/progress"; //气泡框
  326. export default {
  327. components: {
  328. PriceCom,
  329. Progress
  330. },
  331. data() {
  332. return {
  333. endChargeShow: false,
  334. lightColor: this.$lightColor, //高亮颜色
  335. equipmentInfo: { soc: 0, status: 0 },
  336. stationInfo: { priceList: [] },
  337. // 状态栏高度,H5中,此值为0,因为H5不可操作状态栏
  338. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  339. soc: 0,
  340. orderInfo: { status: -1 },
  341. orderInfoUpdateTimeout: null,
  342. orderInfoUpdateTime: 5000,
  343. curnetPrice: {
  344. currentTimeIndex: null,
  345. price: null,
  346. },
  347. chargeMaxAmount: [30, 50, -1, undefined],
  348. //弹出窗设置
  349. setup: {
  350. height: "1000rpx", //弹出层高度
  351. mode: "bottom", //弹出层位置
  352. radius: "30", //圆角 rpx,
  353. close: true //能否点击遮罩退出
  354. },
  355. priceShow: false, //弹窗开关
  356. navbarOnlyBack: {
  357. background: "transparent",
  358. },
  359. navbar: {
  360. background: "#fff",
  361. },
  362. productRefHeight: "",
  363. header: {
  364. top: 0,
  365. height: 50,
  366. },
  367. tabScrollTop: null,
  368. routerVal: "",
  369. countStart: 0,
  370. statusOptions: ['', '未插枪', '准备充电', '充电中', '充电结束', '充电中'],
  371. chargeAmountIndex: 2,
  372. pagesLength: getCurrentPages().length,
  373. //缓存充电时间
  374. chargeDurInt: 0,
  375. //缓存充电时间字符
  376. chargeDurStr: '0',
  377. shouldRetry: true,
  378. };
  379. },
  380. onUnload() {
  381. // 退出页面时,清除轮询任务
  382. this.orderInfoUpdateTimeout && clearTimeout(this.orderInfoUpdateTimeout)
  383. },
  384. mounted() {
  385. const { windowHeight } = uni.getSystemInfoSync();
  386. let bottomHeight = 0;
  387. let topHeight = 0;
  388. let _this = this
  389. uni.getSystemInfo({
  390. success: function (res) {
  391. // res - 各种参数
  392. let bottom = uni.createSelectorQuery().select(".page-bottom");
  393. bottom
  394. .boundingClientRect(function (data) {
  395. if (data && data.height) {
  396. //data - 各种参数
  397. bottomHeight = data.height; // 获取元素宽度
  398. _this.productRefHeight = windowHeight - bottomHeight - topHeight + "px";
  399. }
  400. })
  401. .exec();
  402. let top = uni.createSelectorQuery().select(".header");
  403. top
  404. .boundingClientRect(function (data) {
  405. if (data && data.height) {
  406. //data - 各种参数
  407. topHeight = data.height; // 获取元素宽度
  408. }
  409. })
  410. .exec();
  411. },
  412. });
  413. },
  414. onLoad(options) {
  415. this.routerVal = options;
  416. // #ifdef MP-WEIXIN
  417. uni.showShareMenu({
  418. withShareTicket: true,
  419. menus: ["shareAppMessage", "shareTimeline"],
  420. });
  421. let qid = Foundation.urlParse(decodeURIComponent(options.q)).n
  422. if (qid) {
  423. this.routerVal.id = qid
  424. }
  425. // #endif
  426. // #ifdef MP-ALIPAY
  427. //存储支付宝扫码参数
  428. const connectId = getApp().globalData.connectId
  429. getApp().globalData.connectId = null
  430. if (connectId != null) {
  431. this.routerVal.id = connectId
  432. }
  433. // #endif
  434. },
  435. onShow() {
  436. if (this.$options.filters.isLogin("auth")) {
  437. this.init(this.routerVal.id);
  438. this.$nextTick(() => {
  439. this.$refs.carRef && this.$refs.carRef.reload();
  440. })
  441. } else {
  442. this.$options.filters.navigateToLogin("navigateTo", true);
  443. }
  444. },
  445. methods: {
  446. updateCountStart() {
  447. this.countStart = Number(this.equipmentInfo.soc)
  448. },
  449. share() {
  450. return `/pages/station/index?id=${this.routerVal.id}&goodsId=${this.routerVal.goodsId}`;
  451. },
  452. radioChange(index) {
  453. this.chargeAmountIndex = index
  454. },
  455. chargeMaxAmountChange(e) {
  456. this.chargeMaxAmount[3] = e.target.value
  457. },
  458. /**
  459. * 初始化信息
  460. */
  461. async init(id) {
  462. let response = await getConnector({ connectorId: id, hasPrice: 1 });
  463. if (response.data.code == 401) {
  464. this.$options.filters.navigateToLogin("navigateTo", true);
  465. } else if (response.data.code == 500) {
  466. //充电桩被他人使用中
  467. this.$set(this.orderInfo, 'status', 5)
  468. } else if (response.data.code == 200) {
  469. this.$set(this.orderInfo, 'status', response.data.data.status)
  470. this.$set(this.orderInfo, 'startChargeSeq', response.data.data.startChargeSeq)
  471. // 如果检查到枪在充电中,则去拿枪对应的订单信息
  472. if (this.orderInfo.status != 4 || this.orderInfo.orderStatus != 30 || (this.orderInfo.billInfo && this.orderInfo.billInfo.occupyFlag != 0)) {
  473. this.getChargeInfo()
  474. }
  475. console.log("getConnector", response.data.data)
  476. this.equipmentInfo = Object.assign({}, response.data.data, { soc: 0 });
  477. let stationRes = await getStation(response.data.data.stationId);
  478. this.stationInfo = stationRes.data.data
  479. // 枪详情返回价格详情后,加到
  480. this.$set(this.stationInfo, 'priceList', this.equipmentInfo.priceList)
  481. // 获取当时时段价格
  482. let myDate = new Date();
  483. let currentTime = this.$u.timeFormat(myDate, 'hhMM');
  484. this.curnetPrice.currentTimeIndex = null;
  485. this.curnetPrice.price = null;
  486. response.data.data.priceList.forEach((t, tIndex) => {
  487. if (Number(currentTime) >= Number(t.startTm) && Number(currentTime) < Number(t.endTm)) {
  488. this.curnetPrice.currentTimeIndex = tIndex;
  489. this.curnetPrice.price = Number(t.elecPrice) + Number(t.servicePrice);
  490. }
  491. })
  492. }
  493. this.updateNavigationBarTitle()
  494. if (this.shouldRetry == true && response.data && response.data.data?.status != 2) {
  495. this.shouldRetry = false
  496. setTimeout(() => {
  497. this.init(id)
  498. }, 5000);
  499. }
  500. },
  501. navigateTo(url) {
  502. uni.navigateTo({
  503. url,
  504. });
  505. },
  506. linkMsgDetail() {
  507. serviceCall(this.stationInfo.servicePhone || config.customerServiceMobile)
  508. },
  509. /**
  510. * 返回
  511. */
  512. back() {
  513. console.log(this.pagesLength);
  514. if (this.pagesLength == 1) {
  515. uni.switchTab({
  516. url: "/pages/tabbar/station/stationList",
  517. });
  518. } else {
  519. uni.navigateBack();
  520. }
  521. },
  522. /**
  523. * 规格弹窗开关
  524. */
  525. shutMask() {
  526. this.priceShow = true;
  527. },
  528. charge() {
  529. // 点击先进充电中状态等待接口返回,以防止多次点击
  530. this.$set(this.orderInfo, 'status', 3)
  531. this.$set(this.equipmentInfo, 'status', 1)
  532. this.tabScrollTop = 0
  533. let postData = {
  534. connectorId: this.routerVal.id,
  535. type: this.chargeAmountIndex == 2 ? 1 : 2, //充电类型 1、充满;2、按金额充电
  536. money: Number(this.chargeMaxAmount[this.chargeAmountIndex]),
  537. userFlag: 1
  538. }
  539. startCharge(postData).then((res) => {
  540. if (res.data.code == 200) {
  541. this.orderInfo = Object.assign({ startChargeSeq: res.data.data.startChargeSeq }, { status: 3 })
  542. this.$refs.uTips.show({ title: "启动成功", type: "success" });
  543. // 开始轮询状态变化
  544. this.getChargeInfo()
  545. // 请求通知授权,仅微信支持
  546. // #ifdef MP-WEIXIN
  547. this.requestNotify(res.data.data.data)
  548. // #endif
  549. } else {
  550. this.$refs.uTips.show({ title: res.data.msg, type: "error" });
  551. this.orderInfo.status = 2
  552. }
  553. });
  554. },
  555. requestNotify(startChargeSeq) {
  556. let tmplIds = config.wxNotifyKey
  557. uni.requestSubscribeMessage({
  558. tmplIds,
  559. success(res) {
  560. tmplIds.map(t => {
  561. if (res[t] === 'accept') {
  562. // console.log("用户订阅了启动充电");
  563. setOrderNofity({
  564. startChargeSeq,
  565. tempId: t
  566. })
  567. } else if (res[t] === 'reject') {
  568. // console.log("用户取消订阅启动充电");
  569. } else {
  570. wx.showToast({
  571. title: '授权启动充电订阅消息有误',
  572. icon: 'error'
  573. })
  574. }
  575. })
  576. },
  577. fail: (errCode, errMessage) => {
  578. console.log("订阅消息 失败 " + errCode + " message " + errMessage);
  579. },
  580. });
  581. },
  582. async getChargeInfo() {
  583. // if (this.orderInfo.status == 3 || this.orderInfo.status == 99) {
  584. let res = await getOrderDetail(this.orderInfo.startChargeSeq);
  585. if (res.data.code == 200 && res.data.data != null) {
  586. this.equipmentInfo = res.data.data;
  587. //TODO 改为使用startChargeSeqStat
  588. this.equipmentInfo.status = this.equipmentInfo.startChargeSeqStat
  589. console.log("getOrderDetail", this.equipmentInfo)
  590. // this.equipmentInfo.chargeDurInt = parseInt(this.equipmentInfo.chargeDur)
  591. // 云快充soc是0-1 星云是0-100
  592. this.$set(this.equipmentInfo, 'soc', this.equipmentInfo.soc)
  593. this.$set(this.equipmentInfo, 'currentP', this.equipmentInfo.currentP ? parseInt(this.equipmentInfo.currentP / 1000) : 0)
  594. if ([1, 2].includes(this.equipmentInfo.status)) {
  595. this.updateChargeDur()
  596. } else {
  597. this.clearChargeDurTimer();
  598. }
  599. /*
  600. * 订单充电状态bill 1 启动中 2 充电中 3 停止中 4 已停止
  601. * 订单支付状态order(10进行中 20取消 21待取消 30已完成 40异常订单)
  602. * 只有充电枪状态=4且订单状态=30时,表示充电已停止且订单已结算时,才结算轮巡请求,显示最终订单确认。
  603. */
  604. if (this.equipmentInfo.status == 4 && this.equipmentInfo.orderStatus == 30 && this.equipmentInfo.billInfo.occupyPrice > 0 && this.equipmentInfo.billInfo.occupyFlag == 1) {
  605. this.$set(this.orderInfo, 'status', 98)
  606. }
  607. if (this.equipmentInfo.status == 4) {
  608. this.$set(this.orderInfo, 'status', 99)
  609. this.$refs.uTips.show({ title: "充电结束", type: "success" });
  610. } else if (this.equipmentInfo.status == 5 || (this.equipmentInfo.status == 4 && this.equipmentInfo.orderStatus == 40)) {
  611. this.$set(this.orderInfo, 'status', 99)
  612. this.$refs.uTips.show({ title: "结束异常", type: "error" });
  613. } else {
  614. this.orderInfoUpdateTimeout = setTimeout(() => {
  615. this.getChargeInfo()
  616. }, this.orderInfoUpdateTime)
  617. }
  618. if ([1, 2].includes(this.equipmentInfo.status) == false) {
  619. const duration = parseInt(this.equipmentInfo.chargeDur)
  620. const minutes = parseInt(duration / 1000 / 60)
  621. const seconds = parseInt(duration / 1000) % 60
  622. this.chargeDurStr = `${minutes}分${seconds}秒`
  623. }
  624. this.updateNavigationBarTitle()
  625. }
  626. },
  627. endCharge() {
  628. this.endChargeShow = false
  629. // 暂停拿订单状态,防止拿到上一次的充电中状态
  630. this.orderInfoUpdateTimeout && clearTimeout(this.orderInfoUpdateTimeout)
  631. this.$set(this.equipmentInfo, 'status', 3)
  632. // 间隔后,再去拿订单充电
  633. this.orderInfoUpdateTimeout = setTimeout(() => {
  634. this.getChargeInfo()
  635. }, this.orderInfoUpdateTime)
  636. let postData = {
  637. startChargeSeq: this.orderInfo.startChargeSeq,
  638. }
  639. stopCharge(postData).then((res) => {
  640. console.log(res);
  641. if (res.data.code == 200) {
  642. // this.getChargeInfo()
  643. }
  644. });
  645. },
  646. //前端刷新充电时间
  647. updateChargeDur() {
  648. if (this.equipmentInfo.status != 2) {
  649. this.clearChargeDurTimer()
  650. return
  651. }
  652. if (this.chargeDurInt != 0) {
  653. return
  654. }
  655. let duration = parseInt(this.equipmentInfo.chargeDur)
  656. if (duration <= 0) {
  657. return
  658. }
  659. const minutes = parseInt(duration / 1000 / 60)
  660. const seconds = parseInt(duration / 1000) % 60
  661. this.chargeDurStr = `${minutes}分${seconds}秒`
  662. this.chargeDurInt = duration
  663. this.updateChargeDurTimer = setInterval(() => {
  664. if (this.orderInfo.status == 3) {
  665. if (this.chargeDurInt != 0) {
  666. this.chargeDurInt += 500
  667. let serverDuration = parseInt(this.equipmentInfo.chargeDur)
  668. if ((serverDuration - this.chargeDurInt) > 30000) {
  669. this.chargeDurInt = serverDuration;
  670. }
  671. const minutes = parseInt(this.chargeDurInt / 1000 / 60)
  672. const seconds = parseInt(this.chargeDurInt / 1000) % 60
  673. this.chargeDurStr = `${minutes}分${seconds}秒`
  674. }
  675. } else {
  676. this.clearChargeDurTimer()
  677. }
  678. }, 500)
  679. },
  680. //停止刷新充电时长
  681. clearChargeDurTimer() {
  682. if (this.updateChargeDurTimer) {
  683. clearInterval(this.updateChargeDurTimer)
  684. this.updateChargeDurTimer = null
  685. this.chargeDurInt = 0;
  686. }
  687. },
  688. updateNavigationBarTitle() {
  689. let title = this.statusOptions[this.orderInfo.status]
  690. if (title == null) title = ''
  691. uni.setNavigationBarTitle({
  692. title: title
  693. });
  694. }
  695. },
  696. };
  697. </script>
  698. <style lang="scss" scoped>
  699. .header-title {
  700. font-weight: bold;
  701. // text-align: center;
  702. height: 90rpx;
  703. line-height: 90rpx;
  704. font-size: 34rpx;
  705. }
  706. .price-title {
  707. font-weight: bold;
  708. text-align: center;
  709. height: 90rpx;
  710. line-height: 90rpx;
  711. font-size: 34rpx;
  712. margin-left: 10rpx;
  713. }
  714. .cuxiao-title {
  715. color: #999;
  716. font-size: 24rpx;
  717. }
  718. .cuxiao {
  719. padding: 16rpx 32rpx;
  720. }
  721. .detail-btn {
  722. display: flex;
  723. align-items: center;
  724. > .button {
  725. flex: 1;
  726. width: 100%;
  727. margin: 0 10rpx;
  728. height: 80rpx;
  729. text-align: center;
  730. line-height: 80rpx;
  731. color: #fff;
  732. font-size: 26rpx;
  733. border-radius: 214px;
  734. padding: 0;
  735. background-image: linear-gradient(230deg, #00a5ff 7%, #0089c9 100%);
  736. border: 1px solid #ffffff;
  737. box-shadow: 0 1px 12px 0 #0089c980;
  738. u-image {
  739. vertical-align: sub;
  740. display: inline-block;
  741. margin-right: 10rpx;
  742. }
  743. }
  744. }
  745. .header-only-back {
  746. background: transparent;
  747. }
  748. .header,
  749. .header-only-back {
  750. padding-left: 10rpx;
  751. position: fixed;
  752. top: var(--status-bar-height);
  753. width: 100%;
  754. z-index: 8;
  755. height: 90rpx;
  756. font-size: 30rpx;
  757. transition: all 0.5s;
  758. }
  759. /deep/ .u-navbar {
  760. padding-left: 10rpx;
  761. }
  762. .page-bottom {
  763. position: fixed;
  764. bottom: 0;
  765. left: 0;
  766. z-index: 9;
  767. background: #fff;
  768. height: 110rpx;
  769. width: 100%;
  770. display: flex;
  771. border-top: 2rpx solid #f2f2f2;
  772. box-sizing: border-box;
  773. height: calc(120rpx + constant(safe-area-inset-bottom));
  774. height: calc(120rpx + env(safe-area-inset-bottom));
  775. padding-bottom: 20rpx;
  776. padding-bottom: constant(safe-area-inset-bottom);
  777. padding-bottom: env(safe-area-inset-bottom);
  778. > .icon-btn {
  779. display: flex;
  780. align-items: center;
  781. padding-left: 20rpx;
  782. // flex: 1;
  783. > .icon-btn-item {
  784. // flex: 1;
  785. position: relative;
  786. text-align: center;
  787. font-size: 22rpx;
  788. color: #262626;
  789. display: flex;
  790. flex-direction: column;
  791. width: 60rpx;
  792. height: 100%;
  793. align-items: center;
  794. justify-content: center;
  795. > .icon-btn-name {
  796. margin: 4rpx 0;
  797. }
  798. }
  799. }
  800. > .detail-btn {
  801. flex: 1.5;
  802. }
  803. }
  804. .main-page {
  805. height: calc(100% - var(--status-bar-height));
  806. overflow: hidden;
  807. }
  808. .product-container {
  809. background-image: linear-gradient(
  810. 180deg,
  811. #0593d5 12%,
  812. #00a5ff 18%,
  813. #f7f7f7 44%
  814. );
  815. .header-line {
  816. height: 1px;
  817. background: #f2f2f2;
  818. position: fixed;
  819. top: 90rpx;
  820. left: 0;
  821. right: 0;
  822. z-index: 999;
  823. transition: all 0.5s;
  824. &.scroll-hide {
  825. background: none;
  826. }
  827. }
  828. .scroll-page {
  829. width: 100%;
  830. height: 100%;
  831. }
  832. }
  833. .status_bar {
  834. background: #fff;
  835. height: var(--status-bar-height);
  836. }
  837. .recommend-box,
  838. .detail-box,
  839. .store-recommend,
  840. .store-info,
  841. .evaluate-box,
  842. .card-box,
  843. .group-list {
  844. border-radius: 20rpx;
  845. padding: 0rpx 20rpx;
  846. background: #ffffff;
  847. box-shadow: 0 1px 5px 2px rgba(0, 0, 0, 0.05);
  848. overflow: hidden;
  849. margin: 20rpx;
  850. }
  851. .store-recommend-title,
  852. .evaluate-title,
  853. .group-name {
  854. color: #262626;
  855. font-size: 28rpx;
  856. font-weight: 400;
  857. height: 90rpx;
  858. line-height: 90rpx;
  859. position: relative;
  860. &::before {
  861. background-color: #0974c5;
  862. content: "";
  863. position: absolute;
  864. border-radius: 3rpx;
  865. left: -20rpx;
  866. top: 50%;
  867. -webkit-transform: translateY(-50%);
  868. transform: translateY(-50%);
  869. width: 3px;
  870. height: 15px;
  871. }
  872. }
  873. #main1 {
  874. height: 360rpx;
  875. }
  876. .percent-text {
  877. margin-top: -120rpx;
  878. display: block;
  879. text-align: center;
  880. color: #0089c9;
  881. }
  882. .money {
  883. font-size: 32rpx;
  884. font-weight: 500;
  885. margin-top: 20rpx;
  886. .unit {
  887. font-size: 20rpx;
  888. }
  889. }
  890. .name {
  891. font-weight: 500;
  892. }
  893. .charge-amount {
  894. /deep/ .u-row {
  895. //display: block;
  896. margin-top: 20rpx;
  897. }
  898. }
  899. .radio-button {
  900. height: 80rpx;
  901. border-radius: 20rpx;
  902. background: #f4f6f9;
  903. text-align: center;
  904. line-height: 80rpx;
  905. border: 1px solid #f4f6f9;
  906. &.isActive {
  907. color: #0974c5;
  908. background: rgba(0, 201, 164, 0.1);
  909. border: 1px solid #0974c5;
  910. }
  911. }
  912. .amount-input {
  913. display: flex;
  914. align-items: center;
  915. justify-content: center;
  916. flex-direction: column;
  917. height: 80rpx;
  918. border-radius: 20rpx;
  919. border: 1px solid #f4f6f9;
  920. background: #f4f6f9;
  921. &.isActive {
  922. color: #0974c5;
  923. background: rgba(0, 201, 164, 0.1);
  924. border: 1px solid #0974c5;
  925. }
  926. /deep/ input {
  927. text-align: center;
  928. line-height: 80rpx;
  929. background: transparent;
  930. }
  931. }
  932. .scroll_mask {
  933. // height: 868rpx;
  934. // padding-bottom: 100rpx;
  935. overflow-y: auto;
  936. }
  937. .mask {
  938. height: 600px;
  939. }
  940. .card-box {
  941. padding-top: 0;
  942. }
  943. .card-content {
  944. padding: 0 20rpx;
  945. }
  946. .card-p {
  947. display: block;
  948. padding-bottom: 20rpx;
  949. }
  950. .card-flex {
  951. padding: 30rpx 0;
  952. &.top {
  953. align-items: flex-start;
  954. }
  955. &.title {
  956. padding: 30rpx 0 0;
  957. border: none;
  958. }
  959. &:last-child {
  960. border: none;
  961. }
  962. }
  963. .card-title {
  964. flex: 1;
  965. // padding-bottom: 10rpx;
  966. font-weight: 500;
  967. }
  968. .set-image {
  969. /deep/ .u-image {
  970. margin-right: 10rpx;
  971. }
  972. }
  973. .card-row {
  974. display: flex;
  975. align-items: center;
  976. font-size: 28rpx;
  977. line-height: 40rpx;
  978. padding: 10rpx 0;
  979. .lable {
  980. flex: 1;
  981. color: #707070;
  982. }
  983. .content {
  984. }
  985. .small {
  986. font-size: 24rpx;
  987. color: #707070;
  988. }
  989. }
  990. .card-swapper {
  991. padding: 30rpx 20rpx;
  992. .u-row {
  993. display: block;
  994. .number {
  995. font-size: 48rpx;
  996. font-weight: 700;
  997. text-align: center;
  998. margin-top: 40rpx;
  999. }
  1000. .label {
  1001. font-size: 28rpx;
  1002. color: #707070;
  1003. text-align: center;
  1004. }
  1005. .title {
  1006. font-size: 28rpx;
  1007. text-align: center;
  1008. margin-bottom: 10rpx;
  1009. }
  1010. }
  1011. }
  1012. .actual-pay {
  1013. font-size: 32rpx;
  1014. margin-left: 10rpx;
  1015. }
  1016. .dicount-tag {
  1017. /deep/ .u-tag {
  1018. color: #f28227;
  1019. background-color: transparent;
  1020. border-color: #f28227;
  1021. margin: 0 10rpx;
  1022. display: inline-block;
  1023. }
  1024. }
  1025. /* DarkMode 下的样式 start */
  1026. @media (prefers-color-scheme: dark) {
  1027. .product-container {
  1028. background-image: linear-gradient(
  1029. 180deg,
  1030. #039ef1 12%,
  1031. #056d9e 18%,
  1032. #121425 40%
  1033. );
  1034. }
  1035. .recommend-box,
  1036. .detail-box,
  1037. .store-recommend,
  1038. .store-info,
  1039. .evaluate-box,
  1040. .card-box,
  1041. .group-list {
  1042. background: #222336;
  1043. color: #ffffff;
  1044. box-shadow: 0 1px 5px 2px rgba(255, 255, 255, 0.05);
  1045. }
  1046. .store-recommend-title,
  1047. .evaluate-title,
  1048. .group-name {
  1049. color: #ffffff;
  1050. }
  1051. .title,
  1052. .number,
  1053. .percent-text,
  1054. .money {
  1055. color: #ffffff;
  1056. }
  1057. .card-row .lable {
  1058. color: #a9a9a9;
  1059. }
  1060. .card-row .content {
  1061. color: #ffffff;
  1062. }
  1063. .radio-button {
  1064. background: #f6f6f720;
  1065. }
  1066. .page-bottom {
  1067. background: #222336;
  1068. border-top: 2rpx solid #343434;
  1069. > .icon-btn > .icon-btn-item {
  1070. color: #ffffff;
  1071. }
  1072. .detail-btn > .to-scan {
  1073. background-image: linear-gradient(230deg, #00a5ff 7%, #0089c9 100%);
  1074. border: 1px solid #f6f6f720;
  1075. box-shadow: none;
  1076. }
  1077. }
  1078. }
  1079. </style>