cardRecord.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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" /></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. currentYear: ''
  110. }
  111. },
  112. onLoad() {
  113. this.getTime()
  114. this.getListData()
  115. },
  116. // 页面滑动到底部触发的回调
  117. onReachBottom() {
  118. if (this.list.length < this.total) {
  119. this.page++
  120. this.getListData()
  121. } else {
  122. uni.showToast({
  123. title: '没有更多数据了',
  124. icon: 'none'
  125. })
  126. }
  127. },
  128. computed: {
  129. // 格式化月份
  130. format_month() {
  131. let temTime = this.month < 10 ? '0' + this.month : this.month
  132. return temTime
  133. }
  134. },
  135. methods: {
  136. // 获取当前年份,月份
  137. getTime() {
  138. let date = new Date()
  139. let year = date.getFullYear()
  140. let month = date.getMonth() + 1
  141. this.month = month
  142. this.year = year
  143. this.currentYear = year
  144. },
  145. // 获取打卡记录列表数组
  146. async getListData() {
  147. this.time = this.year + '-' + this.format_month + '-01 00:00:00'
  148. let res = await this.$myRequest_clockIn({
  149. url: '/attendance/api/sign/check/in/list/month/all',
  150. data: {
  151. page: this.page,
  152. size: this.size,
  153. status: this.status,
  154. time: this.time
  155. }
  156. })
  157. // console.log(res);
  158. if (res.code == 200) {
  159. this.total = res.data.total
  160. this.list = [...this.list, ...res.data.list]
  161. }
  162. },
  163. // 点击放大图片
  164. handleBigImg(url) {
  165. this.popupImg = url
  166. this.$refs.popup.open()
  167. },
  168. // 点击分段器回调
  169. onClickItem(e) {
  170. this.list = []
  171. if (e.currentIndex == 0) {
  172. this.status = ''
  173. } else if (e.currentIndex == 1) {
  174. this.status = 4
  175. } else if (e.currentIndex == 2) {
  176. this.status = 3
  177. }
  178. this.page = 1
  179. this.getListData()
  180. },
  181. // 往后选择年份回调
  182. handleDoubleLeft() {
  183. if (this.year <= this.currentYear - 3) {
  184. uni.showToast({
  185. title: `不能选择${this.currentYear - 3}年之前`,
  186. icon: 'none'
  187. })
  188. } else {
  189. this.list = []
  190. this.year -= 1
  191. this.page = 1
  192. this.getListData()
  193. }
  194. },
  195. // 往前选择年份回调
  196. handleDoubleRight() {
  197. if (this.year >= this.currentYear - 0 + 3) {
  198. uni.showToast({
  199. title: `不能选择${this.currentYear - 0 + 3}年之后`,
  200. icon: 'none'
  201. })
  202. } else {
  203. this.list = []
  204. this.year += 1
  205. this.page = 1
  206. this.getListData()
  207. }
  208. },
  209. // 往后选择月份回调
  210. handleLeft() {
  211. if (this.month <= 1) {
  212. if (this.year <= this.currentYear - 3) {
  213. uni.showToast({
  214. title: `不能选择${this.currentYear - 3}年之前`,
  215. icon: 'none'
  216. })
  217. } else {
  218. this.list = []
  219. this.year -= 1
  220. this.month = 12
  221. this.page = 1
  222. this.getListData()
  223. }
  224. } else {
  225. this.list = []
  226. this.month -= 1
  227. this.page = 1
  228. this.getListData()
  229. }
  230. },
  231. // 往前选择月份回调
  232. handleRight() {
  233. if (this.month >= 12) {
  234. if (this.year >= this.currentYear - 0 + 3) {
  235. uni.showToast({
  236. title: `不能选择${this.currentYear - 0 + 3}年之后`,
  237. icon: 'none'
  238. })
  239. } else {
  240. this.list = []
  241. this.year += 1
  242. this.month = 1
  243. this.page = 1
  244. this.getListData()
  245. }
  246. } else {
  247. this.list = []
  248. this.month += 1
  249. this.page = 1
  250. this.getListData()
  251. }
  252. },
  253. // 格式化时间
  254. format_time(timestamp) {
  255. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  256. var date = new Date(timestamp)
  257. var y = date.getFullYear()
  258. var m = date.getMonth() + 1
  259. var d = date.getDate()
  260. m = m < 10 ? '0' + m : m
  261. d = d < 10 ? '0' + d : d
  262. var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  263. var mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  264. var s = date.getSeconds()
  265. s = s < 10 ? '0' + s : s
  266. let strDate = y + '-' + m + '-' + d + ' ' + h + ':' + mm + ':' + s
  267. return strDate
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. .container {
  274. min-width: 100vw;
  275. min-height: 100vh;
  276. background-color: #f2f2f2;
  277. .placeholder {
  278. height: 20rpx;
  279. }
  280. .header {
  281. display: flex;
  282. flex-direction: column;
  283. justify-content: space-evenly;
  284. margin: 0 auto;
  285. width: 690rpx;
  286. height: 192rpx;
  287. background-color: #fff;
  288. .calendar {
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. flex: 1;
  293. .double {
  294. width: 40rpx;
  295. height: 40rpx;
  296. img {
  297. width: 100%;
  298. height: 100%;
  299. }
  300. }
  301. .single {
  302. margin-left: 30rpx;
  303. width: 40rpx;
  304. height: 40rpx;
  305. img {
  306. width: 80%;
  307. height: 70%;
  308. }
  309. }
  310. .single2 {
  311. margin-right: 30rpx;
  312. width: 40rpx;
  313. height: 40rpx;
  314. img {
  315. width: 100%;
  316. height: 70%;
  317. }
  318. }
  319. .time {
  320. width: 180rpx;
  321. height: 44rpx;
  322. font-size: 32rpx;
  323. text-align: center;
  324. }
  325. }
  326. .state {
  327. display: flex;
  328. flex-direction: column;
  329. justify-content: center;
  330. flex: 1;
  331. }
  332. }
  333. .list {
  334. padding-bottom: 50rpx;
  335. .box {
  336. margin: 0 auto;
  337. margin-top: 20rpx;
  338. width: 690rpx;
  339. background-color: #fff;
  340. .person {
  341. display: flex;
  342. align-items: center;
  343. height: 134rpx;
  344. .img {
  345. margin: 0 20rpx 0 30rpx;
  346. width: 70rpx;
  347. height: 70rpx;
  348. img {
  349. width: 100%;
  350. height: 100%;
  351. }
  352. }
  353. .info {
  354. width: 620rpx;
  355. height: 70rpx;
  356. .name {
  357. font-size: 32rpx;
  358. }
  359. .college {
  360. font-size: 24rpx;
  361. color: #a6a6a6;
  362. }
  363. }
  364. }
  365. .imgs {
  366. display: flex;
  367. justify-content: space-evenly;
  368. height: 201rpx;
  369. .imgs_item {
  370. display: flex;
  371. flex-direction: column;
  372. align-items: center;
  373. flex: 1;
  374. .image {
  375. width: 120rpx;
  376. height: 120rpx;
  377. img {
  378. width: 100%;
  379. height: 100%;
  380. }
  381. }
  382. .title {
  383. margin-top: 10rpx;
  384. font-size: 28rpx;
  385. }
  386. }
  387. }
  388. .msg {
  389. margin-left: 30rpx;
  390. .msg_item {
  391. display: flex;
  392. align-items: center;
  393. height: 63rpx;
  394. font-size: 28rpx;
  395. .key {
  396. color: #808080;
  397. }
  398. .value {
  399. }
  400. }
  401. }
  402. }
  403. }
  404. .no_data {
  405. margin: 0 auto;
  406. margin-top: 230rpx;
  407. width: 480rpx;
  408. height: 508rpx;
  409. text-align: center;
  410. img {
  411. width: 100%;
  412. height: 100%;
  413. }
  414. .info {
  415. color: #5792f0;
  416. }
  417. }
  418. .popup_img {
  419. width: 600rpx;
  420. height: 600rpx;
  421. background-color: #fff;
  422. img {
  423. width: 100%;
  424. height: 100%;
  425. }
  426. }
  427. }
  428. </style>