martial-arts/pagesA/my-address/my-address.vue

84 lines
2.7 KiB
Vue

<template>
<view>
<status-container titlet="我的地址" returnc="#FFFFFF">
<view slot="content" style="margin-top: -20rpx;" v-if="loading">
<view @tap="chooseAddress(item)" class="bacf pad-x30 pad-zy20" v-for="(item,index) in addressList" :key="index">
<view class="pad-sx30 pad-zy20 disjbac bbot">
<view class="fon22 col26">
<view class="" style="color: #676767;">{{item.province_str}}{{item.city_str}}{{item.county_str}} <span v-if="item.is_default" class="colf radius4 pad-sx2 pad-zy6 mar-z10 fon22" style="background-color: #f37717;">默认</span></view>
<view class="mar-sx10">{{item.address}}</view>
<view class="">{{item.name}} {{$toolAll.tools.hideMPhone(item.phone)}}</view>
</view>
<view class="disjcac" style="width: 80rpx;height: 80rpx;margin-right: -30rpx;" @tap.stop="$toolAll.tools.goPage(`/pagesB/add-address/add-address?id=${item.id}`)">
<image class="flexs" src="/static/tabbar/icon-edit.png" mode="aspectFill" style="width: 32rpx;height: 34rpx;"></image>
</view>
</view>
</view>
<view class="" v-if="!addressList.length">
<nothingPage content="地址列表空荡荡滴"></nothingPage>
</view>
<view class="disjcac pad-s50">
<view @tap="$toolAll.tools.goPage('/pagesB/add-address/add-address')" class="disjcac radius34" style="width: 396rpx;height: 72rpx;background-color: #f37717;color: #FFFFFF;position: relative;z-index: 100;">
<view class="icon icon-add04 fon28"></view>
<view class="fon26 mar-z10"></view>
</view>
</view>
</view>
</status-container>
</view>
</template>
<script>
import nothingPage from '@/components/nothing/nothing-page.vue';
export default {
components:{
nothingPage
},
data() {
return {
addressList:[],
loading:false,
ifChoose:0
}
},
onShow() {
// 调取获取地址列表
this.getAddress();
},
onLoad(op) {
if(op.ifChoose) this.ifChoose = op.ifChoose;
},
methods: {
// 选择地址
chooseAddress(item){
if(this.ifChoose){
uni.setStorageSync('addressInfo',item);
uni.navigateBack({delta:1})
}
},
// 获取地址列表
getAddress(){
this.$requst.get('/api/user/address').then(res=>{
this.loading = true;
if(res.code==0){
// 设置地址列表
this.addressList = res.data;
let chooseAddress = uni.getStorageSync('addressInfo');
let exitIndex = this.addressList.findIndex(item=>item.id==chooseAddress.id);
if(exitIndex!=-1){
uni.setStorageSync('addressInfo',this.addressList[exitIndex]);
} else if(this.addressList.length==1){
uni.setStorageSync('addressInfo',this.addressList[0]);
}
}
})
}
}
}
</script>
<style>
</style>