commonaddress.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="content">
  3. <view class="box" @click="chooseAddress">
  4. <view class="box-left">
  5. 常用地址
  6. </view>
  7. <view class="box-right">
  8. <!-- <input type="text" value="请选择常用地址" class="box-input"/>
  9. -->
  10. <view class="box-input">
  11. {{addressDetail||'请选择常用地址'}}
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import {
  19. getcomAddress
  20. } from '@/api/index.js';
  21. export default {
  22. data() {
  23. return {
  24. addressDetail: '',
  25. addressData: {
  26. name: '',
  27. mobile: '',
  28. latitude: 0, //纬度
  29. longitude: 0, //经度
  30. address: {
  31. province: '',
  32. city: '',
  33. district: '',
  34. detail: '',
  35. },
  36. area: '',
  37. default: false
  38. },
  39. }
  40. },
  41. onLoad(option){
  42. console.log('传过来的值',option.add)
  43. if (option.add == 'null'){
  44. this.addressDetail = '请选择常用地址'
  45. } else {
  46. this.addressDetail = option.add
  47. }
  48. // this.addressDetail = option.add
  49. },
  50. methods: {
  51. chooseAddress() {
  52. console.log('233')
  53. let obj = this;
  54. uni.chooseLocation({
  55. success: function(res) {
  56. console.log(res)
  57. obj.addressData.area = res.name;
  58. // console.log('位置名称:' + res.name);
  59. // console.log('详细地址:' + res.address);
  60. // console.log('经度:' + res.longitude);
  61. // console.log('纬度:' + res.latitude);
  62. obj.addressData.latitude = res.latitude;
  63. obj.addressData.longitude = res.longitude;
  64. obj.addressDetail = res.address;
  65. console.log('common_address',obj.addressDetail )
  66. console.log('latitude',obj.addressData.latitude )
  67. console.log('longitude',obj.addressData.longitude )
  68. getcomAddress({
  69. common_address: obj.addressDetail,
  70. longitude: obj.addressData.longitude,
  71. latitude: obj.addressData.latitude
  72. }).then(data => {
  73. console.log(333)
  74. console.log(data);
  75. if (data.status == 200) {
  76. obj.$api.msg('保存成功')
  77. }
  78. })
  79. }
  80. });
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. .content {
  87. .box {
  88. margin-top: 24rpx;
  89. padding: 34rpx 32rpx;
  90. background-color: #FFFFFF;
  91. font-size: 28rpx;
  92. display: flex;
  93. .box-right {
  94. margin-left: 34rpx;
  95. .box-input {
  96. .input-placeholder {
  97. height: 70rpx;
  98. color: #FF9797;
  99. }
  100. }
  101. }
  102. }
  103. }
  104. </style>