| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <div style="background-color:#fff;overflow: hidden;" :style="{'border-bottom': borbtm?'1px solid':'none'}">
- <u-navbar title="" @rightClick="rightClick" :autoBack="!isSwitch" placeholder @leftClick="leftClick" :leftIcon="isSwitch? '' : 'arrow-left' ">
- <div slot="center" style="width:80%;">
- <uni-data-select :clear="false" style="flex:1" v-model="hotelIds" :localdata="range" @change="change"></uni-data-select>
- </div>
- </u-navbar>
- <!-- <u--input placeholder="房间号/姓名/手机号/身份证号" border="surround" shape="circle" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" fontSize="12px" :customStyle="{border:'1px solid #e2e2e2',padding:'0 10px',margin:'0 10px',borderRadius:'20px'}">
- </u--input> -->
- <slot name="search"></slot>
- <div style="margin:10px 0 6px 0;">
- <!-- <u-subsection :list="list" mode="subsection" :current="current" @change="sectionChange"></u-subsection> -->
- <slot name="section"></slot>
- </div>
- </div>
- </template>
- <script>
- import {
- mapState
- } from 'vuex'
- import {
- getHotelList
- } from '../utils/api'
- export default {
- props: {
- borbtm: {
- type: Boolean,
- default: true
- },
- isSwitch: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- hotelIds: 0,
- value: 0,
- range: [{
- value: 0,
- text: "全部"
- },
- {
- value: 1,
- text: "沙县大酒店"
- },
- {
- value: 2,
- text: "游泳"
- },
- ],
- }
- },
- computed: {
- // ...mapState(['hotelIdList','hotelId'])
- ...mapState({
- hotelIdList: state => state.hotelIdList,
- hotelId: state => state.hotelId
- })
- },
- watch: {
- hotelIdList(newVal) {
- console.log('header', newVal);
- this.range = newVal.map(item => {
- return {
- value: item.id,
- text: item.name
- }
- })
- }
- },
- async mounted() {
-
- },
- methods: {
- async getHotels(cb) {
- let data = await getHotelList()
- if (data.code == 200) {
- this.$nextTick(() => {
- this.$store.commit('setHotelIdList', data.result.records)
- let cacheStore = uni.getStorageSync("hotelInfo")
- if(cacheStore) {
- this.hotelIds = cacheStore.id
- this.$store.commit('setHotelId', cacheStore.id)
- } else {
- this.hotelIds = data.result.records[0].id
- uni.setStorageSync("hotelInfo",data.result.records[0])
- this.$store.commit('setHotelId', data.result.records[0].id)
- }
- if(cb) {
- cb()
- }
- this.$emit('change',this.hotelIds)
- })
- }
- },
- change(e) {
- console.log(e)
- this.$store.commit('setHotelId', e)
- let hotels = this.hotelIdList
- let index = hotels.findIndex(s=>s.id == e)
- if(index > -1) {
- uni.setStorageSync("hotelInfo",hotels[index])
- }
- console.log(this.hotelId);
- this.$emit('change', e)
- },
- leftClick() {
- if (this.isSwitch) {
- return
- }
- console.log('leftClick');
- },
- rightClick(){}
- }
- }
- </script>
- <style lang="scss">
- /deep/.uni-select {
- border: none !important;
- text-align: center;
- }
- </style>
|