UMessage.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <view>
  3. <u-popup v-model="showUMessage" mode="bottom" border-radius="14" :closeable="true">
  4. <view>
  5. <view class="UMessage">
  6. <view class="q1">系统通知</view>
  7. <view class="q2 margin">尊敬的优电用户,当前站点采用动态调能技术检测到区域用电负荷较高(实时负载率{{loadRate}}%)<br /> 系统已为您智能匹配以下选项:
  8. </view>
  9. <view class="q3card q3card0 margin" @click="payValue=0" :class="{
  10. cardselect:payValue==0,
  11. cardno:payValue!=0
  12. }">
  13. <view class="cardgo">
  14. <view class="cardinfo">
  15. <img src="@/assets/img/riFill-check-fill.svg" alt="">
  16. </view>
  17. </view>
  18. <view class="title"> 前往附近站点 享受即时充电</view>
  19. <view class="q4" v-show="payValue==0" v-if="searchNearStationData.station">
  20. <view class="q41">最近<span class="q4span">{{searchNearStationData.station.name}}</span>
  21. </view>
  22. <view class="q41" >
  23. <template v-if="searchNearStationData.station.distance!=null||searchNearStationData.station.distance != '99999999'">
  24. 距离 <span class="q4span" style="margin-right: 32rpx;" >
  25. {{ searchNearStationData.station.distance>0.1 ? searchNearStationData.station.distance.toFixed(1)+'公里' : '小于100米'}}
  26. </span>
  27. </template>
  28. 空闲桩
  29. <span class="q4span">{{searchNearStationData.availableDeviceNum}}个</span>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="q3card q3card1 margin" @click="payValue=1,loadPredictionCurve()" :class="{
  34. cardselect:payValue==1,
  35. cardno:payValue!=1
  36. }">
  37. <view class="cardgo">
  38. <view class="cardinfo">
  39. <img src="@/assets/img/riFill-check-fill.svg" alt="">
  40. </view>
  41. </view>
  42. <view class="title">预约<span v-show="payValue==1&&payTime"
  43. style="color:#00B962;margin: 0 12rpx;">{{payTime}}</span>充电</view>
  44. <view class="q4" style="margin: 12rpx 0;" v-if="payValue==1&&payTime">
  45. 享 <span style="color: rgba(51, 51, 51, 1);font-weight: bold;margin: 0 8rpx;">{{price}}元/度</span> 充电优惠
  46. </view>
  47. <view class="q4">
  48. 点击查看[负荷预测曲线],了解最佳充电时段。
  49. </view>
  50. <view class="q4" v-show="payValue==1">
  51. <view id="UMessage_pieEcharts">
  52. </view>
  53. </view>
  54. </view>
  55. <view class="q5">再次感谢您对我们的信任,期待您的下次光临!</view>
  56. </view>
  57. <view class="q6">
  58. <view class="q6n1 q6n" @click="bHide">取消充电</view>
  59. <view class=" q6n q6n2" v-if="payValue==0" @click="toSearchPile">查找附近站点 </view>
  60. <view class=" q6n q6n3" v-if="payValue==1&&personInfo.userType==1" @click="toLogin">登录后可预约充电</view>
  61. <view class=" q6n q6n3" v-else-if="payValue==1&&!payValue1bl">{{payTime?'当前时间不可预约':'点击曲线预约充电'}}
  62. </view>
  63. <view class=" q6n q6n2" v-else-if="payValue==1&&payValue1bl" @click="confirmBtn">立即预约</view>
  64. </view>
  65. </view>
  66. </u-popup>
  67. </view>
  68. </template>
  69. <script>
  70. import * as API from '@/apis/umessage.js'
  71. import * as echarts from "echarts";
  72. export default {
  73. name: "UMessage",
  74. props: {
  75. stationId: "",
  76. deviceNo: "",
  77. channelNo: ""
  78. },
  79. data() {
  80. return {
  81. groupId: "8bc25585-4e5b-4895-a94e-431a23a095df",
  82. showUMessage: false,
  83. payValue: 0,
  84. payValue1bl: false, //预约的时间是否合格
  85. payTime: "",
  86. loadRate: 0,
  87. ampereList: [],
  88. myChart: null,
  89. maxAmpere: 0,
  90. personInfo: {},
  91. price:"",
  92. searchNearStationData: {},
  93. cache: null,
  94. };
  95. },
  96. methods: {
  97. bShow() {
  98. this.payValue = 0
  99. this.payTime = ""
  100. this.myChart = null
  101. this.price='';
  102. this.payValue1bl = false;
  103. this.showUMessage = true;
  104. this.findChargingGroup()
  105. },
  106. toHTML(data,params){
  107. this.price=data.data.price;
  108. var result = params[0].name + '<br>';
  109. result += `${params[0].marker} ${params[0].seriesName}: ${params[0].value} A<br>`;
  110. result += `${params[0].marker} 电价: ${data.data.price} 元/度<br>`;
  111. return result
  112. },
  113. bHide() {
  114. this.showUMessage = false;
  115. },
  116. toLogin() {
  117. uni.navigateTo({
  118. url: '/pages/login/login'
  119. })
  120. },
  121. toSearchPile() {
  122. uni.navigateTo({
  123. url: '/pages/searchPile/searchPile'
  124. })
  125. },
  126. initLine() {
  127. if (!this.myChart) {
  128. this.myChart = echarts.init(document.getElementById('UMessage_pieEcharts'), null, {
  129. height: uni.upx2px(300)
  130. });
  131. }
  132. //this.myChart.clear()
  133. var _this = this
  134. var data1 = []
  135. var data2 = []
  136. var pieces=[]
  137. var gt=0
  138. var keyswitch=0//
  139. for (var i in this.ampereList) {
  140. var item = this.ampereList[i]
  141. var key = item.createTime.split(' ')[1]
  142. key = key.substring(0, 5)
  143. data1.push(key)
  144. data2.push(item.ampere)
  145. // if(i==0){
  146. // if(item.ampere>this.maxAmpere){
  147. // keyswitch=1;
  148. // }
  149. // }
  150. // console.log(keyswitch==0&&item.ampere>this.maxAmpere)
  151. // console.log(item.ampere,this.maxAmpere)
  152. // if(keyswitch==0&&item.ampere>this.maxAmpere){
  153. // pieces.push({
  154. // gt: parseInt(gt),
  155. // lte:parseInt(i-1),
  156. // color: 'green'
  157. // })
  158. // gt=i-1
  159. // keyswitch=1
  160. // }else if(keyswitch==1&&item.ampere<this.maxAmpere){
  161. // pieces.push({
  162. // gt: parseInt(gt),
  163. // lte:parseInt(i-1),
  164. // color: 'red'
  165. // })
  166. // gt=i-1
  167. // keyswitch=0
  168. // }
  169. }
  170. // pieces.push({
  171. // gt: parseInt(gt),
  172. // lte:parseInt(this.ampereList.length),
  173. // color: keyswitch?'red':'green'
  174. // })
  175. // visualMap: {
  176. // show: false,
  177. // dimension: 0,
  178. // pieces: pieces
  179. // },
  180. var option = {
  181. xAxis: {
  182. type: 'category',
  183. data: data1
  184. },
  185. yAxis: {
  186. type: 'value'
  187. },
  188. grid: {
  189. top: '25px',
  190. left: '30px',
  191. right: '20px',
  192. bottom: '25px',
  193. // containLabel: true
  194. },
  195. tooltip: {
  196. trigger: 'axis',
  197. formatter: function(params, ticket, callback) {
  198. _this.payTime=params[0].name ;
  199. if( params[0].data>_this.maxAmpere){
  200. _this.payValue1bl=false;
  201. }else{
  202. _this.payValue1bl=true;
  203. }
  204. API.timePointPrice({
  205. deviceNo: _this.deviceNo,
  206. timePoint: params[0].name
  207. }).then((res) => {
  208. callback(ticket, _this.toHTML(res,params));
  209. }).catch(error => {
  210. })
  211. return '加载中...';
  212. }
  213. },
  214. series: [{
  215. data: data2,
  216. type: 'line',
  217. name: '电流',
  218. markLine:this.maxAmpere==0?{}: {
  219. data: [{
  220. name: '参考线',
  221. yAxis: this.maxAmpere, // 参考线的值
  222. lineStyle: {
  223. color: 'red',
  224. type: 'dashed'
  225. }
  226. }]
  227. }
  228. }],
  229. };
  230. console.log(option)
  231. this.myChart.setOption(option);
  232. },
  233. readyToTimingCharging() {
  234. uni.showLoading({
  235. title: "加载中",
  236. mask: true,
  237. })
  238. var submitForm = {
  239. deviceNo: this.deviceNo,
  240. channelNo: this.channelNo,
  241. startTime: this.payTime
  242. }
  243. API.readyToTimingCharging(submitForm).then((res) => {
  244. uni.hideLoading();
  245. this.showUMessage = false
  246. var gunNo=res.data.gunNo
  247. uni.showModal({
  248. title: '预约成功',
  249. showCancel: false,
  250. content: "预约成功,拔枪将会自动取消预约",
  251. success: res1 => {
  252. if (res1.confirm) {
  253. uni.navigateTo({
  254. url:"/pages/searchPile/stationAndPile/chargingPileDetails?isback=1&id="+gunNo
  255. })
  256. } else if (res1.cancel) {
  257. //('用户点击取消');
  258. }
  259. }
  260. })
  261. }).catch(error => {
  262. uni.showToast({
  263. title: error,
  264. icon: "none"
  265. })
  266. })
  267. },
  268. loadPredictionCurve() {
  269. if (this.myChart) {
  270. return
  271. }
  272. uni.showLoading({
  273. title: "加载中",
  274. mask: true,
  275. })
  276. API.loadPredictionCurve({
  277. deviceNo: this.deviceNo
  278. }).then((res) => {
  279. uni.hideLoading();
  280. console.log(res)
  281. this.ampereList = res.data.ampereList
  282. this.maxAmpere = res.data.maxAmpere
  283. console.log(this.maxAmpere)
  284. this.initLine()
  285. }).catch(error => {
  286. uni.showToast({
  287. title: error,
  288. icon: "none"
  289. })
  290. })
  291. },
  292. confirmBtn() {
  293. this.readyToTimingCharging()
  294. },
  295. fetchAdditionalValue() {
  296. },
  297. searchNearStation() {
  298. uni.showLoading({
  299. title: "加载中",
  300. mask: true,
  301. })
  302. API.searchNearStation({
  303. stationId: this.stationId
  304. }).then((res) => {
  305. uni.hideLoading();
  306. console.log(res)
  307. this.searchNearStationData = res.data;
  308. }).catch(error => {
  309. uni.showToast({
  310. title: error,
  311. icon: "none"
  312. })
  313. })
  314. },
  315. findChargingGroup() {
  316. uni.showLoading({
  317. title: "加载中",
  318. mask: true,
  319. })
  320. API.findChargingGroup({
  321. deviceNo: this.deviceNo
  322. }).then((res) => {
  323. uni.hideLoading();
  324. console.log(res)
  325. this.loadRate = res.data.loadRate
  326. this.searchNearStation()
  327. }).catch(error => {
  328. uni.showToast({
  329. title: error,
  330. icon: "none"
  331. })
  332. })
  333. },
  334. },
  335. mounted() {
  336. this.personInfo = this.carhelp.getPersonInfo()
  337. this.cache = new Map()
  338. //this.searchNearStation()
  339. //this.loadPredictionCurve()
  340. }
  341. }
  342. </script>
  343. <style scoped lang="scss">
  344. .q6 {
  345. border: 1px solid rgba(242, 242, 242, 1);
  346. padding: 24rpx;
  347. display: flex;
  348. justify-content: space-around;
  349. .q6n {
  350. padding: 20rpx 0;
  351. border-radius: 50px;
  352. font-size: 34rpx;
  353. text-align: center;
  354. }
  355. .q6n1 {
  356. width: 30%;
  357. background-color: rgba(187, 187, 187, 1);
  358. color: rgba(255, 255, 255, 1);
  359. }
  360. .q6n2 {
  361. background-color: rgba(0, 185, 98, 1);
  362. color: rgba(255, 255, 255, 1);
  363. width: 60%;
  364. }
  365. .q6n3 {
  366. width: 60%;
  367. background-color: rgba(187, 187, 187, 1);
  368. color: rgba(255, 255, 255, 1);
  369. }
  370. }
  371. .UMessage {
  372. padding: 30rpx 40rpx;
  373. .q1 {
  374. color: rgba(16, 16, 16, 1);
  375. font-size: 40rpx;
  376. font-weight: bold;
  377. }
  378. .margin {
  379. margin: 20rpx 0;
  380. }
  381. .q2 {
  382. color: rgba(51, 51, 51, 1);
  383. font-size: 32rpx;
  384. }
  385. .q5 {
  386. color: rgba(119, 119, 119, 1);
  387. font-size: 28rpx;
  388. //margin-bottom: 40rpx;
  389. }
  390. .q4 {
  391. color: rgba(119, 119, 119, 1);
  392. font-size: 28rpx;
  393. .q4span {
  394. color: rgba(51, 51, 51, 1);
  395. margin: 0 8rpx;
  396. font-weight: bold;
  397. }
  398. .q41 {
  399. margin: 8rpx;
  400. }
  401. }
  402. .q3card {
  403. overflow: hidden;
  404. padding: 30rpx 40rpx;
  405. margin-top: 10px;
  406. .title {
  407. font-size: 40rpx;
  408. font-weight: bold;
  409. }
  410. }
  411. .cardselect {
  412. border-radius: 8px;
  413. border: 2px solid rgba(0, 185, 98, 1);
  414. .cardgo {
  415. position: relative;
  416. .cardinfo {
  417. background-color: #00b962;
  418. width: 64rpx;
  419. height: 64rpx;
  420. position: absolute;
  421. top: -44rpx;
  422. right: -44rpx;
  423. border-radius: 0 0 0 8px;
  424. img {
  425. width: 64rpx;
  426. }
  427. }
  428. }
  429. }
  430. .cardno {
  431. border: 2px solid rgba(204, 204, 204, 1);
  432. border-radius: 8px;
  433. .cardgo {
  434. position: relative;
  435. .cardinfo {
  436. background-color: rgba(204, 204, 204, 1);
  437. width: 64rpx;
  438. height: 64rpx;
  439. position: absolute;
  440. top: -44rpx;
  441. right: -44rpx;
  442. border-radius: 0 0 0 8px;
  443. img {
  444. width: 64rpx;
  445. }
  446. }
  447. }
  448. }
  449. }
  450. </style>