clockIn.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="clock">
  3. <view class="clock-button">
  4. <view class="clock-button-outer">
  5. <view class="clock-button-inner">
  6. <view class="tips">
  7. <view>上班打卡</view>
  8. <view>{{ currentTime }}</view>
  9. </view>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="clock-tips">
  14. <view class="clock-tips-content">
  15. <u-icon name="checkmark-circle-fill" color="#0E9CFF" size="15"></u-icon>
  16. <view>已经进入考勤范围,潍坊软件园...<text>重新定位?</text></view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. currentTime: ''
  26. }
  27. },
  28. onShow() {
  29. this.currentDate();
  30. },
  31. onUnload() {
  32. if (this.formatDate) {
  33. clearInterval(this.formatDate); // 在Vue实例销毁前,清除时间定时器
  34. }
  35. },
  36. methods: {
  37. currentDate() {
  38. setInterval(this.formatDate, 500);
  39. },
  40. formatDate() {
  41. let date = new Date();
  42. let year = date.getFullYear(); // 年
  43. let month = date.getMonth() + 1; // 月
  44. let day = date.getDate(); // 日
  45. let week = date.getDay(); // 星期
  46. let hour = date.getHours(); // 时
  47. hour = hour < 10 ? "0" + hour : hour; // 如果只有一位,则前面补零
  48. let minute = date.getMinutes(); // 分
  49. minute = minute < 10 ? "0" + minute : minute; // 如果只有一位,则前面补零
  50. let second = date.getSeconds(); // 秒
  51. second = second < 10 ? "0" + second : second; // 如果只有一位,则前面补零
  52. this.currentTime = `${hour}:${minute}:${second}`;
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .clock {
  59. &-button {
  60. position: relative;
  61. animation-name: example;
  62. animation-duration: 2s;
  63. animation-fill-mode: forwards;
  64. &-outer {
  65. margin: 0 auto;
  66. width: 270rpx;
  67. height: 270rpx;
  68. background-color: #98D4FE;
  69. border-radius: 50%;
  70. display: flex;
  71. justify-content: center;
  72. align-items: center;
  73. }
  74. @keyframes example {
  75. from {
  76. top: 0;
  77. }
  78. to {
  79. top: 286rpx;
  80. }
  81. }
  82. &-inner {
  83. width: 220rpx;
  84. height: 220rpx;
  85. background-color: #0E9CFF;
  86. border-radius: 50%;
  87. display: flex;
  88. align-items: center;
  89. justify-content: center;
  90. color: #fff;
  91. .tips {
  92. view {
  93. color: #f2f2f2;
  94. font-size: 34rpx;
  95. text-align: center;
  96. &:last-child {
  97. color: #ddd;
  98. font-size: 30rpx;
  99. margin-top: 10rpx;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. &-tips {
  106. text-align: center;
  107. margin-top: 320rpx;
  108. &-content {
  109. display: flex;
  110. align-items: center;
  111. justify-content: center;
  112. color: #000;
  113. font-size: 24rpx;
  114. view {
  115. margin-left: 5rpx;
  116. text {
  117. color: #F4993A;
  118. }
  119. }
  120. }
  121. }
  122. }
  123. </style>