2023-02-23
保存地址
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
</view>
|
||||
<view class="address-box">
|
||||
<text v-if="item.defaultStatus == 1" class="tag">默认</text>
|
||||
<text class="address"> {{ item.province }}-{{ item.city }}-{{ item.region }}-{{ item.detailAddress }}</text>
|
||||
<text class="address">{{ item.region }}-{{ item.detailAddress }}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
@@ -11,13 +11,17 @@
|
||||
<input class="input" type="number" maxlength="11" v-model="addressData.phoneNumber" placeholder="收货人手机号码"
|
||||
placeholder-class="placeholder" />
|
||||
</view>
|
||||
|
||||
|
||||
<view class="row b-b">
|
||||
<text class="tit">所在地</text>
|
||||
<view class="input" >
|
||||
<uni-data-select v-model="value" :localdata="range" @change="change"></uni-data-select>
|
||||
<view class="input">
|
||||
<w-select style="" v-model='chooseValue' defaultValue="请选择所在地" :list='range' width="100%"
|
||||
valueName='content' @change='change'>
|
||||
</w-select>
|
||||
|
||||
<!-- <uni-data-select :placeholder="addressData.region" v-model="value" :localdata="range" @change="change"></uni-data-select> -->
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
<!-- <view class="row b-b">
|
||||
<text class="tit">地图:</text>
|
||||
@@ -48,13 +52,14 @@
|
||||
data() {
|
||||
return {
|
||||
mapAddressName: '',
|
||||
chooseValue: "",
|
||||
addressData: {
|
||||
name: '',
|
||||
phoneNumber: '',
|
||||
province: '',
|
||||
city: '',
|
||||
region: '',
|
||||
detailAddress: '',
|
||||
detailAddress: '王宫村服务站',
|
||||
defaultStatus: 0,
|
||||
def: false
|
||||
},
|
||||
@@ -66,16 +71,16 @@
|
||||
},
|
||||
value: 0,
|
||||
range: [{
|
||||
value: '1',
|
||||
text: '王宫村'
|
||||
id: 1,
|
||||
content: '王宫村'
|
||||
},
|
||||
{
|
||||
value: '2',
|
||||
text: '土山村'
|
||||
id: 2,
|
||||
content: '土山村'
|
||||
},
|
||||
{
|
||||
value: '3',
|
||||
text: '马庄村'
|
||||
id: 3,
|
||||
content: '马庄村'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -85,16 +90,24 @@
|
||||
if (option.type === 'edit') {
|
||||
title = '编辑收货地址'
|
||||
this.addressData = JSON.parse(option.data)
|
||||
this.chooseValue = JSON.parse(option.data).region
|
||||
console.log('region》》》', this.addressData.region);
|
||||
console.log('chooseValue》》》', this.chooseValue);
|
||||
}
|
||||
this.manageType = option.type;
|
||||
uni.setNavigationBarTitle({
|
||||
title
|
||||
title:title
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
||||
change(res) {
|
||||
console.log('res', res);
|
||||
// let index = this.range.findIndex((item) => item.value == res)
|
||||
this.addressData.region= res.content
|
||||
this.chooseValue= res.content
|
||||
console.log('region》》》', this.addressData.region);
|
||||
console.log('chooseValue》》》', this.chooseValue);
|
||||
},
|
||||
|
||||
switchChange(e) {
|
||||
@@ -141,11 +154,12 @@
|
||||
async confirm() {
|
||||
const that = this
|
||||
let data = this.addressData;
|
||||
console.log('data》》》', data);
|
||||
if (!data.name) {
|
||||
this.$api.msg('请填写收货人姓名');
|
||||
return;
|
||||
}
|
||||
if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(data.phoneNumber)) {
|
||||
if (!/^1[1-9][0-9]\d{8}$/.test(data.phoneNumber)) {
|
||||
that.$api.msg('请输入正确的手机号码');
|
||||
return
|
||||
}
|
||||
@@ -157,14 +171,14 @@
|
||||
// that.$api.msg('请选择二级城市')
|
||||
// return
|
||||
// }
|
||||
// if (!data.region) {
|
||||
// that.$api.msg('请选择三级区或县')
|
||||
// return
|
||||
// }
|
||||
// if (!data.detailAddress) {
|
||||
// that.$api.msg('请输入详细地址');
|
||||
// return
|
||||
// }
|
||||
if (!data.region) {
|
||||
that.$api.msg('请选择所在的')
|
||||
return
|
||||
}
|
||||
if (!data.detailAddress) {
|
||||
that.$api.msg('请输入取货点');
|
||||
return
|
||||
}
|
||||
|
||||
let data1 = await Api.apiCall('post', Api.goods.addressSave, that.addressData);
|
||||
if (data1) {
|
||||
|
||||
Reference in New Issue
Block a user