238 lines
5.2 KiB
Vue
238 lines
5.2 KiB
Vue
<template>
|
|
<!-- 收货地址 -->
|
|
<view class="w-100 h-100 all">
|
|
<HeaderTop page_title='收货地址'></HeaderTop>
|
|
<view class="list">
|
|
<view class="list_item d-flex j-sb j-center a-center padding-30 border-bottom" v-for="(item,index) in dataList" :key="index">
|
|
<!-- <radio value="" :checked="item.checked" style="width:10%;" v-if="goods_id!=''" /> -->
|
|
<view class="items_info flex-1 padding-zy30">
|
|
<view class="d-flex">
|
|
<view>{{item.consignee}}</view>
|
|
<view class='margin-zy20'>{{item.tel}}</view>
|
|
<view class="is_choose margin-zy20" v-if='item.is_default!=0'>默认</view>
|
|
</view>
|
|
<view>
|
|
{{item.address}}
|
|
</view>
|
|
</view>
|
|
|
|
<image src="../../static/shoppingCart/edit1.png" mode="" style="height:40upx; width:40upx;margin-right: 30upx;" @click.stop="edit(index)"></image>
|
|
</view>
|
|
</view>
|
|
<!-- <block v-for="(item,index) in dataList" :key="index">
|
|
<uni-swipe-action :options="options"
|
|
@click="bindClick($event,index)">
|
|
<uni-list-item @click="choose(item)">
|
|
<view class="text-secondary text-dark">
|
|
<view class="d-flex a-center">
|
|
<text class="text-dark mr-2 font-weight">{{item.consignee}}</text>
|
|
{{item.tel}}
|
|
<text class="main-text-color ml-2"
|
|
v-if="item.isdefault">[默认]</text>
|
|
</view>
|
|
<view>{{item.area_name}} {{"("}}{{item.address}}{{")"}}</view>
|
|
</view>
|
|
</uni-list-item>
|
|
</uni-swipe-action>
|
|
</block> -->
|
|
<view class="x_public_box x-text-white x-bg-159 margin-shu20 shadow addBtn w-90" style="line-height: 80upx;" @click="addPath()">新增收货地址</view>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import store from '@/store/index.js'
|
|
import HeaderTop from '../../components/HeaderTop/HeaderTop.vue'
|
|
import uniListItem from "@/components/uni-ui/uni-list-item/uni-list-item.vue"
|
|
import uniSwipeAction from "@/components/uni-ui/uni-swipe-action/uni-swipe-action.vue"
|
|
import {mapState,mapMutations} from "vuex"
|
|
|
|
import shippingAddress from '../../utils/models/shop.js'
|
|
export default {
|
|
components: {
|
|
uniListItem,
|
|
uniSwipeAction,
|
|
HeaderTop
|
|
|
|
},
|
|
data() {
|
|
return {
|
|
address_id:'',
|
|
goods_id:'',
|
|
dataList:[], //数据列表
|
|
|
|
isChoose:false,
|
|
options: [{
|
|
text: '编辑',
|
|
style: {
|
|
backgroundColor: '#007aff'
|
|
}
|
|
}, {
|
|
text: '删除',
|
|
style: {
|
|
backgroundColor: '#dd524d'
|
|
}
|
|
}],
|
|
}
|
|
},
|
|
computed: {
|
|
...mapState({
|
|
|
|
|
|
|
|
list:state=>state.path.list
|
|
}),
|
|
},
|
|
|
|
onLoad(option) {
|
|
if (option.type === '') {
|
|
this.isChoose = true
|
|
}
|
|
if(option.goods_id){
|
|
|
|
this.goods_id = option.goods_id
|
|
|
|
}
|
|
// 请求数据
|
|
this.getData()
|
|
},
|
|
methods: {
|
|
// 编辑地址
|
|
edit(index){
|
|
// console.log(this.goods_id)
|
|
uni.redirectTo({
|
|
url:'./user-path-edit?address_item='+JSON.stringify(this.dataList[index])
|
|
})
|
|
console.log(JSON.stringify(this.dataList[index]));
|
|
|
|
// {"id":286,
|
|
// "area_id":216,
|
|
// "address":"aeawef",
|
|
// "consignee":"天空",
|
|
// "tel":"1565654848",
|
|
// "is_default":0,
|
|
// "area_name":"河南省 - 洛阳市 - 嵩县",
|
|
// "short_consignee":"天空",
|
|
// "checked":fals,
|
|
// }
|
|
},
|
|
// 选择地址
|
|
|
|
// 地址列表
|
|
async getData(){
|
|
let res = await shippingAddress.addressList();
|
|
this.handleError(res, res => {
|
|
|
|
this.dataList = res.data.data.list
|
|
|
|
|
|
this.dataList.forEach(item=>{
|
|
|
|
item.checked = false
|
|
this.address_id = item.id
|
|
})
|
|
})
|
|
},
|
|
|
|
async deletelist(){
|
|
let res = await shippingAddress.deleteAddress(this.address_id);
|
|
this.handleError(res, res => {
|
|
|
|
if(res.code == 200){
|
|
uni.showToast({
|
|
title:'删除成功'
|
|
})
|
|
}else{
|
|
|
|
|
|
}
|
|
|
|
})
|
|
},
|
|
|
|
|
|
|
|
async bindClick(value,i) {
|
|
let res;
|
|
switch (value.index){
|
|
case 0: // 修改
|
|
let obj = JSON.stringify({
|
|
index:i,
|
|
item:this.address_id
|
|
})
|
|
setTimeout(()=> {
|
|
uni.redirectTo({
|
|
url: '../my/user-path-edit?data='+obj,
|
|
});
|
|
},50);
|
|
break;
|
|
case 1: // 删除
|
|
let res = await shippingAddress.deleteAddress(this.address_id);
|
|
this.handleError(res, res => {
|
|
|
|
if(res.code == 200){
|
|
uni.showModal({
|
|
content: '要删除该收货地址吗?',
|
|
success(res){
|
|
if(res.confirm){
|
|
uni.showToast({
|
|
title:'删除成功'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}else{
|
|
|
|
|
|
}
|
|
|
|
})
|
|
break;
|
|
}
|
|
},
|
|
|
|
|
|
|
|
// 选择收货地址
|
|
// choose(item){
|
|
// if (this.isChoose) {
|
|
// // 通知订单提交页修改收货地址
|
|
// uni.$emit('choosePath',item)
|
|
// // 关闭当前页面
|
|
// uni.navigateBack({
|
|
// delta: 1
|
|
// });
|
|
// }
|
|
// },
|
|
// 新增地址
|
|
addPath() {
|
|
uni.redirectTo({
|
|
url: '../my/user-path-add'
|
|
});
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.is_choose{
|
|
background-color: #EDCA4A;
|
|
color: #FFFFFF;
|
|
height:50upx;
|
|
line-height: 50upx;
|
|
padding: 0 15upx;
|
|
font-size: 28upx;
|
|
border-radius: 20upx;
|
|
}
|
|
.list{
|
|
height:calc(100% - 300upx);
|
|
overflow-y: auto;
|
|
}
|
|
.addBtn{
|
|
position: absolute;
|
|
bottom:0upx;
|
|
left: 34upx;
|
|
}
|
|
|
|
</style>
|