myReservation.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view>
  3. <ujp-navbar title="我的预约">
  4. <view class="screen oldTextjp2" oldstyle="font-size: 16px;" @click="screenClick">筛选</view>
  5. </ujp-navbar>
  6. <view>
  7. <view v-if="screenShow" class="preference" :style="screenShow ? 'z-index:1024;top:'+navBarHeight+'px;' : 'z-index:0'"
  8. style="width: 100%;">
  9. <view class="content-s">
  10. <view class="preference_group">
  11. <view class="preference_group_item" :class="statusClass == index ? 'active' : ''" v-for="(item,index) in statusList" :key="item.id" @click="statusClick(index,item)">{{item.name}}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <u-mask :show="screenShow" @click="screenShow = false" z-index="100"></u-mask>
  16. </view>
  17. <view class="carNone" v-if="appointmentList.length == 0">
  18. <img src="@/assets/static/img/暂无数据-缺省页.png" alt="">
  19. <p>暂无预约</p>
  20. </view>
  21. <view class="reservation-items" v-for="(item,index) in appointmentList" :key="item.id" @click="gotoUrl('pages/user/myReservation/reservationListDetails?id='+item.id)">
  22. <view class="station-name ellipsis">
  23. {{item.stationName}}/{{item.deviceName}}
  24. <view class="toBe-confirmed btn" v-if="item.status == '0'">{{item.statusText}}</view>
  25. <view class="confirmed btn" v-if="item.status == '1'">已确认</view>
  26. <view class="canceled btn" v-if="item.status == '3'">{{item.statusText}}</view>
  27. <view class="have-expired btn" v-if="item.status == '9'">{{item.statusText}}</view>
  28. <view class="confirmed btn" v-if="item.status == '2'">{{item.statusText}}</view>
  29. <view class="refused btn" v-if="item.status == '4'">{{item.statusText}}</view>
  30. <view class="have-expired btn" v-if="item.status == '5'">已过期</view>
  31. <view class="have-expired btn" v-if="item.status == '6'">已过期</view>
  32. </view>
  33. <view class="details-items">
  34. <view class="items">
  35. <view class="items-name">
  36. 预约单号
  37. </view>
  38. <view class="items-content">
  39. {{item.flowNo}}
  40. </view>
  41. </view>
  42. <view class="items">
  43. <view class="items-name">
  44. 充电类型
  45. </view>
  46. <view class="items-content">
  47. {{item.typeText}}
  48. </view>
  49. </view>
  50. <view class="items">
  51. <view class="items-name">
  52. 预约预留时长
  53. </view>
  54. <view class="items-content">
  55. {{item.reserveMinutes}}分钟
  56. </view>
  57. </view>
  58. <view class="items">
  59. <view class="items-name">
  60. 预留截至时间
  61. </view>
  62. <view class="items-content">
  63. {{item.endTime}}
  64. </view>
  65. </view>
  66. <view class="items">
  67. <view class="items-name">
  68. 预约充电时长
  69. </view>
  70. <view class="items-content">
  71. {{item.estimateMinutes != null ? (item.estimateMinutes/60).toFixed(1)+'小时' : '0'}}
  72. </view>
  73. </view>
  74. </view>
  75. <view class="button" v-if="item.status == '0'">
  76. <u-button class="cancel" shape="circle" @click="refuseClick(item,item.status)">取消预约</u-button>
  77. </view>
  78. <view class="button" v-if="item.status == '1'">
  79. <u-button class="navigation" shape="circle" @click="gotoUrl('pages/searchPile/stationAndPile/stationDetails?id='+item.stationId)">导航</u-button>
  80. <u-button class="cancel" shape="circle" @click="refuseClick(item,item.status)">取消预约</u-button>
  81. </view>
  82. <view class="button" v-if="item.status == '2'">
  83. <u-button class="check" shape="circle" @click="gotoUrl('pages/user/myReservation/reservationListDetails?id='+item.id)">查看详情</u-button>
  84. </view>
  85. <!-- <view class="button" v-if="item.status == '3'">
  86. <u-button class="rebook" shape="circle" @click="remakeClick(item)">重新预约</u-button>
  87. <u-button class="canc" shape="circle">删除</u-button>
  88. </view> -->
  89. <!-- <view class="button" v-if="item.status == '9'">
  90. <u-button class="canc" shape="circle">删除</u-button>
  91. </view> -->
  92. </view>
  93. <u-divider v-if="appointmentList.length == recordsTotal && recordsTotal != 0" style="margin-top: 10px;background-color: #F2F4F4;">已经到底了</u-divider>
  94. </view>
  95. </template>
  96. <script>
  97. import * as API from '@/apis/apointment.js'
  98. import {
  99. hourDistanceArr,
  100. currentTimeStamp,
  101. parseUnixTime
  102. } from '@/utils'
  103. export default {
  104. data() {
  105. return {
  106. screenShow: false,
  107. navBarHeight:44,
  108. statusList: [
  109. {id:"",name:"全部预约单"},
  110. {id:"1",name:"已确认"},
  111. {id:"0",name:"待确认"},
  112. {id:"2",name:"已完成"},
  113. {id:"3",name:"已取消"},
  114. {id:"4",name:"已拒绝"},
  115. {id:"9",name:"已过期"},
  116. ],
  117. statusClass: '',
  118. pageIndex: 1,
  119. recordsTotal: 0,
  120. appointmentList: [],
  121. status: '',
  122. }
  123. },
  124. onShow() {
  125. this.getAppointmentList(true);
  126. },
  127. onReachBottom() {
  128. if (this.appointmentList.length < this.recordsTotal) {
  129. this.myLoadmore();
  130. }
  131. },
  132. methods: {
  133. statusClick(index,item) {
  134. this.statusClass = index;
  135. this.screenShow = false;
  136. this.status = item.id;
  137. this.getAppointmentList(true);
  138. },
  139. screenClick() {
  140. this.screenShow = !this.screenShow;
  141. },
  142. getAppointmentList(bl) {
  143. uni.showLoading({
  144. title: "加载中",
  145. mask: true,
  146. })
  147. if (bl) {
  148. this.appointmentList = [];
  149. this.pageIndex = 1;
  150. }
  151. API.myAppointmentList({
  152. pageIndex: this.pageIndex,
  153. status: this.status
  154. }).then((res) => {
  155. uni.hideLoading();
  156. this.appointmentList = [
  157. ...this.appointmentList,
  158. ...res.data.data
  159. ];
  160. this.recordsTotal = res.data.recordsTotal;
  161. var list = res.data.data;
  162. for (let i = 0; i < list.length; i++) {
  163. if(list[i].status == '0') {
  164. }
  165. }
  166. }).catch(error => {
  167. uni.showToast({
  168. title: error,
  169. icon: "none"
  170. })
  171. })
  172. },
  173. myLoadmore() {
  174. this.pageIndex += 1;
  175. this.getAppointmentList()
  176. },
  177. confirmrefuse(item){
  178. uni.showLoading({
  179. title: "加载中",
  180. mask: true,
  181. })
  182. API.regChangeStatus({
  183. id: item.id,
  184. status: '3'
  185. }).then((res) => {
  186. uni.hideLoading();
  187. this.getAppointmentList(true);
  188. }).catch(error => {
  189. uni.showToast({
  190. title: error,
  191. icon: "none"
  192. })
  193. })
  194. },
  195. refuseClick(item,status) {
  196. if(status=='0'){
  197. uni.showModal({
  198. title:"提示",
  199. content: "请确认是否取消预约功能",
  200. success: (res1) => {
  201. if (res1.confirm) {
  202. this.confirmrefuse(item)
  203. } else if (res1.cancel) {
  204. //('用户点击取消');
  205. }
  206. }
  207. })
  208. }else{
  209. uni.showModal({
  210. title: '强制取消',
  211. cancelText:'我再想想',
  212. confirmText:'取消预约',
  213. content: '您的预约单已被确认,如强制取消,平台为保证每位车主的合理权益,会对您作出停用预约充电功能1天的处罚。确定取消预约吗?',
  214. success: res => {
  215. if (res.confirm) {
  216. //付钱 改为组件
  217. this.confirmrefuse(item)
  218. } else if (res.cancel) {
  219. //('用户点击取消');
  220. }
  221. }
  222. });
  223. }
  224. },
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. .carNone{
  230. display: flex;
  231. flex-direction: column;
  232. justify-content: center;
  233. align-items: center;
  234. img{
  235. width: 100%;
  236. height: 100%;
  237. }
  238. p{
  239. margin-top: -60px;
  240. }
  241. }
  242. .preference {
  243. background-color: #ffffff;
  244. left: 0rpx;
  245. position: fixed
  246. }
  247. .preference_group_item {
  248. padding: 15rpx;
  249. text-align: center;
  250. color: #777777;
  251. }
  252. .active {
  253. color: #00B962;
  254. font-size: 18px;
  255. }
  256. .preference_group {
  257. padding-bottom: 20rpx;
  258. }
  259. .content-s{
  260. height: 240px;
  261. overflow-y:scroll;
  262. }
  263. page {
  264. padding-bottom: 155px;
  265. }
  266. .screen {
  267. margin-left: 85.3%;
  268. color: rgba(119, 119, 119, 100);
  269. font-size: 12px
  270. }
  271. .btn {
  272. width: 60px;
  273. height: 24px;
  274. line-height: 20px;
  275. border-radius: 4px;
  276. background-color: rgba(255, 255, 255, 100);
  277. font-size: 14px;
  278. text-align: center;
  279. float: right;
  280. margin-right: 24px;
  281. margin-top: 12px;
  282. }
  283. // 待确认按钮
  284. .toBe-confirmed {
  285. color: rgba(78, 141, 246, 100);
  286. border: 1px solid rgba(78, 141, 246, 100);
  287. }
  288. // 已确认按钮
  289. .confirmed {
  290. border: 1px solid rgba(0, 185, 98, 100);
  291. color: rgba(0, 185, 98, 100);
  292. }
  293. // 已取消按钮
  294. .canceled {
  295. border: 1px solid rgba(153, 153, 153, 100);
  296. color: rgba(153, 153, 153, 100);
  297. ;
  298. }
  299. // 已过期按钮
  300. .have-expired {
  301. color: rgba(162, 169, 181, 100);
  302. border: 1px solid rgba(162, 169, 181, 100);
  303. }
  304. // 已拒绝
  305. .refused {
  306. color: rgba(255, 79, 63, 100);
  307. border: 1px solid rgba(255, 79, 63, 100);
  308. }
  309. .reservation-items {
  310. width: 100%;
  311. background-color: #fff;
  312. padding-left: 14px;
  313. margin-bottom: 12px;
  314. .station-name {
  315. line-height: 48px;
  316. color: rgba(16, 16, 16, 100);
  317. font-size: 20px
  318. }
  319. .ellipsis{
  320. white-space: nowrap;
  321. text-overflow: ellipsis;
  322. overflow: hidden;
  323. }
  324. .details-items {
  325. border: 1px solid rgba(238, 242, 240, 100);
  326. border-left: none;
  327. padding-bottom: 13px;
  328. .items {
  329. display: flex;
  330. justify-content: space-between;
  331. padding: 12px 14px 0px 0;
  332. line-height: 20px;
  333. }
  334. }
  335. ::v-deep .u-alert-tips--bg--warning-light {
  336. background-color: #fff !important;
  337. border: none;
  338. margin-top: 12px;
  339. padding: 8px 0;
  340. .u-alert-desc {
  341. color: #ff7300;
  342. }
  343. }
  344. .button {
  345. height: 56px;
  346. padding: 12px 0;
  347. ::v-deep .u-btn {
  348. width: 100px;
  349. height: 32px;
  350. line-height: 23px;
  351. background-color: rgba(255, 255, 255, 100);
  352. color: rgba(153, 153, 153, 100);
  353. font-size: 16px;
  354. text-align: center;
  355. float: right;
  356. margin-right: 16px;
  357. }
  358. .navigation,
  359. .start {
  360. color: rgba(0, 185, 98, 100);
  361. }
  362. .check {
  363. color: rgba(153, 153, 153, 100);
  364. }
  365. .canc {
  366. color: rgba(153, 153, 153, 100);
  367. }
  368. .rebook {
  369. color: rgba(0, 185, 98, 100);
  370. }
  371. }
  372. }
  373. </style>