record.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. const res = await myRequest({
  128. url: '/wanzai/api/smartVisitor/appointmentPageRecord',
  129. data: {
  130. currentPage: currentPage.value,
  131. pageCount: 6,
  132. userId: uni.getStorageSync('userInfo').id,
  133. type: activeCurrent.value
  134. }
  135. })
  136. // console.log(res)
  137. const result = JSON.parse(decryptDes(res.data))
  138. // console.log(result)
  139. total.value = result.totalCount
  140. list.value = [...list.value, ...result.list]
  141. }
  142. // 点击每一条预约记录时的回调
  143. const handleClick = (item) => {
  144. popObj.value = item
  145. popup.value.open()
  146. }
  147. // 切换分段器时的回调
  148. const onClickItem = (e) => {
  149. if (activeCurrent.value != e.currentIndex) {
  150. activeCurrent.value = e.currentIndex
  151. currentPage.value = 1
  152. list.value = []
  153. getData()
  154. }
  155. }
  156. // 点击取消按钮回调
  157. const handleCancel = (id) => {
  158. uni.showModal({
  159. title: '提示',
  160. content: '确定取消预约吗?',
  161. success: (res) => {
  162. if (res.confirm) {
  163. handleCancelReq(id)
  164. }
  165. }
  166. })
  167. }
  168. // 取消预约请求
  169. const handleCancelReq = async (id) => {
  170. const res = await myRequest({
  171. url: '/wanzai/api/smartVisitor/deleteSmartVisitorById',
  172. data: {
  173. id
  174. }
  175. })
  176. // console.log(res)
  177. uni.showToast({
  178. title: '取消预约成功',
  179. icon: 'none',
  180. duration: 2000
  181. })
  182. setTimeout(() => {
  183. currentPage.value = 1
  184. list.value = []
  185. getData()
  186. }, 2000)
  187. }
  188. // 点击弹窗 x 图标时的回调
  189. const closePop = () => {
  190. popup.value.close()
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. .container {
  195. box-sizing: border-box;
  196. padding-bottom: 30rpx;
  197. min-height: 100vh;
  198. background-color: #f1f6fe;
  199. .body {
  200. padding: 0 20rpx;
  201. .body_box {
  202. padding: 0 20rpx 0 30rpx;
  203. box-sizing: border-box;
  204. margin-top: 20rpx;
  205. width: 710rpx;
  206. border-radius: 15rpx;
  207. background-color: #fff;
  208. .box_title {
  209. display: flex;
  210. justify-content: space-between;
  211. align-items: center;
  212. height: 83rpx;
  213. font-size: 28rpx;
  214. border-bottom: 1rpx solid #e6e6e6;
  215. .title_msg {
  216. display: flex;
  217. align-items: center;
  218. .msg_name {
  219. font-weight: bold;
  220. }
  221. .msg_time {
  222. margin-left: 15rpx;
  223. color: #a6a6a6;
  224. font-size: 24rpx;
  225. }
  226. }
  227. .title_type {
  228. color: #0061ff;
  229. }
  230. .red {
  231. color: #d43030;
  232. }
  233. .green {
  234. color: #00baad;
  235. }
  236. }
  237. .box_info {
  238. display: flex;
  239. flex-direction: column;
  240. .info_box {
  241. display: flex;
  242. align-items: center;
  243. height: 65rpx;
  244. font-size: 24rpx;
  245. .box_key {
  246. width: 120rpx;
  247. color: #a6a6a6;
  248. }
  249. .box_value {
  250. flex: 1;
  251. margin-left: 95rpx;
  252. overflow: hidden;
  253. text-overflow: ellipsis;
  254. white-space: nowrap;
  255. }
  256. }
  257. }
  258. .box_btn {
  259. display: flex;
  260. justify-content: flex-end;
  261. align-items: center;
  262. height: 130rpx;
  263. border-top: 1rpx solid #e6e6e6;
  264. .button {
  265. display: flex;
  266. justify-content: center;
  267. align-items: center;
  268. width: 160rpx;
  269. height: 80rpx;
  270. color: #0061ff;
  271. font-size: 28rpx;
  272. border-radius: 10rpx;
  273. border: 1rpx solid #0061ff;
  274. }
  275. }
  276. }
  277. }
  278. .popup_box {
  279. padding-bottom: 50rpx;
  280. width: 710rpx;
  281. border-radius: 22rpx;
  282. background-color: #fff;
  283. .pop_header {
  284. display: flex;
  285. justify-content: center;
  286. align-items: center;
  287. position: relative;
  288. height: 94rpx;
  289. font-size: 28rpx;
  290. border-bottom: 1rpx solid #e6e6e6;
  291. .header_icon {
  292. position: absolute;
  293. top: 18rpx;
  294. right: 25rpx;
  295. font-size: 40rpx;
  296. }
  297. }
  298. .pop_info {
  299. display: flex;
  300. box-sizing: border-box;
  301. margin-top: 22rpx;
  302. padding: 0 35rpx;
  303. width: 100%;
  304. font-size: 28rpx;
  305. .info_key {
  306. color: #999999;
  307. }
  308. .info_value {
  309. flex: 1;
  310. }
  311. .blue {
  312. color: #0061ff;
  313. }
  314. .red {
  315. color: #d43030;
  316. }
  317. .green {
  318. color: #00baad;
  319. }
  320. }
  321. }
  322. }
  323. // 修改顶部分段器样式
  324. ::v-deep {
  325. .segmented-control {
  326. height: 100rpx;
  327. background-color: #fff;
  328. }
  329. }
  330. </style>