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

354 lines
7.8 KiB

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