address.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="container">
  3. <view class="row b-b" @click="getLocation">
  4. <text class="tit">常用地址</text>
  5. <view class="tit witch">{{ address || '请选择常用地址' }}</view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. // #ifdef MP
  11. import { openMap } from '@/utils/rocessor.js';
  12. // #endif
  13. import { getUserInfo } from '@/api/login.js';
  14. import { changePoint } from '@/api/record.js';
  15. export default {
  16. data() {
  17. return {
  18. address: '', //常用地址
  19. commonly_lat: '',
  20. commonly_lng: ''
  21. };
  22. },
  23. onLoad() {
  24. this.userinfo();
  25. },
  26. methods: {
  27. // 获取当前位置
  28. getLocation() {
  29. let obj = this;
  30. // #ifdef MP
  31. openMap()
  32. .then(() => {
  33. uni.getLocation({
  34. type: 'gcj02',
  35. success(e) {
  36. uni.chooseLocation({
  37. latitude: e.latitude,
  38. longitude: e.longitude,
  39. success(e) {
  40. obj.commonly_lat = e.latitude;
  41. obj.commonly_lng = e.longitude;
  42. obj.address = e.address;
  43. obj.EditAddress();
  44. }
  45. });
  46. }
  47. });
  48. })
  49. .catch(e => {
  50. uni.showModal({
  51. title: '提示',
  52. content: '您未授权无法调用地图定位功能!',
  53. showCancel: false
  54. });
  55. });
  56. // #endif
  57. },
  58. //修改地址
  59. EditAddress() {
  60. let obj = this;
  61. changePoint({
  62. commonly_lat: obj.commonly_lat,
  63. commonly_lng: obj.commonly_lng,
  64. commonly_address:obj.address
  65. })
  66. .then((data ) => {
  67. console.log(data)
  68. obj.$api.msg('修改成功');
  69. })
  70. .catch(err => {
  71. obj.$api.msg(err.msg);
  72. });
  73. },
  74. userinfo() {
  75. let obj = this;
  76. getUserInfo({})
  77. .then(({ data }) => {
  78. obj.address = data.helper_info.commonly_address;
  79. })
  80. .catch(err => {});
  81. },
  82. confirm(e) {
  83. this.loding = true;
  84. bangding({
  85. phone: this.account,
  86. captcha: this.captcha
  87. })
  88. .then(({ data }) => {})
  89. .catch(err => {});
  90. }
  91. }
  92. };
  93. </script>
  94. <style lang="scss">
  95. page {
  96. background: $page-color-base;
  97. }
  98. .container {
  99. padding-top: 30rpx;
  100. }
  101. .witch {
  102. width: 75% !important;
  103. }
  104. .row {
  105. display: flex;
  106. align-items: center;
  107. position: relative;
  108. padding: 0 30rpx;
  109. height: 110rpx;
  110. background: #fff;
  111. .tit {
  112. flex-shrink: 0;
  113. width: 180rpx;
  114. font-size: 30rpx;
  115. color: $font-color-dark;
  116. }
  117. .input {
  118. flex: 1;
  119. font-size: 30rpx;
  120. color: $font-color-dark;
  121. }
  122. .iconlocation {
  123. font-size: 36rpx;
  124. color: $font-color-light;
  125. }
  126. }
  127. .add-btn {
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. width: 690rpx;
  132. height: 80rpx;
  133. margin: 60rpx auto;
  134. font-size: $font-lg;
  135. color: #fff;
  136. background-color: $base-color;
  137. border-radius: 10rpx;
  138. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  139. }
  140. .bg-gray {
  141. background-color: $color-gray;
  142. }
  143. .code {
  144. color: #5dbc7c;
  145. font-size: 23rpx;
  146. border-left: 1px solid #eeeeee;
  147. width: 150rpx;
  148. flex-shrink: 0;
  149. text-align: center;
  150. }
  151. </style>