apointmentRecharge.vue 6.0 KB

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