You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-app/pages/account/address/list.vue

139 lines
2.9 KiB

<!--
* @Author: ch
* @Date: 2022-03-22 13:54:15
* @LastEditors: ch
* @LastEditTime: 2022-04-06 20:22:31
* @Description: file content
-->
<template>
<view class="container">
<view class="address">
<u-loadmore v-if="isLoading" status="loading" />
<BsEmpty tips="暂无收货地址呢~" v-if="!isLoading && !addresList.length"></BsEmpty>
<view class="addressItem" v-for="(item, index) in addresList" :key="item.id"
:class="{'addressItem__last' : index === addresList.length - 1,'addressItem__default':item.isDefault}">
<view>
<view class="addressItem--city">{{item.province}}{{item.city}}{{item.area}}</view>
<view class="addressItem--detail">{{item.detailAddress}}</view>
<view>
<text class="addressItem--name">{{item.name}}</text>
<text>{{item.phone}}</text>
</view>
</view>
<image class="addressItem--edit" src="@/static/account/edit.png"
@click="$Router.push(`/addressEdit?id=${item.id}`)" />
</view>
</view>
<UiButton class="addAddress" type="solid" size="max" @click="$Router.push(`/addressCreate?first=${!addresList.length}`)"></UiButton>
</view>
</template>
<script>
import BsEmpty from "@/components/BsEmpty";
import UiButton from '../../../components/UiButton.vue';
import {ApiGetAddress} from '@/common/api/base';
export default {
components: { BsEmpty, UiButton },
data() {
return {
addresList : [],
isLoading : true
};
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getAddressList();
},
methods: {
async getAddressList(){
this.isLoading = true;
const {error, result} = await ApiGetAddress();
this.isLoading = false;
if(error){
uni.$u.toast(error.message);
return false;
}
this.addresList = result;
this.$store.commit('SET_ADDRESS', result);
}
},
};
</script>
<style lang="scss" scoped>
page{
background: #f8f8f8;
}
.address{
background: #fff;
}
.addressItem{
height: 188rpx;
margin-left: 40rpx;
padding-right: 40rpx;
border-bottom: 1px solid #eee;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
color: #999;
&--detail{
font-size: 28rpx;
color: #333;
margin: 20rpx 0;
}
&--name{
margin-right: 46rpx;
}
&--edit{
width: 26rpx;
height: 26rpx;
}
&__default .addressItem--city{
display: flex;
align-items: center;
&::after{
display: block;
content: '默认';
background: #FF512B;
color: #fff;
border-radius: 4rpx;
padding: 4rpx 6rpx;
margin-left: 20rpx;
}
}
&__last{
border: 0;
}
}
.addAddress{
position: fixed;
bottom: 89rpx;
left: 30rpx;
display: flex;
align-items: center;
justify-content: center;
&::before{
display: inline-block;
content: "+";
margin-right: 20rpx;
font-size: 46rpx;
font-weight: bold;
padding-top: 10rpx;
}
}
</style>