cardRecord.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view class="container">
  3. <view class="placeholder"></view>
  4. <!-- 头部区域 -->
  5. <view class="header">
  6. <!-- 时间区域 -->
  7. <view class="calendar">
  8. <!-- 双左箭头区域 -->
  9. <view class="double" @click="handleDoubleLeft"><img src="../static/imgs/double_left.png" /></view>
  10. <!-- 左箭头区域区域 -->
  11. <view class="single" @click="handleLeft"><img src="../static/imgs/left.png" /></view>
  12. <!-- 时间区域 -->
  13. <view class="time">{{ year }}-{{ format_month }}</view>
  14. <!-- 双右箭头区域 -->
  15. <view class="single2" @click="handleRight"><img src="../static/imgs/right2.png" /></view>
  16. <!-- 右箭头区域 -->
  17. <view class="double" @click="handleDoubleRight"><img src="../static/imgs/double_right.png" /></view>
  18. </view>
  19. <!-- 打卡状态切换区域 -->
  20. <view class="state">
  21. <uni-segmented-control :current="current" :values="items" styleType="text" @clickItem="onClickItem" activeColor="#0082FC"></uni-segmented-control>
  22. </view>
  23. </view>
  24. <!-- 打卡记录区域 -->
  25. <view class="list" v-if="list.length">
  26. <!-- 每一条记录区域 -->
  27. <view class="box" v-for="(item, index) in list" :key="index">
  28. <!-- 人物信息区域 -->
  29. <view class="person">
  30. <view class="img"><img :src="item.headImage || '../static/imgs/headImage.png'" /></view>
  31. <view class="info">
  32. <view class="name">{{ item.name }}</view>
  33. <view class="college">{{ item.college ? item.college : '南昌交通学院' }}</view>
  34. </view>
  35. </view>
  36. <!-- 图片区域 -->
  37. <view class="imgs" v-if="item.status == 4">
  38. <view class="imgs_item" v-if="item.faceImage">
  39. <view class="image" @click="handleBigImg(item.faceImage)"><img :src="item.faceImage" /></view>
  40. <view class="title">匹对照片</view>
  41. </view>
  42. <view class="imgs_item" v-if="item.matchFaceImage">
  43. <view class="image" @click="handleBigImg(item.matchFaceImage)"><img :src="item.matchFaceImage" /></view>
  44. <view class="title">被匹对照片</view>
  45. </view>
  46. <view class="imgs_item" v-if="item.sceneImage">
  47. <view class="image" @click="handleBigImg(item.sceneImage)"><img :src="item.sceneImage" /></view>
  48. <view class="title">场景照片</view>
  49. </view>
  50. </view>
  51. <!-- 打卡信息区域 -->
  52. <view class="msg">
  53. <view class="msg_item">
  54. <view class="key">打卡状态:</view>
  55. <view class="value">{{ item.status == 4 ? '打卡成功' : '打卡失败' }}</view>
  56. </view>
  57. <view class="msg_item">
  58. <view class="key">打卡规则:</view>
  59. <view class="value">{{ item.ruleName }}</view>
  60. </view>
  61. <view class="msg_item" v-if="item.status == 4">
  62. <view class="key">打卡时间:</view>
  63. <view class="value">{{ format_time(item.updateTime) }}</view>
  64. </view>
  65. <view class="msg_item" v-if="item.status == 4">
  66. <view class="key">打卡地址:</view>
  67. <view class="value">{{ item.location }}</view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 暂无数据显示区域 -->
  73. <view class="no_data" v-if="list.length == 0">
  74. <img src="../static/imgs/nodata.png" />
  75. <view class="info">暂无数据</view>
  76. </view>
  77. <!-- 图片放大弹窗区域 -->
  78. <uni-popup ref="popup">
  79. <view class="popup_img"><img :src="popupImg" mode="aspectFit" /></view>
  80. </uni-popup>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. // 第几页
  88. page: 1,
  89. // 每页条数
  90. size: 10,
  91. // 数据总条数
  92. total: 0,
  93. // 打卡状态参数
  94. status: '',
  95. // 打卡时间参数
  96. time: null,
  97. // 当前年份
  98. year: null,
  99. // 当前月份
  100. month: null,
  101. // 分段器选项
  102. items: ['全部', '打卡成功', '打卡失败'],
  103. // 当前所在分段器索引
  104. current: 0,
  105. // 列表数组
  106. list: [],
  107. // 弹窗图片路径
  108. popupImg: '',
  109. // 当前年份(不会修改的值,用来对比年份)
  110. currentYear: ''
  111. }
  112. },
  113. onLoad() {
  114. this.getTime()
  115. this.getListData()
  116. },
  117. // 页面滑动到底部触发的回调
  118. onReachBottom() {
  119. if (this.list.length < this.total) {
  120. this.page++
  121. this.getListData()
  122. } else {
  123. uni.showToast({
  124. title: '没有更多数据了',
  125. icon: 'none'
  126. })
  127. }
  128. },
  129. computed: {
  130. // 格式化月份
  131. format_month() {
  132. let temTime = this.month < 10 ? '0' + this.month : this.month
  133. return temTime
  134. }
  135. },
  136. methods: {
  137. // 获取当前年份,月份
  138. getTime() {
  139. let date = new Date()
  140. let year = date.getFullYear()
  141. let month = date.getMonth() + 1
  142. this.month = month
  143. this.year = year
  144. this.currentYear = year
  145. },
  146. // 获取打卡记录列表数组
  147. async getListData() {
  148. this.time = this.year + '-' + this.format_month + '-01 00:00:00'
  149. let res = await this.$myRequest_clockIn({
  150. url: '/attendance/api/sign/check/in/list/month/all',
  151. data: {
  152. page: this.page,
  153. size: this.size,
  154. status: this.status,
  155. time: this.time
  156. }
  157. })
  158. // console.log(res);
  159. if (res.code == 200) {
  160. this.total = res.data.total
  161. this.list = [...this.list, ...res.data.list]
  162. }
  163. },
  164. // 点击放大图片
  165. handleBigImg(url) {
  166. this.popupImg = url
  167. this.$refs.popup.open()
  168. },
  169. // 点击分段器回调
  170. onClickItem(e) {
  171. this.list = []
  172. if (e.currentIndex == 0) {
  173. this.status = ''
  174. } else if (e.currentIndex == 1) {
  175. this.status = 4
  176. } else if (e.currentIndex == 2) {
  177. this.status = 3
  178. }
  179. this.page = 1
  180. this.getListData()
  181. },
  182. // 往后选择年份回调
  183. handleDoubleLeft() {
  184. if (this.year <= this.currentYear - 3) {
  185. uni.showToast({
  186. title: `不能选择${this.currentYear - 3}年之前`,
  187. icon: 'none'
  188. })
  189. } else {
  190. this.list = []
  191. this.year -= 1
  192. this.page = 1
  193. this.getListData()
  194. }
  195. },
  196. // 往前选择年份回调
  197. handleDoubleRight() {
  198. if (this.year >= this.currentYear - 0 + 3) {
  199. uni.showToast({
  200. title: `不能选择${this.currentYear - 0 + 3}年之后`,
  201. icon: 'none'
  202. })
  203. } else {
  204. this.list = []
  205. this.year += 1
  206. this.page = 1
  207. this.getListData()
  208. }
  209. },
  210. // 往后选择月份回调
  211. handleLeft() {
  212. if (this.month <= 1) {
  213. if (this.year <= this.currentYear - 3) {
  214. uni.showToast({
  215. title: `不能选择${this.currentYear - 3}年之前`,
  216. icon: 'none'
  217. })
  218. } else {
  219. this.list = []
  220. this.year -= 1
  221. this.month = 12
  222. this.page = 1
  223. this.getListData()
  224. }
  225. } else {
  226. this.list = []
  227. this.month -= 1
  228. this.page = 1
  229. this.getListData()
  230. }
  231. },
  232. // 往前选择月份回调
  233. handleRight() {
  234. if (this.month >= 12) {
  235. if (this.year >= this.currentYear - 0 + 3) {
  236. uni.showToast({
  237. title: `不能选择${this.currentYear - 0 + 3}年之后`,
  238. icon: 'none'
  239. })
  240. } else {
  241. this.list = []
  242. this.year += 1
  243. this.month = 1
  244. this.page = 1
  245. this.getListData()
  246. }
  247. } else {
  248. this.list = []
  249. this.month += 1
  250. this.page = 1
  251. this.getListData()
  252. }
  253. },
  254. // 格式化时间
  255. format_time(timestamp) {
  256. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  257. var date = new Date(timestamp)
  258. var y = date.getFullYear()
  259. var m = date.getMonth() + 1
  260. var d = date.getDate()
  261. m = m < 10 ? '0' + m : m
  262. d = d < 10 ? '0' + d : d
  263. var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  264. var mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  265. var s = date.getSeconds()
  266. s = s < 10 ? '0' + s : s
  267. let strDate = y + '-' + m + '-' + d + ' ' + h + ':' + mm + ':' + s
  268. return strDate
  269. }
  270. }
  271. }
  272. </script>
  273. <style lang="scss" scoped>
  274. .container {
  275. min-width: 100vw;
  276. min-height: 100vh;
  277. background-color: #f2f2f2;
  278. .placeholder {
  279. height: 20rpx;
  280. }
  281. .header {
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: space-evenly;
  285. margin: 0 auto;
  286. width: 690rpx;
  287. height: 192rpx;
  288. background-color: #fff;
  289. .calendar {
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. flex: 1;
  294. .double {
  295. width: 40rpx;
  296. height: 40rpx;
  297. img {
  298. width: 100%;
  299. height: 100%;
  300. }
  301. }
  302. .single {
  303. margin-left: 30rpx;
  304. width: 40rpx;
  305. height: 40rpx;
  306. img {
  307. width: 80%;
  308. height: 70%;
  309. }
  310. }
  311. .single2 {
  312. margin-right: 30rpx;
  313. width: 40rpx;
  314. height: 40rpx;
  315. img {
  316. width: 100%;
  317. height: 70%;
  318. }
  319. }
  320. .time {
  321. width: 180rpx;
  322. height: 44rpx;
  323. font-size: 32rpx;
  324. text-align: center;
  325. }
  326. }
  327. .state {
  328. display: flex;
  329. flex-direction: column;
  330. justify-content: center;
  331. flex: 1;
  332. }
  333. }
  334. .list {
  335. padding-bottom: 50rpx;
  336. .box {
  337. margin: 0 auto;
  338. margin-top: 20rpx;
  339. width: 690rpx;
  340. background-color: #fff;
  341. .person {
  342. display: flex;
  343. align-items: center;
  344. height: 134rpx;
  345. .img {
  346. margin: 0 20rpx 0 30rpx;
  347. width: 70rpx;
  348. height: 70rpx;
  349. img {
  350. width: 100%;
  351. height: 100%;
  352. }
  353. }
  354. .info {
  355. width: 620rpx;
  356. height: 70rpx;
  357. .name {
  358. font-size: 32rpx;
  359. }
  360. .college {
  361. font-size: 24rpx;
  362. color: #a6a6a6;
  363. }
  364. }
  365. }
  366. .imgs {
  367. display: flex;
  368. justify-content: space-evenly;
  369. height: 201rpx;
  370. .imgs_item {
  371. display: flex;
  372. flex-direction: column;
  373. align-items: center;
  374. flex: 1;
  375. .image {
  376. width: 120rpx;
  377. height: 120rpx;
  378. img {
  379. width: 100%;
  380. height: 100%;
  381. }
  382. }
  383. .title {
  384. margin-top: 10rpx;
  385. font-size: 28rpx;
  386. }
  387. }
  388. }
  389. .msg {
  390. margin-left: 30rpx;
  391. .msg_item {
  392. display: flex;
  393. align-items: center;
  394. height: 63rpx;
  395. font-size: 28rpx;
  396. .key {
  397. color: #808080;
  398. }
  399. .value {
  400. }
  401. }
  402. }
  403. }
  404. }
  405. .no_data {
  406. margin: 0 auto;
  407. margin-top: 230rpx;
  408. width: 480rpx;
  409. height: 508rpx;
  410. text-align: center;
  411. img {
  412. width: 100%;
  413. height: 100%;
  414. }
  415. .info {
  416. color: #5792f0;
  417. }
  418. }
  419. .popup_img {
  420. }
  421. }
  422. </style>