| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615 |
- <template>
- <view class="container">
- <view class="header2" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }" v-if="headerType">
- <view class="title">靖安乡村民宿</view>
- </view>
- <!-- 顶部图片区域 -->
- <view class="header">
- <swiper class="header_swiper" autoplay circular :interval="3000">
- <swiper-item v-for="banner in headerImgList" :key="banner.id" @click="handleClickBanner(banner)">
- <img mode="aspectFill" class="img" :src="banner.imageUrl" />
- <img v-if="banner.logoUrl.indexOf('2.png') != -1" mode="aspectFill" class="img2" :src="banner.logoUrl" />
- <img v-if="banner.logoUrl.indexOf('1.png') != -1" mode="aspectFill" class="img3" :src="banner.logoUrl" />
- </swiper-item>
- </swiper>
- </view>
- <!-- 主体内容区域 -->
- <view class="content">
- <!-- 条件筛选区域 -->
- <view class="search">
- <!-- 选择乡镇区域 -->
- <view class="search_town" :class="{ active: town }" @click="handleOpen">
- <view class="town_text">
- <img class="img" v-if="town" src="../../static/images/4.png" />
- {{ town ? town : '请选择乡镇' }}
- </view>
- <img src="../../static/index/right2.png" />
- </view>
- <!-- 关键词搜索和民宿级别区域 -->
- <view class="search_center">
- <view class="center_input">
- <input type="text" v-model="keywords" placeholder="乡村民宿/地名/关键词" placeholder-style="color:#808080;font-weight:400;" />
- </view>
- <img class="img" src="../../static/index/right2.png" />
- |
- <view class="center_level" :class="{ active: level }" @click="handleChooseLv">{{ level ? level : '请选择级别' }}</view>
- <img class="img2" src="../../static/index/right2.png" @click="handleChooseLv" />
- </view>
- <!-- 查找按钮区域 -->
- <view class="search_btn" @click="handleSearch">查找</view>
- <view class="search_msg">
- <view class="msg_box">
- <img class="box_img" src="@/static/images/1.png" />
- 真实房源
- </view>
- <view class="msg_box">
- <img class="box_img2" src="@/static/images/3.png" />
- 安心入住
- </view>
- <view class="msg_box">
- <img class="box_img3" src="@/static/images/2.png" />
- 专业客服
- </view>
- </view>
- </view>
- <!-- 轮播图区域 -->
- <swiper class="swiper" indicator-dots circular indicator-color="#BBD8FE" indicator-active-color="#1E7DFB" autoplay interval="3000" v-if="townList.length">
- <swiper-item v-for="(ele, index) in townList" :key="index">
- <view class="swiper_item">
- <view class="item_box" v-for="(swi, index2) in ele" :key="index2" @click="handleChooseTown2(swi.name)">
- <img
- v-if="index === 0 && index2 === 0"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163202_1.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 0 && index2 === 1"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163133_2.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 0 && index2 === 2"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163218_3.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 1 && index2 === 0"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163234_4.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 1 && index2 === 1"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163251_5.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 1 && index2 === 2"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163307_6.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 2 && index2 === 0"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163321_7.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 2 && index2 === 1"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163344_8.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 2 && index2 === 2"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163357_9.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 3 && index2 === 0"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163411_10.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 3 && index2 === 1"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163428_11.png"
- mode="aspectFill"
- />
- <img
- v-if="index === 3 && index2 === 2"
- src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163458_13.png"
- mode="aspectFill"
- />
- <view class="box_town">{{ swi.name }}</view>
- <view class="box_count">剩{{ swi.residueNumber }}间</view>
- </view>
- </view>
- </swiper-item>
- </swiper>
- <view class="body">
- <!-- 优选民宿区域 -->
- <uv-skeletons :loading="loading" :skeleton="skeleton">
- <view class="body_top" v-if="hotelList_you.length">
- <view class="circle"></view>
- <view class="circle color"></view>
- <view class="top_title">优选乡村民宿 .</view>
- <view class="top_msg">让旅途充满乐趣</view>
- <view class="top_more" @click="handleGoHome">查看更多 ></view>
- </view>
- <swiper class="body_swiper" indicator-dots circular indicator-color="#BBD8FE" indicator-active-color="#1E7DFB" interval="3000" v-if="hotelList_you.length">
- <swiper-item v-for="(ele, index) in hotelList_you" :key="index">
- <view class="swiper_box">
- <view class="list_item" v-for="(item, index2) in ele" :key="item.id" @click="goPageDetail(item)">
- <image class="item-img" :src="item.coverImg" mode="scaleToFill"></image>
- <view class="descrition">
- <text class="title">{{ item.hotel_name }}</text>
- <text class="type">
- {{ item.hTypeName }}
- <text class="type_level" v-if="item.type == 1">银宿级</text>
- <text class="type_level" v-if="item.type == 2">金宿级</text>
- <text class="type_level" v-if="item.type == 3">白金级</text>
- </text>
- <text class="distance" v-if="showdDistance">距您直线{{ item.distance }}公里</text>
- <view class="detail">
- <img class="img" src="../../static/index/hotel.png" />
- <view class="price_home">
- <text class="txt1">¥{{ item.min_price ? item.min_price : 0 }}</text>
- <text class="txt2">起</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </swiper-item>
- </swiper>
- </uv-skeletons>
- <!-- 精选攻略区域 -->
- <view class="body_top" v-if="bestNewsList.length">
- <view class="circle"></view>
- <view class="circle color"></view>
- <view class="top_title">精选攻略 .</view>
- <view class="top_msg">宿管家带你住靖安</view>
- <view class="top_more" @click="handleGoPage">查看更多 ></view>
- </view>
- <swiper class="body_strategy" indicator-dots indicator-color="#BBD8FE" indicator-active-color="#1E7DFB" circular :interval="3000" v-if="bestNewsList.length">
- <swiper-item v-for="item in bestNewsList" :key="item.id" @click="handleGoDetail(item)">
- <img v-if="item.image" class="strategy_cover" mode="aspectFill" :src="item.image" />
- <video
- v-if="item.video"
- class="strategy_cover"
- :src="item.video"
- :controls="false"
- :show-center-play-btn="false"
- :show-fullscreen-btn="false"
- :show-play-btn="false"
- ></video>
- <view class="strategy_info">
- <view class="info_title">{{ item.title }}</view>
- <view class="info_tags">
- <view class="tag">{{ item.townName }}</view>
- </view>
- <text class="info_desc">{{ item.content }}</text>
- </view>
- </swiper-item>
- </swiper>
- <!-- 每日推荐区域 -->
- <view class="body_top" v-if="hotelList.length">
- <view class="circle"></view>
- <view class="circle color"></view>
- <view class="top_title">每日推荐 .</view>
- <view class="top_msg">线上订民宿,住着玩个遍</view>
- <view class="top_more" @click="handleGoHome">查看更多 ></view>
- </view>
- <view class="body_list">
- <!-- 每一个民宿区域 -->
- <view class="list_item" v-for="item in hotelList" :key="item.id" @click="goPageDetail(item)">
- <image class="item-img" :src="item.coverImg" mode="scaleToFill"></image>
- <view class="descrition">
- <text class="title">{{ item.hotel_name }}</text>
- <text class="type">
- {{ item.hTypeName }}
- <text class="type_level" v-if="item.type == 1">银宿级</text>
- <text class="type_level" v-if="item.type == 2">金宿级</text>
- <text class="type_level" v-if="item.type == 3">白金级</text>
- </text>
- <text class="distance" v-if="showdDistance">距您直线{{ item.distance }}公里</text>
- <view class="detail">
- <img class="img" src="../../static/index/hotel.png" />
- <view class="price_home">
- <text class="txt1">¥{{ item.min_price ? item.min_price : 0 }}</text>
- <text class="txt2">起</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 特产甄选区域 -->
- <view class="body_top" v-if="goodsList.length">
- <view class="circle"></view>
- <view class="circle color"></view>
- <view class="top_title">特产甄选 .</view>
- <view class="top_msg">明优推荐,土的自然,购的放心</view>
- <view class="top_more" @click="clickGoods">查看更多 ></view>
- </view>
- <view class="body_list">
- <!-- 每一个特产区域 -->
- <view class="item_goods" v-for="item in goodsList" :key="item.id" @click="to_detail(item)">
- <img class="goods_img" mode="aspectFill" :src="item.imgs.split(',')[0]" />
- <view class="goods_name">{{ item.name }}</view>
- <view class="goods_detail">
- <img class="img" src="../../static/index/goods.png" />
- <view class="price_good">
- <text class="txt1">¥{{ item.price }}</text>
- <text class="txt2">起</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 两山资产区域 -->
- <view class="body_top" v-if="newsList.length">
- <view class="circle"></view>
- <view class="circle color"></view>
- <view class="top_title">两山资产 .</view>
- <view class="top_msg">以招商引资,推动镇域经济</view>
- <view class="top_more" @click="handleGoNewsList">查看更多 ></view>
- </view>
- <!-- 两山资产轮播图 -->
- <uni-swiper-dot :info="newsList" mode="round" :dotsStyles="dotsStyles" :current="current">
- <swiper circular autoplay interval="3000" class="body_news" @change="changeDot">
- <swiper-item v-for="item in newsList" :key="item.id" @click="handleGoNews(item)">
- <uv-image width="633rpx" height="332rpx" radius="8rpx" mode="aspectFill" :src="item.url" />
- <view class="news_title">
- {{ item.title ? item.title : '无标题' }}
- </view>
- <view class="news_desc">
- {{ item.desc }}
- </view>
- <mp-html v-if="item.showHtml" @load="htmlLoad(item)" :ref="item.id + 'html'" :content="item.content" />
- </swiper-item>
- </swiper>
- </uni-swiper-dot>
- </view>
- </view>
- <!-- 选择乡镇弹窗区域 -->
- <uni-popup ref="popup" type="center">
- <view class="popup_body">
- <view class="body_header">
- <img src="../../static/my/popup_title.png" />
- <view class="header_title">请选择乡镇</view>
- <img src="../../static/my/popup_title.png" />
- </view>
- <view class="body_content">
- <view class="content_box" v-for="(item, index) in popList" :key="index" @click="handleChooseTown(item.name)">
- <img v-if="index === 0" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163202_1.png" mode="aspectFill" />
- <img v-if="index === 1" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163133_2.png" mode="aspectFill" />
- <img v-if="index === 2" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163218_3.png" mode="aspectFill" />
- <img v-if="index === 3" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163234_4.png" mode="aspectFill" />
- <img v-if="index === 4" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163251_5.png" mode="aspectFill" />
- <img v-if="index === 5" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163307_6.png" mode="aspectFill" />
- <img v-if="index === 6" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163321_7.png" mode="aspectFill" />
- <img v-if="index === 7" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163344_8.png" mode="aspectFill" />
- <img v-if="index === 8" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163357_9.png" mode="aspectFill" />
- <img v-if="index === 9" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163411_10.png" mode="aspectFill" />
- <img v-if="index === 10" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163428_11.png" mode="aspectFill" />
- <img v-if="index === 11" src="https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240523163458_13.png" mode="aspectFill" />
- <view class="box_town">{{ item.name }}</view>
- <view class="box_count">剩{{ item.residueNumber }}间</view>
- </view>
- </view>
- </view>
- </uni-popup>
- <!-- 公告弹窗区域 -->
- <uv-popup ref="popup_sale" mode="center" :closeOnClickOverlay="false" bgColor="none">
- <view class="popupClass">
- <img src="../../static/index/popup_bg.png" />
- <!-- 立即前往区域 -->
- <view class="btn_text">系统处于迭代试用状态,请勿下单预订酒店,如需预订请电联店家老板确认预订渠道。</view>
- <!-- 关闭按钮区域 -->
- <view class="btn_close" @click="handleClose"></view>
- </view>
- </uv-popup>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 用户定位经度
- myLng: 0,
- // 用户定位纬度
- myLat: 0,
- // 是否显示距离差
- showdDistance: false,
- // 搜索框绑定数据
- keywords: '',
- // 当前页
- page: 1,
- // 每页多少条
- rows: 6,
- // 总条数
- total: null,
- // 地区数组
- placeList: [
- {
- name: '靖安县'
- }
- ],
- // 当前选择地区索引
- placeIndex: 0,
- // 选择乡镇弹窗数据
- popList: [],
- // 每日推荐民宿列表数组
- hotelList: [],
- // 优选民宿列表数组
- hotelList_you: [],
- // 当前乡镇
- town: '',
- // 民宿级别
- level: '',
- // 乡镇列表
- townList: [],
- // 顶部导航栏显示隐藏控制
- headerType: false,
- // 状态栏高度
- statusBarH: 0,
- // 胶囊按钮栏高度
- customBarH: 0,
- // 两山资产列表
- newsList: [],
- // 精选攻略数据
- bestNewsList: [],
- // 两山资产轮播图指示点样式
- dotsStyles: {
- backgroundColor: '#BBD8FE',
- selectedBackgroundColor: '#1E7DFB',
- border: 'none',
- selectedBorder: 'none'
- },
- // 两山资产轮播图当前索引值
- current: 0,
- // 特产甄选列表
- goodsList: [],
- // 是否显示骨架屏
- loading: true,
- // 骨架屏参数
- skeleton: [
- {
- type: 'line',
- style: { height: '90rpx', marginTop: '10rpx' }
- },
- 30,
- {
- type: 'flex',
- num: 2,
- children: [
- {
- type: 'custom',
- style: 'width:335rpx;height:460rpx;borderRadius:18rpx'
- },
- {
- type: 'custom',
- style: 'width:335rpx;height:460rpx;borderRadius:18rpx;marginLeft:50rpx;'
- }
- ]
- }
- ],
- // 顶部轮播图图片数组
- headerImgList: []
- }
- },
- created() {
- // 获取系统信息
- uni.getSystemInfo({
- success: (e) => {
- // 获取状态栏高度
- this.statusBarH = e.statusBarHeight + 10
- // // 获取菜单按钮栏高度
- let custom = uni.getMenuButtonBoundingClientRect()
- this.customBarH = custom.height + 10
- }
- })
- },
- mounted() {
- // 开启转发功能
- uni.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline']
- })
- },
- onPageScroll(e) {
- if (e.scrollTop > 100) {
- this.headerType = true
- } else {
- this.headerType = false
- }
- },
- onPullDownRefresh() {
- this.loading = true
- this.hotelList_you = []
- this.hotelList = []
- this.page = 1
- this.getLocation()
- this.getHeaderImgList()
- this.getResidueCount()
- this.getBestNews()
- this.getNews()
- this.getGoodsList()
- setTimeout(() => {
- uni.stopPullDownRefresh()
- }, 1000)
- },
- onLoad() {
- // 获取顶部轮播图数据
- this.getHeaderImgList()
- // 获取乡镇列表
- this.getResidueCount()
- // 获取定位
- this.getLocation()
- // 获取精选攻略
- this.getBestNews()
- // 获取特产列表
- this.getGoodsList()
- // 获取两山资产列表
- this.getNews()
- },
- methods: {
- async getHeaderImgList() {
- const res = await this.$myRequest({
- url: '/mhotel/advertiseopenList.action'
- })
- // console.log(res)
- if (res.code == 200) {
- this.headerImgList = res.data
- }
- },
- async getBestNews() {
- const res = await this.$myRequest({
- url: '/mhotel/articlequeryTop3ArticleLike.action'
- })
- // console.log(res)
- if (res.code == 200 && res.data) {
- this.bestNewsList = res.data
- }
- },
- async getNews() {
- const res = await this.$myRequest({
- url: '/mhotel/appnewlist.action',
- data: {
- page: 1,
- rows: 3
- }
- })
- // console.log(res)
- if (res.code === 200) {
- this.newsList = res.rows
- this.newsList.forEach((ele) => {
- this.$set(ele, 'showHtml', true)
- })
- }
- },
- async getGoodsList() {
- const res = await this.$myRequest_shop({
- url: '/goods/open/page',
- data: {
- curPage: 1,
- pageSize: 4,
- hot: 1,
- state: 1
- }
- })
- // console.log(res)
- if (res.code === '1') {
- this.goodsList = res.data.list
- }
- },
- //跳转到商城总类
- to_detail(options) {
- let userInfo = uni.getStorageSync('userInfo')
- let tokenId = uni.getStorageSync('tokenId')
- if (!userInfo || !tokenId) {
- uni.showModal({
- title: '提示',
- content: '您当前未登录,请授权登录查看社区信息',
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- }
- })
- } else {
- this.$api.togoods({ id: options.id })
- }
- },
- //跳转到特产商城
- clickGoods() {
- let userInfo = uni.getStorageSync('userInfo')
- let tokenId = uni.getStorageSync('tokenId')
- if (!userInfo || !tokenId) {
- uni.showModal({
- title: '提示',
- content: '您当前未登录,请授权登录查看社区信息',
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- }
- })
- } else {
- uni.navigateTo({
- url: '/packageShang/pages/tabbar/home'
- })
- }
- },
- // 获取用户当前位置
- getLocation() {
- uni.getSetting({
- success: (res) => {
- if (!res.authSetting['scope.userLocation']) {
- uni.authorize({
- scope: 'scope.userLocation',
- success: (res) => {
- // 授权成功
- uni.getLocation({
- type: 'gcj02',
- success: (res) => {
- this.myLat = res.latitude
- this.myLng = res.longitude
- this.showdDistance = true
- this.getHotelList_you()
- this.getHotelList_jing()
- }
- })
- },
- fail: () => {
- uni.showModal({
- content: '获取定位权限失败将会影响使用部分功能,是否去设置打开?',
- confirmText: '确认',
- cancelText: '取消',
- success: (res) => {
- if (res.confirm) {
- uni.openSetting({
- success: (res) => {
- console.log(res)
- this.getLocation()
- }
- })
- } else {
- this.showdDistance = false
- this.getHotelList_you()
- this.getHotelList_jing()
- uni.showToast({
- title: '获取定位权限失败',
- icon: 'none'
- })
- }
- }
- })
- }
- })
- } else {
- uni.getLocation({
- type: 'gcj02',
- success: (res) => {
- this.myLat = res.latitude
- this.myLng = res.longitude
- this.showdDistance = true
- this.getHotelList_you()
- this.getHotelList_jing()
- }
- })
- }
- },
- fail: () => {
- uni.showToast({
- title: '获取用户设置权限失败',
- icon: 'none',
- mask: true
- })
- }
- })
- },
- handleGoDetail(info) {
- let openid = uni.getStorageSync('openid')
- if (openid) {
- uni.navigateTo({
- url: `/pagesSub/tweetDetail/tweetDetail?id=${info.id}&townId=${info.townId}`
- })
- } else {
- uni.showToast({
- title: '请先登录',
- icon: 'none',
- mask: true
- })
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }, 1500)
- }
- },
- // 获取民宿列表 优选
- async getHotelList_you() {
- const res = await this.$myRequest({
- url: '/mhotel/ahppreferredPage.action',
- data: {
- page: 1,
- rows: 4,
- type: 3,
- userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
- }
- })
- // console.log(res)
- if (res.code === 200) {
- this.hotelList_you = res.data.pageList
- // 如果定位成功则获取和民宿之间的距离
- if (this.showdDistance && this.hotelList_you.length) {
- this.hotelList_you.forEach((ele) => {
- let lat = ele.hpositionWens.split(',')[0]
- let lng = ele.hpositionWens.split(',')[1]
- ele.distance = this.calculateDistance(lat, lng)
- })
- this.hotelList_you = this.changeList(this.hotelList_you, 2)
- }
- this.loading = false
- }
- },
- // 获取民宿列表 每日推荐
- async getHotelList_jing() {
- const res = await this.$myRequest({
- url: '/mhotel/ahpselectedPage.action',
- data: {
- page: this.page,
- rows: this.rows,
- type: 3,
- userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
- }
- })
- // console.log(res)
- if (res.code === 200) {
- this.hotelList = [...this.hotelList, ...res.data.pageList]
- this.total = res.data.total
- // 如果定位成功则获取和民宿之间的距离
- if (this.showdDistance && this.hotelList.length) {
- this.hotelList.forEach((ele) => {
- let lat = ele.hpositionWens.split(',')[0]
- let lng = ele.hpositionWens.split(',')[1]
- ele.distance = this.calculateDistance(lat, lng)
- })
- }
- }
- },
- handleOpen() {
- this.$refs.popup.open()
- },
- // 获取乡镇
- async getResidueCount() {
- const res = await this.$myRequest({
- url: '/mhotel/ahpgetResidueCount.action'
- })
- // console.log(res)
- if (res.code === 200) {
- let temNum = 0
- res.data.forEach((ele) => {
- temNum += ele.residueNumber
- })
- res.data.unshift({
- name: '靖安县',
- residueNumber: temNum
- })
- this.popList = res.data
- this.townList = this.changeList(this.popList, 3)
- }
- },
- // 变成二维数组
- changeList(arr, num) {
- let newArr = []
- const total = Math.ceil(arr.length / num)
- for (let i = 0; i < total; i++) {
- let a = arr.slice(i * num, (i + 1) * num)
- newArr.push(a)
- }
- return newArr
- },
- // 弹窗点击选择乡镇地址回调
- handleChooseTown(name) {
- this.town = name
- this.$refs.popup.close()
- },
- handleChooseTown2(name) {
- // this.town = name
- uni.navigateTo({
- url: `/pagesSub/home/home?town=${name}&keywords=${this.keywords}&level=${this.level}`
- })
- },
- handleChooseLv() {
- uni.showActionSheet({
- itemList: ['白金级', '金宿级', '银宿级'],
- success: (res) => {
- if (res.tapIndex === 0) {
- this.level = '白金级'
- } else if (res.tapIndex === 1) {
- this.level = '金宿级'
- } else if (res.tapIndex === 2) {
- this.level = '银宿级'
- }
- }
- })
- },
- handleSearch() {
- uni.navigateTo({
- url: `/pagesSub/home/home?town=${this.town}&keywords=${this.keywords}&level=${this.level}`
- })
- },
- goPageDetail(item) {
- uni.navigateTo({
- url: `/pages/detail/detail?id=${item.id}&distance=${item.distance}&town=${item.hotelTownshipName}`
- })
- },
- // 弹窗关闭按钮回调
- handleClose() {
- this.$refs.popup_sale.close()
- },
- // 计算两个点之间的距离
- calculateDistance(lat, lng) {
- let centerLat = lat
- let centerLng = lng
- let red1 = (this.myLat * Math.PI) / 180.0
- let red2 = (centerLat * Math.PI) / 180.0
- let a = red1 - red2
- let b = (this.myLng * Math.PI) / 180.0 - (centerLng * Math.PI) / 180.0
- let R = 6378137
- let distance = R * 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(red1) * Math.cos(red2) * Math.pow(Math.sin(b / 2), 2)))
- let res = (distance / 1000).toFixed(2) * 1
- return res
- },
- handleGoPage() {
- uni.switchTab({
- url: '/pages/community/community'
- })
- },
- handleGoNews(item) {
- let info = encodeURIComponent(JSON.stringify(item))
- uni.navigateTo({
- url: `/pagesSub/newsDetail/newsDetail?info=${info}`
- })
- },
- handleGoNewsList() {
- uni.navigateTo({
- url: '/pagesSub/newsList/newsList'
- })
- },
- htmlLoad(item) {
- let id = item.id + 'html'
- let ctx = this.$refs[id][0]
- let text = ctx.getText()
- let imgs = ctx.imgList[0]
- item.showHtml = false
- item.desc = text
- item.url = imgs
- },
- handleGoHome() {
- uni.navigateTo({
- url: '/pagesSub/home/home'
- })
- },
- changeDot(e) {
- this.current = e.detail.current
- },
- // 点击顶部轮播图广告回调
- handleClickBanner(banner) {
- // console.log(banner)
- switch (banner.jumpWay) {
- case '网页':
- uni.navigateTo({
- url: `/pagesSub/web/web?url=${banner.jumpPoint}`
- })
- break
- case '小程序':
- let openid = uni.getStorageSync('openid')
- let tokenId = uni.getStorageSync('tokenId')
- if (openid && tokenId) {
- if (banner.jumpDirection == '民宿') {
- uni.navigateTo({
- url: `/pages/detail/detail?id=${banner.jumpPoint}&distance=&town=${banner.townId}`
- })
- } else if (banner.jumpDirection == '商品') {
- if (banner.jumpPoint == '首页') {
- uni.navigateTo({
- url: '/packageShang/pages/tabbar/home'
- })
- } else {
- uni.navigateTo({
- url: `/packageShang/pages/goods/goods?id=${banner.jumpPoint}`
- })
- }
- } else if (banner.jumpDirection == '攻略') {
- if (banner.jumpPoint == '首页') {
- uni.switchTab({
- url: '/pages/community/community'
- })
- } else {
- uni.navigateTo({
- url: `/pagesSub/tweetDetail/tweetDetail?id=${banner.jumpPoint}&townId=${banner.townId}`
- })
- }
- } else if (banner.jumpDirection == '优惠券') {
- uni.navigateTo({
- url: `/pagesSub/couponCenter/couponCenter?id=${banner.jumpPoint}`
- })
- }
- } else {
- uni.showToast({
- title: '请先登录',
- icon: 'none',
- mask: true
- })
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }, 1500)
- }
- break
- default:
- uni.previewImage({
- urls: [banner.imageUrl]
- })
- break
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- min-height: 100vh;
- overflow-y: auto;
- background-color: #f2f2f2;
- .header {
- position: relative;
- height: 505rpx;
- .header_swiper {
- width: 100%;
- height: 100%;
- .img {
- width: 100%;
- height: 100%;
- }
- .img2 {
- position: absolute;
- top: 175rpx;
- left: 38rpx;
- width: 208rpx;
- height: 200rpx;
- }
- .img3 {
- position: absolute;
- top: 240rpx;
- left: 38rpx;
- width: 305rpx;
- height: 80rpx;
- }
- }
- }
- .header2 {
- z-index: 999;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- box-sizing: content-box;
- text-align: center;
- background-color: #fff;
- .title {
- font-size: 34rpx;
- }
- }
- .content {
- margin: 20rpx auto 0;
- width: 690rpx;
- border-radius: 12rpx 12rpx 0 0;
- background-color: #f2f2f2;
- .search {
- box-sizing: border-box;
- padding: 0 28rpx;
- width: 690rpx;
- height: 395rpx;
- border-radius: 12rpx;
- background-color: #fff;
- .search_town {
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 89rpx;
- color: #808080;
- font-size: 32rpx;
- border-bottom: 1rpx solid #e6e6e6;
- .town_text {
- display: flex;
- align-items: center;
- margin-left: 10rpx;
- .img {
- margin-right: 23rpx;
- width: 38rpx;
- height: 38rpx;
- }
- }
- img {
- width: 40rpx;
- height: 40rpx;
- }
- }
- .active {
- font-weight: bold;
- color: #000;
- }
- .search_center {
- display: flex;
- align-items: center;
- height: 89rpx;
- color: #a6a6a6;
- font-size: 28rpx;
- img {
- width: 40rpx;
- height: 40rpx;
- }
- .center_input {
- margin: 0 12rpx;
- width: 280rpx;
- color: #000;
- font-weight: bold;
- }
- .img {
- margin-right: 12rpx;
- }
- .center_level {
- flex: 1;
- margin-left: 24rpx;
- font-weight: 400;
- color: #808080;
- }
- .active {
- font-weight: bold;
- color: #000;
- }
- .img2 {
- margin-left: auto;
- }
- }
- .search_btn {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-top: 23rpx;
- width: 623rpx;
- height: 100rpx;
- border-radius: 57rpx;
- color: #fff;
- font-size: 32rpx;
- background-image: url(https://jinganminsu-1320402385.cos.ap-nanjing.myqcloud.com/static//20240329163323_dc9c53e05ab4568185d808ca366b5d0.png);
- background-size: cover;
- }
- .search_msg {
- display: flex;
- justify-content: space-evenly;
- align-items: center;
- width: 623rpx;
- height: 92rpx;
- color: #0095ff;
- font-size: 24rpx;
- .msg_box {
- display: flex;
- align-items: center;
- .box_img {
- margin-right: 8rpx;
- width: 27rpx;
- height: 24rpx;
- }
- .box_img2 {
- margin-right: 8rpx;
- width: 36rpx;
- height: 36rpx;
- }
- .box_img3 {
- margin-right: 8rpx;
- width: 28rpx;
- height: 28rpx;
- }
- }
- }
- }
- .swiper {
- margin: 20rpx auto 0;
- width: 690rpx;
- height: 214rpx;
- border-radius: 12rpx;
- background-color: #fff;
- .swiper_item {
- display: flex;
- justify-content: space-around;
- align-items: center;
- width: 100%;
- height: 100%;
- .item_box {
- position: relative;
- width: 195rpx;
- height: 128rpx;
- border-radius: 12rpx;
- color: #fff;
- img {
- width: 195rpx;
- height: 128rpx;
- border-radius: 12rpx;
- }
- .box_town {
- position: absolute;
- top: 30rpx;
- left: 0;
- right: 0;
- text-align: center;
- font-size: 28rpx;
- font-weight: bold;
- }
- .box_count {
- position: absolute;
- top: 75rpx;
- left: 0;
- right: 0;
- text-align: center;
- font-size: 18rpx;
- }
- }
- }
- }
- .body {
- margin: 0 auto;
- padding-bottom: 20rpx;
- width: 690rpx;
- .body_top {
- display: flex;
- align-items: center;
- height: 89rpx;
- .circle {
- width: 30rpx;
- height: 30rpx;
- border-radius: 50%;
- background-color: #485bed;
- }
- .color {
- margin-left: -15rpx;
- opacity: 0.5;
- background-color: #fff;
- }
- .top_title {
- margin-left: 15rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
- .top_msg {
- margin-top: 5rpx;
- margin-left: 12rpx;
- color: #666666;
- font-size: 22rpx;
- }
- .top_more {
- display: flex;
- align-items: center;
- margin-left: auto;
- color: #4693eb;
- font-size: 24rpx;
- }
- }
- .body_swiper {
- height: 520rpx;
- border-radius: 12rpx;
- .swiper_box {
- display: flex;
- justify-content: space-around;
- .list_item {
- width: 335rpx;
- box-sizing: border-box;
- .item-img {
- width: 100%;
- height: 223rpx;
- border-radius: 18rpx 18rpx 0 0;
- box-sizing: border-box;
- }
- .descrition {
- display: flex;
- flex-direction: column;
- width: 100%;
- border-radius: 0 0 18rpx 18rpx;
- box-sizing: border-box;
- background: rgba(255, 255, 255, 1);
- margin-top: -10rpx;
- .title {
- font-size: 28rpx;
- font-weight: 600;
- padding: 20rpx 20rpx 10rpx;
- color: rgba(0, 0, 0, 1);
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .type {
- padding: 5rpx 20rpx;
- height: 40rpx;
- font-size: 24rpx;
- color: #a6a6a6;
- .type_level {
- margin-left: 20rpx;
- }
- }
- .distance {
- padding: 10rpx 20rpx;
- font-size: 24rpx;
- color: #a6a6a6;
- }
- .detail {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- padding: 0 20rpx 20rpx 20rpx;
- color: rgba(0, 0, 0, 1);
- .img {
- width: 40rpx;
- height: 40rpx;
- }
- .price_home {
- .txt1 {
- font-size: 36rpx;
- font-weight: 600;
- color: rgba(255, 87, 51, 1);
- }
- .txt2 {
- font-size: 24rpx;
- font-weight: 400;
- color: #a6a6a6;
- }
- }
- .score {
- font-size: 24rpx;
- font-weight: 400;
- padding-top: 10rpx;
- color: rgba(166, 166, 166, 1);
- }
- }
- }
- }
- }
- }
- .body_strategy {
- display: flex;
- box-sizing: border-box;
- padding: 24rpx;
- margin-bottom: 10rpx;
- width: 690rpx;
- height: 718rpx;
- border-radius: 12rpx;
- background-color: #fff;
- .strategy_cover {
- width: 640rpx;
- height: 400rpx;
- border-radius: 7rpx;
- }
- .strategy_info {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- margin-left: 20rpx;
- width: 100%;
- height: 190rpx;
- font-size: 24rpx;
- color: #666666;
- overflow: hidden;
- .info_title {
- flex: 1.5;
- display: flex;
- align-items: center;
- font-size: 32rpx;
- font-weight: bold;
- color: #000;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .info_tags {
- flex: 1;
- display: flex;
- .tag {
- margin-right: 10rpx;
- box-sizing: border-box;
- padding: 0 12rpx;
- height: 35rpx;
- color: #1e7dfb;
- font-size: 20rpx;
- border-radius: 30rpx;
- border: 1rpx solid #1e7dfb;
- }
- }
- .info_desc {
- flex: 1.5;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- line-height: 35rpx;
- }
- }
- }
- .body_list {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- .list_item {
- width: 335rpx;
- box-sizing: border-box;
- margin-bottom: 20rpx;
- .item-img {
- width: 100%;
- height: 223rpx;
- border-radius: 18rpx 18rpx 0 0;
- box-sizing: border-box;
- }
- .descrition {
- display: flex;
- flex-direction: column;
- width: 100%;
- border-radius: 0 0 18rpx 18rpx;
- box-sizing: border-box;
- background: rgba(255, 255, 255, 1);
- margin-top: -10rpx;
- .title {
- font-size: 28rpx;
- font-weight: 600;
- padding: 20rpx 20rpx 10rpx;
- color: rgba(0, 0, 0, 1);
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .type {
- padding: 5rpx 20rpx;
- height: 40rpx;
- font-size: 24rpx;
- color: #a6a6a6;
- .type_level {
- margin-left: 20rpx;
- }
- }
- .distance {
- padding: 10rpx 20rpx;
- font-size: 24rpx;
- color: #a6a6a6;
- }
- .detail {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- padding: 0 20rpx 20rpx 20rpx;
- color: rgba(0, 0, 0, 1);
- .img {
- width: 40rpx;
- height: 40rpx;
- }
- .price_home {
- .txt1 {
- font-size: 36rpx;
- font-weight: 600;
- color: rgba(255, 87, 51, 1);
- }
- .txt2 {
- font-size: 24rpx;
- font-weight: 400;
- color: #a6a6a6;
- }
- }
- .score {
- font-size: 24rpx;
- font-weight: 400;
- padding-top: 10rpx;
- color: rgba(166, 166, 166, 1);
- }
- }
- }
- }
- .item_goods {
- margin-bottom: 20rpx;
- width: 335rpx;
- height: 367rpx;
- border-radius: 10rpx;
- background-color: #fff;
- overflow: hidden;
- .goods_img {
- width: 335rpx;
- height: 223rpx;
- border-bottom: 1rpx solid #eee;
- }
- .goods_name {
- margin: 18rpx 5rpx 18rpx 30rpx;
- font-size: 28rpx;
- font-weight: bold;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .goods_detail {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- padding: 0 20rpx 20rpx 20rpx;
- color: rgba(0, 0, 0, 1);
- .img {
- width: 40rpx;
- height: 40rpx;
- }
- .price_good {
- .txt1 {
- font-size: 36rpx;
- font-weight: 600;
- color: rgba(255, 87, 51, 1);
- }
- .txt2 {
- font-size: 24rpx;
- font-weight: 400;
- color: #a6a6a6;
- }
- }
- .score {
- font-size: 24rpx;
- font-weight: 400;
- padding-top: 10rpx;
- color: rgba(166, 166, 166, 1);
- }
- }
- }
- }
- .body_news {
- box-sizing: border-box;
- padding: 25rpx;
- width: 690rpx;
- height: 566rpx;
- border-radius: 12rpx;
- background-color: #fff;
- .news_title {
- margin: 20rpx 0;
- font-size: 32rpx;
- font-weight: bold;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .news_desc {
- font-size: 24rpx;
- color: #666666;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- }
- }
- }
- .popup_body {
- width: 618rpx;
- height: 687rpx;
- border-radius: 21rpx;
- background-color: #fff;
- .body_header {
- display: flex;
- justify-content: center;
- align-items: center;
- position: relative;
- height: 113rpx;
- border-bottom: 1rpx solid #e6e6e6;
- img {
- width: 16rpx;
- height: 16rpx;
- }
- .header_title {
- margin: 0 10rpx;
- font-size: 34rpx;
- font-weight: bold;
- color: #0f194d;
- }
- }
- .body_content {
- display: grid;
- grid-template-columns: repeat(auto-fill, 160rpx);
- gap: 28rpx;
- box-sizing: border-box;
- padding: 26rpx 40rpx 50rpx;
- .content_box {
- position: relative;
- width: 160rpx;
- height: 105rpx;
- color: #fff;
- border-radius: 10rpx;
- img {
- width: 160rpx;
- height: 105rpx;
- border-radius: 10rpx;
- }
- .box_town {
- position: absolute;
- top: 20rpx;
- left: 0;
- right: 0;
- text-align: center;
- font-size: 28rpx;
- font-weight: bold;
- }
- .box_count {
- position: absolute;
- top: 62rpx;
- left: 0;
- right: 0;
- text-align: center;
- font-size: 18rpx;
- }
- }
- }
- }
- .popupClass {
- position: relative;
- width: 481rpx;
- height: 764rpx;
- img {
- width: 100%;
- height: 665rpx;
- }
- .btn_text {
- position: absolute;
- top: 265rpx;
- left: 40rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 400rpx;
- height: 260rpx;
- color: #0f194d;
- font-size: 28rpx;
- border-radius: 43rpx;
- background-color: #fff;
- }
- .btn_close {
- position: absolute;
- top: 586rpx;
- left: 212rpx;
- width: 58rpx;
- height: 58rpx;
- border-radius: 50%;
- }
- }
- }
- </style>
|