123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <view class="choose-hotel">
- <view class="top">
- <!-- #ifdef MP-WEIXIN -->
- <NavigateBar title="酒店选择" control="home" bgcolor="#a09cc4"></NavigateBar>
- <!-- #endif -->
- <!-- #ifdef MP-ALIPAY -->
- <NavigateBar title="酒店选择" bgcolor="#a09cc4"></NavigateBar>
- <!-- #endif -->
- <view class="choose-hotel--input">
- <view class="choose-hotel--input__frame">
- <u-search placeholder="酒店搜索" v-model="hotelName" bgColor="#ffffff" shape="square"
- :showAction="false" color="#181818" margin="0" @change="inputChanged">
- </u-search>
- </view>
- <view class="choose-hotel--input__scan" @click="scanQRCode" v-if="displayScanner">
- <u-icon name="scan" color="#4f4e51" size="28"></u-icon>
- </view>
- </view>
- </view>
- <view class="choose-hotel--dispaly-area" v-if="!notFound">
- <view class="choose-hotel--description" v-for="(hotel, index) in hotelList" :key="index">
- <view class="choose-hotel--description__hotel" @click="goBack(hotel)">
- <view class="choose-hotel--description__hotel-pic">
- <u-image :src="getHotelPicPath(hotel.picturePath)" width="180rpx" height="180rpx"></u-image>
- </view>
- <view class="choose-hotel--description__hotel-name">
- {{ hotel.name }}
- </view>
- </view>
- </view>
- </view>
- <view class="choose-hotel--not-found" v-if="notFound">{{`未查询到名称中包含“${hotelName}”的酒店`}}</view>
- </view>
- </template>
- <script>
- import {
- IMG_BASE_URL
- } from "../../config"
- import {
- mapMutations
- } from 'vuex'
- import getParamByName from 'get-param-by-name'
- import NavigateBar from "../../components/navigateBar/navigate-bar.vue";
- export default {
- components: {
- NavigateBar
- },
- data() {
- return {
- hotelName: "",
- hotelList: [],
- notFound: false,
- displayScanner: true,
- source: "",
- }
- },
- methods: {
- ...mapMutations('m_business', ['updateCurrentHotel']),
- async inputChanged() {
- this.notFound = false
- let res = await uni.$http.post('/hotel', {
- name: this.hotelName,
- isTest: false,
- pageNo: 1,
- pageSize: 999
- })
- if (res.data.data.records.length === 0) {
- this.notFound = true
- return
- }
- this.hotelList = res.data.data.records
- },
- inputFocusd() {
- // 取得焦点时显示shortcut
- console.log("input focused");
- },
- inputBlured() {
- // 失去焦点时关闭shortcut
- console.log("inpot blured");
- },
- async scanQRCode() {
- // #ifdef MP-WEIXIN
- let scanResWX = await wx.scanCode({
- scanType: ['qrCode']
- })
- // console.log("扫描二维码的结果", scanResWX);
- const hotelId = getParamByName("hotelId", scanResWX.result);
- // console.log("hotelName", hotelName);
- this.updateCurrentHotel(this.queryHotelByHotelId(hotelId))
- uni.switchTab({
- url: '/pages/home/home'
- })
- // #endif
- // #ifdef MP-ALIPAY
- let scanResAli = await my.scan({
- scanType: ['qrCode']
- })
- console.log("扫描二维码的结果", scanResAli);
- // #endif
- },
- async getHotels() {
- let res = await uni.$http.post('/hotel', {
- isTest: false,
- pageNo: 1,
- pageSize: 999
- })
- this.hotelList = res.data.data.records
- },
- async queryHotelByHotelId(hotelId) {
- let res = await uni.$http.post('/hotel', {
- hotelId: hotelId,
- isTest: false,
- pageNo: 1,
- pageSize: 999
- })
- return res.data.data.records[0]
- },
- getHotelPicPath(path) {
- return IMG_BASE_URL + '/' + path
- },
- goBack(hotel) {
- this.updateCurrentHotel(hotel)
- console.log(this.source === "home");
- if (this.source === "home") {
- uni.switchTab({
- url: '/pages/home/home'
- })
- } else if (this.source === "selectCheckinType") {
- uni.redirectTo({
- url: '/subpkg_checkin/selectCheckinType/selectCheckinType'
- })
- }
- },
- },
- async onLoad(option) {
- console.log("option", option)
- this.source = option.source
- // #ifdef MP-WEIXIN
- this.displayScanner = true
- // #endif
- // #ifdef MP-ALIPAY
- this.displayScanner = false
- // #endif
- // 首次载入页面渲染全部酒店,后可根据搜索来搜索其他酒店
- await this.getHotels()
- },
- }
- </script>
- <style lang="scss">
- page {
- display: flex;
- flex-direction: column;
- width: 100%;
- height: 100%;
- .choose-hotel {
- display: flex;
- flex-direction: column;
- width: 100%;
- height: 100%;
- .top {
- position: sticky;
- background-color: #f0eff5;
- width: 100%;
- top: 0;
- z-index: 999;
- .choose-hotel--input {
- display: flex;
- flex-direction: row;
- align-items: center;
- padding: 20rpx;
- height: 80rpx;
- .choose-hotel--input__frame {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .choose-hotel--input__scan {
- height: 100%;
- width: 30px;
- display: flex;
- align-items: center;
- justify-content: center;
- padding-left: 20rpx;
- }
- }
- }
- .choose-hotel--dispaly-area {
- background-color: #ffffff;
- width: 100%;
- height: 100%;
- padding-top: 10rpx;
- .choose-hotel--description {
- padding: 5rpx 20rpx;
- .choose-hotel--description__hotel {
- background-color: #f1f1f4;
- display: flex;
- flex-direction: row;
- padding: 20rpx 10rpx;
- border-radius: 6rpx;
- .choose-hotel--description__hotel-name {
- display: flex;
- align-items: center;
- padding-left: 30rpx;
- font-size: 38rpx;
- }
- }
- }
- }
- .choose-hotel--not-found {
- background-color: #ffffff;
- width: 100%;
- position: absolute;
- top: 120rpx;
- left: 0;
- bottom: 0;
- padding-top: 20rpx;
- display: flex;
- justify-content: center;
- font-size: 40rpx;
- }
- }
- }
- </style>
|