chooseAddress.vue 7.0 KB
Newer Older
M
confrim  
maguohua 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 <template>
    <div class="rating_page">
        <head-top head-title="选择地址" go-back='true'></head-top>
        <router-link to="/confirmOrder/chooseAddress/addAddress" class="add_icon_footer" >
            <img src="../../../images/add_address.png" height="24" width="24">
            <span>新增收货地址</span>
        </router-link>
        <ul class="deliverable_address">
            <li v-for="(item,index) in deliverable" @click="chooseAddress(item, index)">
                <svg class="choosed_address" :class="{default_address: defaultIndex == index}">
                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use>
                </svg>
                <div>
                    <header>
                        <span>{{item.name}}</span>
                        <span>{{item.sex == 1? '先生' : '女士'}}</span>
                        <span>{{item.phone}}</span>   
                    </header>
                    <div class="address_detail ellipsis">
M
maguohua 已提交
20
                        <span v-if="item.tag" :style="{backgroundColor: iconColor(item.tag)}">{{item.tag}}</span>
M
confrim  
maguohua 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
                        <p>{{item.address_detail}}</p>   
                    </div>
                </div>
            </li>
        </ul>
        <section id="out_delivery" v-if="deliverdisable.length">
            <header class="out_header">以下地址超出配送范围</header>
            <ul class="deliverable_address">
                <li v-for="(item,index) in deliverdisable">
                    <svg class="choosed_address">
                        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use>
                    </svg>
                    <div>
                        <header>
                            <span>{{item.name}}</span>
                            <span>{{item.sex == 1? '先生' : '女士'}}</span>
                            <span>{{item.phone}}</span>   
                        </header>
                        <div class="address_detail ellipsis">
                            <span v-if="item.tag" :style="{backgroundColor: '#ccc'}">{{item.tag}}</span>
                            <p>{{item.address_detail}}</p>   
                        </div>
                    </div>
                </li>
            </ul>
        </section>
        <alert-tip v-if="showAlert" @closeTip="showAlert = false" :alertText="alertText"></alert-tip>
        <transition name="router-slid">
            <router-view></router-view>
        </transition>  
    </div>
</template>

<script>
M
update  
maguohua 已提交
55
    import headTop from 'src/components/header/head'
M
confrim  
maguohua 已提交
56
    import {mapState, mapMutations} from 'vuex'
M
update  
maguohua 已提交
57 58
    import {getAddress} from 'src/service/getData'
    import alertTip from 'src/components/common/alertTip'
M
confrim  
maguohua 已提交
59 60 61 62

    export default {
      data(){
            return{
M
update  
maguohua 已提交
63 64 65 66 67 68 69
               	addressList: [],
                deliverable: [],
                deliverdisable: [],
                id: null,
                sig: null,
                showAlert: false,
                alertText: null,
M
confrim  
maguohua 已提交
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
            }
        },
        created(){
            this.id = this.$route.query.id;
            this.sig = this.$route.query.sig;
            this.initData();
        },
        components: {
            headTop,
            alertTip,
        },
        props:[],
        computed: {
            ...mapState([
                'userInfo', 'addressIndex'
            ]),
            defaultIndex: function (){
                if (this.addressIndex) {
                    return this.addressIndex;
                }else{
                    return 0;
                }
            }
        },
        methods: {
            ...mapMutations([
                'CHOOSE_ADDRESS'
            ]),
            async initData(){
                if (!(this.userInfo && this.userInfo.user_id)) {
                    this.showAlert = true;
                    this.alertText = '请登陆'
                    return
                }
                this.addressList = await getAddress(this.id, this.sig);
                this.addressList.forEach(item => {
                    if (item.is_deliverable) {
                        this.deliverable.push(item);
                    }else{
                        this.deliverdisable.push(item);
                    }
                    
                })
            },
            iconColor(name){
                switch(name){
                    case '公司': return '#4cd964';
                    case '学校': return '#3190e8';
                }
            },
            chooseAddress(address, index){
                this.CHOOSE_ADDRESS({address, index});
                this.$router.go(-1);
            },
        }
    }
</script>
  
<style lang="scss" scoped>
M
update  
maguohua 已提交
129
    @import 'src/style/mixin';
M
confrim  
maguohua 已提交
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
  
    .rating_page{
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #f5f5f5;
        z-index: 204;
        padding-top: 1.95rem;
        p, span{
            font-family: Helvetica Neue,Tahoma,Arial;
        }
    }
    .add_icon_footer{
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2.5rem;
        background-color: #fff;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 204;
        span{
            @include sc(.7rem, $blue);
            margin-left: .3rem;
        }
    }
    .deliverable_address{
        background-color: #fff;
        li{
            display: flex;
            align-items: center;
            border-bottom: 0.025rem solid #f5f5f5;
            padding: .7rem;
            line-height: 1rem;
            .choosed_address{
                @include wh(.8rem, .8rem);
                fill: #4cd964;
                margin-right: .4rem;
                opacity: 0;
            }
            .default_address{
                opacity: 1;
            }
            header{
M
maguohua 已提交
178
                @include sc(.7rem, #333);
M
confrim  
maguohua 已提交
179
                span:nth-of-type(1){
M
maguohua 已提交
180
                    font-size: .8rem;
M
confrim  
maguohua 已提交
181 182 183 184 185 186 187 188 189 190 191
                    font-weight: bold;
                }
            }
            .address_detail{
                width: 100%;
                display: flex;
                align-items: center;
                span{
                    @include sc(.5rem, #fff);
                    border-radius: .15rem;
                    background-color: #ff5722;
M
maguohua 已提交
192 193 194
                    height: .6rem;
                    line-height: .6rem;
                    padding: 0 .2rem;
M
confrim  
maguohua 已提交
195 196 197
                    margin-right: .3rem;
                }
                p{
M
maguohua 已提交
198
                    @include sc(.6rem, #777);
M
confrim  
maguohua 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
                }
            }
        }
    }
    #out_delivery{
        .out_header{
            @include sc(.6rem, #666);
            line-height: 1.5rem;
            padding-left: .5rem;
        }
        *{
            color: #ccc;
        }
    }
    .router-slid-enter-active, .router-slid-leave-active {
        transition: all .4s;
    }
    .router-slid-enter, .router-slid-leave-active {
        transform: translateX(100%);
    }
</style>