home3.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  1. <template>
  2. <view class="container">
  3. <view class="header2" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }" v-if="headerType">
  4. <view class="title">靖安乡村民宿</view>
  5. </view>
  6. <!-- 顶部图片区域 -->
  7. <view class="header">
  8. <img mode="aspectFill" src="https://chtech.ncjti.edu.cn/hotelReservation/image/14.png" />
  9. <img class="img" src="https://chtech.ncjti.edu.cn/hotelReservation/image/16.png" />
  10. <img class="img2" src="https://chtech.ncjti.edu.cn/hotelReservation/image/17.png" />
  11. <view class="header_msg">有一种生活叫靖安</view>
  12. </view>
  13. <!-- 主体内容区域 -->
  14. <view class="content">
  15. <!-- 条件筛选区域 -->
  16. <view class="search">
  17. <!-- 选择乡镇区域 -->
  18. <view class="search_town" :class="{ active: town }" @click="handleOpen">
  19. {{ town ? town : '请选择乡镇' }}
  20. <img src="../../static/index/right2.png" />
  21. </view>
  22. <!-- 关键词搜索和民宿级别区域 -->
  23. <view class="search_center">
  24. <view class="center_input">
  25. <input type="text" v-model="keywords" placeholder="民宿/地名/关键词" placeholder-style="color:#A6A6A6;font-weight:400;" />
  26. </view>
  27. <img class="img" src="../../static/index/right2.png" />
  28. |
  29. <view class="center_level" :class="{ active: level }" @click="handleChooseLv">{{ level ? level : '请选择民宿级别' }}</view>
  30. <img class="img2" src="../../static/index/right2.png" @click="handleChooseLv" />
  31. </view>
  32. <!-- 查找按钮区域 -->
  33. <view class="search_btn" @click="handleSearch">查找</view>
  34. </view>
  35. <!-- 轮播图区域 -->
  36. <swiper class="swiper" indicator-dots circular indicator-color="#BBD8FE" indicator-active-color="#1E7DFB" autoplay interval="3000" v-if="townList.length">
  37. <swiper-item v-for="(ele, index) in townList" :key="index">
  38. <view class="swiper_item">
  39. <view class="item_box" v-for="(swi, index2) in ele" :key="index2" @click="handleChooseTown2(swi.name)">
  40. <img v-if="index === 0 && index2 === 0" src="https://chtech.ncjti.edu.cn/hotelReservation/image/1.png" mode="aspectFill" />
  41. <img v-if="index === 0 && index2 === 1" src="https://chtech.ncjti.edu.cn/hotelReservation/image/2.png" mode="aspectFill" />
  42. <img v-if="index === 0 && index2 === 2" src="https://chtech.ncjti.edu.cn/hotelReservation/image/3.png" mode="aspectFill" />
  43. <img v-if="index === 1 && index2 === 0" src="https://chtech.ncjti.edu.cn/hotelReservation/image/4.png" mode="aspectFill" />
  44. <img v-if="index === 1 && index2 === 1" src="https://chtech.ncjti.edu.cn/hotelReservation/image/5.png" mode="aspectFill" />
  45. <img v-if="index === 1 && index2 === 2" src="https://chtech.ncjti.edu.cn/hotelReservation/image/6.png" mode="aspectFill" />
  46. <img v-if="index === 2 && index2 === 0" src="https://chtech.ncjti.edu.cn/hotelReservation/image/7.png" mode="aspectFill" />
  47. <img v-if="index === 2 && index2 === 1" src="https://chtech.ncjti.edu.cn/hotelReservation/image/8.png" mode="aspectFill" />
  48. <img v-if="index === 2 && index2 === 2" src="https://chtech.ncjti.edu.cn/hotelReservation/image/9.png" mode="aspectFill" />
  49. <img v-if="index === 3 && index2 === 0" src="https://chtech.ncjti.edu.cn/hotelReservation/image/10.png" mode="aspectFill" />
  50. <img v-if="index === 3 && index2 === 1" src="https://chtech.ncjti.edu.cn/hotelReservation/image/11.png" mode="aspectFill" />
  51. <img v-if="index === 3 && index2 === 2" src="https://chtech.ncjti.edu.cn/hotelReservation/image/12.png" mode="aspectFill" />
  52. <view class="box_town">{{ swi.name }}</view>
  53. <view class="box_count">剩{{ swi.residueNumber }}间</view>
  54. </view>
  55. </view>
  56. </swiper-item>
  57. </swiper>
  58. <view class="body">
  59. <!-- 优选民宿区域 -->
  60. <uv-skeletons :loading="loading" :skeleton="skeleton">
  61. <view class="body_top" v-if="hotelList_you.length">
  62. <view class="circle"></view>
  63. <view class="circle color"></view>
  64. <view class="top_title">优选民宿 .</view>
  65. <view class="top_msg">特色优选民宿,让旅途充满乐趣</view>
  66. <view class="top_more" @click="handleGoHome">
  67. 更多
  68. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/13.png" />
  69. </view>
  70. </view>
  71. <view class="body_list">
  72. <!-- 每一个民宿区域 -->
  73. <view class="list_item" v-for="(item, index) in hotelList_you" :key="index" @click="goPageDetail(item)">
  74. <image class="item-img" :src="item.coverImg" mode="scaleToFill"></image>
  75. <view class="descrition">
  76. <text class="title">{{ item.hotel_name }}</text>
  77. <text class="type">{{ item.hTypeName }}</text>
  78. <text class="distance" v-if="showdDistance">距您直线{{ item.distance }}公里</text>
  79. <view class="detail">
  80. <img class="img" src="../../static/index/hotel.png" />
  81. <view class="price_home">
  82. <text class="txt1">¥{{ item.min_price }}</text>
  83. <text class="txt2">起</text>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </uv-skeletons>
  90. <!-- 精选攻略区域 -->
  91. <view class="body_top" v-if="bestNewsInfo">
  92. <view class="circle"></view>
  93. <view class="circle color"></view>
  94. <view class="top_title">精选攻略 .</view>
  95. <view class="top_msg">宝藏分享社区</view>
  96. <view class="top_more" @click="handleGoPage">
  97. 更多
  98. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/13.png" />
  99. </view>
  100. </view>
  101. <view v-if="bestNewsInfo" class="body_strategy" @click="handleGoDetail(bestNewsInfo)">
  102. <img v-if="bestNewsInfo.image" class="strategy_cover" mode="aspectFill" :src="bestNewsInfo.image" />
  103. <video
  104. v-if="bestNewsInfo.video"
  105. class="strategy_cover"
  106. :src="bestNewsInfo.video"
  107. :show-center-play-btn="false"
  108. :show-fullscreen-btn="false"
  109. :show-play-btn="false"
  110. ></video>
  111. <view class="strategy_info">
  112. <view class="info_title">{{ bestNewsInfo.title }}</view>
  113. <view class="info_tags">
  114. <view class="tag">{{ bestNewsInfo.townName }}</view>
  115. </view>
  116. <view class="info_desc">
  117. {{ bestNewsInfo.content }}
  118. </view>
  119. </view>
  120. </view>
  121. <!-- 招商资讯区域 -->
  122. <view class="body_top" v-if="newsList.length">
  123. <view class="circle"></view>
  124. <view class="circle color"></view>
  125. <view class="top_title">招商资讯 .</view>
  126. <view class="top_msg">以招商引资,推动镇域经济</view>
  127. <view class="top_more" @click="handleGoNewsList">
  128. 更多
  129. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/13.png" />
  130. </view>
  131. </view>
  132. <!-- 招商资讯轮播图 -->
  133. <uni-swiper-dot :info="newsList" mode="round" :dotsStyles="dotsStyles" :current="current">
  134. <swiper circular autoplay interval="3000" class="body_news" @change="changeDot">
  135. <swiper-item v-for="item in newsList" :key="item.id" @click="handleGoNews(item)">
  136. <uv-image width="633rpx" height="332rpx" radius="8rpx" mode="aspectFill" :src="item.url" />
  137. <view class="news_title">
  138. {{ item.title ? item.title : '无标题' }}
  139. </view>
  140. <view class="news_desc">
  141. {{ item.desc }}
  142. </view>
  143. <mp-html v-if="item.showHtml" @load="htmlLoad(item)" :ref="item.id + 'html'" :content="item.content" />
  144. </swiper-item>
  145. </swiper>
  146. </uni-swiper-dot>
  147. <!-- 特产甄选区域 -->
  148. <view class="body_top" v-if="goodsList.length">
  149. <view class="circle"></view>
  150. <view class="circle color"></view>
  151. <view class="top_title">特产甄选 .</view>
  152. <view class="top_msg">明优推荐,土的自然,购的放心</view>
  153. <view class="top_more" @click="clickGoods">
  154. 更多
  155. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/13.png" />
  156. </view>
  157. </view>
  158. <view class="body_list">
  159. <!-- 每一个特产区域 -->
  160. <view class="item_goods" v-for="item in goodsList" :key="item.id" @click="to_detail(item)">
  161. <img class="goods_img" mode="aspectFill" :src="item.imgs.split(',')[0]" />
  162. <view class="goods_name">{{ item.name }}</view>
  163. <view class="goods_detail">
  164. <img class="img" src="../../static/index/goods.png" />
  165. <view class="price_good">
  166. <text class="txt1">¥{{ item.price }}</text>
  167. <text class="txt2">起</text>
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. <!-- 精选推荐区域 -->
  173. <view class="body_top" v-if="hotelList.length">
  174. <view class="circle"></view>
  175. <view class="circle color"></view>
  176. <view class="top_title">精选推荐 .</view>
  177. <view class="top_msg">线上订民宿,住着玩个遍</view>
  178. <view class="top_more" @click="handleGoHome">
  179. 更多
  180. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/13.png" />
  181. </view>
  182. </view>
  183. <view class="body_list">
  184. <!-- 每一个民宿区域 -->
  185. <view class="list_item" v-for="item in hotelList" :key="item.id" @click="goPageDetail(item)">
  186. <image class="item-img" :src="item.coverImg" mode="scaleToFill"></image>
  187. <view class="descrition">
  188. <text class="title">{{ item.hotel_name }}</text>
  189. <text class="type">{{ item.hTypeName }}</text>
  190. <text class="distance" v-if="showdDistance">距您直线{{ item.distance }}公里</text>
  191. <view class="detail">
  192. <img class="img" src="../../static/index/hotel.png" />
  193. <view class="price_home">
  194. <text class="txt1">¥{{ item.min_price }}</text>
  195. <text class="txt2">起</text>
  196. </view>
  197. </view>
  198. </view>
  199. </view>
  200. </view>
  201. <!-- 没有数据时展示的页面 -->
  202. <view class="noData" v-if="!hotelList.length">
  203. <img src="../../static/images/noData.png" />
  204. 暂无推荐数据
  205. </view>
  206. </view>
  207. </view>
  208. <!-- 选择乡镇弹窗区域 -->
  209. <uni-popup ref="popup" type="center">
  210. <view class="popup_body">
  211. <view class="body_header">
  212. <img src="../../static/my/popup_title.png" />
  213. <view class="header_title">请选择乡镇</view>
  214. <img src="../../static/my/popup_title.png" />
  215. </view>
  216. <view class="body_content">
  217. <view class="content_box" v-for="(item, index) in popList" :key="index" @click="handleChooseTown(item.name)">
  218. <img v-if="index === 0" src="https://chtech.ncjti.edu.cn/hotelReservation/image/1.png" mode="aspectFill" />
  219. <img v-if="index === 1" src="https://chtech.ncjti.edu.cn/hotelReservation/image/2.png" mode="aspectFill" />
  220. <img v-if="index === 2" src="https://chtech.ncjti.edu.cn/hotelReservation/image/3.png" mode="aspectFill" />
  221. <img v-if="index === 3" src="https://chtech.ncjti.edu.cn/hotelReservation/image/4.png" mode="aspectFill" />
  222. <img v-if="index === 4" src="https://chtech.ncjti.edu.cn/hotelReservation/image/5.png" mode="aspectFill" />
  223. <img v-if="index === 5" src="https://chtech.ncjti.edu.cn/hotelReservation/image/6.png" mode="aspectFill" />
  224. <img v-if="index === 6" src="https://chtech.ncjti.edu.cn/hotelReservation/image/7.png" mode="aspectFill" />
  225. <img v-if="index === 7" src="https://chtech.ncjti.edu.cn/hotelReservation/image/8.png" mode="aspectFill" />
  226. <img v-if="index === 8" src="https://chtech.ncjti.edu.cn/hotelReservation/image/9.png" mode="aspectFill" />
  227. <img v-if="index === 9" src="https://chtech.ncjti.edu.cn/hotelReservation/image/10.png" mode="aspectFill" />
  228. <img v-if="index === 10" src="https://chtech.ncjti.edu.cn/hotelReservation/image/11.png" mode="aspectFill" />
  229. <img v-if="index === 11" src="https://chtech.ncjti.edu.cn/hotelReservation/image/12.png" mode="aspectFill" />
  230. <view class="box_town">{{ item.name }}</view>
  231. <view class="box_count">剩{{ item.residueNumber }}间</view>
  232. </view>
  233. </view>
  234. </view>
  235. </uni-popup>
  236. <!-- 公告弹窗区域 -->
  237. <uv-popup ref="popup_sale" mode="center" :closeOnClickOverlay="false" bgColor="none">
  238. <view class="popupClass">
  239. <img src="../../static/index/popup_bg.png" />
  240. <!-- 立即前往区域 -->
  241. <!-- <view class="btn_go" @click="handleGo"></view> -->
  242. <view class="btn_text">系统处于迭代试用状态,请勿下单预订酒店,如需预订请电联店家老板确认预订渠道。</view>
  243. <!-- 关闭按钮区域 -->
  244. <view class="btn_close" @click="handleClose"></view>
  245. </view>
  246. </uv-popup>
  247. </view>
  248. </template>
  249. <script>
  250. export default {
  251. data() {
  252. return {
  253. // 用户定位经度
  254. myLng: 0,
  255. // 用户定位纬度
  256. myLat: 0,
  257. // 是否显示距离差
  258. showdDistance: false,
  259. // 搜索框绑定数据
  260. keywords: '',
  261. // 当前页
  262. page: 1,
  263. // 每页多少条
  264. rows: 6,
  265. // 总条数
  266. total: null,
  267. // 地区数组
  268. placeList: [
  269. {
  270. name: '靖安县'
  271. }
  272. ],
  273. // 当前选择地区索引
  274. placeIndex: 0,
  275. // 选择乡镇弹窗数据
  276. popList: [],
  277. // 精选民宿列表数组
  278. hotelList: [],
  279. // 优选民宿列表数组
  280. hotelList_you: [],
  281. // 当前乡镇
  282. town: '',
  283. // 民宿级别
  284. level: '',
  285. // 乡镇列表
  286. townList: [],
  287. // 顶部导航栏显示隐藏控制
  288. headerType: false,
  289. // 状态栏高度
  290. statusBarH: 0,
  291. // 胶囊按钮栏高度
  292. customBarH: 0,
  293. // 招商资讯列表
  294. newsList: [],
  295. // 精选攻略数据
  296. bestNewsInfo: null,
  297. // 招商资讯轮播图指示点样式
  298. dotsStyles: {
  299. backgroundColor: '#BBD8FE',
  300. selectedBackgroundColor: '#1E7DFB',
  301. border: 'none',
  302. selectedBorder: 'none'
  303. },
  304. // 招商资讯轮播图当前索引值
  305. current: 0,
  306. // 特产甄选列表
  307. goodsList: [],
  308. // 是否显示骨架屏
  309. loading: true,
  310. // 骨架屏参数
  311. skeleton: [
  312. {
  313. type: 'line',
  314. style: { height: '90rpx', marginTop: '10rpx' }
  315. },
  316. 30,
  317. {
  318. type: 'flex',
  319. num: 2,
  320. children: [
  321. {
  322. type: 'custom',
  323. style: 'width:335rpx;height:460rpx;borderRadius:18rpx'
  324. },
  325. {
  326. type: 'custom',
  327. style: 'width:335rpx;height:460rpx;borderRadius:18rpx;marginLeft:50rpx;'
  328. }
  329. ]
  330. }
  331. ]
  332. }
  333. },
  334. created() {
  335. // 获取系统信息
  336. uni.getSystemInfo({
  337. success: (e) => {
  338. // 获取状态栏高度
  339. this.statusBarH = e.statusBarHeight + 10
  340. // // 获取菜单按钮栏高度
  341. let custom = uni.getMenuButtonBoundingClientRect()
  342. this.customBarH = custom.height + 10
  343. }
  344. })
  345. },
  346. mounted() {
  347. // 开启转发功能
  348. uni.showShareMenu({
  349. withShareTicket: true,
  350. menus: ['shareAppMessage', 'shareTimeline']
  351. })
  352. },
  353. onReachBottom() {
  354. if (this.hotelList.length < this.total) {
  355. this.page++
  356. this.getHotelList_jing()
  357. } else {
  358. uni.showToast({
  359. title: '没有更多数据了',
  360. icon: 'none'
  361. })
  362. }
  363. },
  364. onPageScroll(e) {
  365. if (e.scrollTop > 100) {
  366. this.headerType = true
  367. } else {
  368. this.headerType = false
  369. }
  370. },
  371. onPullDownRefresh() {
  372. this.loading = true
  373. this.hotelList_you = []
  374. this.hotelList = []
  375. this.page = 1
  376. this.getLocation()
  377. this.getResidueCount()
  378. this.getBestNews()
  379. this.getNews()
  380. this.getGoodsList()
  381. setTimeout(() => {
  382. uni.stopPullDownRefresh()
  383. }, 1000)
  384. },
  385. onLoad() {
  386. // 获取乡镇列表
  387. this.getResidueCount()
  388. // 获取定位
  389. this.getLocation()
  390. // 获取精选攻略
  391. this.getBestNews()
  392. // 获取招商资讯列表
  393. this.getNews()
  394. // 获取特产列表
  395. this.getGoodsList()
  396. },
  397. methods: {
  398. async getBestNews() {
  399. const res = await this.$myRequest({
  400. url: '/mhotel/articlequeryMaxArticleLike.action'
  401. })
  402. // console.log(res)
  403. if (res.code == 200) {
  404. this.bestNewsInfo = res.data
  405. }
  406. },
  407. async getNews() {
  408. const res = await this.$myRequest({
  409. url: '/mhotel/appnewlist.action',
  410. data: {
  411. page: 1,
  412. rows: 3
  413. }
  414. })
  415. // console.log(res)
  416. if (res.code === 200) {
  417. this.newsList = res.rows
  418. this.newsList.forEach((ele) => {
  419. this.$set(ele, 'showHtml', true)
  420. })
  421. }
  422. },
  423. async getGoodsList() {
  424. const res = await this.$myRequest_shop({
  425. url: '/goods/open/page',
  426. data: {
  427. curPage: 1,
  428. pageSize: 4,
  429. hot: 1,
  430. state: 1
  431. }
  432. })
  433. // console.log(res)
  434. if (res.code === '1') {
  435. this.goodsList = res.data.list
  436. }
  437. },
  438. //跳转到商城总类
  439. to_detail(options) {
  440. let userInfo = uni.getStorageSync('userInfo')
  441. let tokenId = uni.getStorageSync('tokenId')
  442. if (!userInfo || !tokenId) {
  443. uni.showModal({
  444. title: '提示',
  445. content: '您当前未登录,请授权登录查看社区信息',
  446. showCancel: false,
  447. success: (res) => {
  448. if (res.confirm) {
  449. uni.navigateTo({
  450. url: '/pages/login/login'
  451. })
  452. }
  453. }
  454. })
  455. } else {
  456. this.$api.togoods({ id: options.id })
  457. }
  458. },
  459. //跳转到特产商城
  460. clickGoods() {
  461. let userInfo = uni.getStorageSync('userInfo')
  462. let tokenId = uni.getStorageSync('tokenId')
  463. if (!userInfo || !tokenId) {
  464. uni.showModal({
  465. title: '提示',
  466. content: '您当前未登录,请授权登录查看社区信息',
  467. showCancel: false,
  468. success: (res) => {
  469. if (res.confirm) {
  470. uni.navigateTo({
  471. url: '/pages/login/login'
  472. })
  473. }
  474. }
  475. })
  476. } else {
  477. uni.navigateTo({
  478. url: '/packageShang/pages/tabbar/home'
  479. })
  480. }
  481. },
  482. // 获取用户当前位置
  483. getLocation() {
  484. uni.getSetting({
  485. success: (res) => {
  486. if (!res.authSetting['scope.userLocation']) {
  487. uni.authorize({
  488. scope: 'scope.userLocation',
  489. success: (res) => {
  490. // 授权成功
  491. uni.getLocation({
  492. type: 'gcj02',
  493. success: (res) => {
  494. this.myLat = res.latitude
  495. this.myLng = res.longitude
  496. this.showdDistance = true
  497. this.getHotelList_you()
  498. this.getHotelList_jing()
  499. }
  500. })
  501. },
  502. fail: () => {
  503. uni.showModal({
  504. content: '获取定位权限失败将会影响使用部分功能,是否去设置打开?',
  505. confirmText: '确认',
  506. cancelText: '取消',
  507. success: (res) => {
  508. if (res.confirm) {
  509. uni.openSetting({
  510. success: (res) => {
  511. console.log(res)
  512. this.getLocation()
  513. }
  514. })
  515. } else {
  516. this.showdDistance = false
  517. this.getHotelList_you()
  518. this.getHotelList_jing()
  519. uni.showToast({
  520. title: '获取定位权限失败',
  521. icon: 'none'
  522. })
  523. }
  524. }
  525. })
  526. }
  527. })
  528. } else {
  529. uni.getLocation({
  530. type: 'gcj02',
  531. success: (res) => {
  532. this.myLat = res.latitude
  533. this.myLng = res.longitude
  534. this.showdDistance = true
  535. this.getHotelList_you()
  536. this.getHotelList_jing()
  537. }
  538. })
  539. }
  540. },
  541. fail: () => {
  542. uni.showToast({
  543. title: '获取用户设置权限失败',
  544. icon: 'none',
  545. mask: true
  546. })
  547. }
  548. })
  549. },
  550. handleGoDetail(info) {
  551. let openid = uni.getStorageSync('openid')
  552. if (openid) {
  553. uni.navigateTo({
  554. url: `/pagesSub/tweetDetail/tweetDetail?id=${info.id}&townId=${info.townId}`
  555. })
  556. } else {
  557. uni.showToast({
  558. title: '请先登录',
  559. icon: 'none',
  560. mask: true
  561. })
  562. setTimeout(() => {
  563. uni.navigateTo({
  564. url: '/pages/login/login'
  565. })
  566. }, 1500)
  567. }
  568. },
  569. // 获取民宿列表 优选
  570. async getHotelList_you() {
  571. const res = await this.$myRequest({
  572. url: '/mhotel/ahppreferredPage.action',
  573. data: {
  574. page: 1,
  575. rows: 4,
  576. type: 3,
  577. userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
  578. }
  579. })
  580. // console.log(res)
  581. if (res.code === 200) {
  582. this.hotelList_you = res.data.pageList
  583. // 如果定位成功则获取和民宿之间的距离
  584. if (this.showdDistance && this.hotelList_you.length) {
  585. this.hotelList_you.forEach((ele) => {
  586. let lat = ele.hpositionWens.split(',')[0]
  587. let lng = ele.hpositionWens.split(',')[1]
  588. ele.distance = this.calculateDistance(lat, lng)
  589. })
  590. }
  591. this.loading = false
  592. }
  593. },
  594. // 获取民宿列表 精选
  595. async getHotelList_jing() {
  596. const res = await this.$myRequest({
  597. url: '/mhotel/ahpselectedPage.action',
  598. data: {
  599. page: this.page,
  600. rows: this.rows,
  601. type: 3,
  602. userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
  603. }
  604. })
  605. // console.log(res)
  606. if (res.code === 200) {
  607. this.hotelList = [...this.hotelList, ...res.data.pageList]
  608. this.total = res.data.total
  609. // 如果定位成功则获取和民宿之间的距离
  610. if (this.showdDistance && this.hotelList.length) {
  611. this.hotelList.forEach((ele) => {
  612. let lat = ele.hpositionWens.split(',')[0]
  613. let lng = ele.hpositionWens.split(',')[1]
  614. ele.distance = this.calculateDistance(lat, lng)
  615. })
  616. }
  617. }
  618. },
  619. handleOpen() {
  620. this.$refs.popup.open()
  621. },
  622. // 获取乡镇
  623. async getResidueCount() {
  624. const res = await this.$myRequest({
  625. url: '/mhotel/ahpgetResidueCount.action'
  626. })
  627. // console.log(res)
  628. if (res.code === 200) {
  629. let temNum = 0
  630. res.data.forEach((ele) => {
  631. temNum += ele.residueNumber
  632. })
  633. res.data.unshift({
  634. name: '靖安县',
  635. residueNumber: temNum
  636. })
  637. this.popList = res.data
  638. this.townList = this.changeList(this.popList, 3)
  639. }
  640. },
  641. // 变成二维数组
  642. changeList(arr, num) {
  643. let newArr = []
  644. const total = Math.ceil(arr.length / num)
  645. for (let i = 0; i < total; i++) {
  646. let a = arr.slice(i * num, (i + 1) * num)
  647. newArr.push(a)
  648. }
  649. return newArr
  650. },
  651. // 弹窗点击选择乡镇地址回调
  652. handleChooseTown(name) {
  653. this.town = name
  654. this.$refs.popup.close()
  655. },
  656. handleChooseTown2(name) {
  657. // this.town = name
  658. uni.navigateTo({
  659. url: `/pagesSub/home/home?town=${name}&keywords=${this.keywords}&level=${this.level}`
  660. })
  661. },
  662. handleChooseLv() {
  663. uni.showActionSheet({
  664. itemList: ['白金', '金宿', '银宿'],
  665. success: (res) => {
  666. if (res.tapIndex === 0) {
  667. this.level = '白金'
  668. } else if (res.tapIndex === 1) {
  669. this.level = '金宿'
  670. } else if (res.tapIndex === 2) {
  671. this.level = '银宿'
  672. }
  673. }
  674. })
  675. },
  676. handleSearch() {
  677. uni.navigateTo({
  678. url: `/pagesSub/home/home?town=${this.town}&keywords=${this.keywords}&level=${this.level}`
  679. })
  680. },
  681. goPageDetail(item) {
  682. uni.navigateTo({
  683. url: `/pages/detail/detail?id=${item.id}&distance=${item.distance}&town=${item.hotelTownshipName}`
  684. })
  685. },
  686. // 弹窗关闭按钮回调
  687. handleClose() {
  688. this.$refs.popup_sale.close()
  689. },
  690. // 立即前往按钮回调
  691. handleGo() {
  692. console.log(111)
  693. },
  694. // 计算两个点之间的距离
  695. calculateDistance(lat, lng) {
  696. let centerLat = lat
  697. let centerLng = lng
  698. let red1 = (this.myLat * Math.PI) / 180.0
  699. let red2 = (centerLat * Math.PI) / 180.0
  700. let a = red1 - red2
  701. let b = (this.myLng * Math.PI) / 180.0 - (centerLng * Math.PI) / 180.0
  702. let R = 6378137
  703. 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)))
  704. let res = (distance / 1000).toFixed(2) * 1
  705. return res
  706. },
  707. handleGoPage() {
  708. uni.switchTab({
  709. url: '/pages/community/community'
  710. })
  711. },
  712. handleGoNews(item) {
  713. let info = encodeURIComponent(JSON.stringify(item))
  714. uni.navigateTo({
  715. url: `/pagesSub/newsDetail/newsDetail?info=${info}`
  716. })
  717. },
  718. handleGoNewsList() {
  719. uni.navigateTo({
  720. url: '/pagesSub/newsList/newsList'
  721. })
  722. },
  723. htmlLoad(item) {
  724. let id = item.id + 'html'
  725. let ctx = this.$refs[id][0]
  726. let text = ctx.getText()
  727. let imgs = ctx.imgList[0]
  728. item.showHtml = false
  729. item.desc = text
  730. item.url = imgs
  731. },
  732. handleGoHome() {
  733. uni.navigateTo({
  734. url: '/pagesSub/home/home'
  735. })
  736. },
  737. changeDot(e) {
  738. this.current = e.detail.current
  739. }
  740. }
  741. }
  742. </script>
  743. <style lang="scss" scoped>
  744. .container {
  745. display: flex;
  746. flex-direction: column;
  747. min-height: 100vh;
  748. overflow-y: auto;
  749. background-color: #f2f2f2;
  750. .header {
  751. position: relative;
  752. height: 505rpx;
  753. img {
  754. width: 100%;
  755. height: 100%;
  756. border-radius: 0 0 20rpx 20rpx;
  757. }
  758. .img {
  759. position: absolute;
  760. top: 135rpx;
  761. left: 61rpx;
  762. width: 160rpx;
  763. height: 40rpx;
  764. }
  765. .img2 {
  766. position: absolute;
  767. top: 193rpx;
  768. left: 38rpx;
  769. width: 268rpx;
  770. height: 88rpx;
  771. }
  772. .header_msg {
  773. position: absolute;
  774. top: 283rpx;
  775. left: 38rpx;
  776. display: flex;
  777. justify-content: center;
  778. align-items: center;
  779. width: 291rpx;
  780. height: 65rpx;
  781. font-size: 31rpx;
  782. color: #fff;
  783. border-radius: 16rpx;
  784. background: rgba(255, 255, 255, 0.2);
  785. }
  786. }
  787. .header2 {
  788. z-index: 999;
  789. position: fixed;
  790. top: 0;
  791. left: 0;
  792. right: 0;
  793. box-sizing: content-box;
  794. text-align: center;
  795. background-color: #fff;
  796. .title {
  797. font-size: 34rpx;
  798. }
  799. }
  800. .content {
  801. z-index: 1;
  802. margin: -102rpx auto 0;
  803. width: 690rpx;
  804. border-radius: 12rpx 12rpx 0 0;
  805. background-color: #f2f2f2;
  806. .search {
  807. box-sizing: border-box;
  808. padding: 0 28rpx;
  809. width: 690rpx;
  810. height: 353rpx;
  811. border-radius: 12rpx;
  812. background-color: #fff;
  813. .search_town {
  814. display: flex;
  815. justify-content: space-between;
  816. align-items: center;
  817. height: 89rpx;
  818. color: #a6a6a6;
  819. font-size: 32rpx;
  820. border-bottom: 1rpx solid #e6e6e6;
  821. img {
  822. width: 40rpx;
  823. height: 40rpx;
  824. }
  825. }
  826. .active {
  827. font-weight: bold;
  828. color: #000;
  829. }
  830. .search_center {
  831. display: flex;
  832. align-items: center;
  833. height: 89rpx;
  834. color: #a6a6a6;
  835. font-size: 28rpx;
  836. img {
  837. width: 40rpx;
  838. height: 40rpx;
  839. }
  840. .center_input {
  841. margin-right: 12rpx;
  842. width: 250rpx;
  843. color: #000;
  844. font-weight: bold;
  845. }
  846. .img {
  847. margin-right: 12rpx;
  848. }
  849. .center_level {
  850. flex: 1;
  851. margin-left: 24rpx;
  852. font-weight: 400;
  853. }
  854. .active {
  855. font-weight: bold;
  856. color: #000;
  857. }
  858. .img2 {
  859. margin-left: auto;
  860. }
  861. }
  862. .search_btn {
  863. display: flex;
  864. justify-content: center;
  865. align-items: center;
  866. margin-top: 23rpx;
  867. width: 623rpx;
  868. height: 100rpx;
  869. border-radius: 57rpx;
  870. color: #fff;
  871. font-size: 32rpx;
  872. background: linear-gradient(90deg, #2697ef 0%, #5e35eb 100%);
  873. }
  874. }
  875. .swiper {
  876. margin: 20rpx auto 0;
  877. width: 690rpx;
  878. height: 214rpx;
  879. border-radius: 12rpx;
  880. background-color: #fff;
  881. .swiper_item {
  882. display: flex;
  883. justify-content: space-around;
  884. align-items: center;
  885. width: 100%;
  886. height: 100%;
  887. .item_box {
  888. position: relative;
  889. width: 195rpx;
  890. height: 128rpx;
  891. border-radius: 12rpx;
  892. color: #fff;
  893. img {
  894. width: 195rpx;
  895. height: 128rpx;
  896. border-radius: 12rpx;
  897. }
  898. .box_town {
  899. position: absolute;
  900. top: 30rpx;
  901. left: 0;
  902. right: 0;
  903. text-align: center;
  904. font-size: 28rpx;
  905. font-weight: bold;
  906. }
  907. .box_count {
  908. position: absolute;
  909. top: 75rpx;
  910. left: 0;
  911. right: 0;
  912. text-align: center;
  913. font-size: 18rpx;
  914. }
  915. }
  916. }
  917. }
  918. .body {
  919. margin: 0 auto;
  920. width: 690rpx;
  921. .body_top {
  922. display: flex;
  923. align-items: center;
  924. height: 89rpx;
  925. .circle {
  926. width: 30rpx;
  927. height: 30rpx;
  928. border-radius: 50%;
  929. background-color: #485bed;
  930. }
  931. .color {
  932. margin-left: -15rpx;
  933. opacity: 0.5;
  934. background-color: #fff;
  935. }
  936. .top_title {
  937. margin-left: 15rpx;
  938. font-size: 32rpx;
  939. font-weight: bold;
  940. }
  941. .top_msg {
  942. margin-top: 5rpx;
  943. margin-left: 12rpx;
  944. color: #666666;
  945. font-size: 24rpx;
  946. }
  947. .top_more {
  948. display: flex;
  949. align-items: center;
  950. margin-left: auto;
  951. color: #a6a6a6;
  952. font-size: 24rpx;
  953. img {
  954. width: 32rpx;
  955. height: 32rpx;
  956. }
  957. }
  958. }
  959. .body_strategy {
  960. display: flex;
  961. box-sizing: border-box;
  962. padding: 20rpx;
  963. margin-bottom: 10rpx;
  964. width: 690rpx;
  965. height: 235rpx;
  966. border-radius: 12rpx;
  967. background-color: #fff;
  968. .strategy_cover {
  969. width: 253rpx;
  970. height: 190rpx;
  971. border-radius: 7rpx;
  972. }
  973. .strategy_info {
  974. flex: 1;
  975. display: flex;
  976. flex-direction: column;
  977. justify-content: space-between;
  978. margin-left: 20rpx;
  979. width: 500rpx;
  980. height: 170rpx;
  981. font-size: 24rpx;
  982. color: #666666;
  983. overflow: hidden;
  984. .info_title {
  985. font-size: 32rpx;
  986. font-weight: bold;
  987. color: #000;
  988. overflow: hidden;
  989. text-overflow: ellipsis;
  990. white-space: nowrap;
  991. }
  992. .info_title2 {
  993. font-size: 32rpx;
  994. font-weight: bold;
  995. color: #000;
  996. display: -webkit-box;
  997. -webkit-box-orient: vertical;
  998. -webkit-line-clamp: 2;
  999. overflow: hidden;
  1000. }
  1001. .info_tags {
  1002. display: flex;
  1003. .tag {
  1004. margin-right: 10rpx;
  1005. box-sizing: border-box;
  1006. padding: 0 12rpx;
  1007. height: 35rpx;
  1008. color: #1e7dfb;
  1009. font-size: 20rpx;
  1010. border-radius: 30rpx;
  1011. border: 1rpx solid #1e7dfb;
  1012. }
  1013. }
  1014. .info_desc {
  1015. display: -webkit-box;
  1016. -webkit-box-orient: vertical;
  1017. -webkit-line-clamp: 2;
  1018. overflow: hidden;
  1019. }
  1020. }
  1021. }
  1022. .body_list {
  1023. display: flex;
  1024. flex-wrap: wrap;
  1025. justify-content: space-between;
  1026. .list_item {
  1027. width: 335rpx;
  1028. box-sizing: border-box;
  1029. margin-bottom: 20rpx;
  1030. .item-img {
  1031. width: 100%;
  1032. height: 223rpx;
  1033. border-radius: 18rpx 18rpx 0 0;
  1034. box-sizing: border-box;
  1035. }
  1036. .descrition {
  1037. display: flex;
  1038. flex-direction: column;
  1039. width: 100%;
  1040. border-radius: 0 0 18rpx 18rpx;
  1041. box-sizing: border-box;
  1042. background: rgba(255, 255, 255, 1);
  1043. margin-top: -10rpx;
  1044. .title {
  1045. font-size: 28rpx;
  1046. font-weight: 600;
  1047. padding: 20rpx 20rpx 10rpx;
  1048. color: rgba(0, 0, 0, 1);
  1049. overflow: hidden;
  1050. white-space: nowrap;
  1051. text-overflow: ellipsis;
  1052. }
  1053. .type {
  1054. padding: 5rpx 20rpx;
  1055. height: 40rpx;
  1056. font-size: 24rpx;
  1057. color: #a6a6a6;
  1058. }
  1059. .distance {
  1060. padding: 10rpx 20rpx;
  1061. font-size: 24rpx;
  1062. color: #a6a6a6;
  1063. }
  1064. .detail {
  1065. display: flex;
  1066. flex-direction: row;
  1067. justify-content: space-between;
  1068. align-items: center;
  1069. padding: 0 20rpx 20rpx 20rpx;
  1070. color: rgba(0, 0, 0, 1);
  1071. .img {
  1072. width: 40rpx;
  1073. height: 40rpx;
  1074. }
  1075. .price_home {
  1076. .txt1 {
  1077. font-size: 36rpx;
  1078. font-weight: 600;
  1079. color: rgba(255, 87, 51, 1);
  1080. }
  1081. .txt2 {
  1082. font-size: 24rpx;
  1083. font-weight: 400;
  1084. color: #a6a6a6;
  1085. }
  1086. }
  1087. .score {
  1088. font-size: 24rpx;
  1089. font-weight: 400;
  1090. padding-top: 10rpx;
  1091. color: rgba(166, 166, 166, 1);
  1092. }
  1093. }
  1094. }
  1095. }
  1096. .item_goods {
  1097. margin-bottom: 20rpx;
  1098. width: 335rpx;
  1099. height: 367rpx;
  1100. border-radius: 10rpx;
  1101. background-color: #fff;
  1102. overflow: hidden;
  1103. .goods_img {
  1104. width: 335rpx;
  1105. height: 223rpx;
  1106. border-bottom: 1rpx solid #eee;
  1107. }
  1108. .goods_name {
  1109. margin: 18rpx 5rpx 18rpx 30rpx;
  1110. font-size: 28rpx;
  1111. font-weight: bold;
  1112. overflow: hidden;
  1113. white-space: nowrap;
  1114. text-overflow: ellipsis;
  1115. }
  1116. .goods_detail {
  1117. display: flex;
  1118. flex-direction: row;
  1119. justify-content: space-between;
  1120. align-items: center;
  1121. padding: 0 20rpx 20rpx 20rpx;
  1122. color: rgba(0, 0, 0, 1);
  1123. .img {
  1124. width: 40rpx;
  1125. height: 40rpx;
  1126. }
  1127. .price_good {
  1128. .txt1 {
  1129. font-size: 36rpx;
  1130. font-weight: 600;
  1131. color: rgba(255, 87, 51, 1);
  1132. }
  1133. .txt2 {
  1134. font-size: 24rpx;
  1135. font-weight: 400;
  1136. color: #a6a6a6;
  1137. }
  1138. }
  1139. .score {
  1140. font-size: 24rpx;
  1141. font-weight: 400;
  1142. padding-top: 10rpx;
  1143. color: rgba(166, 166, 166, 1);
  1144. }
  1145. }
  1146. }
  1147. }
  1148. .body_news {
  1149. box-sizing: border-box;
  1150. padding: 25rpx;
  1151. width: 690rpx;
  1152. height: 566rpx;
  1153. border-radius: 12rpx;
  1154. background-color: #fff;
  1155. .news_title {
  1156. margin: 20rpx 0;
  1157. font-size: 32rpx;
  1158. font-weight: bold;
  1159. overflow: hidden;
  1160. text-overflow: ellipsis;
  1161. white-space: nowrap;
  1162. }
  1163. .news_desc {
  1164. font-size: 24rpx;
  1165. color: #666666;
  1166. display: -webkit-box;
  1167. -webkit-box-orient: vertical;
  1168. -webkit-line-clamp: 2;
  1169. overflow: hidden;
  1170. }
  1171. }
  1172. .noData {
  1173. display: flex;
  1174. flex-direction: column;
  1175. justify-content: center;
  1176. align-items: center;
  1177. padding-bottom: 65rpx;
  1178. img {
  1179. margin-top: 80rpx;
  1180. width: 600rpx;
  1181. height: 600rpx;
  1182. }
  1183. }
  1184. }
  1185. }
  1186. .popup_body {
  1187. width: 618rpx;
  1188. height: 687rpx;
  1189. border-radius: 21rpx;
  1190. background-color: #fff;
  1191. .body_header {
  1192. display: flex;
  1193. justify-content: center;
  1194. align-items: center;
  1195. position: relative;
  1196. height: 113rpx;
  1197. border-bottom: 1rpx solid #e6e6e6;
  1198. img {
  1199. width: 16rpx;
  1200. height: 16rpx;
  1201. }
  1202. .header_title {
  1203. margin: 0 10rpx;
  1204. font-size: 34rpx;
  1205. font-weight: bold;
  1206. color: #0f194d;
  1207. }
  1208. }
  1209. .body_content {
  1210. display: grid;
  1211. grid-template-columns: repeat(auto-fill, 160rpx);
  1212. gap: 28rpx;
  1213. box-sizing: border-box;
  1214. padding: 26rpx 40rpx 50rpx;
  1215. .content_box {
  1216. position: relative;
  1217. width: 160rpx;
  1218. height: 105rpx;
  1219. color: #fff;
  1220. border-radius: 10rpx;
  1221. img {
  1222. width: 160rpx;
  1223. height: 105rpx;
  1224. border-radius: 10rpx;
  1225. }
  1226. .box_town {
  1227. position: absolute;
  1228. top: 20rpx;
  1229. left: 0;
  1230. right: 0;
  1231. text-align: center;
  1232. font-size: 28rpx;
  1233. font-weight: bold;
  1234. }
  1235. .box_count {
  1236. position: absolute;
  1237. top: 62rpx;
  1238. left: 0;
  1239. right: 0;
  1240. text-align: center;
  1241. font-size: 18rpx;
  1242. }
  1243. }
  1244. }
  1245. }
  1246. .popupClass {
  1247. position: relative;
  1248. width: 481rpx;
  1249. height: 764rpx;
  1250. img {
  1251. width: 100%;
  1252. height: 665rpx;
  1253. }
  1254. .btn_go {
  1255. position: absolute;
  1256. top: 415rpx;
  1257. left: 40rpx;
  1258. width: 396rpx;
  1259. height: 76rpx;
  1260. border-radius: 43rpx;
  1261. }
  1262. .btn_text {
  1263. position: absolute;
  1264. top: 265rpx;
  1265. left: 40rpx;
  1266. display: flex;
  1267. justify-content: center;
  1268. align-items: center;
  1269. width: 400rpx;
  1270. height: 260rpx;
  1271. color: #0f194d;
  1272. font-size: 28rpx;
  1273. border-radius: 43rpx;
  1274. background-color: #fff;
  1275. }
  1276. .btn_close {
  1277. position: absolute;
  1278. top: 586rpx;
  1279. left: 212rpx;
  1280. width: 58rpx;
  1281. height: 58rpx;
  1282. border-radius: 50%;
  1283. }
  1284. }
  1285. }
  1286. </style>