home3.vue 32 KB

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