|
@@ -3,15 +3,20 @@
|
|
|
<form @submit="formSubmit" report-submit='true'>
|
|
|
<view class='addAddress borderPad'>
|
|
|
<view class='list borRadius14'>
|
|
|
- <view class='item acea-row' style="border: none;">
|
|
|
+ <view class='item acea-row' style="border: none;" v-if="addType">
|
|
|
+ <view class='name'>驿站名称</view>
|
|
|
+ <input type='text' placeholder="请输入驿站名称" placeholder-style="color:#ccc;" name='expressName' :value="userAddress.expressName"
|
|
|
+ placeholder-class='placeholder' maxlength="20"></input>
|
|
|
+ </view>
|
|
|
+ <view class='item acea-row' style="border: none;" v-else>
|
|
|
<view class='name'>姓名</view>
|
|
|
- <input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='realName'
|
|
|
- :value="userAddress.realName" placeholder-class='placeholder' maxlength="20"></input>
|
|
|
+ <input type='text' placeholder="请输入姓名" placeholder-style="color:#ccc;" name='realName' :value="userAddress.realName"
|
|
|
+ placeholder-class='placeholder' maxlength="20"></input>
|
|
|
</view>
|
|
|
- <view class='item acea-row'>
|
|
|
+ <view class='item acea-row' v-if="!addType">
|
|
|
<view class='name'>手机号码</view>
|
|
|
- <input type='number' placeholder='请输入手机号码' placeholder-style="color:#ccc;" name="phone"
|
|
|
- :value='userAddress.phone' placeholder-class='placeholder' maxlength="11"></input>
|
|
|
+ <input type='number' placeholder='请输入手机号码' placeholder-style="color:#ccc;" name="phone" :value='userAddress.phone'
|
|
|
+ placeholder-class='placeholder' maxlength="11"></input>
|
|
|
</view>
|
|
|
<view class='item acea-row row-between-wrapper'>
|
|
|
<view class='name'>所在地区</view>
|
|
@@ -19,7 +24,7 @@
|
|
|
<view class="region_count" @click="changeRegion">
|
|
|
<text v-if="!addressInfo.length" style="color:#cdcdcd;">请选择地址</text>
|
|
|
<text v-else>{{addressText}}</text>
|
|
|
-
|
|
|
+
|
|
|
</view>
|
|
|
</view>
|
|
|
<text class="iconfont icon-xiangyou"></text>
|
|
@@ -27,7 +32,7 @@
|
|
|
<view class='item acea-row row-between-wrapper'>
|
|
|
<view class='name'>详细地址</view>
|
|
|
<input class="address" type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detail'
|
|
|
- placeholder-class='placeholder' v-model='userAddress.detail' maxlength="100"></input>
|
|
|
+ placeholder-class='placeholder' v-model='userAddress.detail' maxlength="100"></input>
|
|
|
<view class='iconfont icon-dizhi font_color' @tap="chooseLocation"></view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -38,25 +43,29 @@
|
|
|
</view>
|
|
|
|
|
|
<button class='keepBnt bg_color' form-type="submit">{{orderNo!=0?'保存并使用':'立即保存'}}</button>
|
|
|
- <!-- #ifdef MP -->
|
|
|
- <view class="wechatAddress" v-if="!addressId" @click="getWxAddress">导入微信地址</view>
|
|
|
- <!-- #endif -->
|
|
|
- <!-- #ifdef H5 -->
|
|
|
- <view class="wechatAddress" v-if="this.$wechat.isWeixin() && !addressId" @click="getAddress">导入微信地址</view>
|
|
|
- <!-- #endif -->
|
|
|
+ <view v-if="!addType">
|
|
|
+ <!-- #ifdef MP -->
|
|
|
+ <view class="wechatAddress" v-if="!addressId" @click="getWxAddress">导入微信地址</view>
|
|
|
+ <!-- #endif -->
|
|
|
+ <!-- #ifdef H5 -->
|
|
|
+ <view class="wechatAddress" v-if="this.$wechat.isWeixin() && !addressId" @click="getAddress">导入微信地址</view>
|
|
|
+ <!-- #endif -->
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</form>
|
|
|
<view v-show="showLoading" class="bg-fixed"></view>
|
|
|
- <areaWindow ref="areaWindow" :display="display" :address="addressInfo" @submit="OnChangeAddress"
|
|
|
- @changeClose="changeClose"></areaWindow>
|
|
|
+ <areaWindow ref="areaWindow" :display="display" :address="addressInfo" @submit="OnChangeAddress" @changeClose="changeClose"></areaWindow>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
editAddress,
|
|
|
+ editExpressAddress,
|
|
|
addAddress,
|
|
|
+ addExpressAddress,
|
|
|
getAddressDetail,
|
|
|
+ getAddressExpressDetail,
|
|
|
getCity,
|
|
|
getWxAddressInfo
|
|
|
} from '@/api/user.js';
|
|
@@ -105,6 +114,7 @@
|
|
|
display: false,
|
|
|
addressInfo: [],
|
|
|
addressData: [],
|
|
|
+ addType: null,
|
|
|
orderNo: '' //订单id
|
|
|
};
|
|
|
},
|
|
@@ -128,6 +138,7 @@
|
|
|
if (this.isLogin) {
|
|
|
this.orderNo = options.orderNo || 0;
|
|
|
this.addressId = options.id || 0;
|
|
|
+ this.addType = options.addType || null;
|
|
|
uni.setNavigationBarTitle({
|
|
|
title: this.addressId ? '编辑地址' : '添加地址'
|
|
|
})
|
|
@@ -150,7 +161,8 @@
|
|
|
getUserAddress: function() {
|
|
|
if (!this.addressId) return false;
|
|
|
let that = this;
|
|
|
- getAddressDetail(this.addressId).then(res => {
|
|
|
+ const getAddApi = this.addType ? getAddressExpressDetail(this.addressId) : getAddressDetail(this.addressId);
|
|
|
+ getAddApi.then(res => {
|
|
|
if (res.data) {
|
|
|
that.$set(that, 'userAddress', res.data);
|
|
|
that.addressInfo = [{
|
|
@@ -186,14 +198,16 @@
|
|
|
onConfirm(val) {
|
|
|
this.region = val.checkArr[0] + '-' + val.checkArr[1] + '-' + val.checkArr[2];
|
|
|
},
|
|
|
- //选择定位
|
|
|
+ //选择定位
|
|
|
chooseLocation: function() {
|
|
|
- this.$util.$L.getLocation().then(res=>{
|
|
|
+ this.$util.$L.getLocation().then(res => {
|
|
|
uni.chooseLocation({
|
|
|
latitude: uni.getStorageSync('user_latitude'),
|
|
|
longitude: uni.getStorageSync('user_longitude'),
|
|
|
success: (res) => {
|
|
|
this.$set(this.userAddress, 'detail', res.name);
|
|
|
+ this.$set(this.userAddress, 'latitude', res.latitude);
|
|
|
+ this.$set(this.userAddress, 'longitude', res.longitude);
|
|
|
}
|
|
|
})
|
|
|
})
|
|
@@ -257,15 +271,21 @@
|
|
|
formSubmit: Debounce(function(e) {
|
|
|
let that = this,
|
|
|
value = e.detail.value;
|
|
|
- if (!value.realName) return that.$util.Tips({
|
|
|
- title: '请填写收货人姓名'
|
|
|
- });
|
|
|
- if (!value.phone) return that.$util.Tips({
|
|
|
- title: '请填写手机号码'
|
|
|
- });
|
|
|
- if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(value.phone)) return that.$util.Tips({
|
|
|
- title: '请输入正确的手机号码'
|
|
|
- });
|
|
|
+ if (!this.addType) {
|
|
|
+ if (!value.realName) return that.$util.Tips({
|
|
|
+ title: '请填写收货人姓名'
|
|
|
+ });
|
|
|
+ if (!value.phone) return that.$util.Tips({
|
|
|
+ title: '请填写手机号码'
|
|
|
+ });
|
|
|
+ if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(value.phone)) return that.$util.Tips({
|
|
|
+ title: '请输入正确的手机号码'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (!value.expressName) return that.$util.Tips({
|
|
|
+ title: '请填写驿站名称'
|
|
|
+ });
|
|
|
+ }
|
|
|
if (!that.addressInfo.length == '省-市-区-街道') return that.$util.Tips({
|
|
|
title: '请选择所在地区'
|
|
|
});
|
|
@@ -279,41 +299,47 @@
|
|
|
value.cityId = that.addressInfo[1].regionId;
|
|
|
value.district = that.addressInfo[2].regionName;
|
|
|
value.districtId = that.addressInfo[2].regionId;
|
|
|
- value.street = that.addressInfo.length>3?that.addressInfo[3].regionName:'';
|
|
|
+ value.street = that.addressInfo.length > 3 ? that.addressInfo[3].regionName : '';
|
|
|
value.isDefault = that.userAddress.isDefault;
|
|
|
+ if (this.addType) {
|
|
|
+ value.latitude = that.userAddress.latitude;
|
|
|
+ value.longitude = that.userAddress.longitude;
|
|
|
+ }
|
|
|
|
|
|
uni.showLoading({
|
|
|
title: '保存中',
|
|
|
mask: true
|
|
|
})
|
|
|
if (that.addressId) {
|
|
|
- editAddress(value).then(res => {
|
|
|
+ const editApi = this.addType ? editExpressAddress(value) : editAddress(value);
|
|
|
+ editApi.then(res => {
|
|
|
that.$util.Tips({
|
|
|
title: '修改成功',
|
|
|
icon: 'success'
|
|
|
});
|
|
|
- uni.hideLoading();
|
|
|
+ uni.hideLoading();
|
|
|
that.onSuccess();
|
|
|
}).catch(err => {
|
|
|
- uni.hideLoading();
|
|
|
+ uni.hideLoading();
|
|
|
return that.$util.Tips({
|
|
|
title: err
|
|
|
});
|
|
|
})
|
|
|
} else {
|
|
|
- addAddress(value).then(res => {
|
|
|
+ const addApi = this.addType ? addExpressAddress(value) : addAddress(value);
|
|
|
+ addApi.then(res => {
|
|
|
that.$util.Tips({
|
|
|
title: '添加成功',
|
|
|
icon: 'success'
|
|
|
});
|
|
|
that.addressId = res.data;
|
|
|
- uni.hideLoading();
|
|
|
+ uni.hideLoading();
|
|
|
that.onSuccess();
|
|
|
}).catch(err => {
|
|
|
return that.$util.Tips({
|
|
|
title: err
|
|
|
});
|
|
|
- uni.hideLoading();
|
|
|
+ uni.hideLoading();
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -321,8 +347,8 @@
|
|
|
onSuccess() {
|
|
|
let orderNo = this.orderNo;
|
|
|
let id = this.addressId;
|
|
|
- setTimeout(()=> {
|
|
|
- if (orderNo!=0 && id!=0) {
|
|
|
+ setTimeout(() => {
|
|
|
+ if (orderNo != 0 && id != 0) {
|
|
|
uni.redirectTo({
|
|
|
url: '/pages/goods/order_confirm/index?is_address=1&orderNo=' + orderNo +
|
|
|
'&addressId=' + id
|
|
@@ -380,8 +406,9 @@
|
|
|
width: 120rpx;
|
|
|
}
|
|
|
|
|
|
- .addAddress .list .item input, .address {
|
|
|
- flex: 1;
|
|
|
+ .addAddress .list .item input,
|
|
|
+ .address {
|
|
|
+ flex: 1;
|
|
|
width: 490rpx;
|
|
|
margin-left: 20rpx;
|
|
|
font-size: 30rpx;
|