|
|
|
|
@ -1,33 +1,36 @@ |
|
|
|
|
<template> |
|
|
|
|
<view class="add_box"> |
|
|
|
|
<view class="address_box" > |
|
|
|
|
<view class="address_item" v-for="item in addressData" :key="item.name"> |
|
|
|
|
<view class="top_box"> |
|
|
|
|
<view class="address_item" v-for="(item,index) in addressData" :key="index"> |
|
|
|
|
<view class="top_box" @click="turnToOrder(item)"> |
|
|
|
|
<view class="top_item"> |
|
|
|
|
<view class="top"> |
|
|
|
|
<span class="name_txt">{{item.name}}</span> |
|
|
|
|
<span class="name_txt">{{item.consignee}}</span> |
|
|
|
|
<span class="phone_txt">{{item.phone}}</span> |
|
|
|
|
</view> |
|
|
|
|
<view class="bottom"> |
|
|
|
|
{{item.address}} |
|
|
|
|
{{item.province}} {{item.city}} {{item.area}}{{item.address}} |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="edit_box"> |
|
|
|
|
<view class="edit_box" @click="handleEdit(item)"> |
|
|
|
|
<view class="img_box"> |
|
|
|
|
<image class="img" src="../../../static/image/edit.png" mode=""></image> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="bottom_item"> |
|
|
|
|
<view v-if="item.status == 0" class="no_checked"></view> |
|
|
|
|
<view v-if="item.status == 1" class="checked"> |
|
|
|
|
<view v-if="item.isDefault == 0" class="no_checked"></view> |
|
|
|
|
<view v-if="item.isDefault == 1" class="checked"> |
|
|
|
|
<p class="item"></p> |
|
|
|
|
</view> |
|
|
|
|
<p class="no_default" v-if="item.status == 0">设为默认</p> |
|
|
|
|
<p v-if="item.status == 1" class="default_txt">默认地址</p> |
|
|
|
|
<p class="no_default" v-if="item.isDefault == 0" @click="handleDefault(item)">设为默认</p> |
|
|
|
|
<p v-if="item.isDefault == 1" class="default_txt">默认地址</p> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<uni-load-more iconType="circle" :status="status" @clickLoadMore="loadMore" |
|
|
|
|
:content-text="contentText"></uni-load-more> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<view class="btn_box"> |
|
|
|
|
<p class="btn" @click="handleAdd">添加新地址</p> |
|
|
|
|
</view> |
|
|
|
|
@ -36,7 +39,7 @@ |
|
|
|
|
<view class="popup-content" > |
|
|
|
|
<view class="title_box"> |
|
|
|
|
<view class="tit_txt"> |
|
|
|
|
新增地址 |
|
|
|
|
{{title}} |
|
|
|
|
</view> |
|
|
|
|
<view class="image_box"> |
|
|
|
|
<image class="img" src="../../../static/image/cancel.png" mode=""></image> |
|
|
|
|
@ -48,7 +51,7 @@ |
|
|
|
|
收货人: |
|
|
|
|
</view> |
|
|
|
|
<view class="right_item"> |
|
|
|
|
张三 |
|
|
|
|
<uni-easyinput v-model="buyUser" :inputBorder="false" placeholder="请输入收货人姓名"></uni-easyinput> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="content_item"> |
|
|
|
|
@ -56,7 +59,7 @@ |
|
|
|
|
联系电话: |
|
|
|
|
</view> |
|
|
|
|
<view class="right_item"> |
|
|
|
|
15612345678 |
|
|
|
|
<uni-easyinput v-model="buyPhone" :inputBorder="false" placeholder="请输入联系方式"></uni-easyinput> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="content_item"> |
|
|
|
|
@ -84,7 +87,7 @@ |
|
|
|
|
详细地址: |
|
|
|
|
</view> |
|
|
|
|
<view class="right_item"> |
|
|
|
|
大港街道大港三路8号铁路住宅小区6号楼大港街道大港三路8号铁路住宅小区6号楼 |
|
|
|
|
<uni-easyinput type="textarea" :inputBorder="false" autoHeight v-model="address" placeholder="请输入详细地址"></uni-easyinput> |
|
|
|
|
</view> |
|
|
|
|
<view class="right_icon" @click="handlePosition"> |
|
|
|
|
<image src="../../../static/image/position.png"></image> |
|
|
|
|
@ -92,14 +95,14 @@ |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="button_box"> |
|
|
|
|
<p class="btn">删除</p> |
|
|
|
|
<p class="btn">保存</p> |
|
|
|
|
<p class="btn" v-if="!isEdit" @click="closePop">取消</p> |
|
|
|
|
<p class="btn" v-if="isEdit" @click="handleDelete">删除</p> |
|
|
|
|
<p class="btn" @click="handleSave">保存</p> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</uni-popup> |
|
|
|
|
</view> |
|
|
|
|
<!-- <uni-load-more iconType="circle" :status="status" @clickLoadMore="loadMore" |
|
|
|
|
:content-text="contentText"></uni-load-more> --> |
|
|
|
|
|
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
@ -108,6 +111,10 @@ |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
isEdit:false, |
|
|
|
|
buyUser:'', |
|
|
|
|
buyPhone:'', |
|
|
|
|
address:'', |
|
|
|
|
imgPrefix: getApp().globalData.imgPrefix, |
|
|
|
|
locationArr: [ |
|
|
|
|
[], |
|
|
|
|
@ -119,8 +126,8 @@ |
|
|
|
|
city:'', |
|
|
|
|
district:'', |
|
|
|
|
addressData: [ |
|
|
|
|
{name:'张三',phone:'15612345678',address:'山东省青岛市市北区大港街道大港三路8号铁路住宅小区6号楼6单元666室',status:1}, |
|
|
|
|
{name:'张三',phone:'15612345678',address:'山东省青岛市市北区大港街道大港三路8号铁路住宅小区6号楼6单元666室',status:0}, |
|
|
|
|
// {name:'张三',phone:'15612345678',address:'山东省青岛市市北区大港街道大港三路8号铁路住宅小区6号楼6单元666室',status:1}, |
|
|
|
|
// {name:'张三',phone:'15612345678',address:'山东省青岛市市北区大港街道大港三路8号铁路住宅小区6号楼6单元666室',status:0}, |
|
|
|
|
], |
|
|
|
|
allCityData, |
|
|
|
|
current: 0, |
|
|
|
|
@ -131,10 +138,15 @@ |
|
|
|
|
contentdown: "点击查看更多", |
|
|
|
|
contentrefresh: "正在加载...", |
|
|
|
|
contentnomore: "没有更多数据了", |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
title:'', |
|
|
|
|
addressId:'', |
|
|
|
|
userInfo:{}, |
|
|
|
|
pageFrom:'' |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onLoad() { |
|
|
|
|
onLoad(options) { |
|
|
|
|
this.pageFrom = options.from; |
|
|
|
|
this.getData() |
|
|
|
|
let userInfo = uni.getStorageSync('userInfo'); |
|
|
|
|
if (userInfo) { |
|
|
|
|
@ -143,8 +155,222 @@ |
|
|
|
|
this.loadMore(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.userInfo = JSON.parse(uni.getStorageSync('userInfo')); |
|
|
|
|
// console.log(userInfo) |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 保存地址 |
|
|
|
|
handleSave(){ |
|
|
|
|
if(this.userInfo){ |
|
|
|
|
if(!this.isEdit){ |
|
|
|
|
if(this.address == '' || this.province == '' || this.buyUser == '' || this.buyPhone == ''){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请完整填写信息', |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
let params = { |
|
|
|
|
userId:this.userInfo.id, |
|
|
|
|
consignee:this.buyUser, |
|
|
|
|
phone:this.buyPhone, |
|
|
|
|
province:this.province, |
|
|
|
|
city:this.city, |
|
|
|
|
district:this.district ? this.district : '', |
|
|
|
|
address:this.address, |
|
|
|
|
isDefault:0 |
|
|
|
|
} |
|
|
|
|
uni.request({ |
|
|
|
|
url:getApp().globalData.baseUrl + '/address/save', |
|
|
|
|
method:'POST', |
|
|
|
|
header:{ |
|
|
|
|
'Blade-Auth': 'bearer ' + uni.getStorageSync('token') |
|
|
|
|
}, |
|
|
|
|
data:params, |
|
|
|
|
success:(res) =>{ |
|
|
|
|
console.log(res) |
|
|
|
|
if(res.data.code == 200){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '新增成功', |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
this.$refs.popup.close(); |
|
|
|
|
this.hasMore = true; |
|
|
|
|
this.current = 0; |
|
|
|
|
this.loadMore() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
if(this.address == '' || this.province == '' || this.buyUser == '' || this.buyPhone == ''){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请完整填写信息', |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
let params = { |
|
|
|
|
id:this.addressId, |
|
|
|
|
userId:this.userInfo.id, |
|
|
|
|
consignee:this.buyUser, |
|
|
|
|
phone:this.buyPhone, |
|
|
|
|
province:this.province, |
|
|
|
|
city:this.city, |
|
|
|
|
district:this.district ? this.district : '', |
|
|
|
|
address:this.address, |
|
|
|
|
} |
|
|
|
|
uni.request({ |
|
|
|
|
url:getApp().globalData.baseUrl + '/address/update', |
|
|
|
|
method:"POST", |
|
|
|
|
header:{ |
|
|
|
|
'Blade-Auth': 'bearer ' + uni.getStorageSync('token') |
|
|
|
|
}, |
|
|
|
|
data:JSON.stringify(params), |
|
|
|
|
success:res =>{ |
|
|
|
|
console.log(res) |
|
|
|
|
if(res.data.code == 200){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '地址修改成功', |
|
|
|
|
icon: 'none' |
|
|
|
|
}); |
|
|
|
|
this.addressData = [] |
|
|
|
|
this.$refs.popup.close(); |
|
|
|
|
this.hasMore = true; |
|
|
|
|
this.current = 0; |
|
|
|
|
this.loadMore() |
|
|
|
|
}else{ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.data.msg, |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
console.log(this.address) |
|
|
|
|
}, |
|
|
|
|
// 编辑地址 |
|
|
|
|
handleEdit(item){ |
|
|
|
|
console.log(item) |
|
|
|
|
this.title = '编辑地址' |
|
|
|
|
this.addressId = item.id |
|
|
|
|
this.isEdit = true; |
|
|
|
|
this.buyUser = item.consignee; |
|
|
|
|
this.buyPhone = item.phone; |
|
|
|
|
this.address = item.address; |
|
|
|
|
this.province = item.province; |
|
|
|
|
this.city = item.city; |
|
|
|
|
this.district = item.area; |
|
|
|
|
this.$refs.popup.open('bottom') |
|
|
|
|
}, |
|
|
|
|
// 删除地址 |
|
|
|
|
handleDelete(){ |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: '提示', |
|
|
|
|
content: '确认删除该地址?', |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
uni.request({ |
|
|
|
|
url:getApp().globalData.baseUrl + '/address/delete?ids=' + this.addressId, |
|
|
|
|
method:"POST", |
|
|
|
|
header:{ |
|
|
|
|
'Blade-Auth': 'bearer ' + uni.getStorageSync('token') |
|
|
|
|
}, |
|
|
|
|
success:(res) =>{ |
|
|
|
|
console.log(res) |
|
|
|
|
if(res.data.code == 200){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '删除成功', |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
this.addressData = [] |
|
|
|
|
this.$refs.popup.close(); |
|
|
|
|
this.hasMore = true; |
|
|
|
|
this.current = 0; |
|
|
|
|
this.loadMore() |
|
|
|
|
}else{ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.data.msg, |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} else if (res.cancel) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 添加默认 |
|
|
|
|
handleDefault(item){ |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: '提示', |
|
|
|
|
content: '确认将该地址设置为默认地址?', |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.confirm) { |
|
|
|
|
let params = { |
|
|
|
|
id:item.id, |
|
|
|
|
userId:this.userInfo.id, |
|
|
|
|
isDefault:1 |
|
|
|
|
} |
|
|
|
|
uni.request({ |
|
|
|
|
url:getApp().globalData.baseUrl + '/address/update', |
|
|
|
|
method:"POST", |
|
|
|
|
header:{ |
|
|
|
|
'Blade-Auth': 'bearer ' + uni.getStorageSync('token') |
|
|
|
|
}, |
|
|
|
|
data:JSON.stringify(params), |
|
|
|
|
success:res =>{ |
|
|
|
|
console.log(res) |
|
|
|
|
if(res.data.code == 200){ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '默认地址设置成功', |
|
|
|
|
icon: 'none' |
|
|
|
|
}); |
|
|
|
|
this.addressData = [] |
|
|
|
|
this.$refs.popup.close(); |
|
|
|
|
this.hasMore = true; |
|
|
|
|
this.current = 0; |
|
|
|
|
this.loadMore() |
|
|
|
|
}else{ |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: res.data.msg, |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else if(res.cancel){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
turnToOrder(item){ |
|
|
|
|
if(this.pageFrom == 1){ |
|
|
|
|
var pages = getCurrentPages(); // 获取页面栈 |
|
|
|
|
var currPage = pages[pages.length - 1]; // 当前页面 |
|
|
|
|
var prevPage = pages[pages.length - 2]; // 上一个页面 |
|
|
|
|
console.log(pages) |
|
|
|
|
console.log(prevPage) |
|
|
|
|
if(prevPage.__route__ == 'pages/pages_zhentou/order/confirmOrder'){ |
|
|
|
|
prevPage.__data__.changeAddress( |
|
|
|
|
{ |
|
|
|
|
name:item.consignee, |
|
|
|
|
phone:item.phone, |
|
|
|
|
address:item.province + item.city + (item.area ? item.area : '') + item.address, |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 取消新增 |
|
|
|
|
closePop(){ |
|
|
|
|
this.$refs.popup.close(); |
|
|
|
|
}, |
|
|
|
|
// 获取地区数据 |
|
|
|
|
getData() { |
|
|
|
|
console.log(this.allCityData) |
|
|
|
|
@ -158,12 +384,13 @@ |
|
|
|
|
console.log(this.locationArr) |
|
|
|
|
}, |
|
|
|
|
cityChange(e) { |
|
|
|
|
console.log(e) |
|
|
|
|
console.log('111') |
|
|
|
|
this.multiIndex = e.detail.value; |
|
|
|
|
console.log(this.locationArr) |
|
|
|
|
this.province = this.locationArr[0][this.multiIndex[0]] |
|
|
|
|
this.city = this.locationArr[1][this.multiIndex[1]] |
|
|
|
|
this.district = this.locationArr[2][this.multiIndex[2]] |
|
|
|
|
this.district = this.locationArr[2][this.multiIndex[2]]; |
|
|
|
|
this.address = '' |
|
|
|
|
}, |
|
|
|
|
columnchange(e) { |
|
|
|
|
let value = e.detail.value; |
|
|
|
|
@ -207,6 +434,14 @@ |
|
|
|
|
}, |
|
|
|
|
// 添加地址 |
|
|
|
|
handleAdd(){ |
|
|
|
|
this.isEdit = false; |
|
|
|
|
this.title = '新增地址' |
|
|
|
|
this.buyUser = ''; |
|
|
|
|
this.buyPhone = ''; |
|
|
|
|
this.address = ''; |
|
|
|
|
this.province = ''; |
|
|
|
|
this.city = ''; |
|
|
|
|
this.district = ''; |
|
|
|
|
this.$refs.popup.open('bottom') |
|
|
|
|
}, |
|
|
|
|
// 定位 |
|
|
|
|
@ -269,6 +504,9 @@ |
|
|
|
|
url: getApp().globalData.baseUrl + '/address/list?userId=' + this.userInfo.id + '¤t=' + this |
|
|
|
|
.current + '&size=' + this.size, |
|
|
|
|
method: 'GET', |
|
|
|
|
header:{ |
|
|
|
|
'Blade-Auth': 'bearer ' + uni.getStorageSync('token') |
|
|
|
|
}, |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
this.addressData = this.addressData.concat(res.data.data.records); |
|
|
|
|
|