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

328 lines
7.2 KiB

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