terminal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <ax-body blank="0">
  3. <image src="@/static/img/page-bg01.png" class="page-background"></image>
  4. <view class="body" :class="{ visit }">
  5. <!-- 主图 -->
  6. <view class="app-flex c-center host-graph">
  7. <image src="@/static/img/charging-01.png" mode="widthFix" class="image"></image>
  8. </view>
  9. <!-- 主参数 -->
  10. <view class="parameter">
  11. <view class="param">
  12. <view class="value">{{ deviceInfo.current }}</view>
  13. <view class="name">电流A</view>
  14. </view>
  15. <view class="param">
  16. <view class="value">{{ deviceInfo.currentVoltage || '0' }}</view>
  17. <view class="name">电压V</view>
  18. </view>
  19. <view class="param">
  20. <view class="value">{{ deviceInfo.power }}</view>
  21. <view class="name">功率KW</view>
  22. </view>
  23. </view>
  24. <view v-if="!visit" class="block">
  25. <view class="card">
  26. <view class="title">
  27. <text>我的抵扣券</text>
  28. <view class="more" v-if="isEc">
  29. <view class="switch" :class="{ 'personal': personal == 1 }"><text
  30. @click="changeAccount(1)">个人</text><text @click="changeAccount(2)">集团</text></view>
  31. </view>
  32. </view>
  33. <view class="coupon-image-card"
  34. :style="{ backgroundImage: `url(${personal == 1 ? selectedImg : defaultImg})` }">
  35. <view class="coupon-title">充电抵扣券</view>
  36. <view class="price-info">
  37. <view class="price-numer">{{ accountInfo.balance }}</view>
  38. <view class="price-text">剩余可抵扣充电余量</view>
  39. </view>
  40. <view class="shop-coupon-btn"
  41. :style="{ backgroundColor: personal == 1 ? '#FF6457' : '#3EB6F8' }" @click="gotoCouponBuy">
  42. 立即购券</view>
  43. </view>
  44. <!-- <view class="coupon" :class="{'personal':personal==1}">
  45. <view class="name">{{personal == 1?'充电抵扣券':'集团抵扣券'}}</view>
  46. <view class="feature"><view class="line"></view></view>
  47. <view class="info">
  48. <view class="value">{{accountInfo.balance}}</view>
  49. <view class="describe">剩余可抵扣充电费用 (元)</view>
  50. </view>
  51. </view> -->
  52. </view>
  53. </view>
  54. <view class="block">
  55. <view class="card">
  56. <view class="title">
  57. <text>费用信息</text>
  58. <view @click="$app.url.goto('/pages/site-more/site-more?show=1&stationId=' + stationInfo.id)"
  59. class="more"><text>价格详情</text>
  60. <icon class="ax-iconline i-arrow-right icon"></icon>
  61. </view>
  62. </view>
  63. <view class="cell">
  64. <view class="lable">{{ personal == 1 ? '当前电价' : '集团折扣价' }}</view>
  65. <view class="contet app-flex middle">
  66. <view v-if="personal == 1"><text class="money">{{ deviceInfo.currentPrice }}</text><text>
  67. 元/度</text></view>
  68. <view v-else>
  69. <text class="obsolete">
  70. {{ deviceInfo.enterprisePrice }} 元/度
  71. </text>
  72. <text class="money">{{ getCurrEcPrice() }}</text><text> 元/度</text>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="cell" v-if="discountInfo && personal == 1">
  77. <view class="lable">优惠</view>
  78. <view class="contet app-flex middle">
  79. <view>{{ discountInfo.temp3 }}<text class="money">{{ discountInfo.discount ?
  80. parseFloat(discountInfo.discount).toFixed(4) : "0.0000" }}</text><text>
  81. 元/度</text></view>
  82. </view>
  83. </view>
  84. <view class="cell" v-if="deviceInfo.isFirmUser">
  85. <view class="lable">企业专享价</view>
  86. <view class="contet app-flex middle">
  87. <view><text class="money">{{ deviceInfo.enterprisePrice }}</text><text>
  88. 元/度</text></view>
  89. </view>
  90. </view>
  91. <view class="cell">
  92. <view class="lable">当前时段</view>
  93. <view class="contet">{{ deviceInfo.currentPeriodDesc }}</view>
  94. </view>
  95. <view class="cell">
  96. <view class="lable">停车参考</view>
  97. <view class="contet">{{ deviceInfo.parkingTips }}</view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="block">
  102. <view class="card">
  103. <view class="title">终端信息</view>
  104. <view class="cell">
  105. <view class="lable">终端状态</view>
  106. <view class="contet">{{ deviceInfo.statusName }}</view>
  107. </view>
  108. <view class="cell">
  109. <view class="lable">终端编号</view>
  110. <view class="contet">{{ deviceInfo.connectorCode }}</view>
  111. </view>
  112. <view class="cell">
  113. <view class="lable">充电电站</view>
  114. <view class="contet">{{ deviceInfo.stationName }}</view>
  115. </view>
  116. <view class="cell">
  117. <view class="lable">充电终端</view>
  118. <view class="contet">{{ deviceInfo.connectorName }}</view>
  119. </view>
  120. <view class="cell">
  121. <view class="lable">车位编号</view>
  122. <view class="contet">{{ deviceInfo.parkNo ? deviceInfo.parkNo : "无" }}</view>
  123. </view>
  124. </view>
  125. </view>
  126. <!-- 信息 -->
  127. <view class="footer">
  128. <view class="tips">账单信息可能会有所延迟,具体以实际结算为准</view>
  129. <view>
  130. <button @click="startup()" class="startup">启动终端充电</button>
  131. <ax-ios-indicator min="10"></ax-ios-indicator>
  132. </view>
  133. </view>
  134. </view>
  135. <ax-popup ref="filter" position="" maskType="black" maskEnable>
  136. <view class="Modal-tips">
  137. <view class="tips-icon">!</view>
  138. <view class="icon-title">温馨提示</view>
  139. <view class="tips-text" v-if="payment_msg != null">
  140. 您有一笔超充订单{{ (payment_msg.maspAmount + payment_msg.maspRealAmount).toFixed(2) }}元待补缴</view>
  141. <view class="tips-btn">
  142. <view class="cancel-btn" @click="$refs.filter.close()">取消</view>
  143. <view class="confirm-btn" @click="$app.url.goto('/pages/coupon-buy/coupon-buy')">购券并补缴</view>
  144. </view>
  145. </view>
  146. </ax-popup>
  147. </ax-body>
  148. </template>
  149. <script>
  150. export default {
  151. onLoad(opts) {
  152. console.log("参数信息:", opts)
  153. /**
  154. * 判断终端是否占用状态
  155. * 判断占用终端设备的是不是用户自己
  156. */
  157. this.deviceId = opts.deviceId
  158. this.deviceStatus = opts.deviceStatus
  159. },
  160. onShow() {
  161. this.queryInChange(this.deviceId, this.deviceStatus);
  162. /**
  163. * 刷新用户信息
  164. */
  165. this.userInfo = this.$app.storage.get(this.$config.keyname.userInfo);
  166. if (!this.userInfo.phone) {
  167. this.$app.url.goto('/pages/login/login')
  168. return;
  169. }
  170. // this.$api.login({
  171. // "checkStatus": 1
  172. // }).then(() => {
  173. // this.userInfo = this.$app.storage.get(this.$config.keyname.userInfo);
  174. // if (this.userInfo.ecId) {
  175. // //查询该集团账户是否正常使用。
  176. // this.$api.base("post", "/chargeApi/queryEcInfo", {
  177. // "ecId": this.userInfo.ecId
  178. // }, {}).then(res => {
  179. // if (res.ecInfo && res.ecInfo.ecStatus == 1) {
  180. // this.isEc = true;
  181. // }
  182. // })
  183. // }
  184. // })
  185. },
  186. mounted() {
  187. this.get_paymentMsg()
  188. setTimeout(() => {
  189. if (this.payment_msg != null) {
  190. this.$refs.filter.open()
  191. }
  192. }, 500)
  193. },
  194. data() {
  195. return {
  196. payment_msg: null,
  197. deviceId: 0,
  198. deviceStatus: 0,
  199. visit: '',
  200. personal: 1, // 1 个人订单 2 集团订单
  201. isEc: false, //是否集团的用户
  202. nowPriceTime: {}, //当前价格时间段信息
  203. deviceInfo: {}, //充电桩的信息
  204. accountInfo: { //账户信息
  205. balance: 0, //可用抵用券余额
  206. },
  207. userInfo: {},
  208. stationInfo: {}, //站点信息
  209. orderInfo: {}, //临时订单信息
  210. checkNum: 0, //检测订单状态次数
  211. ecInfo: {}, //集团信息
  212. discountInfo: null, //优惠信息
  213. selectedImg: 'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/AwQTRxpEMqOG50293e26d86888b3e0f7324c429d2019.png/1.png',
  214. defaultImg: 'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/SPh1u3KAqte830a107b2e3c5033b1d1027516d84d780.png/1.png'
  215. }
  216. },
  217. methods: {
  218. //通过用户id查询是否还有在充电中的订单
  219. queryInChange(deviceId, deviceStatus) {
  220. if (deviceStatus == 3 || deviceStatus == 4) {
  221. //占用充电状态;终端占用且不是自己,进入访问模式
  222. this.visit = true;
  223. }
  224. this.getDeviceInfo(deviceId); //获取设备、站的详情信息
  225. this.getAccountInfo(); //获取账户信息
  226. },
  227. //获取设备的详情信息
  228. getDeviceInfo(deviceId) {
  229. this.$api.base("get", "/applet/v1/station/connector/detail", {
  230. "connectorId": deviceId
  231. }, {}).then(res => {
  232. this.deviceInfo = res.data;
  233. this.nowPriceTime = res.nowPriceTime;
  234. this.stationInfo = res.stationInfo;
  235. if (res.discountInfo) {
  236. this.discountInfo = res.discountInfo
  237. }
  238. if (this.deviceInfo.tipsStatus == 1) {
  239. this.$app.popup.alert(this.deviceInfo.tipsContent, "温馨提示");
  240. }
  241. })
  242. },
  243. // get_paymentMsg() {
  244. // // maspStatus(1:待补缴,2:已补缴)realPredictServiceCost平台;maspAmount第三方
  245. // this.$api.base("post", "/chargeApi/queryOrderList-arrearage", {}, {}).then(res => {
  246. // this.payment_msg = res.data
  247. // })
  248. // },
  249. //获取账户信息
  250. // getAccountInfo() {
  251. // if (this.personal == 1) {
  252. // //获取个人账户信息
  253. // this.$api.base("post", "/chargeApi/getUserAccount", {}, {}).then(res => {
  254. // this.accountInfo.balance = res.userAccount.balance;
  255. // })
  256. // } else {
  257. // //获取集团账户信息
  258. // this.$api.base("post", "/chargeApi/getEcUserAccount", {}, {
  259. // error: false
  260. // }).then(res => {
  261. // this.ecInfo = res.ecInfo;
  262. // this.accountInfo.balance = res.ecUserAccount.balance;
  263. // }).catch(err => {
  264. // this.accountInfo.balance = 0;
  265. // this.$app.popup.alert(err.msg, "温馨提示");
  266. // })
  267. // }
  268. // },
  269. //切换账户
  270. changeAccount(type) {
  271. if (this.personal == type) {
  272. return;
  273. }
  274. this.personal = type;
  275. this.getAccountInfo();
  276. },
  277. //当前集团折扣价
  278. getCurrEcPrice() {
  279. if (!this.nowPriceTime) {
  280. return 0;
  281. }
  282. var currEcP = this.nowPriceTime.price;
  283. if (this.ecInfo && this.ecInfo.ecDiscount) {
  284. var realServicePrice = this.nowPriceTime.servicePrice
  285. if (this.stationInfo.contractServicePrice) {
  286. realServicePrice = this.stationInfo.contractServicePrice
  287. }
  288. currEcP = (this.nowPriceTime.electrovalence + realServicePrice + this.nowPriceTime.addServicePrice *
  289. this.ecInfo.ecDiscount / 100);
  290. }
  291. console.log("dddd", currEcP)
  292. if (currEcP) {
  293. currEcP = currEcP.toFixed(2);
  294. }
  295. return Number(currEcP).toFixed(4);
  296. },
  297. //转换出电压值
  298. getVolt() {
  299. if (!this.deviceInfo.power) {
  300. return 0;
  301. }
  302. var v = this.deviceInfo.power / this.deviceInfo.current * 1000;
  303. return v;
  304. },
  305. startup() {
  306. if (this.visit) {
  307. this.$app.popup.alert("该充电枪被占用或存在异常,请重新尝试或更换其他充电枪。", "温馨提示");
  308. return;
  309. }
  310. //判断账户余额是否大于两元
  311. if (this.deviceInfo.availableBalance <= 3) {
  312. return this.$app.popup.confirm("无法启动充电,抵扣余量需大于3元,请先购买充电券!", "温馨提示!", {
  313. confirmText: "立即购券"
  314. }).then(confirm => {
  315. if (confirm) {
  316. this.$app.url.goto('/pages/coupon-buy/coupon-buy', true);
  317. }
  318. });
  319. }
  320. //统一下单并启动接口
  321. this.get_subMessage();
  322. },
  323. get_subMessage() {
  324. let _this = this
  325. uni.requestSubscribeMessage({
  326. tmplIds: ['03bv7QSrzH4DSjmNsI9P0lq0Vj3sBwpN5mgfZln7Rc4'],
  327. success(res) {
  328. _this.startChangeAndOrder();
  329. }
  330. })
  331. },
  332. // 主动发起购券操作
  333. gotoCouponBuy() {
  334. this.$app.url.goto('/pages/coupon-buy/coupon-buy', true);
  335. },
  336. //统一下单并启动接口
  337. startChangeAndOrder() {
  338. var obj = {
  339. orderType: this.deviceInfo.isEcUser ? 1 : 0, //订单类型 0-平台 1-企业
  340. equipmentId: this.deviceInfo.equipmentId,
  341. stationId: this.deviceInfo.stationId,
  342. couponId: null,
  343. equipAuthSeq: '',
  344. connectorId: ''
  345. }
  346. this.$api.base("post", "/applet/v1/charge/invokeCharge", obj, {}).then(res => {
  347. //下单成功,并进行了订单预充值
  348. this.orderInfo = res.orderInfo;
  349. if (res.flg && res.flg == 1) {
  350. //用户有充电中的订单
  351. this.$app.popup.confirm("您有一个进行中充电订单,不可再次启动。", null, {
  352. showCancel: false,
  353. confirmText: "查看订单"
  354. }).then(cres => {
  355. this.$app.url.goto('/pages/charging/charging?orderId=' + this.orderInfo.id +
  356. "&deviceId=" + this.deviceInfo.id, false);
  357. });
  358. } else {
  359. //正常启动充电订单
  360. this.$app.url.goto('/pages/charging/charging?orderId=' + this.orderInfo.id + "&deviceId=" +
  361. this.deviceInfo.id, false);
  362. }
  363. })
  364. },
  365. // 延迟5s查询一下订单,看看是否真的启动成功
  366. checkedStartStatus() {
  367. this.$api.base("post", "/chargeApi/checkedStartStatus", {
  368. "id": this.orderInfo.id
  369. }, {}).then(res => {
  370. if (res.code == 0) {
  371. var respObj = res.obj;
  372. if (respObj.code == 200) {
  373. if (respObj.status == 1) {
  374. uni.hideLoading();
  375. //状态为1说明正常启动
  376. this.$app.url.goto('/pages/charging/charging?orderId=' + this.orderInfo.id +
  377. "&deviceId=" + this.deviceInfo.id, false);
  378. } else {
  379. //其他状态,说明充电桩,未启动。或其他问题,需要再次进行进行验证
  380. if (this.checkNum < 20) {
  381. this.checkNum = this.checkNum + 1;
  382. //延迟2s查询一下订单,看看是否真的启动成功
  383. setTimeout(() => this.checkedStartStatus(), 2000);
  384. }
  385. }
  386. } else {
  387. uni.hideLoading();
  388. this.$app.popup.alert(respObj.msg, "温馨提示");
  389. }
  390. } else {
  391. uni.hideLoading();
  392. }
  393. })
  394. },
  395. }
  396. }
  397. </script>
  398. <style scoped>
  399. @import url("terminal.css");
  400. </style>