record.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="container">
  3. <!-- 分段器区域 -->
  4. <uni-segmented-control :current="activeCurrent" :values="controlList" @clickItem="onClickItem" styleType="text" activeColor="#0061FF"></uni-segmented-control>
  5. <!-- 预约记录区域 -->
  6. <view class="body">
  7. <!-- 每一条预约记录区域 -->
  8. <view class="body_box" v-for="item in list" :key="item.id" @click="handleClick(item)">
  9. <view class="box_title">
  10. <view class="title_msg">
  11. <view class="msg_name">{{ item.userName }}</view>
  12. <view class="msg_time">/{{ time_format(item.createTime) }}</view>
  13. </view>
  14. <view class="title_type" v-if="item.statuStr == '待审核'">{{ item.statuStr }}</view>
  15. <view class="title_type red" v-if="item.statuStr == '已拒绝'">{{ item.statuStr }}</view>
  16. <view class="title_type green" v-if="item.statuStr == '已推送'">{{ item.statuStr }}</view>
  17. </view>
  18. <view class="box_info">
  19. <view class="info_box">
  20. <view class="box_key">来访时间</view>
  21. <view class="box_value">{{ time_format(item.visitorTime) }}</view>
  22. </view>
  23. <view class="info_box">
  24. <view class="box_key">访问事由</view>
  25. <view class="box_value">{{ item.visitReason }}</view>
  26. </view>
  27. </view>
  28. <view class="box_btn" v-if="item.statuStr == '待审核'">
  29. <view class="button" @click.stop="handleCancel(item.id)">取消预约</view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 没有数据时展示的页面 -->
  34. <NoData v-if="!list.length" />
  35. <!-- 详情弹窗区域 -->
  36. <uni-popup ref="popup" type="center" :is-mask-click="false">
  37. <view class="popup_box">
  38. <!-- 弹窗标题区域 -->
  39. <view class="pop_header">
  40. 预约详情
  41. <view class="header_icon" @click="closePop">×</view>
  42. </view>
  43. <!-- 弹窗详细信息区域 -->
  44. <view class="pop_info">
  45. <view class="info_key">状态:</view>
  46. <view class="info_value blue" v-if="popObj.statuStr == '待审核'">{{ popObj.statuStr }}</view>
  47. <view class="info_value red" v-if="popObj.statuStr == '已拒绝'">{{ popObj.statuStr }}</view>
  48. <view class="info_value green" v-if="popObj.statuStr == '已推送'">{{ popObj.statuStr }}</view>
  49. </view>
  50. <view class="pop_info">
  51. <view class="info_key">访客姓名:</view>
  52. <view class="info_value">{{ popObj.userName }}</view>
  53. </view>
  54. <view class="pop_info">
  55. <view class="info_key">访客手机号:</view>
  56. <view class="info_value">{{ popObj.userPhone }}</view>
  57. </view>
  58. <view class="pop_info">
  59. <view class="info_key">来访时间:</view>
  60. <view class="info_value" v-if="popObj.visitorTime">{{ time_format(popObj.visitorTime) }}</view>
  61. </view>
  62. <view class="pop_info">
  63. <view class="info_key">证件号:</view>
  64. <view class="info_value">{{ popObj.userNumber || '暂无' }}</view>
  65. </view>
  66. <view class="pop_info">
  67. <view class="info_key">访问事由:</view>
  68. <view class="info_value">{{ popObj.visitReason }}</view>
  69. </view>
  70. <view class="pop_info">
  71. <view class="info_key">车牌号:</view>
  72. <view class="info_value">{{ popObj.carNum ? popObj.carNum : '暂无' }}</view>
  73. </view>
  74. <view class="pop_info">
  75. <view class="info_key">同行人数:</view>
  76. <view class="info_value">{{ popObj.peerNum ? popObj.peerNum : '暂无' }}</view>
  77. </view>
  78. <view class="pop_info">
  79. <view class="info_key">{{ popObj.visitorType == 1 ? '受访学生' : '受访人' }}:</view>
  80. <view class="info_value">{{ popObj.respondentName }}({{ popObj.responcode || popObj.respondentPhone }})</view>
  81. </view>
  82. </view>
  83. </uni-popup>
  84. <!-- 底部导航栏区域 -->
  85. <Tabber />
  86. </view>
  87. </template>
  88. <script setup>
  89. import { ref } from 'vue'
  90. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  91. import Tabber from '@/components/tabber.vue'
  92. import NoData from '@/components/noData.vue'
  93. import { myRequest } from '@/utils/api.js'
  94. import { decryptDes } from '@/utils/des.js'
  95. import { time_format } from '@/utils/formatTime.js'
  96. // 分段器当前索引
  97. const activeCurrent = ref(0)
  98. // 当前页
  99. const currentPage = ref(1)
  100. // 记录总条数
  101. const total = ref(0)
  102. // 分段器数组
  103. const controlList = ['全部', '待审核', '已拒绝', '进校核销', '出校核销', '已完成']
  104. // 预约记录数组
  105. const list = ref([])
  106. // 弹窗元素标记
  107. const popup = ref(null)
  108. // 弹窗详细信息
  109. const popObj = ref({})
  110. onLoad(() => {
  111. getData()
  112. })
  113. // 页面上拉到最底部时触发的回调
  114. onReachBottom(() => {
  115. if (total.value > list.value.length) {
  116. currentPage.value++
  117. getData()
  118. } else {
  119. uni.showToast({
  120. title: '没有更多数据了',
  121. icon: 'none'
  122. })
  123. }
  124. })
  125. // 获取预约记录数据
  126. const getData = async () => {
  127. let type
  128. if (activeCurrent.value == 0) {
  129. type = 0
  130. } else if (activeCurrent.value == 1) {
  131. type = 1
  132. } else if (activeCurrent.value == 2) {
  133. type = 2
  134. } else if (activeCurrent.value == 3) {
  135. type = 7
  136. } else if (activeCurrent.value == 4) {
  137. type = 8
  138. } else if (activeCurrent.value == 5) {
  139. type = 9
  140. }
  141. const res = await myRequest({
  142. url: '/wanzai/api/smartVisitor/appointmentPageRecord',
  143. data: {
  144. currentPage: currentPage.value,
  145. pageCount: 6,
  146. userId: uni.getStorageSync('userInfo').id,
  147. type
  148. }
  149. })
  150. // console.log(res)
  151. const result = JSON.parse(decryptDes(res.data))
  152. // console.log(result)
  153. total.value = result.totalCount
  154. list.value = [...list.value, ...result.list]
  155. }
  156. // 点击每一条预约记录时的回调
  157. const handleClick = (item) => {
  158. popObj.value = item
  159. popup.value.open()
  160. }
  161. // 切换分段器时的回调
  162. const onClickItem = (e) => {
  163. if (activeCurrent.value != e.currentIndex) {
  164. activeCurrent.value = e.currentIndex
  165. currentPage.value = 1
  166. list.value = []
  167. getData()
  168. }
  169. }
  170. // 点击取消按钮回调
  171. const handleCancel = (id) => {
  172. uni.showModal({
  173. title: '提示',
  174. content: '确定取消预约吗?',
  175. success: (res) => {
  176. if (res.confirm) {
  177. handleCancelReq(id)
  178. }
  179. }
  180. })
  181. }
  182. // 取消预约请求
  183. const handleCancelReq = async (id) => {
  184. const res = await myRequest({
  185. url: '/wanzai/api/smartVisitor/deleteSmartVisitorById',
  186. data: {
  187. id
  188. }
  189. })
  190. // console.log(res)
  191. uni.showToast({
  192. title: '取消预约成功',
  193. icon: 'none',
  194. duration: 2000
  195. })
  196. setTimeout(() => {
  197. currentPage.value = 1
  198. list.value = []
  199. getData()
  200. }, 2000)
  201. }
  202. // 点击弹窗 x 图标时的回调
  203. const closePop = () => {
  204. popup.value.close()
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. .container {
  209. box-sizing: border-box;
  210. padding-bottom: 30rpx;
  211. min-height: 100vh;
  212. background-color: #f1f6fe;
  213. .body {
  214. padding: 0 20rpx;
  215. .body_box {
  216. padding: 0 20rpx 0 30rpx;
  217. box-sizing: border-box;
  218. margin-top: 20rpx;
  219. width: 710rpx;
  220. border-radius: 15rpx;
  221. background-color: #fff;
  222. .box_title {
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. height: 83rpx;
  227. font-size: 28rpx;
  228. border-bottom: 1rpx solid #e6e6e6;
  229. .title_msg {
  230. display: flex;
  231. align-items: center;
  232. .msg_name {
  233. font-weight: bold;
  234. }
  235. .msg_time {
  236. margin-left: 15rpx;
  237. color: #a6a6a6;
  238. font-size: 24rpx;
  239. }
  240. }
  241. .title_type {
  242. color: #0061ff;
  243. }
  244. .red {
  245. color: #d43030;
  246. }
  247. .green {
  248. color: #00baad;
  249. }
  250. }
  251. .box_info {
  252. display: flex;
  253. flex-direction: column;
  254. .info_box {
  255. display: flex;
  256. align-items: center;
  257. height: 65rpx;
  258. font-size: 24rpx;
  259. .box_key {
  260. width: 120rpx;
  261. color: #a6a6a6;
  262. }
  263. .box_value {
  264. flex: 1;
  265. margin-left: 95rpx;
  266. overflow: hidden;
  267. text-overflow: ellipsis;
  268. white-space: nowrap;
  269. }
  270. }
  271. }
  272. .box_btn {
  273. display: flex;
  274. justify-content: flex-end;
  275. align-items: center;
  276. height: 130rpx;
  277. border-top: 1rpx solid #e6e6e6;
  278. .button {
  279. display: flex;
  280. justify-content: center;
  281. align-items: center;
  282. width: 160rpx;
  283. height: 80rpx;
  284. color: #0061ff;
  285. font-size: 28rpx;
  286. border-radius: 10rpx;
  287. border: 1rpx solid #0061ff;
  288. }
  289. }
  290. }
  291. }
  292. .popup_box {
  293. padding-bottom: 50rpx;
  294. width: 710rpx;
  295. border-radius: 22rpx;
  296. background-color: #fff;
  297. .pop_header {
  298. display: flex;
  299. justify-content: center;
  300. align-items: center;
  301. position: relative;
  302. height: 94rpx;
  303. font-size: 28rpx;
  304. border-bottom: 1rpx solid #e6e6e6;
  305. .header_icon {
  306. position: absolute;
  307. top: 18rpx;
  308. right: 25rpx;
  309. font-size: 40rpx;
  310. }
  311. }
  312. .pop_info {
  313. display: flex;
  314. box-sizing: border-box;
  315. margin-top: 22rpx;
  316. padding: 0 35rpx;
  317. width: 100%;
  318. font-size: 28rpx;
  319. .info_key {
  320. color: #999999;
  321. }
  322. .info_value {
  323. flex: 1;
  324. }
  325. .blue {
  326. color: #0061ff;
  327. }
  328. .red {
  329. color: #d43030;
  330. }
  331. .green {
  332. color: #00baad;
  333. }
  334. }
  335. }
  336. }
  337. // 修改顶部分段器样式
  338. ::v-deep {
  339. .segmented-control {
  340. height: 100rpx;
  341. background-color: #fff;
  342. }
  343. }
  344. </style>