【PT.SCC实名制管理系统】24.10.01 -30天,考勤打卡小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

299 lines
6.4 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. <template>
  2. <view class="home">
  3. <!-- 顶部背景 -->
  4. <view class="home-top">
  5. <image class="home-top-bg" src="https://tennis-oss.xzaiyp.top/2024-10-22/81f3569e-c60c-4945-bfc9-b0e976f26d8e.png" mode="widthFix"></image>
  6. </view>
  7. <!-- 卡片(地图) -->
  8. <view class="card">
  9. <view @click="openBroadside" class="team">
  10. <view class="change-icon">
  11. <image src="https://tennis-oss.xzaiyp.top/2024-10-22/4e624b94-e080-4ec4-86de-196ad83538a5.png" mode="widthFix"></image>
  12. </view>
  13. <view class="project"
  14. v-if="userInfo.team">
  15. {{ userInfo.team.name }}
  16. </view>
  17. </view>
  18. <view class="map">
  19. <map style="width: 100%; height: 100%"
  20. :latitude="latitude"
  21. :longitude="longitude"
  22. :markers="covers" :scale="13">
  23. </map>
  24. </view>
  25. </view>
  26. <!-- 打卡按钮 -->
  27. <view class="punch-card">
  28. <view @click="toClock" class="circle">
  29. <view class="title">拍照打卡</view>
  30. <view class="time">{{ date.format('YYYY-MM-DD HH:mm:ss') }}</view>
  31. </view>
  32. </view>
  33. <!-- 签到记录 -->
  34. <div @click="toRecord" class="sign">
  35. <div class="sign-title">
  36. <image class="sign-title-img" src="https://tennis-oss.xzaiyp.top/2024-10-22/3d70c0d0-f298-4187-8b01-d809757f4049.png" mode="widthFix"></image>
  37. <div class="title">打卡记录</div>
  38. </div>
  39. <div class="project">
  40. <text class="project-name"
  41. v-if="userInfo.team">{{ userInfo.team.name }}</text>
  42. <uv-icon name="arrow-right" color="#000"></uv-icon>
  43. </div>
  44. </div>
  45. <!-- tab栏 -->
  46. <tabbar :select="0"></tabbar>
  47. <!-- 侧边栏 -->
  48. <broadside ref="broadside"></broadside>
  49. </view>
  50. </template>
  51. <script>
  52. import tabbar from '../../components/base/tabbar.vue'
  53. import broadside from '../../components/broadside/broadside.vue'
  54. import { mapState } from 'vuex'
  55. export default {
  56. name: "Home",
  57. components: {
  58. tabbar,
  59. broadside
  60. },
  61. data() {
  62. return {
  63. latitude: 39.909,
  64. longitude: 116.39742,
  65. covers: [],
  66. inter : null,
  67. date : this.$dayjs()
  68. }
  69. },
  70. computed : {
  71. ...mapState(['teamList', 'userInfo']),
  72. },
  73. onLoad() {
  74. this.inter = setInterval(() => {
  75. this.date = this.$dayjs()
  76. }, 1000)
  77. },
  78. onUnload() {
  79. clearInterval(this.inter)
  80. },
  81. onShow() {
  82. this.getLocation()
  83. this.$store.commit('getUserInfo')
  84. },
  85. methods: {
  86. // 跳转签到记录
  87. toRecord() {
  88. uni.navigateTo({
  89. url: "/pages/subPack/record/record"
  90. })
  91. },
  92. //打开侧边栏
  93. openBroadside() {
  94. this.$refs.broadside.open()
  95. },
  96. toClock(){
  97. // 检查当前是否在打卡时间段内
  98. this.$api('clockTime', {
  99. lon : this.longitude,
  100. lat : this.latitude
  101. }, res => {
  102. //打卡(跳转人脸识别)
  103. if(res.code == 200){
  104. uni.navigateTo({
  105. // url: "/pages/subPack/face/face"
  106. url: "/pages/subPack/human/human"
  107. })
  108. }
  109. })
  110. },
  111. //获取用户位置
  112. getLocation() {
  113. let self = this;
  114. uni.getLocation({
  115. type: 'gcj02',
  116. success: function(res) {
  117. self.longitude = res.longitude;
  118. self.latitude = res.latitude;
  119. // self.covers.push({
  120. // id: 1,
  121. // latitude: res.latitude,
  122. // longitude: res.longitude,
  123. // iconPath: 'https://tennis-oss.xzaiyp.top/2024-10-22/103fa1db-8524-45e6-8d00-c36a69977a5b.png',
  124. // width: 30,
  125. // height: 30
  126. // })
  127. },
  128. fail() {
  129. self.checkAndRequestLocationPermission()
  130. }
  131. });
  132. },
  133. checkAndRequestLocationPermission() {
  134. let self = this;
  135. uni.getSetting({
  136. success: function(res) {
  137. if (!res.authSetting['scope.userLocation']) {
  138. // 用户未授权定位权限
  139. uni.showModal({
  140. title: '提示',
  141. content: '当前定位未开启,请点击确定手动开启定位',
  142. success: function(modalRes) {
  143. if (modalRes.confirm) {
  144. // 用户选择确认开启定位
  145. uni.openSetting({
  146. success: function(settingRes) {
  147. if (settingRes.authSetting[
  148. 'scope.userLocation']) {
  149. // 重新获取位置信息
  150. self.getLocation();
  151. } else {
  152. // 用户未开启定位权限
  153. console.log('用户未开启定位权限');
  154. }
  155. },
  156. fail: function(err) {
  157. console.log('打开设置页面失败:', err);
  158. }
  159. });
  160. } else {
  161. // 用户选择取消
  162. self.getLocation()
  163. }
  164. }
  165. });
  166. } else {
  167. // 用户已授权定位权限但获取位置失败(可能是设备未开启定位服务)
  168. console.log('用户已授权定位权限,但获取位置失败');
  169. // 可以提示用户检查设备定位服务是否开启
  170. }
  171. }
  172. });
  173. },
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .home {
  179. background: $bg-color;
  180. min-height: 100vh;
  181. // 顶部背景
  182. .home-top {
  183. height: 490rpx;
  184. overflow: hidden;
  185. .home-top-bg {
  186. width: 750rpx;
  187. }
  188. }
  189. // 卡片(地图)
  190. .card {
  191. width: 95%;
  192. margin: -340rpx auto 0rpx auto;
  193. position: relative;
  194. .team {
  195. display: flex;
  196. margin: 15rpx 0rpx;
  197. color: white;
  198. font-size: 34rpx;
  199. .change-icon {
  200. display: flex;
  201. align-items: center;
  202. width: 40rpx;
  203. margin-right: 10rpx;
  204. image {
  205. width: 100%;
  206. }
  207. }
  208. }
  209. .map {
  210. height: 350rpx;
  211. background: $main-color;
  212. border-radius: 20rpx;
  213. overflow: hidden;
  214. }
  215. }
  216. //打卡按钮
  217. .punch-card {
  218. display: flex;
  219. justify-content: center;
  220. margin: 60rpx 0rpx;
  221. .circle {
  222. display: flex;
  223. flex-direction: column;
  224. justify-content: center;
  225. align-items: center;
  226. width: 370rpx;
  227. height: 370rpx;
  228. border-radius: 50%;
  229. background: $main-color;
  230. color: white;
  231. .title {
  232. font-size: 36rpx;
  233. }
  234. .time {
  235. font-size: 30rpx;
  236. margin-top: 20rpx;
  237. }
  238. }
  239. }
  240. // 签到记录
  241. .sign {
  242. display: flex;
  243. flex-wrap: wrap;
  244. width: 90%;
  245. margin: 0rpx auto;
  246. background: white;
  247. border-radius: 15rpx;
  248. box-sizing: border-box;
  249. padding: 30rpx 30rpx 30rpx 20rpx;
  250. box-shadow: 0rpx 0rpx 10rpx rgba(0, 0, 0, .1);
  251. .sign-title {
  252. display: flex;
  253. width: 30%;
  254. .sign-title-img {
  255. width: 40rpx;
  256. margin-right: 15rpx;
  257. }
  258. .title {}
  259. }
  260. .project {
  261. display: flex;
  262. width: 70%;
  263. justify-content: space-between;
  264. .project-name {
  265. color: $main-color;
  266. }
  267. }
  268. }
  269. }
  270. </style>