location.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="container">
  3. <!-- 地图区域 -->
  4. <view class="map">
  5. <map style="width: 100%; height: 100%;" :latitude="latitude" :longitude="longitude" :scale="18"
  6. :markers="covers">
  7. </map>
  8. </view>
  9. <!-- 盒子区域 -->
  10. <view class="box">
  11. <!-- 定位区域 -->
  12. <view class="top">
  13. <view class="left">
  14. <view class="left_title">
  15. 我的位置
  16. </view>
  17. <view class="left_place">
  18. 南昌交通学院食堂
  19. </view>
  20. </view>
  21. <view class="right">
  22. <img src="./imgs/refresh.png">
  23. </view>
  24. </view>
  25. <!-- 拍照区域 -->
  26. <view class="center">
  27. <view class="center_left">
  28. 身份认证(必填)
  29. </view>
  30. <view class="center_right" @click="handlePhoto">
  31. <img src="./imgs/photo.png">
  32. </view>
  33. </view>
  34. <!-- 提示倒计时区域 -->
  35. <view class="bottom">
  36. <view class="button">
  37. 15:05:05 打卡(15分钟内提交打卡)
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. latitude: 39.909,
  48. longitude: 116.39742,
  49. covers: [{
  50. id: 1,
  51. latitude: 39.909,
  52. longitude: 116.39742,
  53. iconPath: '../../static/location.png',
  54. width: 20,
  55. height: 20
  56. }],
  57. imgUrl: ""
  58. };
  59. },
  60. onLoad() {
  61. // this.getLocationData()
  62. },
  63. methods: {
  64. getLocationData() {
  65. console.log(123);
  66. uni.getLocation({
  67. type: 'gcj02',
  68. success: function(res) {
  69. console.log('当前位置的经度:' + res.longitude);
  70. console.log('当前位置的纬度:' + res.latitude);
  71. }
  72. });
  73. },
  74. // 点击拍照图标回调
  75. handlePhoto() {
  76. // 获取用户摄像头权限
  77. uni.authorize({
  78. scope: 'scope.camera',
  79. success() {
  80. // uni.navigateTo({
  81. // url: "/pages/location/location"
  82. // })
  83. uni.chooseImage({
  84. count: 1,
  85. sourceType: ['camera'],
  86. success: (res) => {
  87. console.log(res);
  88. console.log(res.tempFilePaths[0]);
  89. console.log(JSON.stringify(res.tempFilePaths));
  90. // this.imgUrl = JSON.stringify(res.tempFilePaths)
  91. // console.log(this.imgUrl);
  92. uni.navigateTo({
  93. url: "/pages/authentication/authentication"
  94. })
  95. }
  96. });
  97. },
  98. fail() {
  99. uni.showModal({
  100. title: '提示',
  101. content: '请先开启摄像头权限,否则将无法使用打卡功能',
  102. cancelText: '不授权',
  103. confirmText: '授权',
  104. success: function(res) {
  105. if (res.confirm) {
  106. uni.openSetting({
  107. success(res) {}
  108. })
  109. } else if (res.cancel) {}
  110. }
  111. });
  112. }
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .container {
  120. .map {
  121. position: relative;
  122. width: 100vw;
  123. height: 100vh;
  124. }
  125. .box {
  126. position: absolute;
  127. left: 30rpx;
  128. bottom: 30rpx;
  129. width: 690rpx;
  130. height: 387rpx;
  131. .top {
  132. display: flex;
  133. box-sizing: border-box;
  134. padding: 0 30rpx;
  135. width: 690rpx;
  136. height: 123rpx;
  137. border-radius: 14rpx 14rpx 0 0;
  138. background-color: #fff;
  139. .left {
  140. display: flex;
  141. flex-direction: column;
  142. justify-content: space-evenly;
  143. flex: 6;
  144. .left_title {
  145. font-size: 32rpx;
  146. }
  147. .left_place {
  148. font-size: 24rpx;
  149. font-weight: 200;
  150. color: #808080;
  151. }
  152. }
  153. .right {
  154. display: flex;
  155. justify-content: center;
  156. align-items: center;
  157. flex: 1;
  158. img {
  159. width: 42rpx;
  160. height: 42rpx;
  161. }
  162. }
  163. }
  164. .center {
  165. display: flex;
  166. box-sizing: border-box;
  167. padding: 0 30rpx;
  168. width: 690rpx;
  169. height: 122rpx;
  170. line-height: 122rpx;
  171. background-color: #fff;
  172. .center_left {
  173. flex: 6;
  174. font-size: 32rpx;
  175. }
  176. .center_right {
  177. flex: 1;
  178. display: flex;
  179. justify-content: center;
  180. align-items: center;
  181. img {
  182. width: 49rpx;
  183. height: 39rpx;
  184. }
  185. }
  186. }
  187. .bottom {
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. box-sizing: border-box;
  192. padding: 0 30rpx;
  193. width: 690rpx;
  194. height: 140rpx;
  195. border-radius: 0 0 14rpx 14rpx;
  196. background-color: #fff;
  197. .button {
  198. width: 630rpx;
  199. height: 80rpx;
  200. line-height: 80rpx;
  201. border-radius: 16rpx;
  202. text-align: center;
  203. font-size: 32rpx;
  204. color: #fff;
  205. background: linear-gradient(180deg, #00ACFC 0%, #0082FC 100%);
  206. }
  207. }
  208. }
  209. }
  210. </style>