location.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="container">
  3. <!-- 地图区域 -->
  4. <view class="map">
  5. <map style="width: 100%; height: 100%;" :latitude="latitude" :longitude="longitude" :scale="16"
  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. {{address}}
  19. </view>
  20. </view>
  21. <view class="right" @click="getLocationData">
  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. 请在08:00-09:00时间段之内提交打卡
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. var QQMapWX = require('../../util/qqmap-wx-jssdk1.1/qqmap-wx-jssdk');
  45. var qqmapsdk;
  46. export default {
  47. data() {
  48. return {
  49. // 定位经纬度
  50. latitude: null,
  51. longitude: null,
  52. // 地图标记点属性
  53. covers: [{
  54. id: 1,
  55. latitude: null,
  56. longitude: null,
  57. iconPath: '../../static/location.png',
  58. width: 20,
  59. height: 20
  60. }],
  61. // 照片信息
  62. imgUrl: "",
  63. // 定位位置信息
  64. address: ""
  65. };
  66. },
  67. onLoad() {
  68. // 实例化API核心类
  69. qqmapsdk = new QQMapWX({
  70. // 申请的key
  71. key: 'R43BZ-2XROX-L7T45-T5OQI-IBDFT-GNBOI'
  72. });
  73. this.getLocationData()
  74. },
  75. methods: {
  76. // 获取定位具体信息
  77. getLocationData() {
  78. qqmapsdk.reverseGeocoder({
  79. success: (res) => {
  80. // console.log(res);
  81. // console.log(res.result);
  82. if (res.status == 0) {
  83. // 获取详细地址信息
  84. this.address = res.result.address
  85. // 获取地址经纬度
  86. this.latitude = res.result.location.lat
  87. this.longitude = res.result.location.lng
  88. // 获取标记点地址经纬度
  89. this.covers[0].latitude = res.result.location.lat
  90. this.covers[0].longitude = res.result.location.lng
  91. } else {
  92. uni.showToast({
  93. title: "请求定位失败",
  94. icon: 'none'
  95. })
  96. }
  97. }
  98. })
  99. },
  100. // 点击拍照图标回调
  101. handlePhoto() {
  102. // 获取用户摄像头权限
  103. uni.authorize({
  104. scope: 'scope.camera',
  105. success() {
  106. uni.chooseImage({
  107. count: 1,
  108. sourceType: ['camera'],
  109. success: (res) => {
  110. console.log(res);
  111. console.log(res.tempFilePaths[0]);
  112. console.log(JSON.stringify(res.tempFilePaths));
  113. // this.imgUrl = JSON.stringify(res.tempFilePaths)
  114. // console.log(this.imgUrl);
  115. uni.navigateTo({
  116. url: "/pages/authentication/authentication"
  117. })
  118. }
  119. });
  120. },
  121. fail() {
  122. uni.showModal({
  123. title: '提示',
  124. content: '请先开启摄像头权限,否则将无法使用打卡功能',
  125. cancelText: '不授权',
  126. confirmText: '授权',
  127. success: function(res) {
  128. if (res.confirm) {
  129. uni.openSetting({
  130. success(res) {}
  131. })
  132. } else if (res.cancel) {}
  133. }
  134. });
  135. }
  136. })
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .container {
  143. .map {
  144. position: relative;
  145. width: 100vw;
  146. height: 100vh;
  147. }
  148. .box {
  149. position: absolute;
  150. left: 30rpx;
  151. bottom: 30rpx;
  152. width: 690rpx;
  153. height: 387rpx;
  154. .top {
  155. display: flex;
  156. box-sizing: border-box;
  157. padding: 0 30rpx;
  158. width: 690rpx;
  159. height: 123rpx;
  160. border-radius: 14rpx 14rpx 0 0;
  161. background-color: #fff;
  162. .left {
  163. display: flex;
  164. flex-direction: column;
  165. justify-content: space-evenly;
  166. flex: 6;
  167. .left_title {
  168. font-size: 32rpx;
  169. }
  170. .left_place {
  171. font-size: 24rpx;
  172. font-weight: 200;
  173. color: #808080;
  174. }
  175. }
  176. .right {
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. flex: 1;
  181. img {
  182. width: 42rpx;
  183. height: 42rpx;
  184. }
  185. }
  186. }
  187. .center {
  188. display: flex;
  189. box-sizing: border-box;
  190. padding: 0 30rpx;
  191. width: 690rpx;
  192. height: 122rpx;
  193. line-height: 122rpx;
  194. background-color: #fff;
  195. .center_left {
  196. flex: 6;
  197. font-size: 32rpx;
  198. }
  199. .center_right {
  200. flex: 1;
  201. display: flex;
  202. justify-content: center;
  203. align-items: center;
  204. img {
  205. width: 49rpx;
  206. height: 39rpx;
  207. }
  208. }
  209. }
  210. .bottom {
  211. display: flex;
  212. justify-content: center;
  213. align-items: center;
  214. box-sizing: border-box;
  215. padding: 0 30rpx;
  216. width: 690rpx;
  217. height: 140rpx;
  218. border-radius: 0 0 14rpx 14rpx;
  219. background-color: #fff;
  220. .button {
  221. width: 630rpx;
  222. height: 80rpx;
  223. line-height: 80rpx;
  224. border-radius: 16rpx;
  225. text-align: center;
  226. font-size: 32rpx;
  227. color: #fff;
  228. background: linear-gradient(180deg, #00ACFC 0%, #0082FC 100%);
  229. }
  230. }
  231. }
  232. }
  233. </style>