record.vue 8.4 KB

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