myReservation.vue 9.0 KB

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