apointmentRecharge.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. <view class="bottom">
  56. :class="{
  57. buttonlockStatus:lockStatus
  58. button:!lockStatus
  59. }"
  60. @click="submit()"
  61. shape="square">提交预约</u-button>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. currentTimeStamp,
  68. parseUnixTime
  69. } from '@/utils'
  70. import * as API from '@/apis/apointment.js'
  71. import * as newsApi from '@/apis/news.js'
  72. export default {
  73. data() {
  74. return {
  75. id:0,
  76. lockStatus:false,
  77. lockTime:"",
  78. detail:{},
  79. timeList:[],
  80. numList:[60,90,120,0],
  81. apointment:"",
  82. selectTime:15,
  83. selectNum:60,
  84. }
  85. },
  86. onLoad(op) {
  87. this.id= op.id;
  88. this.getInfo()
  89. },
  90. methods:{
  91. submit(){
  92. if(this.lockStatus){
  93. return
  94. }
  95. uni.showLoading({
  96. title: "加载中",
  97. mask: true,
  98. })
  99. API.submitAppointment({
  100. gunNo:this.id,
  101. waitMinute:this.selectTime,
  102. chargingMinute:this.selectNum,
  103. }).then((res) => {
  104. uni.hideLoading()
  105. uni.reLaunch({
  106. url:"/pages/user/myReservation/reservationListDetails?id="+res.data+"&isback=1"
  107. })
  108. }).catch(error => {
  109. uni.showToast({
  110. title: error
  111. })
  112. })
  113. },
  114. getInfo(){
  115. newsApi.findConfigureByKey({
  116. key:"apointment"
  117. }).then((res) => {
  118. this.apointment = res.data.value;
  119. }).catch(error => {
  120. })
  121. uni.showLoading({
  122. title: "加载中",
  123. mask: true,
  124. })
  125. API.information({
  126. gunNo:this.id,
  127. }).then((res) => {
  128. uni.hideLoading()
  129. this.lockStatus=res.data.lockStatus
  130. this.lockTime=res.data.lockTime
  131. this.detail= {
  132. stationName:res.data.gun.stationName,
  133. deviceName:res.data.gun.deviceName,
  134. gunType:res.data.gun.gunType,
  135. };
  136. if(res.data.gunShare.reserveMinutes){
  137. this.timeList=res.data.gunShare.reserveMinutes.split(",")
  138. this.selectTime=this.timeList[0]
  139. if(this.timeList.indexOf("30")>-1){
  140. this.selectTime='30'
  141. }
  142. }
  143. }).catch(error => {
  144. uni.showToast({
  145. title: error
  146. })
  147. })
  148. },
  149. getPercent(estimateMinute) {
  150. var value="";
  151. var ms =estimateMinute
  152. if (ms > 0) {
  153. var Hour = parseInt(Math.floor(ms / 60 ));
  154. var Fen = parseInt(Math.floor(ms % 60 ));
  155. if(Hour>0){
  156. value=Hour + "小时"
  157. }
  158. value += Fen+"分钟"
  159. }
  160. return value;
  161. },
  162. },
  163. computed:{
  164. endtime1(){
  165. var date=new Date().getTime()+this.selectTime*60*1000
  166. return parseUnixTime(new Date(date))
  167. },
  168. endtime2(){
  169. var date=new Date().getTime()+this.selectNum*60*1000
  170. return parseUnixTime(new Date(date))
  171. },
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. page {
  177. padding-bottom: 191px;
  178. }
  179. .box {
  180. width: 91.4%;
  181. background-color: #fff;
  182. margin: 12px auto 0;
  183. padding: 12px;
  184. border-radius: 8px;
  185. }
  186. // 站点详情
  187. .station-details {
  188. .station-name {
  189. color: rgba(0, 185, 98, 100);
  190. font-size: 20px;
  191. line-height: 20px;
  192. }
  193. .details {
  194. width: 100%;
  195. margin-top: 8px;
  196. display: flex;
  197. flex-wrap: wrap;
  198. justify-content: space-between;
  199. .details-item {
  200. width: 95%;
  201. color: rgba(102, 102, 102, 100);
  202. line-height: 20px;
  203. text-align: left;
  204. margin-top: 4px;
  205. }
  206. }
  207. }
  208. // 电压详情
  209. .voltage-details {
  210. display: flex;
  211. justify-content: space-around;
  212. .item-num {
  213. height: 27px;
  214. color: rgba(0, 185, 98, 100);
  215. font-size: 20px;
  216. text-align: center;
  217. }
  218. .item-text {
  219. text-align: center;
  220. margin-top: 4px;
  221. }
  222. .border {
  223. height: 36px;
  224. width: 0;
  225. border: 1px solid rgba(237, 237, 237, 100);
  226. margin-top: 8px;
  227. }
  228. }
  229. // 预留时长
  230. .reserved-time {
  231. p {
  232. line-height: 18px;
  233. color: rgba(0, 185, 98, 100);
  234. font-size: 16px;
  235. margin-bottom: 42px;
  236. }
  237. .time1 {
  238. line-height: 33px;
  239. color: rgba(16, 16, 16, 100);
  240. font-size: 24px;
  241. text-align: center;
  242. margin-top: 8px;
  243. }
  244. .time0,
  245. .time2 {
  246. line-height: 22px;
  247. opacity: 0.5;
  248. color: rgba(16, 16, 16, 100);
  249. font-size: 16px;
  250. text-align: center;
  251. margin-top: 8px;
  252. }
  253. .end-time {
  254. line-height: 20px;
  255. color: rgba(102, 102, 102, 100);
  256. font-size: 14px;
  257. text-align: center;
  258. margin-top: 13px;
  259. }
  260. }
  261. // 预约需知
  262. .need-know {
  263. .name {
  264. line-height: 18px;
  265. color: rgba(0, 185, 98, 100);
  266. font-size: 16px;
  267. text-align: left;
  268. margin-bottom: 12px;
  269. }
  270. p{
  271. line-height: 16px;
  272. color: rgba(102, 102, 102, 100);
  273. font-size: 14px;
  274. text-align: left;
  275. margin-top:8px;
  276. }
  277. }
  278. .bottom {
  279. background-color: #fff;
  280. width: 100%;
  281. height: 64px;
  282. line-height: 64px;
  283. position: fixed;
  284. bottom: 0;
  285. left: 0;
  286. z-index: 999;
  287. padding: 12px 16px;
  288. .button {
  289. border-radius: 50px;
  290. background-color: rgba(0, 185, 98, 100);
  291. color: rgba(255, 255, 255, 100);
  292. font-size: 16px;
  293. }
  294. .buttonlockStatus{
  295. border-radius: 50px;
  296. background-color: rgba(0, 185, 98, 100);
  297. background-color: #e7edea;
  298. color: #141212;
  299. color: rgba(255, 255, 255, 100);
  300. font-size: 16px;
  301. }
  302. }
  303. </style>