mySubscribe.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="container">
  3. <view class="list" v-if="info">
  4. <!-- 每一个预约记录区域 -->
  5. <view class="box">
  6. <view class="box_header">
  7. <view class="header_left">{{ info.school }}</view>
  8. <view class="header_right">预约成功</view>
  9. </view>
  10. <view class="box_info">
  11. <view class="info_box">车牌号:{{ info.carNumber }}</view>
  12. <view class="info_box">学生姓名:{{ info.name }}</view>
  13. <view class="info_box">手机号:{{ info.phone }}</view>
  14. <!-- <view class="info_box">身份证号:{{ info.studentCard }}</view> -->
  15. <view class="info_box">到访开始时间:{{ info.startTime }}</view>
  16. <view class="info_box">到访结束时间:{{ info.endTime }}</view>
  17. <!-- <view class="info_box">同行人数:{{ info.peerNum }}</view> -->
  18. <view class="info_box">访问事由:{{ info.visitorReason }}</view>
  19. <!-- <view class="info_box">校区:{{ info.school }}</view> -->
  20. <view class="info_btn" @click="handleCancel">取消预约</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="noData" v-else>
  25. 暂无约车信息
  26. <view class="btn" @click="handleSub">去预约</view>
  27. </view>
  28. <view class="btn" @click="handleSelect">宿舍选择</view>
  29. <view class="btn" @click="logout">退出登录</view>
  30. </view>
  31. </template>
  32. <script setup>
  33. import { onLoad } from '@dcloudio/uni-app'
  34. import { ref } from 'vue'
  35. import { getVisitorRecordReq, deleteVisitorRecordReq } from '@/api/index.js'
  36. // 我的预约信息
  37. const info = ref(null)
  38. onLoad(() => {
  39. // 获取我的预约信息
  40. getVisitorRecord()
  41. })
  42. // 获取我的预约
  43. const getVisitorRecord = async () => {
  44. const res = await getVisitorRecordReq()
  45. // console.log(res)
  46. if (res.code == 200) {
  47. info.value = res.data
  48. }
  49. }
  50. // 取消预约按钮回调
  51. const handleCancel = () => {
  52. uni.showModal({
  53. title: '提示',
  54. content: '确定取消预约吗?',
  55. success: async (res) => {
  56. if (res.confirm) {
  57. const res = await deleteVisitorRecordReq(info.value)
  58. // console.log(res)
  59. if (res.code == 200) {
  60. uni.showToast({
  61. title: '取消成功',
  62. icon: 'success'
  63. })
  64. setTimeout(() => {
  65. info.value = null
  66. getVisitorRecord()
  67. }, 1500)
  68. }
  69. }
  70. }
  71. })
  72. }
  73. // 去预约按钮回调
  74. const handleSub = () => {
  75. uni.navigateTo({
  76. url: '/pages/subscribe/subscribe'
  77. })
  78. }
  79. // 宿舍选择按钮回调
  80. const handleSelect = () => {
  81. uni.showModal({
  82. title: '提示',
  83. content: '确定前往宿舍选择吗?',
  84. success: (res) => {
  85. if (res.confirm) {
  86. uni.reLaunch({
  87. url: '/pages/select/select'
  88. })
  89. }
  90. }
  91. })
  92. }
  93. // 退出登录回调
  94. const logout = () => {
  95. uni.showModal({
  96. title: '提示',
  97. content: '确定退出登录吗?',
  98. success: (res) => {
  99. if (res.confirm) {
  100. let urlstr = uni.getStorageSync('urlstr')
  101. uni.clearStorageSync()
  102. window.location.href = `https://chtech.ncjti.edu.cn/welcome/welcomeH5/#/?urlstr=${urlstr}`
  103. }
  104. }
  105. })
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .container {
  110. box-sizing: border-box;
  111. padding: 12rpx 0;
  112. min-height: 100vh;
  113. background-color: #f5f9ff;
  114. .list {
  115. .box {
  116. margin-bottom: 20rpx;
  117. background-color: #fff;
  118. .box_header {
  119. display: flex;
  120. align-items: center;
  121. justify-content: space-between;
  122. padding: 0 20rpx;
  123. height: 86rpx;
  124. font-size: 28rpx;
  125. border-bottom: 2rpx solid #cccccc;
  126. .header_left {
  127. font-weight: bold;
  128. }
  129. .header_right {
  130. color: #0061ff;
  131. }
  132. }
  133. .box_info {
  134. padding: 30rpx 20rpx 40rpx;
  135. font-size: 28rpx;
  136. .info_box {
  137. margin-bottom: 20rpx;
  138. }
  139. .info_btn {
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. margin-left: auto;
  144. margin-top: 35rpx;
  145. width: 180rpx;
  146. height: 70rpx;
  147. font-size: 28rpx;
  148. color: #fff;
  149. border-radius: 8rpx;
  150. background-color: #0061ff;
  151. }
  152. }
  153. }
  154. }
  155. .noData {
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. justify-content: center;
  160. margin-top: 400rpx;
  161. .btn {
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. margin-top: 50rpx;
  166. width: 180rpx;
  167. height: 70rpx;
  168. font-size: 28rpx;
  169. color: #fff;
  170. border-radius: 8rpx;
  171. background-color: #0061ff;
  172. }
  173. }
  174. .btn {
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. margin: 50rpx 20rpx;
  179. height: 100rpx;
  180. font-size: 32rpx;
  181. color: #fff;
  182. border-radius: 8rpx;
  183. background-color: #0061ff;
  184. }
  185. }
  186. </style>