{yun:}include file="$wapstyle/member/cheader.htm"{/yun}

<div id="yunvue" class="none">
    <section class="wap_member_box">
        <div class="Subclass" v-if="defaultLinkShow">
            <div class="com_cardlist_tit">
                <a href="javascript:void(0);" >{{Link.link_address}}【默认企业地址】</a>
            </div>

            <div class="com_member_hr_p1">
                <span class="member_c9">所在区域 </span>{{Link.cityStr}}
            </div>

            <div class="com_member_hr_p1">
                <span class="member_c9">联&nbsp;&nbsp;系&nbsp;&nbsp;人 </span>{{Link.link_man}}
            </div>

            <div class="com_member_hr_p1">
                <span class="member_c9">联系电话 </span>{{Link.phone_n}}<template v-if="Link.phone"> &nbsp;&nbsp;&nbsp;</template>{{Link.tel_n}}
            </div>
        </div>
        <div class="Subclass" v-for="(item, akey) in list" :key="akey">
            <div class="com_cardlist_tit">
                <a href="javascript:void(0);" >{{item.link_address}}</a>
            </div>

            <div class="com_member_hr_p1">
                <span class="member_c9">所在区域 </span>{{item.city}}
            </div>

            <div class="com_member_hr_p1">
                <span class="member_c9">联&nbsp;&nbsp;系&nbsp;&nbsp;人 </span>{{item.link_man}}
            </div>
            <div class="com_member_hr_p1">
                <span class="member_c9">联系电话 </span>{{item.phone_n}}<template v-if="item.phone_n"> &nbsp;&nbsp;&nbsp;</template>{{item.tel_n}}
            </div>
            <div class="interview_card_bom">
                <div class="card_bom_icon">
                    <a href="javascript:void(0);" @click="pageTo('index.php?c=newAddress&id='+item.id)"><img src="{yun:}$wap_style{/yun}/images/Apply_compile.png" alt=""></a>
                </div>
                <div class="card_bom_icon">
                    <a href="javascript:void(0);" @click="del(item.id,akey)" class=" "><img src="{yun:}$wap_style{/yun}/images/resume_del.png" alt=""></a>
                </div>
            </div>
        </div>
        <div onclick="navigateTo('index.php?c=newAddress')" href="javascript:void(0)"> <div class="issue_post_body_btn">添加新地址</div></div>
        <div v-if="total >limit" class="page_pd">
            <van-pagination v-model="page" :total-items="total" :items-per-page="limit" force-ellipses @change="pageChange"/>
        </div>
    </section>
</div>

<script type="text/javascript">
    var currentPage = parseInt('{yun:}$smarty.get.page{/yun}');
    currentPage = currentPage ? currentPage : 1;
    new Vue({
        el: '#yunvue',
        data: {
            defaultLinkShow: false,
            Link: [],
            list: [],
            limit: 4,
            total: 0,
            page: currentPage,
        },
        computed: {
            count() {
                if (this.total > this.limit) {
                    return 2;
                } else if (this.list.length == 0) {
                    return 0;
                } else {
                    return 1;
                }
            }
        },
        created() {
            this.getAddress();
        },
        methods: {
            getAddress: function () {

                var that = this;
                var paramer = {};
                paramer['page'] = that.page;
                paramer['limit'] = that.limit;
                showLoading();
                $.post('{yun:}url d=wxapp h=com m=set c=address{/yun}', paramer, function (data) {
                    hideLoading();

                    if (data.data.comLink){

                        that.defaultLinkShow = true;
                        that.Link    =   data.data.comLink;
                    }

                    let list = data.data.list;
                    if (data) {
                        if (list && list.length > 0) {
                            that.list = list;
                        }
                    }
                    that.total = data.total;
                    that.page = currentPage;
                    $("#yunvue").css('display', 'block');
                }, 'json');
            },
            del: function (id, key) {
                var that = this;
                var paramer = {
                    id: id,
                };
                showConfirm('确定删除?', () => {
                    showLoading('删除中...')
                    $.post('{yun:}url d=wxapp h=com m=set c=delAddress{/yun}', paramer, function (data) {
                        hideLoading();
                        if (data.error == 1) {
                            showToast(data.msg, 2, function () {
                                location.reload();
                            });
                        } else {
                            showToast(data.msg);
                        }
                    });
                });
            },
            pageChange: function (e) {
                location.href = 'index.php?c=address&page=' + e;
            },
            pageTo: function (url) {
                window.location.href = url;
            }
        }
    });
</script>
</body>
</html>
