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

84 lines
2.7 KiB
Vue
Raw Normal View History

2022-08-03 13:28:45 +00:00
<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">
2022-08-04 08:01:19 +00:00
<view class="pad-sx30 pad-zy20 disjbac bbot">
<view class="fon22 col26">
2022-08-18 08:21:58 +00:00
<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>
2022-08-04 08:01:19 +00:00
</view>
2022-08-18 08:21:58 +00:00
<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>
2022-08-04 08:01:19 +00:00
</view>
</view>
<view class="" v-if="!addressList.length">
<nothingPage content="地址列表空荡荡滴"></nothingPage>
</view>
2022-08-04 08:01:19 +00:00
<view class="disjcac pad-s50">
2022-08-12 10:14:13 +00:00
<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;">
2022-08-04 08:01:19 +00:00
<view class="icon icon-add04 fon28"></view>
2022-08-04 10:05:43 +00:00
<view class="fon26 mar-z10">新增收货地址</view>
2022-08-04 08:01:19 +00:00
</view>
</view>
2022-08-03 13:28:45 +00:00
</view>
</status-container>
2022-08-03 13:28:45 +00:00
</view>
</template>
<script>
import nothingPage from '@/components/nothing/nothing-page.vue';
2022-08-03 13:28:45 +00:00
export default {
components:{
nothingPage
2022-08-03 13:28:45 +00:00
},
data() {
return {
addressList:[],
loading:false,
ifChoose:0
2022-08-03 13:28:45 +00:00
}
},
onShow() {
// 调取获取地址列表
this.getAddress();
},
onLoad(op) {
if(op.ifChoose) this.ifChoose = op.ifChoose;
},
2022-08-03 13:28:45 +00:00
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]);
}
}
})
}
2022-08-03 13:28:45 +00:00
}
}
</script>
<style>
</style>