apointmentRecharge.vue 7.9 KB

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