home.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="container">
  3. <!-- 头部学生信息区域 -->
  4. <view class="header">
  5. <view class="img">
  6. <img
  7. src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0">
  8. </view>
  9. <view class="msg">
  10. <view class="name">
  11. 程佳欢
  12. </view>
  13. <view class="major">
  14. 文法学院
  15. </view>
  16. </view>
  17. </view>
  18. <!-- 主体打卡区域 -->
  19. <view class="body">
  20. <!-- 卡片区域 -->
  21. <view class="card">
  22. <!-- 每一个卡片区域 -->
  23. <view class="item" v-for="item in list" :key="item.id">
  24. <view class="item_box">
  25. <view class="title">
  26. {{item.title}}
  27. </view>
  28. <view class="time">
  29. {{item.time}}
  30. </view>
  31. <view class="type">
  32. <img v-if="item.type=='已打卡'" src="./imgs/success.png">
  33. <span v-if="item.type=='已打卡'">09:00</span>
  34. {{item.type}}
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- 打卡区域 -->
  40. <view :class="{clock:flags,active:!flags}" @click="handlePunch">
  41. <view class="info" v-if="flags&&list.length">
  42. 打卡
  43. </view>
  44. <view class="info" v-else>
  45. 无法打卡
  46. </view>
  47. <view class="time">
  48. 11:11:56
  49. </view>
  50. </view>
  51. <!-- 位置信息区域 -->
  52. <view class="address" v-if="flags&&list.length">
  53. 江西省南昌市经开区黄家湖东路122号
  54. </view>
  55. <view class="address" v-if="addressFlags&&!flags">
  56. 不在管理员设定范围打卡
  57. </view>
  58. <view class="address" v-if="timeFlags&&!flags">
  59. 未到打卡时间无法打卡
  60. </view>
  61. <view class="address" v-if="!list.length">
  62. 无打卡任务无需打卡
  63. </view>
  64. <view class="address" v-if="!list.length">
  65. 今日休息无需打卡
  66. </view>
  67. <view class="address" v-if="!list.length">
  68. 下一次打卡时间段为18:00-19:00
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. data() {
  76. return {
  77. list: [{
  78. id: 1,
  79. title: "课间操打卡规则",
  80. time: "08:00-9:00",
  81. type: "已打卡"
  82. },
  83. {
  84. id: 2,
  85. title: "课间操打卡规则2",
  86. time: "08:00-10:00",
  87. type: "未打卡"
  88. },
  89. {
  90. id: 3,
  91. title: "课间操打卡规则3",
  92. time: "08:00-19:00",
  93. type: "已打卡"
  94. },
  95. ],
  96. flags: true,
  97. addressFlags: false,
  98. timeFlags: false
  99. };
  100. },
  101. methods: {
  102. // 点击打卡按钮回调
  103. handlePunch() {
  104. // 获取用户摄像头权限
  105. uni.authorize({
  106. scope: 'scope.camera',
  107. success() {
  108. uni.navigateTo({
  109. url: "/pages/location/location"
  110. })
  111. },
  112. fail() {
  113. uni.showModal({
  114. title: '提示',
  115. content: '请先开启摄像头权限,否则将无法使用打卡功能',
  116. cancelText: '不授权',
  117. confirmText: '授权',
  118. success: function(res) {
  119. if (res.confirm) {
  120. uni.openSetting({
  121. success(res) {}
  122. })
  123. } else if (res.cancel) {}
  124. }
  125. });
  126. }
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .container {
  134. padding-top: 20rpx;
  135. .header {
  136. display: flex;
  137. margin: 0 30rpx 30rpx 30rpx;
  138. width: 690rpx;
  139. height: 130rpx;
  140. background-color: #fff;
  141. .img {
  142. margin: 30rpx;
  143. width: 70rpx;
  144. height: 70rpx;
  145. img {
  146. width: 100%;
  147. height: 100%;
  148. }
  149. }
  150. .msg {
  151. margin: 30rpx 0;
  152. height: 70rpx;
  153. line-height: 36rpx;
  154. .name {
  155. font-size: 32rpx;
  156. font-weight: 400;
  157. }
  158. .major {
  159. font-size: 24rpx;
  160. font-weight: 400;
  161. color: #A6A6A6;
  162. }
  163. }
  164. }
  165. .body {
  166. margin: 0 30rpx;
  167. width: 690rpx;
  168. height: 919rpx;
  169. background-color: #fff;
  170. .card {
  171. padding-top: 30rpx;
  172. white-space: nowrap;
  173. height: 160rpx;
  174. overflow-x: auto;
  175. .item {
  176. display: inline-block;
  177. margin: 0 15rpx;
  178. width: 300rpx;
  179. height: 130rpx;
  180. line-height: 12rpx;
  181. border-radius: 8rpx;
  182. font-weight: 400;
  183. background-color: #E6E6E6;
  184. .item_box {
  185. display: flex;
  186. flex-direction: column;
  187. justify-content: space-evenly;
  188. height: 130rpx;
  189. padding-left: 30rpx;
  190. .title {
  191. font-size: 28rpx;
  192. }
  193. .time {
  194. font-size: 24rpx;
  195. }
  196. .type {
  197. font-size: 24rpx;
  198. color: #808080;
  199. img {
  200. margin-right: 10rpx;
  201. width: 20rpx;
  202. height: 20rpx;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. .clock {
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: center;
  212. align-items: center;
  213. margin: auto;
  214. margin-top: 145rpx;
  215. width: 300rpx;
  216. height: 300rpx;
  217. border-radius: 150rpx;
  218. text-align: center;
  219. color: #fff;
  220. background: linear-gradient(180deg, #00ACFC 0%, #0082FC 100%);
  221. .info {
  222. height: 58rpx;
  223. font-size: 40rpx;
  224. font-weight: 700;
  225. }
  226. .time {
  227. height: 41rpx;
  228. font-size: 28rpx;
  229. font-weight: 400;
  230. }
  231. }
  232. .active {
  233. display: flex;
  234. flex-direction: column;
  235. justify-content: center;
  236. align-items: center;
  237. margin: auto;
  238. margin-top: 145rpx;
  239. width: 300rpx;
  240. height: 300rpx;
  241. border-radius: 150rpx;
  242. text-align: center;
  243. color: #fff;
  244. background: linear-gradient(180deg, #CCCCCC 0%, #B3B3B3 100%);
  245. .info {
  246. height: 58rpx;
  247. font-size: 40rpx;
  248. font-weight: 700;
  249. }
  250. .time {
  251. height: 41rpx;
  252. font-size: 28rpx;
  253. font-weight: 400;
  254. }
  255. }
  256. .address {
  257. margin-top: 34rpx;
  258. height: 35rpx;
  259. line-height: 35rpx;
  260. text-align: center;
  261. font-size: 24rpx;
  262. font-weight: 400;
  263. color: #808080;
  264. }
  265. }
  266. }
  267. </style>