home.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. onLoad() {
  102. // this.getRulesList()
  103. },
  104. methods: {
  105. // 获取打卡规则列表
  106. async getRulesList() {
  107. console.log(1);
  108. let res = await this.$myRequest({
  109. url: "/attendance/api/settings/rule/list",
  110. })
  111. console.log(res);
  112. console.log(2);
  113. },
  114. // 点击打卡按钮回调
  115. handlePunch() {
  116. // 获取用户摄像头权限
  117. uni.authorize({
  118. scope: 'scope.camera',
  119. success() {
  120. uni.navigateTo({
  121. url: "/pages/location/location"
  122. })
  123. },
  124. fail() {
  125. uni.showModal({
  126. title: '提示',
  127. content: '请先开启摄像头权限,否则将无法使用打卡功能',
  128. cancelText: '不授权',
  129. confirmText: '授权',
  130. success: function(res) {
  131. if (res.confirm) {
  132. uni.openSetting({
  133. success(res) {}
  134. })
  135. } else if (res.cancel) {}
  136. }
  137. });
  138. }
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .container {
  146. padding-top: 20rpx;
  147. .header {
  148. display: flex;
  149. margin: 0 30rpx 30rpx 30rpx;
  150. width: 690rpx;
  151. height: 130rpx;
  152. background-color: #fff;
  153. .img {
  154. margin: 30rpx;
  155. width: 70rpx;
  156. height: 70rpx;
  157. img {
  158. width: 100%;
  159. height: 100%;
  160. }
  161. }
  162. .msg {
  163. margin: 30rpx 0;
  164. height: 70rpx;
  165. line-height: 36rpx;
  166. .name {
  167. font-size: 32rpx;
  168. font-weight: 400;
  169. }
  170. .major {
  171. font-size: 24rpx;
  172. font-weight: 400;
  173. color: #A6A6A6;
  174. }
  175. }
  176. }
  177. .body {
  178. margin: 0 30rpx;
  179. width: 690rpx;
  180. height: 919rpx;
  181. background-color: #fff;
  182. .card {
  183. padding-top: 30rpx;
  184. white-space: nowrap;
  185. height: 160rpx;
  186. overflow-x: auto;
  187. .item {
  188. display: inline-block;
  189. margin: 0 15rpx;
  190. width: 300rpx;
  191. height: 130rpx;
  192. line-height: 12rpx;
  193. border-radius: 8rpx;
  194. font-weight: 400;
  195. background-color: #E6E6E6;
  196. .item_box {
  197. display: flex;
  198. flex-direction: column;
  199. justify-content: space-evenly;
  200. height: 130rpx;
  201. padding-left: 30rpx;
  202. .title {
  203. font-size: 28rpx;
  204. }
  205. .time {
  206. font-size: 24rpx;
  207. }
  208. .type {
  209. font-size: 24rpx;
  210. color: #808080;
  211. img {
  212. margin-right: 10rpx;
  213. width: 20rpx;
  214. height: 20rpx;
  215. }
  216. }
  217. }
  218. }
  219. }
  220. .clock {
  221. display: flex;
  222. flex-direction: column;
  223. justify-content: center;
  224. align-items: center;
  225. margin: auto;
  226. margin-top: 145rpx;
  227. width: 300rpx;
  228. height: 300rpx;
  229. border-radius: 150rpx;
  230. text-align: center;
  231. color: #fff;
  232. background: linear-gradient(180deg, #00ACFC 0%, #0082FC 100%);
  233. .info {
  234. height: 58rpx;
  235. font-size: 40rpx;
  236. font-weight: 700;
  237. }
  238. .time {
  239. height: 41rpx;
  240. font-size: 28rpx;
  241. font-weight: 400;
  242. }
  243. }
  244. .active {
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: center;
  248. align-items: center;
  249. margin: auto;
  250. margin-top: 145rpx;
  251. width: 300rpx;
  252. height: 300rpx;
  253. border-radius: 150rpx;
  254. text-align: center;
  255. color: #fff;
  256. background: linear-gradient(180deg, #CCCCCC 0%, #B3B3B3 100%);
  257. .info {
  258. height: 58rpx;
  259. font-size: 40rpx;
  260. font-weight: 700;
  261. }
  262. .time {
  263. height: 41rpx;
  264. font-size: 28rpx;
  265. font-weight: 400;
  266. }
  267. }
  268. .address {
  269. margin-top: 34rpx;
  270. height: 35rpx;
  271. line-height: 35rpx;
  272. text-align: center;
  273. font-size: 24rpx;
  274. font-weight: 400;
  275. color: #808080;
  276. }
  277. }
  278. }
  279. </style>