editAddress.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="content">
  3. <view class="content1" v-if="!isShowMap">
  4. <view class="top">
  5. 编辑地址
  6. </view>
  7. <!-- <view class="row flex">
  8. <u-radio-group placement="row" class="select-type">
  9. <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in radiolist1" :key="index"
  10. :label="item.name" :name="item.name" @change="radioChange">
  11. </u-radio>
  12. </u-radio-group>
  13. </view> -->
  14. <view class="">
  15. <u--form labelPosition="left" :model="addressInfo" :rules="rules" ref="form1" labelWidth='100'>
  16. <u-form-item label="所属区域" ref="item1" borderBottom>
  17. <view @click='toMap'>
  18. {{addressInfo.area?(addressInfo.province+addressInfo.city+addressInfo.area):'选择所属区域 '}}
  19. </view>
  20. </u-form-item>
  21. <u-form-item label="详细地址" prop="addressInfo.detailedAddress" ref="item1" borderBottom>
  22. <u--input v-model="addressInfo.detailedAddress" border="none" placeholder="详细地址"></u--input>
  23. </u-form-item>
  24. <u-form-item label="联系人" prop="addressInfo.contacts" ref="item1" borderBottom>
  25. <u--input v-model="addressInfo.contacts" border="none" placeholder="联系人">></u--input>
  26. </u-form-item>
  27. <u-form-item label="联系电话" prop="addressInfo.contactPhone" ref="item1">
  28. <u--input v-model="addressInfo.contactPhone" border="none" placeholder="联系电话">></u--input>
  29. </u-form-item>
  30. </u--form>
  31. </view>
  32. </view>
  33. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true' :showCancelButton='true'
  34. confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  35. <view class="submit" @click="$u.throttle(submit, 5000)">提交</view>
  36. <u-toast ref="uToast"></u-toast>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. mapState
  42. } from 'vuex';
  43. export default {
  44. data() {
  45. return {
  46. isShowAlert: false,
  47. alertTitle: '确定提交地址信息?',
  48. isShowMap: false,
  49. addressInfo: {
  50. commonId: "",
  51. province: "",
  52. city: "",
  53. area: "",
  54. detailedAddress: "",
  55. contacts: "",
  56. contactPhone: "",
  57. longitude: "",
  58. latitude: ""
  59. },
  60. rules: {
  61. // 'addressInfo.name': {
  62. // type: 'string',
  63. // required: true,
  64. // message: '请填写姓名',
  65. // trigger: ['blur', 'change']
  66. // },
  67. },
  68. };
  69. },
  70. onLoad(options) {
  71. console.log(options)
  72. this.addressInfo = options
  73. },
  74. computed: {
  75. ...mapState(['hasLogin', 'userInfo'])
  76. },
  77. methods: {
  78. confirmClick() {
  79. this.$request.baseRequest('post', '/cargoOwnerAddressInfo/api/editCargoOwnerAddress', this.addressInfo)
  80. .then(
  81. res => {
  82. if (res.code == 200) {
  83. this.$refs.uToast.show({
  84. type: 'success',
  85. message: "提交成功",
  86. complete() {
  87. // uni.$u.route('/pages/release/selectAddress');
  88. uni.navigateBack({
  89. delta:1
  90. })
  91. }
  92. })
  93. }
  94. })
  95. .catch(res => {
  96. uni.showToast({
  97. title: res.message,
  98. icon: 'none',
  99. duration: 2000
  100. })
  101. });
  102. this.isShowAlert = false
  103. },
  104. cancelClick() {
  105. this.isShowAlert = false
  106. },
  107. radioChange(n) {
  108. console.log('radioChange', n);
  109. },
  110. toMap() {
  111. let that = this
  112. // this.isShowMap = true
  113. uni.getLocation({
  114. type: 'wgs84',
  115. success: function (res) {
  116. console.log('当前位置的经度:' + res.longitude);
  117. console.log('当前位置的纬度:' + res.latitude);
  118. uni.chooseLocation({
  119. latitude: res.latitude,
  120. longitude: res.longitude,
  121. success: function(res) {
  122. console.log(res);
  123. console.log('位置名称:' + res.name);
  124. console.log('详细地址:' + res.address);
  125. console.log('纬度:' + res.latitude);
  126. console.log('经度:' + res.longitude);
  127. let _address = that.$helper.formatLocation(res.address)
  128. console.log('----------------------------')
  129. console.log(_address)
  130. that.addressInfo.latitude = res.latitude
  131. that.addressInfo.longitude = res.longitude
  132. that.addressInfo.detailedAddress = _address.Village
  133. that.addressInfo.province = _address.Province
  134. that.addressInfo.city = _address.City
  135. that.addressInfo.area = _address.Country
  136. that.addressInfo.commonId = that.userInfo.id
  137. that.$forceUpdate()
  138. },
  139. fail(err) {
  140. console.log(err)
  141. },
  142. complete(res1) {
  143. console.log(res1)
  144. }
  145. });
  146. }
  147. })
  148. // console.log(123)
  149. // uni.$u.route('/pages/release/map', {
  150. // id: 1,
  151. // });
  152. },
  153. submit() {
  154. this.isShowAlert = true
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .select-color{
  161. color: #C6CBD5;
  162. }
  163. .content{
  164. background: white;
  165. height: calc(100vh - 90rpx);
  166. }
  167. .content1 {
  168. padding: 40rpx;
  169. .top {
  170. font-size: 42rpx;
  171. font-weight: 700;
  172. color: rgba(0, 0, 0, 0.85);
  173. }
  174. }
  175. .submit{
  176. position: absolute;
  177. bottom: 40rpx;
  178. display: flex;
  179. justify-content: center;
  180. align-items: center;
  181. width: 80%;
  182. font-size: 36rpx;
  183. color: #FFFFFF;
  184. background: #2772FB;
  185. border-radius: 50rpx;
  186. padding: 20rpx 0;
  187. left: 0;
  188. right: 0;
  189. margin: auto;
  190. }
  191. </style>