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.

103 lines
2.5 KiB

  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="设置驾校经纬度信息"></topNavbar>
  4. <view class="pad">
  5. <view class="adrsCon">
  6. <view class="adr" v-if="vuex_cityInfo.city" @click="getLatLngFn">{{vuex_cityInfo.city}} <text v-if="vuex_cityInfo.name"> / {{vuex_cityInfo.name}}</text></view>
  7. <view class="adr" v-else @click="getLatLngFn" style="display: flex;align-items: center;">
  8. <text>获取定位信息</text>
  9. <!-- <image src="@/static/images/index/down.png" mode="" style="width: 18rpx;height: 18rpx;margin-left: 6rpx;"></image> -->
  10. </view>
  11. <view class="adrsIcon">
  12. <image src="@/static/images/index/down.png" mode=""></image>
  13. </view>
  14. </view>
  15. <view class="card">
  16. 温馨提示确保你所在位置是您的驾校更新当前位置会影响科目一学员打卡与学员距离您驾校的位置距离计算
  17. <view class="btnBg" @click="oneBtnClick">更新位置</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import { setLngLat } from '@/config/api.js'
  24. export default {
  25. data() {
  26. return {
  27. }
  28. },
  29. onLoad() {
  30. // this.$store.dispatch('getCity')
  31. },
  32. methods: {
  33. async getLatLngFn() {
  34. try{
  35. uni.showLoading({
  36. title: '正在更新位置...'
  37. })
  38. await this.$store.dispatch('getCity')
  39. this.refresh()
  40. }catch(e){
  41. uni.hideLoading()
  42. }
  43. },
  44. async oneBtnClick() {
  45. let _this = this
  46. await this.$store.dispatch('getCity')
  47. if(!this.vuex_cityInfo.lng) return this.$u.toast('没有获取到您的定位信息')
  48. uni.showModal({
  49. title: `确定要更新您的驾校经纬为 ${this.vuex_cityInfo.name?this.vuex_cityInfo.name:'当前位置'} 吗?`,
  50. success() {
  51. _this.setLngLatFn()
  52. }
  53. })
  54. },
  55. async setLngLatFn() {
  56. let obj = {longitude: this.vuex_cityInfo.lng, latitude: this.vuex_cityInfo.lat}
  57. console.log(obj, '参数')
  58. const res = await setLngLat(obj)
  59. this.$u.toast('更新经纬度成功')
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .adrsCon {
  66. display: flex;
  67. align-items: center;
  68. // width: 180rpx;
  69. height: 88rpx;
  70. .adrsIcon {
  71. width: 17rpx;
  72. height: 17rpx;
  73. margin-top: 4rpx;
  74. }
  75. .adr {
  76. padding-right: 14rpx;
  77. font-size: 28rpx;
  78. color: #fff;
  79. }
  80. }
  81. .qcode {
  82. width: 100%;
  83. display: flex;
  84. align-items: center;
  85. justify-content: center;
  86. padding: 20rpx 0;
  87. height: 500rpx;
  88. }
  89. .card {
  90. padding: 28rpx;
  91. margin-bottom: 24rpx;
  92. color: #999;
  93. }
  94. .btnBg {
  95. margin: 50rpx 0 20rpx 0;
  96. }
  97. </style>