|
|
@ -31,21 +31,22 @@ |
|
|
</view> |
|
|
</view> |
|
|
<view class="lf-row-between"> |
|
|
<view class="lf-row-between"> |
|
|
<view @tap="setInfo(item)"> |
|
|
<view @tap="setInfo(item)"> |
|
|
<text class="lf-iconfont icon--1"></text> |
|
|
|
|
|
|
|
|
<text class="lf-iconfont icon-bianji"></text> |
|
|
<text class="lf-m-l-10">编辑</text> |
|
|
<text class="lf-m-l-10">编辑</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="lf-m-l-50" @click="deleteAddress(item)"> |
|
|
|
|
|
<text class="lf-iconfont icon--1"></text> |
|
|
|
|
|
|
|
|
<view class="lf-m-l-50 lf-color-red" @click="deleteAddress(item, index)"> |
|
|
|
|
|
<text class="lf-iconfont icon-shanchu"></text> |
|
|
<text class="lf-m-l-10">删除</text> |
|
|
<text class="lf-m-l-10">删除</text> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
<lf-nocontent src="/static/images/empty.png" text="您还未添加地址" v-if="list.length <= 0 && !is_load"></lf-nocontent> |
|
|
</view> |
|
|
</view> |
|
|
<view style="height: 230rpx;"></view> |
|
|
<view style="height: 230rpx;"></view> |
|
|
<view class="add-address" @tap="add"> |
|
|
<view class="add-address" @tap="add"> |
|
|
<view class="small-btn"> |
|
|
<view class="small-btn"> |
|
|
<text class="lf-iconfont icon--2"></text> |
|
|
|
|
|
|
|
|
<text class="lf-iconfont icon-jia"></text> |
|
|
<text class="lf-m-l-10">新增收货地址</text> |
|
|
<text class="lf-m-l-10">新增收货地址</text> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
@ -61,7 +62,8 @@ export default { |
|
|
list: [], |
|
|
list: [], |
|
|
order_no: '', |
|
|
order_no: '', |
|
|
url: '', |
|
|
url: '', |
|
|
id:'' |
|
|
|
|
|
|
|
|
id:'', |
|
|
|
|
|
is_load: true |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -89,29 +91,62 @@ export default { |
|
|
props: {}, |
|
|
props: {}, |
|
|
methods: { |
|
|
methods: { |
|
|
// 删除收货地址 |
|
|
// 删除收货地址 |
|
|
deleteAddress(item){ |
|
|
|
|
|
|
|
|
deleteAddress(item, index){ |
|
|
console.log("item", item) |
|
|
console.log("item", item) |
|
|
var token = this.$cookieStorage.get('user_token'); |
|
|
|
|
|
this.$http.ajax({ |
|
|
|
|
|
api: '/api/address/'+ item.id, |
|
|
|
|
|
method: 'DELETE', |
|
|
|
|
|
header: { |
|
|
|
|
|
Authorization: token |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
console.log("删除地址", res); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '温馨提示', |
|
|
|
|
|
content: '您确定删除该收货地址吗?', |
|
|
|
|
|
success: result => { |
|
|
|
|
|
if(result.confirm){ |
|
|
|
|
|
var token = this.$cookieStorage.get('user_token'); |
|
|
|
|
|
this.$http.ajax({ |
|
|
|
|
|
api: '/api/address/'+ item.id, |
|
|
|
|
|
method: 'DELETE', |
|
|
|
|
|
header: { |
|
|
|
|
|
Authorization: token |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
console.log("删除地址", res); |
|
|
|
|
|
this.$msg('删除成功', {icon: 'success'}); |
|
|
|
|
|
this.list.splice(index, 1); |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.$msg('删除失败', {icon: 'error'}); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 切换默认地址 |
|
|
// 切换默认地址 |
|
|
radioChange(e){ |
|
|
radioChange(e){ |
|
|
let current = e.target.value; |
|
|
let current = e.target.value; |
|
|
|
|
|
let id = null; |
|
|
this.list.forEach((item, index) => { |
|
|
this.list.forEach((item, index) => { |
|
|
if(current == index){ |
|
|
if(current == index){ |
|
|
item.is_default = 1; |
|
|
item.is_default = 1; |
|
|
|
|
|
id = item.id; |
|
|
}else{ |
|
|
}else{ |
|
|
item.is_default = 0; |
|
|
item.is_default = 0; |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
this.switchDefaultAddress(id); |
|
|
|
|
|
}, |
|
|
|
|
|
switchDefaultAddress(id){ |
|
|
|
|
|
var token = this.$cookieStorage.get('user_token'); |
|
|
|
|
|
this.$http.ajax({ |
|
|
|
|
|
api: 'api/address/'+ id, |
|
|
|
|
|
method: 'PUT', |
|
|
|
|
|
header: { |
|
|
|
|
|
Authorization: token |
|
|
|
|
|
}, |
|
|
|
|
|
data: { |
|
|
|
|
|
is_default: 1 |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
this.$msg('操作成功', {icon: 'success'}); |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.$msg('切换默认地址失败'); |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
setInfo(e) { |
|
|
setInfo(e) { |
|
|
// var from = e.currentTarget.dataset.info; |
|
|
// var from = e.currentTarget.dataset.info; |
|
|
@ -150,6 +185,7 @@ export default { |
|
|
|
|
|
|
|
|
// 查询收货地址列表 |
|
|
// 查询收货地址列表 |
|
|
queryAddressList() { |
|
|
queryAddressList() { |
|
|
|
|
|
this.is_load = true; |
|
|
var token = this.$cookieStorage.get('user_token'); |
|
|
var token = this.$cookieStorage.get('user_token'); |
|
|
this.$http.get({ |
|
|
this.$http.get({ |
|
|
api: 'api/address', |
|
|
api: 'api/address', |
|
|
@ -159,7 +195,7 @@ export default { |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
if (res.statusCode == 200) { |
|
|
if (res.statusCode == 200) { |
|
|
res = res.data; |
|
|
res = res.data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (res.status) { |
|
|
if (res.status) { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
list: res.data |
|
|
list: res.data |
|
|
@ -176,7 +212,10 @@ export default { |
|
|
image: '../../../static/error.png' |
|
|
image: '../../../static/error.png' |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
this.is_load = false; |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.is_load = false; |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
setData: function (obj) { |
|
|
setData: function (obj) { |
|
|
@ -213,7 +252,9 @@ export default { |
|
|
</style> |
|
|
</style> |
|
|
<style rel="stylesheet/less" lang="less"> |
|
|
<style rel="stylesheet/less" lang="less"> |
|
|
@import "list"; |
|
|
@import "list"; |
|
|
|
|
|
|
|
|
|
|
|
.lf-color-red{ |
|
|
|
|
|
color: red; |
|
|
|
|
|
} |
|
|
.user-item, .menu-item{ |
|
|
.user-item, .menu-item{ |
|
|
height: 50rpx; |
|
|
height: 50rpx; |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
|