header.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div style="background-color:#fff;overflow: hidden;" :style="{'border-bottom': borbtm?'1px solid':'none'}">
  3. <u-navbar title="" @rightClick="rightClick" :autoBack="!isSwitch" placeholder @leftClick="leftClick" :leftIcon="isSwitch? '' : 'arrow-left' ">
  4. <div slot="center" style="width:auto">
  5. <uni-data-select :clear="false" style="flex:1" v-model="hotelIds" :localdata="range" @change="change"></uni-data-select>
  6. </div>
  7. </u-navbar>
  8. <!-- <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'}">
  9. </u--input> -->
  10. <slot name="search"></slot>
  11. <div style="margin:10px 0 6px 0;">
  12. <!-- <u-subsection :list="list" mode="subsection" :current="current" @change="sectionChange"></u-subsection> -->
  13. <slot name="section"></slot>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import {
  19. mapState
  20. } from 'vuex'
  21. import {
  22. getHotelList
  23. } from '../utils/api'
  24. export default {
  25. props: {
  26. borbtm: {
  27. type: Boolean,
  28. default: true
  29. },
  30. isSwitch: {
  31. type: Boolean,
  32. default: false
  33. }
  34. },
  35. data() {
  36. return {
  37. hotelIds: 0,
  38. value: 0,
  39. range: [{
  40. value: 0,
  41. text: "全部"
  42. },
  43. {
  44. value: 1,
  45. text: "沙县大酒店"
  46. },
  47. {
  48. value: 2,
  49. text: "游泳"
  50. },
  51. ],
  52. }
  53. },
  54. computed: {
  55. // ...mapState(['hotelIdList','hotelId'])
  56. ...mapState({
  57. hotelIdList: state => state.hotelIdList,
  58. hotelId: state => state.hotelId
  59. })
  60. },
  61. watch: {
  62. hotelIdList(newVal) {
  63. console.log('header', newVal);
  64. this.range = newVal.map(item => {
  65. return {
  66. value: item.id,
  67. text: item.name
  68. }
  69. })
  70. this.hotelIds = newVal[0].id
  71. }
  72. },
  73. async mounted() {
  74. let data = await getHotelList()
  75. if (data.code == 200) {
  76. this.$nextTick(() => {
  77. this.$store.commit('setHotelIdList', data.result.records)
  78. this.hotelIds = data.result.records[0].id
  79. this.$store.commit('setHotelId', data.result.records[0].id)
  80. this.$emit('change', data.result.records[0].id)
  81. })
  82. }
  83. },
  84. methods: {
  85. change(e) {
  86. console.log(e)
  87. this.$store.commit('setHotelId', e)
  88. console.log(this.hotelId);
  89. this.$emit('change', e)
  90. },
  91. leftClick() {
  92. if (this.isSwitch) {
  93. return
  94. }
  95. console.log('leftClick');
  96. },
  97. rightClick(){}
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. /deep/.uni-select {
  103. border: none !important;
  104. text-align: center;
  105. }
  106. </style>