shop.vue 9.7 KB
Newer Older
M
maguohua 已提交
1 2 3 4 5
 <template>
    <div>
        <header class="shop_detail_header" v-if="!showLoading">
            <img :src="getImgPath(shopDetailData.image_path)" class="header_cover_img">
            <section class="description_header">
M
maguohua 已提交
6
                <section class="description_top" @click="showActivitiesFun">
M
maguohua 已提交
7 8 9 10 11 12 13 14
                    <section class="description_left">
                        <img :src="getImgPath(shopDetailData.image_path)">
                    </section>
                    <section class="description_right">
                        <h4 class="description_title ellipsis">{{shopDetailData.name}}</h4>
                        <p class="description_text">商家配送/{{shopDetailData.order_lead_time}}分钟送达/配送费¥{{shopDetailData.float_delivery_fee}}</p>
                        <p class="description_promotion ellipsis">公告:{{shopDetailData.promotion_info}}</p>
                    </section>
M
maguohua 已提交
15 16 17
                    <svg width="14" height="14" xmlns="http://www.w3.org/2000/svg" version="1.1" class="description_arrow" >
                        <path d="M0 0 L8 7 L0 14"  stroke="#fff" stroke-width="1" fill="none"/>
                    </svg>
M
maguohua 已提交
18
                </section>
M
maguohua 已提交
19
                <footer class="description_footer" v-if="shopDetailData.activities.length" @click="showActivitiesFun">
M
maguohua 已提交
20 21 22 23 24 25
                    <p class="ellipsis">
                        <span class="tip_icon" :style="{backgroundColor: '#' + shopDetailData.activities[0].icon_color, borderColor: '#' + shopDetailData.activities[0].icon_color}">{{shopDetailData.activities[0].icon_name}}</span>
                        <span>{{shopDetailData.activities[0].description}}(APP专享)</span>
                    </p>
                    <p>{{shopDetailData.activities.length}}个活动</p>
                </footer>
M
maguohua 已提交
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
                <transition name="fadeactivities">
                    <section class="activities_details" v-if="showActivities">
                        <h2 class="activities_shoptitle">{{shopDetailData.name}}</h2>
                        <h3 class="activities_ratingstar">
                            <rating-star :rating='shopDetailData.rating'></rating-star>
                        </h3>
                        <section class="activities_list">
                            <header class="activities_title_style"><span>优惠信息</span></header>
                            <ul>
                                <li v-for="item in shopDetailData.activities" :key="item.id">
                                    <span class="activities_icon" :style="{backgroundColor: '#' + item.icon_color, borderColor: '#' + item.icon_color}">{{item.icon_name}}</span>
                                    <span>{{item.description}}(APP专享)</span>
                                </li>
                            </ul>
                        </section>
                        <section class="activities_shopinfo">
                            <header class="activities_title_style"><span>商家公告</span></header>
                            <p>{{shopDetailData.promotion_info}}</p>
                        </section>
                        <svg width="60" height="60" class="close_activities" @click.stop="showActivitiesFun">
                            <circle cx="30" cy="30" r="25" stroke="#555" stroke-width="1" fill="none"/>
                            <line x1="22" y1="38" x2="38" y2="22" style="stroke:#999;stroke-width:2"/>
                            <line x1="22" y1="22" x2="38" y2="38" style="stroke:#999;stroke-width:2"/>
                        </svg>
                    </section>
                </transition>  
M
maguohua 已提交
52 53 54 55
            </section>
        </header>
       <loading v-if="showLoading"></loading>
    </div>
M
updata  
maguohua 已提交
56 57 58
</template>

<script>
M
maguohua 已提交
59 60 61 62
    import {mapState, mapMutations} from 'vuex'
    import {imgBaseUrl} from '../../config/env'
    import {msiteAdress, shopDetails} from '../../service/getData'
    import loading from '../../components/common/loading'
M
maguohua 已提交
63
    import ratingStar from '../../components/common/ratingStar'
M
maguohua 已提交
64
    import {getImgPath} from '../../components/common/mixin'
M
maguohua 已提交
65
    
M
maguohua 已提交
66 67 68 69 70 71 72
    export default {
        data(){
            return{
                geohash: '', //geohash位置信息
                shopId: null, //商店id值
                showLoading: true, //显示加载动画
                shopDetailData: null, //商铺详情
M
maguohua 已提交
73
                showActivities: false, //是否显示活动详情
M
maguohua 已提交
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
            }
        },
        created(){
            this.geohash = this.$route.query.geohash;
            this.shopId = this.$route.query.id;
        },
        async mounted(){
            if (!this.latitude) {
                //获取位置信息
                let res = await msiteAdress(this.geohash);
                // 记录当前经度纬度进入vuex
                this.RECORD_ADDRESS(res);
            }
            this.shopDetailData = await shopDetails(this.shopId, this.latitude, this.longitude);
            this.showLoading = false;
        },
        mixins: [getImgPath],
        components: {
M
maguohua 已提交
92 93
            loading,
            ratingStar,
M
maguohua 已提交
94 95 96 97 98 99 100 101 102 103
        },
        computed: {
            ...mapState([
                'latitude','longitude'
            ])
        },
        methods: {
            ...mapMutations([
                'RECORD_ADDRESS'
            ]),
M
maguohua 已提交
104 105 106
            showActivitiesFun(){
                this.showActivities = !this.showActivities;
            }
M
maguohua 已提交
107
        }
M
updata  
maguohua 已提交
108

M
maguohua 已提交
109
    }
M
updata  
maguohua 已提交
110 111 112
</script>

<style lang="scss" scoped>
M
maguohua 已提交
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 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
    @import '../../style/mixin.scss';
    .shop_detail_header{
        overflow: hidden;
        position: relative;
        .header_cover_img{
            width: 100%;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 9;
            filter: blur(10px);
        }
        .description_header{
            position: relative;
            z-index: 10;
            background-color: rgba(119,103,137,.43);
            padding: 0.43rem;
            .description_top{
                display: flex;
                .description_left{
                    margin-right: 0.3rem;
                    img{
                        @include wh(2.9rem, 2.9rem);
                        display: block;
                        border-radius: 0.15rem;
                    }
                }
                .description_right{
                    flex: 1;
                    .description_title{
                        @include sc(.8rem, #fff);
                        font-weight: bold;
                        width: 100%;
                        margin-bottom: 0.3rem;
                    }
                    .description_text{
                        @include sc(.5rem, #fff);
                        margin-bottom: 0.3rem;
                    }
                    .description_promotion{
                        @include sc(.5rem, #fff);
                        width: 12.5rem;
                    }
                }
M
maguohua 已提交
157 158 159 160 161
                .description_arrow{
                    @include ct;
                    right: 0.3rem;
                    z-index: 11;
                }
M
maguohua 已提交
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
            }
            .description_footer{
                @include fj;
                margin-top: 0.5rem;
                p{
                    @include sc(.5rem, #fff);
                    span{
                        color: #fff;
                    }
                    .tip_icon{
                        padding: .01rem;
                        border: 0.025rem solid #fff;
                        border-radius: 0.1rem;
                    }
                }
                .ellipsis{
                    width: 87%;
                }
            }
M
maguohua 已提交
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
            .activities_details{
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background-color: #262626;
                z-index: 12;
                padding: 1.25rem;
                .activities_shoptitle{
                    text-align: center;
                    @include sc(.8rem, #fff);
                }
                .activities_ratingstar{
                    display: flex;
                    justify-content: center;
                    transform: scale(2.2);
                    margin-top: .7rem;
                }
                .activities_list{
                    margin-top: 1.5rem;
                    margin-bottom: 1rem;
                    @include sc(.5rem, #fff);
                    li{
                        
                        .activities_icon{
                            padding: .01rem;
                            border: 0.025rem solid #fff;
                            border-radius: 0.1rem;
                        }
                        span{
                            color: #fff;
                            line-height: .7rem;
                        }
                    }
                }
                .activities_shopinfo{
                    p{
                        line-height: .7rem;
                        @include sc(.5rem, #fff);
                    }
                }
                .activities_title_style{
                    text-align: center;
                    margin-bottom: 1rem;
                    span{
                        @include sc(.5rem, #fff);
                        border: 0.025rem solid #555;
                        padding: .2rem .4rem;
                        border-radius: 0.5rem;
                    }
M
maguohua 已提交
232

M
maguohua 已提交
233 234 235 236 237 238 239 240 241 242 243 244 245 246
                }
                .close_activities{
                    position: absolute;
                    bottom: 1rem;
                    @include cl;
                }
            }
            
            .fadeactivities-enter-active, .fadeactivities-leave-active {
                transition: opacity .5s;
            }
            .fadeactivities-enter, .fadeactivities-leave-active {
                opacity: 0;
            }
M
maguohua 已提交
247 248
        }
    }
M
updata  
maguohua 已提交
249
</style>