apointmentRecharge.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <view>
  3. <u-navbar title="预约充电"></u-navbar>
  4. <!-- 站点详情 -->
  5. <view class="station-details box">
  6. <p class="station-name">{{detail.stationName}}</p>
  7. <view class="details">
  8. <view class="details-item">
  9. 充电桩类型:{{detail.gunType=='1'?'直流快充':'交流慢充'}}
  10. </view>
  11. <view class="details-item">
  12. 桩号:{{detail.deviceName}}
  13. </view>
  14. <view class="details-item">
  15. 枪号:{{id}}
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 预留时长 -->
  20. <view class="reserved-time box">
  21. <p>充电桩预留时长</p>
  22. <template v-for="(item,i) in timeList">
  23. <view :key="i" @click="selectTime=item" :class="{
  24. time1:selectTime==item,
  25. time2:selectTime!=item
  26. }">
  27. {{item}}分钟
  28. </view>
  29. </template>
  30. <view class="end-time">
  31. 预留截止时间:{{endtime1}}
  32. </view>
  33. </view>
  34. <!-- 预计充电时长 -->
  35. <view class="reserved-time box">
  36. <p>预计充电时长</p>
  37. <template v-for="(item,i) in numList">
  38. <view :key="i" @click="selectNum=item" :class="{
  39. time1:selectNum==item,
  40. time0:selectNum!=item
  41. }">
  42. {{getPercent(item)}}
  43. </view>
  44. </template>
  45. <view class="end-time">
  46. 预留充满时间:{{endtime2}}
  47. </view>
  48. </view>
  49. <!-- 预约需知 -->
  50. <view class="need-know box">
  51. <p class="name">预约需知</p>
  52. <p v-html="apointment">
  53. </p>
  54. </view>
  55. <u-modal v-model="show">
  56. <view style="padding: 10px;">
  57. 因您近期存在预约超时未前往充电的违约行为,平台为保证每位车主的合理权益,
  58. 对您作出停用预约充电功能1天的处罚。
  59. 您可于<span style="color: #00b962;">{{lockTime}}</span>后使用此功能。
  60. </view>
  61. </u-modal>
  62. <view class="bottom">
  63. <u-button
  64. :class="{
  65. button:!lockStatus,
  66. buttonlockStatus:lockStatus
  67. }"
  68. @click="submit()"
  69. shape="square">提交预约</u-button>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import {
  75. currentTimeStamp,
  76. parseUnixTime
  77. } from '@/utils'
  78. import * as API from '@/apis/apointment.js'
  79. import * as newsApi from '@/apis/news.js'
  80. export default {
  81. data() {
  82. return {
  83. id:0,
  84. lockStatus:false,
  85. lockTime:"",
  86. detail:{},
  87. timeList:[],
  88. numList:[60,90,120,0],
  89. apointment:"",
  90. selectTime:15,
  91. selectNum:60,
  92. show:false,
  93. }
  94. },
  95. onLoad(op) {
  96. this.id= op.id;
  97. this.getInfo()
  98. },
  99. methods:{
  100. submit(){
  101. if(this.lockStatus){
  102. return
  103. }
  104. uni.showLoading({
  105. title: "加载中",
  106. mask: true,
  107. })
  108. API.submitAppointment({
  109. gunNo:this.id,
  110. waitMinute:this.selectTime,
  111. chargingMinute:this.selectNum,
  112. }).then((res) => {
  113. uni.hideLoading()
  114. uni.reLaunch({
  115. url:"/pages/user/myReservation/reservationListDetails?id="+res.data+"&isback=1"
  116. })
  117. }).catch(error => {
  118. uni.showToast({
  119. title: error
  120. })
  121. })
  122. },
  123. getInfo(){
  124. newsApi.findConfigureByKey({
  125. key:"apointment"
  126. }).then((res) => {
  127. this.apointment = res.data.value;
  128. }).catch(error => {
  129. })
  130. uni.showLoading({
  131. title: "加载中",
  132. mask: true,
  133. })
  134. API.information({
  135. gunNo:this.id,
  136. }).then((res) => {
  137. uni.hideLoading()
  138. this.lockStatus=res.data.lockStatus
  139. this.lockTime=res.data.lockTime
  140. if(this.lockStatus){
  141. this.show=true;
  142. }
  143. this.detail= {
  144. stationName:res.data.gun.stationName,
  145. deviceName:res.data.gun.deviceName,
  146. gunType:res.data.gun.gunType,
  147. };
  148. if(res.data.gunShare.reserveMinutes){
  149. this.timeList=res.data.gunShare.reserveMinutes.split(",")
  150. this.selectTime=this.timeList[0]
  151. if(this.timeList.indexOf("30")>-1){
  152. this.selectTime='30'
  153. }
  154. //this.timeList=[2]
  155. }
  156. }).catch(error => {
  157. uni.showToast({
  158. title: error
  159. })
  160. })
  161. },
  162. getPercent(estimateMinute) {
  163. var value="";
  164. var ms =estimateMinute
  165. if (ms > 0) {
  166. var Hour = parseInt(Math.floor(ms / 60 ));
  167. var Fen = parseInt(Math.floor(ms % 60 ));
  168. if(Hour>0){
  169. value+=Hour + "小时"
  170. }
  171. if(Fen>0){
  172. value+=Fen + "分钟"
  173. }
  174. }
  175. return value;
  176. },
  177. },
  178. computed:{
  179. endtime1(){
  180. var date=new Date().getTime()+this.selectTime*60*1000
  181. return parseUnixTime(new Date(date))
  182. },
  183. endtime2(){
  184. var date=new Date().getTime()+this.selectNum*60*1000+this.selectTime*60*1000
  185. return parseUnixTime(new Date(date))
  186. },
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. page {
  192. padding-bottom: 191px;
  193. }
  194. .box {
  195. width: 91.4%;
  196. background-color: #fff;
  197. margin: 12px auto 0;
  198. padding: 12px;
  199. border-radius: 8px;
  200. }
  201. // 站点详情
  202. .station-details {
  203. .station-name {
  204. color: rgba(0, 185, 98, 100);
  205. font-size: 20px;
  206. line-height: 20px;
  207. }
  208. .details {
  209. width: 100%;
  210. margin-top: 8px;
  211. display: flex;
  212. flex-wrap: wrap;
  213. justify-content: space-between;
  214. .details-item {
  215. width: 95%;
  216. color: rgba(102, 102, 102, 100);
  217. line-height: 20px;
  218. text-align: left;
  219. margin-top: 4px;
  220. }
  221. }
  222. }
  223. // 电压详情
  224. .voltage-details {
  225. display: flex;
  226. justify-content: space-around;
  227. .item-num {
  228. height: 27px;
  229. color: rgba(0, 185, 98, 100);
  230. font-size: 20px;
  231. text-align: center;
  232. }
  233. .item-text {
  234. text-align: center;
  235. margin-top: 4px;
  236. }
  237. .border {
  238. height: 36px;
  239. width: 0;
  240. border: 1px solid rgba(237, 237, 237, 100);
  241. margin-top: 8px;
  242. }
  243. }
  244. // 预留时长
  245. .reserved-time {
  246. p {
  247. line-height: 18px;
  248. color: rgba(0, 185, 98, 100);
  249. font-size: 16px;
  250. margin-bottom: 42px;
  251. }
  252. .time1 {
  253. line-height: 33px;
  254. color: rgba(16, 16, 16, 100);
  255. font-size: 24px;
  256. text-align: center;
  257. margin-top: 8px;
  258. }
  259. .time0,
  260. .time2 {
  261. line-height: 22px;
  262. opacity: 0.5;
  263. color: rgba(16, 16, 16, 100);
  264. font-size: 16px;
  265. text-align: center;
  266. margin-top: 8px;
  267. }
  268. .end-time {
  269. line-height: 20px;
  270. color: rgba(102, 102, 102, 100);
  271. font-size: 14px;
  272. text-align: center;
  273. margin-top: 13px;
  274. }
  275. }
  276. // 预约需知
  277. .need-know {
  278. .name {
  279. line-height: 18px;
  280. color: rgba(0, 185, 98, 100);
  281. font-size: 16px;
  282. text-align: left;
  283. margin-bottom: 12px;
  284. }
  285. p{
  286. line-height: 16px;
  287. color: rgba(102, 102, 102, 100);
  288. font-size: 14px;
  289. text-align: left;
  290. margin-top:8px;
  291. }
  292. }
  293. .bottom {
  294. background-color: #fff;
  295. width: 100%;
  296. height: 64px;
  297. line-height: 64px;
  298. position: fixed;
  299. bottom: 0;
  300. left: 0;
  301. z-index: 999;
  302. padding: 12px 16px;
  303. .button {
  304. border-radius: 50px;
  305. background-color: rgba(0, 185, 98, 100);
  306. color: rgba(255, 255, 255, 100);
  307. font-size: 16px;
  308. }
  309. .buttonlockStatus{
  310. border-radius: 50px;
  311. background-color: #c1c5c3;
  312. color: rgba(255, 255, 255, 100);
  313. font-size: 16px;
  314. }
  315. }
  316. </style>