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

339 lines
7.3 KiB

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