home3.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  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.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 in hotelList.slice(0, 4)" :key="item.id" @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. town: '',
  278. // 民宿级别
  279. level: '',
  280. // 乡镇列表
  281. townList: [],
  282. // 顶部导航栏显示隐藏控制
  283. headerType: false,
  284. // 状态栏高度
  285. statusBarH: 0,
  286. // 胶囊按钮栏高度
  287. customBarH: 0,
  288. // 招商资讯列表
  289. newsList: [],
  290. // 精选攻略数据
  291. bestNewsInfo: null,
  292. // 招商资讯轮播图指示点样式
  293. dotsStyles: {
  294. backgroundColor: '#BBD8FE',
  295. selectedBackgroundColor: '#1E7DFB',
  296. border: 'none',
  297. selectedBorder: 'none'
  298. },
  299. // 招商资讯轮播图当前索引值
  300. current: 0,
  301. // 特产甄选列表
  302. goodsList: []
  303. }
  304. },
  305. created() {
  306. // 获取系统信息
  307. uni.getSystemInfo({
  308. success: (e) => {
  309. // 获取状态栏高度
  310. this.statusBarH = e.statusBarHeight + 10
  311. // // 获取菜单按钮栏高度
  312. let custom = uni.getMenuButtonBoundingClientRect()
  313. this.customBarH = custom.height + 10
  314. }
  315. })
  316. },
  317. mounted() {
  318. // 开启转发功能
  319. uni.showShareMenu({
  320. withShareTicket: true,
  321. menus: ['shareAppMessage', 'shareTimeline']
  322. })
  323. },
  324. onReachBottom() {
  325. if (this.hotelList.length < this.total) {
  326. this.page++
  327. this.getHotelList()
  328. } else {
  329. uni.showToast({
  330. title: '没有更多数据了',
  331. icon: 'none'
  332. })
  333. }
  334. },
  335. onPageScroll(e) {
  336. if (e.scrollTop > 100) {
  337. this.headerType = true
  338. } else {
  339. this.headerType = false
  340. }
  341. },
  342. onPullDownRefresh() {
  343. this.hotelList = []
  344. this.page = 1
  345. this.getLocation()
  346. this.getResidueCount()
  347. this.getBestNews()
  348. this.getNews()
  349. this.getGoodsList()
  350. setTimeout(() => {
  351. uni.stopPullDownRefresh()
  352. }, 1000)
  353. },
  354. onLoad() {
  355. // 获取乡镇列表
  356. this.getResidueCount()
  357. // 获取精选攻略
  358. this.getBestNews()
  359. // 获取招商资讯列表
  360. this.getNews()
  361. // 获取特产列表
  362. this.getGoodsList()
  363. // 获取定位
  364. this.getLocation()
  365. },
  366. methods: {
  367. async getBestNews() {
  368. const res = await this.$myRequest({
  369. url: '/mhotel/articlequeryMaxArticleLike.action'
  370. })
  371. // console.log(res)
  372. if (res.code == 200) {
  373. this.bestNewsInfo = res.data
  374. }
  375. },
  376. async getNews() {
  377. const res = await this.$myRequest({
  378. url: '/mhotel/appnewlist.action',
  379. data: {
  380. page: 1,
  381. rows: 3
  382. }
  383. })
  384. // console.log(res)
  385. if (res.code === 200) {
  386. this.newsList = res.rows
  387. this.newsList.forEach((ele) => {
  388. this.$set(ele, 'showHtml', true)
  389. })
  390. }
  391. },
  392. async getGoodsList() {
  393. const res = await this.$myRequest_shop({
  394. url: '/goods/open/page',
  395. data: {
  396. curPage: 1,
  397. pageSize: 4,
  398. hot: 1,
  399. state:1
  400. }
  401. })
  402. // console.log(res)
  403. if (res.code === '1') {
  404. this.goodsList = res.data.list
  405. }
  406. },
  407. //跳转到商城总类
  408. to_detail(options) {
  409. let userInfo = uni.getStorageSync('userInfo')
  410. let tokenId = uni.getStorageSync('tokenId')
  411. if (!userInfo || !tokenId) {
  412. uni.showModal({
  413. title: '提示',
  414. content: '您当前未登录,请授权登录查看社区信息',
  415. showCancel: false,
  416. success: (res) => {
  417. if (res.confirm) {
  418. uni.navigateTo({
  419. url: '/pages/login/login'
  420. })
  421. }
  422. }
  423. })
  424. } else {
  425. this.$api.togoods({ id: options.id })
  426. }
  427. },
  428. //跳转到特产商城
  429. clickGoods() {
  430. let userInfo = uni.getStorageSync('userInfo')
  431. let tokenId = uni.getStorageSync('tokenId')
  432. if (!userInfo || !tokenId) {
  433. uni.showModal({
  434. title: '提示',
  435. content: '您当前未登录,请授权登录查看社区信息',
  436. showCancel: false,
  437. success: (res) => {
  438. if (res.confirm) {
  439. uni.navigateTo({
  440. url: '/pages/login/login'
  441. })
  442. }
  443. }
  444. })
  445. } else {
  446. uni.navigateTo({
  447. url: '/packageShang/pages/tabbar/home'
  448. })
  449. }
  450. },
  451. // 获取用户当前位置
  452. getLocation() {
  453. uni.getSetting({
  454. success: (res) => {
  455. if (!res.authSetting['scope.userLocation']) {
  456. uni.authorize({
  457. scope: 'scope.userLocation',
  458. success: (res) => {
  459. // 授权成功
  460. uni.getLocation({
  461. type: 'gcj02',
  462. success: (res) => {
  463. this.myLat = res.latitude
  464. this.myLng = res.longitude
  465. this.showdDistance = true
  466. this.getHotelList()
  467. }
  468. })
  469. },
  470. fail: () => {
  471. uni.showModal({
  472. content: '获取定位权限失败将会影响使用部分功能,是否去设置打开?',
  473. confirmText: '确认',
  474. cancelText: '取消',
  475. success: (res) => {
  476. if (res.confirm) {
  477. uni.openSetting({
  478. success: (res) => {
  479. console.log(res)
  480. this.getLocation()
  481. }
  482. })
  483. } else {
  484. this.showdDistance = false
  485. this.getHotelList()
  486. uni.showToast({
  487. title: '获取定位权限失败',
  488. icon: 'none'
  489. })
  490. }
  491. }
  492. })
  493. }
  494. })
  495. } else {
  496. uni.getLocation({
  497. type: 'gcj02',
  498. success: (res) => {
  499. this.myLat = res.latitude
  500. this.myLng = res.longitude
  501. this.showdDistance = true
  502. this.getHotelList()
  503. }
  504. })
  505. }
  506. },
  507. fail: () => {
  508. uni.showToast({
  509. title: '获取用户设置权限失败',
  510. icon: 'none',
  511. mask: true
  512. })
  513. }
  514. })
  515. },
  516. handleGoDetail(info) {
  517. let openid = uni.getStorageSync('openid')
  518. if (openid) {
  519. uni.navigateTo({
  520. url: `/pages/tweetDetail/tweetDetail?id=${info.id}&townId=${info.townId}`
  521. })
  522. } else {
  523. uni.showToast({
  524. title: '请先登录',
  525. icon: 'none',
  526. mask: true
  527. })
  528. setTimeout(() => {
  529. uni.navigateTo({
  530. url: '/pages/login/login'
  531. })
  532. }, 1500)
  533. }
  534. },
  535. // 获取民宿列表
  536. async getHotelList() {
  537. const res = await this.$myRequest({
  538. url: '/mhotel/ahphomePage.action',
  539. data: {
  540. // queryValue: this.keywords,
  541. page: this.page,
  542. rows: this.rows,
  543. type: 3,
  544. // hotel_township: this.placeList[this.placeIndex].id || '',
  545. userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
  546. }
  547. })
  548. // console.log(res)
  549. if (res.code === 200) {
  550. this.hotelList = [...this.hotelList, ...res.data.pageList]
  551. this.total = res.data.total
  552. // 如果定位成功则获取和民宿之间的距离
  553. if (this.showdDistance && this.hotelList.length) {
  554. this.hotelList.forEach((ele) => {
  555. let lat = ele.hpositionWens.split(',')[0]
  556. let lng = ele.hpositionWens.split(',')[1]
  557. ele.distance = this.calculateDistance(lat, lng)
  558. })
  559. }
  560. this.$refs.popup_sale.open()
  561. }
  562. },
  563. handleOpen() {
  564. this.$refs.popup.open()
  565. },
  566. // 获取乡镇
  567. async getResidueCount() {
  568. const res = await this.$myRequest({
  569. url: '/mhotel/ahpgetResidueCount.action'
  570. })
  571. // console.log(res)
  572. if (res.code === 200) {
  573. let temNum = 0
  574. res.data.forEach((ele) => {
  575. temNum += ele.residueNumber
  576. })
  577. res.data.unshift({
  578. name: '靖安县',
  579. residueNumber: temNum
  580. })
  581. this.popList = res.data
  582. this.townList = this.changeList(this.popList, 3)
  583. }
  584. },
  585. // 变成二维数组
  586. changeList(arr, num) {
  587. let newArr = []
  588. const total = Math.ceil(arr.length / num)
  589. for (let i = 0; i < total; i++) {
  590. let a = arr.slice(i * num, (i + 1) * num)
  591. newArr.push(a)
  592. }
  593. return newArr
  594. },
  595. // 弹窗点击选择乡镇地址回调
  596. handleChooseTown(name) {
  597. this.town = name
  598. this.$refs.popup.close()
  599. },
  600. handleChooseTown2(name) {
  601. // this.town = name
  602. uni.navigateTo({
  603. url: `/pages/home/home?town=${name}&keywords=${this.keywords}&level=${this.level}`
  604. })
  605. },
  606. handleChooseLv() {
  607. uni.showActionSheet({
  608. itemList: ['白金', '金宿', '银宿'],
  609. success: (res) => {
  610. if (res.tapIndex === 0) {
  611. this.level = '白金'
  612. } else if (res.tapIndex === 1) {
  613. this.level = '金宿'
  614. } else if (res.tapIndex === 2) {
  615. this.level = '银宿'
  616. }
  617. }
  618. })
  619. },
  620. handleSearch() {
  621. uni.navigateTo({
  622. url: `/pages/home/home?town=${this.town}&keywords=${this.keywords}&level=${this.level}`
  623. })
  624. },
  625. goPageDetail(item) {
  626. uni.navigateTo({
  627. url: `/pages/detail/detail?id=${item.id}&distance=${item.distance}`
  628. })
  629. },
  630. // 弹窗关闭按钮回调
  631. handleClose() {
  632. this.$refs.popup_sale.close()
  633. },
  634. // 立即前往按钮回调
  635. handleGo() {
  636. console.log(111)
  637. },
  638. // 计算两个点之间的距离
  639. calculateDistance(lat, lng) {
  640. let centerLat = lat
  641. let centerLng = lng
  642. let red1 = (this.myLat * Math.PI) / 180.0
  643. let red2 = (centerLat * Math.PI) / 180.0
  644. let a = red1 - red2
  645. let b = (this.myLng * Math.PI) / 180.0 - (centerLng * Math.PI) / 180.0
  646. let R = 6378137
  647. 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)))
  648. let res = (distance / 1000).toFixed(2) * 1
  649. return res
  650. },
  651. handleGoPage() {
  652. uni.switchTab({
  653. url: '/pages/community/community'
  654. })
  655. },
  656. handleGoNews(item) {
  657. let info = encodeURIComponent(JSON.stringify(item))
  658. uni.navigateTo({
  659. url: `/pages/newsDetail/newsDetail?info=${info}`
  660. })
  661. },
  662. handleGoNewsList() {
  663. uni.navigateTo({
  664. url: '/pages/newsList/newsList'
  665. })
  666. },
  667. htmlLoad(item) {
  668. let id = item.id + 'html'
  669. let ctx = this.$refs[id][0]
  670. let text = ctx.getText()
  671. let imgs = ctx.imgList[0]
  672. item.showHtml = false
  673. item.desc = text
  674. item.url = imgs
  675. },
  676. handleGoHome() {
  677. uni.navigateTo({
  678. url: '/pages/home/home'
  679. })
  680. },
  681. changeDot(e) {
  682. this.current = e.detail.current
  683. }
  684. }
  685. }
  686. </script>
  687. <style lang="scss" scoped>
  688. .container {
  689. display: flex;
  690. flex-direction: column;
  691. min-height: 100vh;
  692. overflow-y: auto;
  693. background-color: #f2f2f2;
  694. .header {
  695. position: relative;
  696. height: 505rpx;
  697. img {
  698. width: 100%;
  699. height: 100%;
  700. border-radius: 0 0 20rpx 20rpx;
  701. }
  702. .img {
  703. position: absolute;
  704. top: 135rpx;
  705. left: 61rpx;
  706. width: 160rpx;
  707. height: 40rpx;
  708. }
  709. .img2 {
  710. position: absolute;
  711. top: 193rpx;
  712. left: 38rpx;
  713. width: 268rpx;
  714. height: 88rpx;
  715. }
  716. .header_msg {
  717. position: absolute;
  718. top: 283rpx;
  719. left: 38rpx;
  720. display: flex;
  721. justify-content: center;
  722. align-items: center;
  723. width: 291rpx;
  724. height: 65rpx;
  725. font-size: 31rpx;
  726. color: #fff;
  727. border-radius: 16rpx;
  728. background: rgba(255, 255, 255, 0.2);
  729. }
  730. }
  731. .header2 {
  732. z-index: 999;
  733. position: fixed;
  734. top: 0;
  735. left: 0;
  736. right: 0;
  737. box-sizing: content-box;
  738. text-align: center;
  739. background-color: #fff;
  740. .title {
  741. font-size: 34rpx;
  742. }
  743. }
  744. .content {
  745. z-index: 1;
  746. margin: -102rpx auto 0;
  747. width: 690rpx;
  748. border-radius: 12rpx 12rpx 0 0;
  749. background-color: #f2f2f2;
  750. .search {
  751. box-sizing: border-box;
  752. padding: 0 28rpx;
  753. width: 690rpx;
  754. height: 353rpx;
  755. border-radius: 12rpx;
  756. background-color: #fff;
  757. .search_town {
  758. display: flex;
  759. justify-content: space-between;
  760. align-items: center;
  761. height: 89rpx;
  762. color: #a6a6a6;
  763. font-size: 32rpx;
  764. border-bottom: 1rpx solid #e6e6e6;
  765. img {
  766. width: 40rpx;
  767. height: 40rpx;
  768. }
  769. }
  770. .active {
  771. font-weight: bold;
  772. color: #000;
  773. }
  774. .search_center {
  775. display: flex;
  776. align-items: center;
  777. height: 89rpx;
  778. color: #a6a6a6;
  779. font-size: 28rpx;
  780. img {
  781. width: 40rpx;
  782. height: 40rpx;
  783. }
  784. .center_input {
  785. margin-right: 12rpx;
  786. width: 250rpx;
  787. color: #000;
  788. font-weight: bold;
  789. }
  790. .img {
  791. margin-right: 12rpx;
  792. }
  793. .center_level {
  794. flex: 1;
  795. margin-left: 24rpx;
  796. font-weight: 400;
  797. }
  798. .active {
  799. font-weight: bold;
  800. color: #000;
  801. }
  802. .img2 {
  803. margin-left: auto;
  804. }
  805. }
  806. .search_btn {
  807. display: flex;
  808. justify-content: center;
  809. align-items: center;
  810. margin-top: 23rpx;
  811. width: 623rpx;
  812. height: 100rpx;
  813. border-radius: 57rpx;
  814. color: #fff;
  815. font-size: 32rpx;
  816. background: linear-gradient(90deg, #2697ef 0%, #5e35eb 100%);
  817. }
  818. }
  819. .swiper {
  820. margin: 20rpx auto 0;
  821. width: 690rpx;
  822. height: 214rpx;
  823. border-radius: 12rpx;
  824. background-color: #fff;
  825. .swiper_item {
  826. display: flex;
  827. justify-content: space-around;
  828. align-items: center;
  829. width: 100%;
  830. height: 100%;
  831. .item_box {
  832. position: relative;
  833. width: 195rpx;
  834. height: 128rpx;
  835. border-radius: 12rpx;
  836. color: #fff;
  837. img {
  838. width: 195rpx;
  839. height: 128rpx;
  840. border-radius: 12rpx;
  841. }
  842. .box_town {
  843. position: absolute;
  844. top: 30rpx;
  845. left: 0;
  846. right: 0;
  847. text-align: center;
  848. font-size: 28rpx;
  849. font-weight: bold;
  850. }
  851. .box_count {
  852. position: absolute;
  853. top: 75rpx;
  854. left: 0;
  855. right: 0;
  856. text-align: center;
  857. font-size: 18rpx;
  858. }
  859. }
  860. }
  861. }
  862. .body {
  863. margin: 0 auto;
  864. width: 690rpx;
  865. .body_top {
  866. display: flex;
  867. align-items: center;
  868. height: 89rpx;
  869. .circle {
  870. width: 30rpx;
  871. height: 30rpx;
  872. border-radius: 50%;
  873. background-color: #485bed;
  874. }
  875. .color {
  876. margin-left: -15rpx;
  877. opacity: 0.5;
  878. background-color: #fff;
  879. }
  880. .top_title {
  881. margin-left: 15rpx;
  882. font-size: 32rpx;
  883. font-weight: bold;
  884. }
  885. .top_msg {
  886. margin-top: 5rpx;
  887. margin-left: 12rpx;
  888. color: #666666;
  889. font-size: 24rpx;
  890. }
  891. .top_more {
  892. display: flex;
  893. align-items: center;
  894. margin-left: auto;
  895. color: #a6a6a6;
  896. font-size: 24rpx;
  897. img {
  898. width: 32rpx;
  899. height: 32rpx;
  900. }
  901. }
  902. }
  903. .body_strategy {
  904. display: flex;
  905. box-sizing: border-box;
  906. padding: 20rpx;
  907. margin-bottom: 10rpx;
  908. width: 690rpx;
  909. height: 235rpx;
  910. border-radius: 12rpx;
  911. background-color: #fff;
  912. .strategy_cover {
  913. width: 253rpx;
  914. height: 190rpx;
  915. border-radius: 7rpx;
  916. }
  917. .strategy_info {
  918. flex: 1;
  919. display: flex;
  920. flex-direction: column;
  921. justify-content: space-between;
  922. margin-left: 20rpx;
  923. width: 500rpx;
  924. height: 170rpx;
  925. font-size: 24rpx;
  926. color: #666666;
  927. overflow: hidden;
  928. .info_title {
  929. font-size: 32rpx;
  930. font-weight: bold;
  931. color: #000;
  932. overflow: hidden;
  933. text-overflow: ellipsis;
  934. white-space: nowrap;
  935. }
  936. .info_title2 {
  937. font-size: 32rpx;
  938. font-weight: bold;
  939. color: #000;
  940. display: -webkit-box;
  941. -webkit-box-orient: vertical;
  942. -webkit-line-clamp: 2;
  943. overflow: hidden;
  944. }
  945. .info_tags {
  946. display: flex;
  947. .tag {
  948. margin-right: 10rpx;
  949. box-sizing: border-box;
  950. padding: 0 12rpx;
  951. height: 35rpx;
  952. color: #1e7dfb;
  953. font-size: 20rpx;
  954. border-radius: 30rpx;
  955. border: 1rpx solid #1e7dfb;
  956. }
  957. }
  958. .info_desc {
  959. display: -webkit-box;
  960. -webkit-box-orient: vertical;
  961. -webkit-line-clamp: 2;
  962. overflow: hidden;
  963. }
  964. }
  965. }
  966. .body_list {
  967. display: flex;
  968. flex-wrap: wrap;
  969. justify-content: space-between;
  970. .list_item {
  971. width: 335rpx;
  972. box-sizing: border-box;
  973. margin-bottom: 20rpx;
  974. .item-img {
  975. width: 100%;
  976. height: 223rpx;
  977. border-radius: 18rpx 18rpx 0 0;
  978. box-sizing: border-box;
  979. }
  980. .descrition {
  981. display: flex;
  982. flex-direction: column;
  983. width: 100%;
  984. border-radius: 0 0 18rpx 18rpx;
  985. box-sizing: border-box;
  986. background: rgba(255, 255, 255, 1);
  987. margin-top: -10rpx;
  988. .title {
  989. font-size: 28rpx;
  990. font-weight: 600;
  991. padding: 20rpx 20rpx 10rpx;
  992. color: rgba(0, 0, 0, 1);
  993. overflow: hidden;
  994. white-space: nowrap;
  995. text-overflow: ellipsis;
  996. }
  997. .type {
  998. padding: 5rpx 20rpx;
  999. height: 40rpx;
  1000. font-size: 24rpx;
  1001. color: #a6a6a6;
  1002. }
  1003. .distance {
  1004. padding: 10rpx 20rpx;
  1005. font-size: 24rpx;
  1006. color: #a6a6a6;
  1007. }
  1008. .detail {
  1009. display: flex;
  1010. flex-direction: row;
  1011. justify-content: space-between;
  1012. align-items: center;
  1013. padding: 0 20rpx 20rpx 20rpx;
  1014. color: rgba(0, 0, 0, 1);
  1015. .img {
  1016. width: 40rpx;
  1017. height: 40rpx;
  1018. }
  1019. .price_home {
  1020. .txt1 {
  1021. font-size: 36rpx;
  1022. font-weight: 600;
  1023. color: rgba(255, 87, 51, 1);
  1024. }
  1025. .txt2 {
  1026. font-size: 24rpx;
  1027. font-weight: 400;
  1028. color: #a6a6a6;
  1029. }
  1030. }
  1031. .score {
  1032. font-size: 24rpx;
  1033. font-weight: 400;
  1034. padding-top: 10rpx;
  1035. color: rgba(166, 166, 166, 1);
  1036. }
  1037. }
  1038. }
  1039. }
  1040. .item_goods {
  1041. margin-bottom: 20rpx;
  1042. width: 335rpx;
  1043. height: 367rpx;
  1044. border-radius: 10rpx;
  1045. background-color: #fff;
  1046. overflow: hidden;
  1047. .goods_img {
  1048. width: 335rpx;
  1049. height: 223rpx;
  1050. border-bottom: 1rpx solid #eee;
  1051. }
  1052. .goods_name {
  1053. margin: 18rpx 5rpx 18rpx 30rpx;
  1054. font-size: 28rpx;
  1055. font-weight: bold;
  1056. overflow: hidden;
  1057. white-space: nowrap;
  1058. text-overflow: ellipsis;
  1059. }
  1060. .goods_detail {
  1061. display: flex;
  1062. flex-direction: row;
  1063. justify-content: space-between;
  1064. align-items: center;
  1065. padding: 0 20rpx 20rpx 20rpx;
  1066. color: rgba(0, 0, 0, 1);
  1067. .img {
  1068. width: 40rpx;
  1069. height: 40rpx;
  1070. }
  1071. .price_good {
  1072. .txt1 {
  1073. font-size: 36rpx;
  1074. font-weight: 600;
  1075. color: rgba(255, 87, 51, 1);
  1076. }
  1077. .txt2 {
  1078. font-size: 24rpx;
  1079. font-weight: 400;
  1080. color: #a6a6a6;
  1081. }
  1082. }
  1083. .score {
  1084. font-size: 24rpx;
  1085. font-weight: 400;
  1086. padding-top: 10rpx;
  1087. color: rgba(166, 166, 166, 1);
  1088. }
  1089. }
  1090. }
  1091. }
  1092. .body_news {
  1093. box-sizing: border-box;
  1094. padding: 25rpx;
  1095. width: 690rpx;
  1096. height: 566rpx;
  1097. border-radius: 12rpx;
  1098. background-color: #fff;
  1099. .news_title {
  1100. margin: 20rpx 0;
  1101. font-size: 32rpx;
  1102. font-weight: bold;
  1103. overflow: hidden;
  1104. text-overflow: ellipsis;
  1105. white-space: nowrap;
  1106. }
  1107. .news_desc {
  1108. font-size: 24rpx;
  1109. color: #666666;
  1110. display: -webkit-box;
  1111. -webkit-box-orient: vertical;
  1112. -webkit-line-clamp: 2;
  1113. overflow: hidden;
  1114. }
  1115. }
  1116. .noData {
  1117. display: flex;
  1118. flex-direction: column;
  1119. justify-content: center;
  1120. align-items: center;
  1121. padding-bottom: 65rpx;
  1122. img {
  1123. margin-top: 80rpx;
  1124. width: 600rpx;
  1125. height: 600rpx;
  1126. }
  1127. }
  1128. }
  1129. }
  1130. .popup_body {
  1131. width: 618rpx;
  1132. height: 687rpx;
  1133. border-radius: 21rpx;
  1134. background-color: #fff;
  1135. .body_header {
  1136. display: flex;
  1137. justify-content: center;
  1138. align-items: center;
  1139. position: relative;
  1140. height: 113rpx;
  1141. border-bottom: 1rpx solid #e6e6e6;
  1142. img {
  1143. width: 16rpx;
  1144. height: 16rpx;
  1145. }
  1146. .header_title {
  1147. margin: 0 10rpx;
  1148. font-size: 34rpx;
  1149. font-weight: bold;
  1150. color: #0f194d;
  1151. }
  1152. }
  1153. .body_content {
  1154. display: grid;
  1155. grid-template-columns: repeat(auto-fill, 160rpx);
  1156. gap: 28rpx;
  1157. box-sizing: border-box;
  1158. padding: 26rpx 40rpx 50rpx;
  1159. .content_box {
  1160. position: relative;
  1161. width: 160rpx;
  1162. height: 105rpx;
  1163. color: #fff;
  1164. border-radius: 10rpx;
  1165. img {
  1166. width: 160rpx;
  1167. height: 105rpx;
  1168. border-radius: 10rpx;
  1169. }
  1170. .box_town {
  1171. position: absolute;
  1172. top: 20rpx;
  1173. left: 0;
  1174. right: 0;
  1175. text-align: center;
  1176. font-size: 28rpx;
  1177. font-weight: bold;
  1178. }
  1179. .box_count {
  1180. position: absolute;
  1181. top: 62rpx;
  1182. left: 0;
  1183. right: 0;
  1184. text-align: center;
  1185. font-size: 18rpx;
  1186. }
  1187. }
  1188. }
  1189. }
  1190. .popupClass {
  1191. position: relative;
  1192. width: 481rpx;
  1193. height: 764rpx;
  1194. img {
  1195. width: 100%;
  1196. height: 665rpx;
  1197. }
  1198. .btn_go {
  1199. position: absolute;
  1200. top: 415rpx;
  1201. left: 40rpx;
  1202. width: 396rpx;
  1203. height: 76rpx;
  1204. border-radius: 43rpx;
  1205. }
  1206. .btn_text {
  1207. position: absolute;
  1208. top: 265rpx;
  1209. left: 40rpx;
  1210. display: flex;
  1211. justify-content: center;
  1212. align-items: center;
  1213. width: 400rpx;
  1214. height: 260rpx;
  1215. color: #0f194d;
  1216. font-size: 28rpx;
  1217. border-radius: 43rpx;
  1218. background-color: #fff;
  1219. }
  1220. .btn_close {
  1221. position: absolute;
  1222. top: 586rpx;
  1223. left: 212rpx;
  1224. width: 58rpx;
  1225. height: 58rpx;
  1226. border-radius: 50%;
  1227. }
  1228. }
  1229. }
  1230. </style>