【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.

304 lines
6.4 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year 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. // uni.navigateTo({
  98. // url: "/pages/subPack/human/human"
  99. // })
  100. // 检查当前是否在打卡时间段内
  101. this.$api('clockTime', {
  102. lon : this.longitude,
  103. lat : this.latitude
  104. }, res => {
  105. //打卡(跳转人脸识别)
  106. if(res.code == 200){
  107. uni.navigateTo({
  108. // url: "/pages/subPack/face/face"
  109. url: "/pages/subPack/human/human"
  110. })
  111. }
  112. })
  113. },
  114. //获取用户位置
  115. getLocation() {
  116. let self = this;
  117. uni.getLocation({
  118. type: 'gcj02',
  119. success: function(res) {
  120. self.longitude = res.longitude;
  121. self.latitude = res.latitude;
  122. // self.covers.push({
  123. // id: 1,
  124. // latitude: res.latitude,
  125. // longitude: res.longitude,
  126. // iconPath: 'https://tennis-oss.xzaiyp.top/2024-10-22/103fa1db-8524-45e6-8d00-c36a69977a5b.png',
  127. // width: 30,
  128. // height: 30
  129. // })
  130. },
  131. fail() {
  132. self.checkAndRequestLocationPermission()
  133. }
  134. });
  135. },
  136. checkAndRequestLocationPermission() {
  137. let self = this;
  138. uni.getSetting({
  139. success: function(res) {
  140. if (!res.authSetting['scope.userLocation']) {
  141. // 用户未授权定位权限
  142. uni.showModal({
  143. title: '提示',
  144. content: '当前定位未开启,请点击确定手动开启定位',
  145. success: function(modalRes) {
  146. if (modalRes.confirm) {
  147. // 用户选择确认开启定位
  148. uni.openSetting({
  149. success: function(settingRes) {
  150. if (settingRes.authSetting[
  151. 'scope.userLocation']) {
  152. // 重新获取位置信息
  153. self.getLocation();
  154. } else {
  155. // 用户未开启定位权限
  156. console.log('用户未开启定位权限');
  157. }
  158. },
  159. fail: function(err) {
  160. console.log('打开设置页面失败:', err);
  161. }
  162. });
  163. } else {
  164. // 用户选择取消
  165. self.getLocation()
  166. }
  167. }
  168. });
  169. } else {
  170. // 用户已授权定位权限但获取位置失败(可能是设备未开启定位服务)
  171. console.log('用户已授权定位权限,但获取位置失败');
  172. // 可以提示用户检查设备定位服务是否开启
  173. }
  174. }
  175. });
  176. },
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .home {
  182. background: $bg-color;
  183. min-height: 100vh;
  184. // 顶部背景
  185. .home-top {
  186. height: 490rpx;
  187. overflow: hidden;
  188. .home-top-bg {
  189. width: 750rpx;
  190. }
  191. }
  192. // 卡片(地图)
  193. .card {
  194. width: 95%;
  195. margin: -340rpx auto 0rpx auto;
  196. position: relative;
  197. .team {
  198. display: flex;
  199. margin: 15rpx 0rpx;
  200. color: white;
  201. font-size: 34rpx;
  202. .change-icon {
  203. display: flex;
  204. align-items: center;
  205. width: 40rpx;
  206. margin-right: 10rpx;
  207. image {
  208. width: 100%;
  209. }
  210. }
  211. }
  212. .map {
  213. height: 350rpx;
  214. background: $main-color;
  215. border-radius: 20rpx;
  216. overflow: hidden;
  217. }
  218. }
  219. //打卡按钮
  220. .punch-card {
  221. display: flex;
  222. justify-content: center;
  223. margin: 60rpx 0rpx;
  224. .circle {
  225. display: flex;
  226. flex-direction: column;
  227. justify-content: center;
  228. align-items: center;
  229. width: 370rpx;
  230. height: 370rpx;
  231. border-radius: 50%;
  232. background: $main-color;
  233. color: white;
  234. .title {
  235. font-size: 36rpx;
  236. }
  237. .time {
  238. font-size: 30rpx;
  239. margin-top: 20rpx;
  240. }
  241. }
  242. }
  243. // 签到记录
  244. .sign {
  245. display: flex;
  246. flex-wrap: wrap;
  247. width: 90%;
  248. margin: 0rpx auto;
  249. background: white;
  250. border-radius: 15rpx;
  251. box-sizing: border-box;
  252. padding: 30rpx 30rpx 30rpx 20rpx;
  253. box-shadow: 0rpx 0rpx 10rpx rgba(0, 0, 0, .1);
  254. .sign-title {
  255. display: flex;
  256. width: 30%;
  257. .sign-title-img {
  258. width: 40rpx;
  259. margin-right: 15rpx;
  260. }
  261. .title {}
  262. }
  263. .project {
  264. display: flex;
  265. width: 70%;
  266. justify-content: space-between;
  267. .project-name {
  268. color: $main-color;
  269. }
  270. }
  271. }
  272. }
  273. </style>