|
@@ -50,13 +50,13 @@
|
|
|
<view class="r" @tap="getLocation"><text class="iconfont icon-dingwei1"></text>定位</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="row">
|
|
|
+ <!-- <view class="row">
|
|
|
<view class="title">门牌号</view>
|
|
|
<view class="right input"><input type="text" placeholder="请输入门牌号" maxlength="15" v-model="formData.houseNo"></view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
<view class="row mt20">
|
|
|
<view class="title">设为默认</view>
|
|
|
- <view class="right default"><switch @change="switchChange" color="#3D8FFD" v-model="formData.defaultAddr" :checked="formData.defaultAddr" style="transform:scale(0.7)" /></view>
|
|
|
+ <view class="right default"><switch @change="switchChange" color="#01C30B" v-model="formData.defaultAddr" :checked="formData.defaultAddr" style="transform:scale(0.7)" /></view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
@@ -70,7 +70,6 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import {mapState} from 'vuex';
|
|
|
import {getArea} from '@/common/utils/util.js';
|
|
|
|
|
|
export default {
|
|
@@ -88,16 +87,13 @@
|
|
|
area: '',
|
|
|
street: '',
|
|
|
address: '',
|
|
|
- houseNo: '',
|
|
|
+ // houseNo: '',
|
|
|
defaultAddr: false,
|
|
|
},
|
|
|
canClickSave: true, // 能否点击提交
|
|
|
clipboard: '',
|
|
|
}
|
|
|
},
|
|
|
- computed:{
|
|
|
- ...mapState(['userInfo', 'isLogin', 'userId'])
|
|
|
- },
|
|
|
onLoad({id, addressData}) {
|
|
|
this.editId = id;
|
|
|
if(id) {
|
|
@@ -115,7 +111,7 @@
|
|
|
city: addressData.city,
|
|
|
area: addressData.area,
|
|
|
address: addressData.address,
|
|
|
- houseNo: addressData.houseNo,
|
|
|
+ // houseNo: addressData.houseNo,
|
|
|
defaultAddr: addressData.defaultAddr,
|
|
|
}
|
|
|
this.regionValue = [addressData.province, addressData.city, addressData.area];
|
|
@@ -125,13 +121,8 @@
|
|
|
methods: {
|
|
|
async getRegion(address) {
|
|
|
const result = new Promise((resolve, reject) => {
|
|
|
- this.$axios({
|
|
|
- url: '/lbs/amap/region/query2',
|
|
|
- method: 'post',
|
|
|
- server: 'pc',
|
|
|
- params: {
|
|
|
- address
|
|
|
- }
|
|
|
+ this.$api.post('/lbs/amap/region/query2', {
|
|
|
+ address
|
|
|
}).then(res => {
|
|
|
resolve(res.data);
|
|
|
})
|
|
@@ -242,15 +233,10 @@
|
|
|
return rs;
|
|
|
},
|
|
|
|
|
|
-
|
|
|
// 获取地址信息
|
|
|
getAddressData() {
|
|
|
- this.$axios({
|
|
|
- url: '/user/address/detail',
|
|
|
- method: 'get',
|
|
|
- params: {
|
|
|
- userAddressId: this.editId
|
|
|
- }
|
|
|
+ this.$api.get('/user/address/detail', {
|
|
|
+ userAddressId: this.editId
|
|
|
}).then(res => {
|
|
|
this.formData = {
|
|
|
name: res.data.name,
|
|
@@ -259,7 +245,7 @@
|
|
|
city: res.data.city,
|
|
|
area: res.data.area,
|
|
|
address: res.data.address,
|
|
|
- houseNo: res.data.houseNo,
|
|
|
+ // houseNo: res.data.houseNo,
|
|
|
defaultAddr: res.data.defaultAddr,
|
|
|
}
|
|
|
this.regionValue = [res.data.province, res.data.city, res.data.area];
|
|
@@ -333,14 +319,10 @@
|
|
|
|
|
|
// 获取街道列表
|
|
|
getStreetList(street) {
|
|
|
- this.$axios({
|
|
|
- url: '/common/street',
|
|
|
- method: 'get',
|
|
|
- params: {
|
|
|
- province: this.regionValue[0],
|
|
|
- city: this.regionValue[1],
|
|
|
- area: this.regionValue[2],
|
|
|
- }
|
|
|
+ this.$api.get('/user/address/street', {
|
|
|
+ province: this.regionValue[0],
|
|
|
+ city: this.regionValue[1],
|
|
|
+ area: this.regionValue[2],
|
|
|
}).then(res => {
|
|
|
this.streetList = res.data;
|
|
|
if(street) {
|
|
@@ -409,7 +391,7 @@
|
|
|
if(!this.vailateData())return;
|
|
|
|
|
|
let params = this.formData;
|
|
|
- params.userId = this.userId;
|
|
|
+ params.userId = this.$store.state.user.userId;
|
|
|
let url = '';
|
|
|
if(this.editId) {
|
|
|
params.userAddressId = this.editId;
|
|
@@ -417,12 +399,7 @@
|
|
|
}else {
|
|
|
url = '/user/address/save';
|
|
|
}
|
|
|
- this.$axios({
|
|
|
- url: url,
|
|
|
- type: 'json',
|
|
|
- params,
|
|
|
- isLoading: 1,
|
|
|
- }).then(res => {
|
|
|
+ this.$api.post(url, params).then(res => {
|
|
|
this.$successToast(this.editId? '编辑成功':'添加成功');
|
|
|
this.$backPage(1, 1000);
|
|
|
})
|
|
@@ -433,12 +410,8 @@
|
|
|
this.$modal({
|
|
|
content: '确定要删除该地址吗?',
|
|
|
}).then(() => {
|
|
|
- this.$axios({
|
|
|
- url: '/user/address/del',
|
|
|
- params: {
|
|
|
- userAddressId: this.editId
|
|
|
- },
|
|
|
- isLoading: 1,
|
|
|
+ this.$api.post('/user/address/del', {
|
|
|
+ userAddressId: this.editId
|
|
|
}).then(res => {
|
|
|
this.$successToast('删除成功');
|
|
|
this.$backPage(1, 1000);
|