home3.vue 31 KB

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