record.vue 8.2 KB

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