choose_room_f.html 10.0 KB
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <script src="../../assets/js/fontsize.js"></script>
    <!--<link rel="stylesheet" href="../../assets/css/api.css"/>-->
    <link rel="stylesheet" href="../../assets/icon/iconfont.css">
    <style>
        body, html {
            background-color: transparent !important;
            height: 100%;
        }

        .meal {
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        .meal_title {
            text-align: center;
            color: #424242;
            font-size: 15px;
            font-weight: bold;
            border-bottom: 1px solid #ccc;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.25rem;
        }

        .meal_item {
            background-color: #fff;
        }

        .pay_box {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 10% 0.25rem 10%;
        }

        .pay_num {
            font-size: 12px;
            color: #424242;
        }

        .pay_btn_box {
            display: flex;
            align-items: center;
        }

        .pay_btn_box .iconfont {
            font-size: 20px;
            color: #ccc;
        }

        .pay_btn_box input {
            width: 0.5rem;
            text-align: center;
            border: 0;
            outline: none;
            font-size: 15px;
        }

        .pay_num .limit {
            padding: 0;
            font-size: 12px;
            color: #ccc;
        }

        .pay_btn {
            font-size: 15px;
            color: #fff;
            background-color: #dbb25f;
            text-align: center;
            padding: 0.2rem 0;
        }

        .room_box, .price_box {
            display: flex;
            /*align-items: center;*/
            justify-content: space-between;
            padding: 0.2rem 0.4rem 0 0.4rem;

        }

        .room_left {
            font-size: 15px;
            color: #424242;
        }

        .youhui {
            color: #d8b25f;
            font-size: 12px;
            margin-left: 0.1rem;
        }

        .room_right {
            color: #dbb25f;
            font-size: 15px;
        }

        .old_price {
            text-decoration: line-through;
            color: #ccc;
            margin-left: 0.1rem;
        }

        .room_tips {
            color: #ccc;
            font-size: 12px;
            padding: 0 0.4rem;
        }

        .price_left, .price_right {
            display: flex;
            /*align-items: center;*/
            flex-wrap: wrap;
            flex: 1;
        }

        .price_left span, .price_right span {
            background-color: #f2f2f2;
            color: #424242;
            padding: 0 0.2rem;
            font-size: 14px;
            margin: 0 0.2rem 0.2rem 0;
            border-radius: 0.05rem;
            cursor: pointer;
            min-width: 0.88rem;
            text-align: center;
            height: 0.48rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .icon-cuohao {
            font-size: 15px;
            color: #424242;
        }

        .price_box .span_active {
            background-color: #dbb25f;
            color: #fff;
        }
    </style>
</head>
<body>
<div id="app">
    <div @click="close" class="meal">
        <div class="meal_item" @click.stop>
            <div class="meal_title"><span></span><span>入住选择</span><span class="iconfont icon-cuohao"
                                                                        @click="close"></span></div>
            <div class="room_box">
                <div class="room_left">
                    <div><span>服务价格</span><span class="youhui">优惠¥{{price_info.count?price_info.count:0}}</span></div>
                </div>
                <div class="room_right">
                    <span>¥{{price_info.price?price_info.price:0}}</span>
                    <span class="old_price">原价{{price_info.o_price?price_info.o_price:0}}</span>
                </div>
            </div>
            <div class="room_tips">此价格包含护理、房间、用餐费用</div>
            <div class="price_box">
                <div class="price_left">
                    <span :class="{'span_active':index==active_index}"
                          v-for="(item,index) in attribute[0]"
                          @click="choose_left(index)">{{item}}</span>
                </div>
                <div class="price_right">
                    <span :class="{'span_active':index==active_index2}"
                          v-for="(item,index) in attribute[1]"
                          @click="choose_right(index)">{{item}}</span>
                </div>
            </div>
            <div class="pay_box">
                <span class="pay_num">入住周期 <span
                        class="limit">({{price_info.limit_num?price_info.limit_num:0}}{{unit}})</span></span>
                <div class="pay_btn_box">
                    <span class="iconfont icon-jian" @click="reduce"></span>
                    <input type="number" placeholder="" value="1" v-model="num">
                    <span class="iconfont icon-jikediancanicon09" @click="plus"></span>
                </div>
            </div>
            <div class="pay_btn" @click.stop="pay_go">确定</div>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
    new FastClick(document.body);
</script>
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../../assets/js/swiper-3.4.2.min.js"></script>
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            num: 0,
            // sever_list: [
            //     {name: '自理'},
            //     {name: '半自理'},
            //     {name: '爱理不理'},
            //     {name: '特护'},
            // ],
            active_index: -1,
            active_index2: -1,
            // room_list: [
            //     {name: '单人间'},
            //     {name: '双人间'},
            //     {name: '三人间'},
            //     {name: '多人间'},
            // ],
            active_left: '',
            active_right: '',
            attribute: [],
            id: '',
            price_info: [],
            unit: ''
        },
        created: function () {
            apiready = function () {
                app.attribute = api.pageParam.attribute;
                app.id = api.pageParam.id;
                app.unit = api.pageParam.unit;
            }
        },
        methods: {
            close: function () {
                api.closeWin();
            },
            choose_left: function (index) {
                app.active_index = index;
                app.active_left = app.attribute[0][index];
                app.num = app.price_info.limit_num;
                app.getPrice();
            },
            choose_right: function (index) {
                app.active_index2 = index;
                app.active_right = app.attribute[1][index];
                app.getPrice();
                app.num = app.price_info.limit_num;
            },
            reduce: function () {
                if (app.price_info.limit_num) {
                    if (app.num > app.price_info.limit_num) {
                        app.num--
                    } else {
                        toastMsg('不能低于' + app.price_info.limit_num + '个月哦')
                    }
                }else {
                    toastMsg('请选择入住类型')
                }
            },
            plus: function () {
                if (app.num < app.price_info.limit_num) {
                } else {
                    app.num++
                }
            },
            getPrice: function () {
                if (app.active_left && app.active_right) {
                    var post = {
                        attribute: app.active_left + '_' + app.active_right,
                        id: app.id
                    };
                    getRequest('post', 'portal/Goods/getPrice', post, null).then(function (res) {
                        if (res.data.code == 1) {
                            app.price_info = res.data.data;
                            app.num = app.price_info.limit_num;
                            app.attribute_id = app.price_info.attribute_id
                        }
                    })
                } else {
                    toastMsg('请选择入住类型')
                }

            },
            pay_go: function () {
                if (app.active_left && app.active_right) {
                    api.sendEvent({
                        name: 'room',
                        extra: {
                            name_left: app.active_left,
                            name_right: app.active_right,
                            num: app.num,
                            price: app.price_info.price,
                            attribute_id: app.attribute_id
                        }
                    });
                    app.close()
                }
                else {
                    toastMsg('请选择入住类型')
                }
            }
        }
    })
</script>