| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <template>
- <view class="address">
- <view class="noaddress" v-if="addressList.length == 0">
- <view class="noaddress-bg center">
- <image src="/static/image/publice/zanwushouhuo@2x.png" mode=""></image>
- <text>暂无收货地址</text>
- </view>
- <button class="btn-no" hover-class="hover-view" @click="navTo(0)">添加收货地址</button>
- </view>
- <view class="address-list" v-else>
- <view class="address-list-main">
- <view class="address-list-item flex" v-for="(item, index) in addressList" :key="index" @click="selectAddress(item)">
- <view class="address-list-item-info">
- <view class="address-list-scq">{{ item.province }} {{ item.city }} {{ item.area }}</view>
- <view class="address-list-detail">{{ item.detail }}</view>
- <view class="address-list-userInfo flexs">
- <text>{{ item.username }}</text>
- <text>{{ item.mobile }}</text>
- </view>
- </view>
- <view class="edit" @click.stop="editAddress(item)"><image src="/static/image/me/bianji@2x.png" mode=""></image></view>
- </view>
- </view>
- <button class="btn btn-no" @click="navTo(0)">新增收货地址</button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- type: 1, //1回收选择地址
- addressList: []
- };
- },
- methods: {
- //编辑地址
- editAddress(item) {
- uni.setStorageSync('editAddress', JSON.stringify(item));
- uni.navigateTo({ url: '/pages/me/addSite?type=1' });
- },
- //选择地址
- selectAddress(item) {
- if (this.type == 1 || this.type == 2) {
- uni.setStorageSync(this.type == 1 ? 'applyAddress' : '', JSON.stringify(item));
- uni.navigateBack();
- }
- },
- navTo(type) {
- uni.navigateTo({ url: '/pages/me/addSite?type=' + type });
- },
- //获取收货地址
- loadData() {
- this.$api.myAddress().then(res => {
- if (res.code === 1) {
- this.addressList = res.data;
- if (res.data.length == 0) {
- uni.removeStorageSync('applyAddress');
- }
- }
- });
- }
- },
- loadData({ type }) {
- this.type = type;
- },
- onShow() {
- this.loadData();
- }
- };
- </script>
- <style lang="scss">
- .noaddress {
- display: flex;
- padding: 165rpx 30rpx 35rpx 30rpx;
- flex-direction: column;
- justify-content: space-between;
- height: calc(100vh - 44px);
- .noaddress-bg {
- flex-direction: column;
- image {
- width: 354rpx;
- height: 310rpx;
- margin-bottom: 50rpx;
- }
- text {
- font-size: 28rpx;
- font-weight: bold;
- }
- }
- }
- .btn-no {
- height: 98rpx;
- color: #333333;
- font-size: 30rpx;
- font-weight: bold;
- background: #ffffff;
- box-shadow: 0rpx 0rpx 121rpx 0rpx rgba(63, 52, 2, 0.12);
- border-radius: 10rpx;
- }
- .address-list-main {
- padding: 30rpx 30rpx 130rpx 30rpx;
- .address-list-item {
- padding: 30rpx;
- margin-bottom: 30rpx;
- background: #ffffff;
- .address-list-scq {
- color: #666666;
- font-size: 28rpx;
- }
- .address-list-detail {
- font-size: 26rpx;
- margin: 20rpx 0;
- }
- .address-list-userInfo {
- text {
- color: #999999;
- font-size: 30rpx;
- &:last-child {
- font-size: 28rpx;
- margin-left: 20rpx;
- }
- }
- }
- .edit {
- width: 44rpx;
- height: 44rpx;
- }
- }
- }
- .btn {
- width: 690rpx;
- left: 50%;
- bottom: 34rpx;
- transform: translateX(-50%);
- position: fixed;
- }
- </style>
|