home3.vue 33 KB

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