2020-08-13 08:12:57 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<form @submit="formSubmit" report-submit='true'>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class='addAddress pad30'>
|
|
|
|
|
<view class='list borRadius14'>
|
|
|
|
|
<view class='item acea-row row-between-wrapper' style="border: none;">
|
2020-08-13 08:12:57 +00:00
|
|
|
|
<view class='name'>姓名</view>
|
2023-06-26 12:06:29 +00:00
|
|
|
|
<input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='name'
|
|
|
|
|
:value="userAddress.name" placeholder-class='placeholder' maxlength="4" />
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view class='item acea-row row-between-wrapper'>
|
|
|
|
|
<view class='name'>联系电话</view>
|
2023-06-26 12:06:29 +00:00
|
|
|
|
<input type='number' placeholder='请输入联系电话' placeholder-style="color:#ccc;" name="mobile"
|
|
|
|
|
:value='userAddress.mobile' placeholder-class='placeholder' maxlength="11" />
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
2021-11-15 02:16:11 +00:00
|
|
|
|
<view class='item acea-row row-between-wrapper relative'>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
<view class='name'>所在地区</view>
|
|
|
|
|
<view class="address">
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<picker mode="multiSelector" @change="bindRegionChange"
|
2023-06-26 12:06:29 +00:00
|
|
|
|
@columnchange="bindMultiPickerColumnChange" :range="multiArray">
|
2020-08-13 08:12:57 +00:00
|
|
|
|
<view class='acea-row'>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class="picker line1">{{region[0]}},{{region[1]}},{{region[2]}}</view>
|
2021-11-15 02:16:11 +00:00
|
|
|
|
<view class='iconfont icon-xiangyou abs_right'></view>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
</picker>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2021-11-15 02:16:11 +00:00
|
|
|
|
<view class='item acea-row row-between-wrapper relative'>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
<view class='name'>详细地址</view>
|
2023-06-26 12:06:29 +00:00
|
|
|
|
<input type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detailAddress'
|
|
|
|
|
placeholder-class='placeholder' v-model='userAddress.detailAddress' maxlength="18" />
|
|
|
|
|
<view class='iconfont icon-dizhi font-color abs_right' @tap="chooseLocation" />
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class='default acea-row row-middle borRadius14'>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
<checkbox-group @change='ChangeIsDefault'>
|
2023-06-26 12:06:29 +00:00
|
|
|
|
<checkbox :checked="userAddress.defaultStatus" />设置为默认地址
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</checkbox-group>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<button class='keepBnt bg-color' form-type="submit">立即保存</button>
|
|
|
|
|
<!-- #ifdef MP -->
|
|
|
|
|
<view class="wechatAddress" v-if="!id" @click="getWxAddress">导入微信地址</view>
|
|
|
|
|
<!-- #endif -->
|
|
|
|
|
<!-- #ifdef H5 -->
|
|
|
|
|
<view class="wechatAddress" v-if="this.$wechat.isWeixin() && !id" @click="getAddress">导入微信地址</view>
|
|
|
|
|
<!-- #endif -->
|
|
|
|
|
</view>
|
|
|
|
|
</form>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2023-06-26 12:06:29 +00:00
|
|
|
|
import { editAddress } from '@/api/user.js';
|
|
|
|
|
import * as AddressApi from '@/api/member/address.js';
|
|
|
|
|
import * as AreaApi from '@/api/system/area.js';
|
|
|
|
|
import { toLogin } from '@/libs/login.js';
|
|
|
|
|
import { mapGetters } from "vuex";
|
2020-08-13 08:12:57 +00:00
|
|
|
|
import home from '@/components/home';
|
2021-11-15 02:16:11 +00:00
|
|
|
|
let app = getApp();
|
2020-08-13 08:12:57 +00:00
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
home
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
id: 0, // 地址 id
|
|
|
|
|
district: [], // 地区,树形结构
|
2020-08-13 08:12:57 +00:00
|
|
|
|
userAddress: {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
defaultStatus: false
|
|
|
|
|
}, // 地址详情
|
|
|
|
|
region: ['省', '市', '区'], // userAddress 对应的省市区
|
|
|
|
|
multiArray: [], // 当前的省、市、区
|
|
|
|
|
multiIndex: [0, 0, 0], // 当前选中的省 index、市 index、区 index
|
|
|
|
|
cityId: 0, // 区的编号~ 变量名暂时没改过来
|
|
|
|
|
|
|
|
|
|
// TODO 芋艿:看看后面咋搞回来
|
|
|
|
|
cartId: '', // 购物车id
|
|
|
|
|
pinkId: 0, // 拼团id
|
|
|
|
|
couponId: 0, // 优惠券id
|
|
|
|
|
bargain: false, // 是否是砍价
|
|
|
|
|
combination: false, // 是否是拼团
|
|
|
|
|
secKill: false, // 是否是秒杀
|
2020-08-13 08:12:57 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: mapGetters(['isLogin']),
|
2021-06-11 09:41:16 +00:00
|
|
|
|
watch: {
|
|
|
|
|
isLogin: {
|
|
|
|
|
handler: function(newV, oldV) {
|
|
|
|
|
if (newV) {
|
2021-03-19 10:26:43 +00:00
|
|
|
|
this.getUserAddress();
|
|
|
|
|
this.getCityList();
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-06-11 09:41:16 +00:00
|
|
|
|
deep: true
|
2021-03-19 10:26:43 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-08-13 08:12:57 +00:00
|
|
|
|
onLoad(options) {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
if (!this.isLogin) {
|
|
|
|
|
toLogin();
|
|
|
|
|
return
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
2023-06-26 12:06:29 +00:00
|
|
|
|
|
|
|
|
|
this.preOrderNo = options.preOrderNo || 0;
|
|
|
|
|
this.id = options.id || 0;
|
|
|
|
|
uni.setNavigationBarTitle({
|
|
|
|
|
title: options.id ? '修改地址' : '添加地址'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 获取地址详情
|
|
|
|
|
this.getUserAddress();
|
|
|
|
|
|
|
|
|
|
// 检测城市数据是否存在缓存,有的话从缓存取,没有的话请求接口
|
|
|
|
|
if (this.$Cache.has('cityList')) {
|
|
|
|
|
this.district = this.$Cache.getItem('cityList')
|
|
|
|
|
this.initialize();
|
|
|
|
|
} else {
|
|
|
|
|
this.getCityList();
|
|
|
|
|
}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* 获得地址
|
|
|
|
|
*/
|
|
|
|
|
getUserAddress: function() {
|
|
|
|
|
if (!this.id) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
AddressApi.getAddress(this.id).then(res => {
|
|
|
|
|
this.$set(this, 'userAddress', res.data);
|
|
|
|
|
this.$set(this, 'region', res.data.areaName.split(' '));
|
|
|
|
|
this.city_id = res.data.areaId
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 提交用户添加地址
|
|
|
|
|
*/
|
|
|
|
|
formSubmit: function(e) {
|
|
|
|
|
// 参数校验
|
|
|
|
|
const value = e.detail.value;
|
|
|
|
|
if (!value.name) {
|
|
|
|
|
return this.$util.Tips({
|
|
|
|
|
title: '请填写收货人姓名'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (!value.mobile) {
|
|
|
|
|
return this.$util.Tips({
|
|
|
|
|
title: '请填写联系电话'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(value.mobile)) {
|
|
|
|
|
return this.$util.Tips({
|
|
|
|
|
title: '请输入正确的手机号码'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (this.region === '省-市-区') {
|
|
|
|
|
return this.$util.Tips({
|
|
|
|
|
title: '请选择所在地区'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (!value.detailAddress) {
|
|
|
|
|
return this.$util.Tips({
|
|
|
|
|
title: '请填写详细地址'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
value.id = this.id;
|
|
|
|
|
value.areaId = this.cityId;
|
|
|
|
|
value.defaultStatus = this.userAddress.defaultStatus;
|
|
|
|
|
|
|
|
|
|
// 提交保存
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '保存中',
|
|
|
|
|
mask: true
|
|
|
|
|
})
|
|
|
|
|
const saveOrUpdateAddress = this.id > 0 ? AddressApi.updateAddress : AddressApi.createAddress;
|
|
|
|
|
saveOrUpdateAddress(value).then(res => {
|
|
|
|
|
if (this.id) {
|
|
|
|
|
this.$util.Tips({
|
|
|
|
|
title: '修改成功',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.$util.Tips({
|
|
|
|
|
title: '添加成功',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (this.preOrderNo > 0) {
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
url: '/pages/users/order_confirm/index?preOrderNo=' + this.preOrderNo + '&addressId=' + (this.id ? this.id : res.data)
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
return history.back();
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifndef H5
|
|
|
|
|
return uni.navigateBack({
|
|
|
|
|
delta: 1,
|
|
|
|
|
})
|
|
|
|
|
// #endif
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
return this.$util.Tips({
|
|
|
|
|
title: err
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// TODO 芋艿:需要改下
|
|
|
|
|
ChangeIsDefault: function(e) {
|
|
|
|
|
this.$set(this.userAddress, 'defaultStatus', !this.userAddress.defaultStatus);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取地址数据
|
|
|
|
|
*/
|
2020-08-13 08:12:57 +00:00
|
|
|
|
getCityList: function() {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
AreaApi.getAreaTree().then(res => {
|
2021-11-15 02:16:11 +00:00
|
|
|
|
this.district = res.data;
|
|
|
|
|
let oneDay = 24 * 3600 * 1000;
|
2023-06-26 12:06:29 +00:00
|
|
|
|
this.$Cache.setItem({name: 'cityList', value:res.data, expires:oneDay * 7}); //设置七天过期时间
|
|
|
|
|
this.initialize();
|
2020-08-13 08:12:57 +00:00
|
|
|
|
})
|
|
|
|
|
},
|
2023-06-26 12:06:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* 初始化当前的 multiArray
|
|
|
|
|
*/
|
2020-08-13 08:12:57 +00:00
|
|
|
|
initialize: function() {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
const province = [];
|
|
|
|
|
const city = [];
|
|
|
|
|
const area = [];
|
|
|
|
|
if (this.district.length) {
|
|
|
|
|
// 省
|
|
|
|
|
this.district.forEach(item => {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
province.push(item.name);
|
|
|
|
|
});
|
2023-06-26 12:06:29 +00:00
|
|
|
|
// 市
|
|
|
|
|
const cityChildren = this.district[0].children || [];
|
|
|
|
|
cityChildren.forEach(item => {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
city.push(item.name);
|
|
|
|
|
});
|
2023-06-26 12:06:29 +00:00
|
|
|
|
// 区
|
|
|
|
|
const areaChildren = cityChildren.length ? (cityChildren[0].children || []) : [];
|
|
|
|
|
areaChildren.forEach(item => {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
area.push(item.name);
|
|
|
|
|
});
|
|
|
|
|
this.multiArray = [province, city, area]
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-06-26 12:06:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* 提交省市区的选择
|
|
|
|
|
*/
|
2020-08-13 08:12:57 +00:00
|
|
|
|
bindRegionChange: function(e) {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
const multiIndex = this.multiIndex;
|
|
|
|
|
const multiArray = this.multiArray;
|
|
|
|
|
const value = e.detail.value;
|
|
|
|
|
const province = this.district[multiIndex[0]] || {
|
|
|
|
|
children: []
|
|
|
|
|
};
|
|
|
|
|
const city = province.children[multiIndex[1]] || {
|
|
|
|
|
children: []
|
|
|
|
|
};
|
|
|
|
|
const area = city.children[multiIndex[2]] || {
|
|
|
|
|
id: 0
|
|
|
|
|
};
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.region = [multiArray[0][value[0]], multiArray[1][value[1]], multiArray[2][value[2]]]
|
2023-06-26 12:06:29 +00:00
|
|
|
|
this.cityId = area.id
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 选择省市区的滚动
|
|
|
|
|
*/
|
2020-08-13 08:12:57 +00:00
|
|
|
|
bindMultiPickerColumnChange: function(e) {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
const column = e.detail.column; // multiArray 的下标
|
|
|
|
|
const value = e.detail.value; // multiArray 的值,即选中的第几个
|
|
|
|
|
const multiArray = this.multiArray;
|
|
|
|
|
const multiIndex = this.multiIndex;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
multiIndex[column] = value;
|
|
|
|
|
switch (column) {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
case 0: // 选择【省】
|
|
|
|
|
const currentCity = this.district[value] || {
|
|
|
|
|
child: []
|
|
|
|
|
};
|
|
|
|
|
const areaList = currentCity.children[0] || {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
child: []
|
|
|
|
|
};
|
2023-06-26 12:06:29 +00:00
|
|
|
|
multiArray[1] = currentCity.children.map((item) => {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
return item.name;
|
|
|
|
|
});
|
2023-06-26 12:06:29 +00:00
|
|
|
|
multiArray[2] = areaList.children.map((item) => {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
return item.name;
|
|
|
|
|
});
|
|
|
|
|
break;
|
2023-06-26 12:06:29 +00:00
|
|
|
|
case 1: // 选择【市】
|
|
|
|
|
const cityList = this.district[multiIndex[0]].children[multiIndex[1]].children || [];
|
|
|
|
|
multiArray[2] = cityList.map(item => {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
return item.name;
|
|
|
|
|
});
|
|
|
|
|
break;
|
2023-06-26 12:06:29 +00:00
|
|
|
|
case 2: // 选择【区】
|
2020-08-13 08:12:57 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2021-11-15 02:16:11 +00:00
|
|
|
|
// #ifdef MP || APP-PLUS
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.$set(this.multiArray, 0, multiArray[0]);
|
|
|
|
|
this.$set(this.multiArray, 1, multiArray[1]);
|
|
|
|
|
this.$set(this.multiArray, 2, multiArray[2]);
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
this.multiArray = multiArray;
|
|
|
|
|
// #endif
|
|
|
|
|
this.multiIndex = multiIndex
|
|
|
|
|
},
|
2023-06-26 12:06:29 +00:00
|
|
|
|
/**
|
|
|
|
|
* 通过地图,选择到具体的地址
|
|
|
|
|
* TODO 芋艿:需要测试下;
|
|
|
|
|
*/
|
2021-11-15 02:16:11 +00:00
|
|
|
|
chooseLocation: function () {
|
|
|
|
|
uni.chooseLocation({
|
|
|
|
|
success: (res) => {
|
2023-06-26 12:06:29 +00:00
|
|
|
|
this.$set(this.userAddress, 'detailAddress', res.address.replace(/.+?(省|市|自治区|自治州|县|区)/g,''));
|
2021-11-15 02:16:11 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-06-26 12:06:29 +00:00
|
|
|
|
// 导入共享地址(小程序)TODO 芋艿:待实现
|
2020-08-13 08:12:57 +00:00
|
|
|
|
getWxAddress: function() {
|
|
|
|
|
let that = this;
|
|
|
|
|
uni.authorize({
|
|
|
|
|
scope: 'scope.address',
|
|
|
|
|
success: function(res) {
|
|
|
|
|
uni.chooseAddress({
|
|
|
|
|
success: function(res) {
|
|
|
|
|
let addressP = {};
|
|
|
|
|
addressP.province = res.provinceName;
|
|
|
|
|
addressP.city = res.cityName;
|
|
|
|
|
addressP.district = res.countyName;
|
|
|
|
|
addressP.cityId = 0;
|
|
|
|
|
editAddress({
|
|
|
|
|
address: addressP,
|
2023-06-26 12:06:29 +00:00
|
|
|
|
defaultStatus: 1,
|
|
|
|
|
name: res.userName,
|
2020-08-13 08:12:57 +00:00
|
|
|
|
postCode: res.postalCode,
|
2023-06-26 12:06:29 +00:00
|
|
|
|
mobile: res.telNumber,
|
2020-08-13 08:12:57 +00:00
|
|
|
|
detail: res.detailInfo,
|
|
|
|
|
id: 0
|
|
|
|
|
}).then(res => {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
if (that.cartId) {
|
|
|
|
|
let cartId = that.cartId;
|
|
|
|
|
let pinkId = that.pinkId;
|
|
|
|
|
let couponId = that.couponId;
|
|
|
|
|
that.cartId = '';
|
|
|
|
|
that.pinkId = '';
|
|
|
|
|
that.couponId = '';
|
|
|
|
|
uni.navigateTo({
|
2021-06-11 09:41:16 +00:00
|
|
|
|
url: '/pages/users/order_confirm/index?cartId=' +
|
|
|
|
|
cartId +
|
|
|
|
|
'&addressId=' + (
|
|
|
|
|
that.id ? that
|
|
|
|
|
.id :
|
|
|
|
|
res.data
|
|
|
|
|
.id) +
|
|
|
|
|
'&pinkId=' +
|
|
|
|
|
pinkId +
|
|
|
|
|
'&couponId=' +
|
|
|
|
|
couponId +
|
|
|
|
|
'&secKill=' + that
|
|
|
|
|
.secKill +
|
|
|
|
|
'&combination=' +
|
|
|
|
|
that.combination +
|
|
|
|
|
'&bargain=' + that
|
|
|
|
|
.bargain
|
2020-08-13 08:12:57 +00:00
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateBack({
|
|
|
|
|
delta: 1
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: "添加成功",
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
fail: function(res) {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
if (res.errMsg == 'chooseAddress:cancel') return that.$util
|
|
|
|
|
.Tips({
|
|
|
|
|
title: '取消选择'
|
|
|
|
|
});
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
fail: function(res) {
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '您已拒绝导入微信地址权限',
|
|
|
|
|
content: '是否进入权限管理,调整授权?',
|
|
|
|
|
success(res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
uni.openSetting({
|
|
|
|
|
success: function(res) {}
|
|
|
|
|
});
|
|
|
|
|
} else if (res.cancel) {
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: '已取消!'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-06-26 12:06:29 +00:00
|
|
|
|
// 导入共享地址(微信);TODO 芋艿:待实现
|
2020-08-13 08:12:57 +00:00
|
|
|
|
getAddress() {
|
|
|
|
|
let that = this;
|
|
|
|
|
that.$wechat.openAddress().then(userInfo => {
|
|
|
|
|
// open();
|
|
|
|
|
editAddress({
|
|
|
|
|
id: this.id,
|
2023-06-26 12:06:29 +00:00
|
|
|
|
name: userInfo.userName,
|
|
|
|
|
mobile: userInfo.telNumber,
|
2020-08-13 08:12:57 +00:00
|
|
|
|
address: {
|
|
|
|
|
province: userInfo.provinceName,
|
|
|
|
|
city: userInfo.cityName,
|
|
|
|
|
district: userInfo.countryName,
|
|
|
|
|
cityId: 0
|
|
|
|
|
},
|
|
|
|
|
detail: userInfo.detailInfo,
|
2023-06-26 12:06:29 +00:00
|
|
|
|
defaultStatus: 1,
|
2020-08-13 08:12:57 +00:00
|
|
|
|
postCode: userInfo.postalCode
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
if (that.cartId) {
|
|
|
|
|
let cartId = that.cartId;
|
|
|
|
|
let pinkId = that.pinkId;
|
|
|
|
|
let couponId = that.couponId;
|
|
|
|
|
that.cartId = '';
|
|
|
|
|
that.pinkId = '';
|
|
|
|
|
that.couponId = '';
|
|
|
|
|
uni.navigateTo({
|
2021-06-11 09:41:16 +00:00
|
|
|
|
url: '/pages/users/order_confirm/index?cartId=' +
|
|
|
|
|
cartId + '&addressId=' + (that.id ? that.id :
|
|
|
|
|
res.data
|
|
|
|
|
.id) + '&pinkId=' + pinkId + '&couponId=' +
|
|
|
|
|
couponId + '&secKill=' + that.secKill +
|
|
|
|
|
'&combination=' + that.combination + '&bargain=' +
|
|
|
|
|
that.bargain
|
2020-08-13 08:12:57 +00:00
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.navigateTo({
|
2021-06-11 09:41:16 +00:00
|
|
|
|
url: '/pages/users/user_address_list/index'
|
2020-08-13 08:12:57 +00:00
|
|
|
|
})
|
|
|
|
|
// history.back();
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
// close();
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
title: "添加成功",
|
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
// close();
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: err || "添加失败"
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.addAddress {
|
|
|
|
|
padding-top: 20rpx;
|
|
|
|
|
}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
.addAddress .list {
|
|
|
|
|
background-color: #fff;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
padding: 0 24rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .list .item {
|
|
|
|
|
border-top: 1rpx solid #eee;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
height: 90rpx;
|
|
|
|
|
line-height: 90rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .list .item .name {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
// width: 195rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
color: #333;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .list .item .address {
|
|
|
|
|
flex: 1;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
margin-left: 50rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .list .item input {
|
|
|
|
|
width: 475rpx;
|
|
|
|
|
font-size: 30rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
font-weight: 400;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .list .item .placeholder {
|
|
|
|
|
color: #ccc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .list .item picker .picker {
|
|
|
|
|
width: 410rpx;
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .default {
|
|
|
|
|
padding: 0 30rpx;
|
|
|
|
|
height: 90rpx;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
margin-top: 23rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .default checkbox {
|
|
|
|
|
margin-right: 15rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .keepBnt {
|
|
|
|
|
width: 690rpx;
|
|
|
|
|
height: 86rpx;
|
|
|
|
|
border-radius: 50rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 86rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
margin: 80rpx auto 24rpx auto;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.addAddress .wechatAddress {
|
|
|
|
|
width: 690rpx;
|
|
|
|
|
height: 86rpx;
|
|
|
|
|
border-radius: 50rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 86rpx;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
font-size: 32rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #E93323 ;
|
|
|
|
|
border: 1px solid #E93323;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
2021-11-15 02:16:11 +00:00
|
|
|
|
.relative{
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
.icon-dizhi{
|
|
|
|
|
font-size: 44rpx;
|
|
|
|
|
z-index: 100;
|
|
|
|
|
}
|
|
|
|
|
.abs_right{
|
|
|
|
|
position: absolute;
|
|
|
|
|
right:0;
|
|
|
|
|
}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</style>
|