home3.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  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">
  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="acpectFill" :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">
  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">
  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. text-align: center;
  737. background-color: #fff;
  738. .title {
  739. font-size: 34rpx;
  740. }
  741. }
  742. .content {
  743. z-index: 1;
  744. margin: -102rpx auto 0;
  745. width: 690rpx;
  746. border-radius: 12rpx 12rpx 0 0;
  747. background-color: #f2f2f2;
  748. .search {
  749. box-sizing: border-box;
  750. padding: 0 28rpx;
  751. width: 690rpx;
  752. height: 353rpx;
  753. border-radius: 12rpx;
  754. background-color: #fff;
  755. .search_town {
  756. display: flex;
  757. justify-content: space-between;
  758. align-items: center;
  759. height: 89rpx;
  760. color: #a6a6a6;
  761. font-size: 32rpx;
  762. border-bottom: 1rpx solid #e6e6e6;
  763. img {
  764. width: 40rpx;
  765. height: 40rpx;
  766. }
  767. }
  768. .active {
  769. font-weight: bold;
  770. color: #000;
  771. }
  772. .search_center {
  773. display: flex;
  774. align-items: center;
  775. height: 89rpx;
  776. color: #a6a6a6;
  777. font-size: 28rpx;
  778. img {
  779. width: 40rpx;
  780. height: 40rpx;
  781. }
  782. .center_input {
  783. margin-right: 12rpx;
  784. width: 250rpx;
  785. color: #000;
  786. font-weight: bold;
  787. }
  788. .img {
  789. margin-right: 12rpx;
  790. }
  791. .center_level {
  792. flex: 1;
  793. margin-left: 24rpx;
  794. font-weight: 400;
  795. }
  796. .active {
  797. font-weight: bold;
  798. color: #000;
  799. }
  800. .img2 {
  801. margin-left: auto;
  802. }
  803. }
  804. .search_btn {
  805. display: flex;
  806. justify-content: center;
  807. align-items: center;
  808. margin-top: 23rpx;
  809. width: 623rpx;
  810. height: 100rpx;
  811. border-radius: 57rpx;
  812. color: #fff;
  813. font-size: 32rpx;
  814. background: linear-gradient(90deg, #2697ef 0%, #5e35eb 100%);
  815. }
  816. }
  817. .swiper {
  818. margin: 20rpx auto 0;
  819. width: 690rpx;
  820. height: 214rpx;
  821. border-radius: 12rpx;
  822. background-color: #fff;
  823. .swiper_item {
  824. display: flex;
  825. justify-content: space-around;
  826. align-items: center;
  827. width: 100%;
  828. height: 100%;
  829. .item_box {
  830. position: relative;
  831. width: 195rpx;
  832. height: 128rpx;
  833. border-radius: 12rpx;
  834. color: #fff;
  835. img {
  836. width: 195rpx;
  837. height: 128rpx;
  838. border-radius: 12rpx;
  839. }
  840. .box_town {
  841. position: absolute;
  842. top: 30rpx;
  843. left: 0;
  844. right: 0;
  845. text-align: center;
  846. font-size: 28rpx;
  847. font-weight: bold;
  848. }
  849. .box_count {
  850. position: absolute;
  851. top: 75rpx;
  852. left: 0;
  853. right: 0;
  854. text-align: center;
  855. font-size: 18rpx;
  856. }
  857. }
  858. }
  859. }
  860. .body {
  861. margin: 0 auto;
  862. width: 690rpx;
  863. .body_top {
  864. display: flex;
  865. align-items: center;
  866. height: 89rpx;
  867. .circle {
  868. width: 30rpx;
  869. height: 30rpx;
  870. border-radius: 50%;
  871. background-color: #485bed;
  872. }
  873. .color {
  874. margin-left: -15rpx;
  875. opacity: 0.5;
  876. background-color: #fff;
  877. }
  878. .top_title {
  879. margin-left: 15rpx;
  880. font-size: 32rpx;
  881. font-weight: bold;
  882. }
  883. .top_msg {
  884. margin-top: 5rpx;
  885. margin-left: 12rpx;
  886. color: #666666;
  887. font-size: 24rpx;
  888. }
  889. .top_more {
  890. display: flex;
  891. align-items: center;
  892. margin-left: auto;
  893. color: #a6a6a6;
  894. font-size: 24rpx;
  895. img {
  896. width: 32rpx;
  897. height: 32rpx;
  898. }
  899. }
  900. }
  901. .body_strategy {
  902. display: flex;
  903. box-sizing: border-box;
  904. padding: 20rpx;
  905. margin-bottom: 10rpx;
  906. width: 690rpx;
  907. height: 235rpx;
  908. border-radius: 12rpx;
  909. background-color: #fff;
  910. .strategy_cover {
  911. width: 253rpx;
  912. height: 190rpx;
  913. border-radius: 7rpx;
  914. }
  915. .strategy_info {
  916. flex: 1;
  917. display: flex;
  918. flex-direction: column;
  919. justify-content: space-between;
  920. margin-left: 20rpx;
  921. width: 500rpx;
  922. height: 170rpx;
  923. font-size: 24rpx;
  924. color: #666666;
  925. overflow: hidden;
  926. .info_title {
  927. font-size: 32rpx;
  928. font-weight: bold;
  929. color: #000;
  930. overflow: hidden;
  931. text-overflow: ellipsis;
  932. white-space: nowrap;
  933. }
  934. .info_title2 {
  935. font-size: 32rpx;
  936. font-weight: bold;
  937. color: #000;
  938. display: -webkit-box;
  939. -webkit-box-orient: vertical;
  940. -webkit-line-clamp: 2;
  941. overflow: hidden;
  942. }
  943. .info_tags {
  944. display: flex;
  945. .tag {
  946. margin-right: 10rpx;
  947. box-sizing: border-box;
  948. padding: 0 12rpx;
  949. height: 35rpx;
  950. color: #1e7dfb;
  951. font-size: 20rpx;
  952. border-radius: 30rpx;
  953. border: 1rpx solid #1e7dfb;
  954. }
  955. }
  956. .info_desc {
  957. display: -webkit-box;
  958. -webkit-box-orient: vertical;
  959. -webkit-line-clamp: 2;
  960. overflow: hidden;
  961. }
  962. }
  963. }
  964. .body_list {
  965. display: flex;
  966. flex-wrap: wrap;
  967. justify-content: space-between;
  968. .list_item {
  969. width: 335rpx;
  970. box-sizing: border-box;
  971. margin-bottom: 20rpx;
  972. .item-img {
  973. width: 100%;
  974. height: 223rpx;
  975. border-radius: 18rpx 18rpx 0 0;
  976. box-sizing: border-box;
  977. }
  978. .descrition {
  979. display: flex;
  980. flex-direction: column;
  981. width: 100%;
  982. border-radius: 0 0 18rpx 18rpx;
  983. box-sizing: border-box;
  984. background: rgba(255, 255, 255, 1);
  985. margin-top: -10rpx;
  986. .title {
  987. font-size: 28rpx;
  988. font-weight: 600;
  989. padding: 20rpx 20rpx 10rpx;
  990. color: rgba(0, 0, 0, 1);
  991. overflow: hidden;
  992. white-space: nowrap;
  993. text-overflow: ellipsis;
  994. }
  995. .type {
  996. padding: 5rpx 20rpx;
  997. height: 40rpx;
  998. font-size: 24rpx;
  999. color: #a6a6a6;
  1000. }
  1001. .distance {
  1002. padding: 10rpx 20rpx;
  1003. font-size: 24rpx;
  1004. color: #a6a6a6;
  1005. }
  1006. .detail {
  1007. display: flex;
  1008. flex-direction: row;
  1009. justify-content: space-between;
  1010. align-items: center;
  1011. padding: 0 20rpx 20rpx 20rpx;
  1012. color: rgba(0, 0, 0, 1);
  1013. .img {
  1014. width: 40rpx;
  1015. height: 40rpx;
  1016. }
  1017. .price {
  1018. .txt1 {
  1019. font-size: 36rpx;
  1020. font-weight: 600;
  1021. color: rgba(255, 87, 51, 1);
  1022. }
  1023. .txt2 {
  1024. font-size: 24rpx;
  1025. font-weight: 400;
  1026. color: #a6a6a6;
  1027. }
  1028. }
  1029. .score {
  1030. font-size: 24rpx;
  1031. font-weight: 400;
  1032. padding-top: 10rpx;
  1033. color: rgba(166, 166, 166, 1);
  1034. }
  1035. }
  1036. }
  1037. }
  1038. .item_goods {
  1039. margin-bottom: 20rpx;
  1040. width: 335rpx;
  1041. height: 367rpx;
  1042. border-radius: 10rpx;
  1043. background-color: #fff;
  1044. overflow: hidden;
  1045. .goods_img {
  1046. width: 335rpx;
  1047. height: 223rpx;
  1048. border-bottom: 1rpx solid #eee;
  1049. }
  1050. .goods_name {
  1051. margin: 18rpx 5rpx 18rpx 30rpx;
  1052. font-size: 28rpx;
  1053. font-weight: bold;
  1054. overflow: hidden;
  1055. white-space: nowrap;
  1056. text-overflow: ellipsis;
  1057. }
  1058. .goods_detail {
  1059. display: flex;
  1060. flex-direction: row;
  1061. justify-content: space-between;
  1062. align-items: center;
  1063. padding: 0 20rpx 20rpx 20rpx;
  1064. color: rgba(0, 0, 0, 1);
  1065. .img {
  1066. width: 40rpx;
  1067. height: 40rpx;
  1068. }
  1069. .price {
  1070. .txt1 {
  1071. font-size: 36rpx;
  1072. font-weight: 600;
  1073. color: rgba(255, 87, 51, 1);
  1074. }
  1075. .txt2 {
  1076. font-size: 24rpx;
  1077. font-weight: 400;
  1078. color: #a6a6a6;
  1079. }
  1080. }
  1081. .score {
  1082. font-size: 24rpx;
  1083. font-weight: 400;
  1084. padding-top: 10rpx;
  1085. color: rgba(166, 166, 166, 1);
  1086. }
  1087. }
  1088. }
  1089. }
  1090. .body_news {
  1091. box-sizing: border-box;
  1092. padding: 25rpx;
  1093. width: 690rpx;
  1094. height: 566rpx;
  1095. border-radius: 12rpx;
  1096. background-color: #fff;
  1097. .news_title {
  1098. margin: 20rpx 0;
  1099. font-size: 32rpx;
  1100. font-weight: bold;
  1101. overflow: hidden;
  1102. text-overflow: ellipsis;
  1103. white-space: nowrap;
  1104. }
  1105. .news_desc {
  1106. font-size: 24rpx;
  1107. color: #666666;
  1108. display: -webkit-box;
  1109. -webkit-box-orient: vertical;
  1110. -webkit-line-clamp: 2;
  1111. overflow: hidden;
  1112. }
  1113. }
  1114. .noData {
  1115. display: flex;
  1116. flex-direction: column;
  1117. justify-content: center;
  1118. align-items: center;
  1119. padding-bottom: 65rpx;
  1120. img {
  1121. margin-top: 80rpx;
  1122. width: 600rpx;
  1123. height: 600rpx;
  1124. }
  1125. }
  1126. }
  1127. }
  1128. .popup_body {
  1129. width: 618rpx;
  1130. height: 687rpx;
  1131. border-radius: 21rpx;
  1132. background-color: #fff;
  1133. .body_header {
  1134. display: flex;
  1135. justify-content: center;
  1136. align-items: center;
  1137. position: relative;
  1138. height: 113rpx;
  1139. border-bottom: 1rpx solid #e6e6e6;
  1140. img {
  1141. width: 16rpx;
  1142. height: 16rpx;
  1143. }
  1144. .header_title {
  1145. margin: 0 10rpx;
  1146. font-size: 34rpx;
  1147. font-weight: bold;
  1148. color: #0f194d;
  1149. }
  1150. }
  1151. .body_content {
  1152. display: grid;
  1153. grid-template-columns: repeat(auto-fill, 160rpx);
  1154. gap: 28rpx;
  1155. box-sizing: border-box;
  1156. padding: 26rpx 40rpx 50rpx;
  1157. .content_box {
  1158. position: relative;
  1159. width: 160rpx;
  1160. height: 105rpx;
  1161. color: #fff;
  1162. border-radius: 10rpx;
  1163. img {
  1164. width: 160rpx;
  1165. height: 105rpx;
  1166. border-radius: 10rpx;
  1167. }
  1168. .box_town {
  1169. position: absolute;
  1170. top: 20rpx;
  1171. left: 0;
  1172. right: 0;
  1173. text-align: center;
  1174. font-size: 28rpx;
  1175. font-weight: bold;
  1176. }
  1177. .box_count {
  1178. position: absolute;
  1179. top: 62rpx;
  1180. left: 0;
  1181. right: 0;
  1182. text-align: center;
  1183. font-size: 18rpx;
  1184. }
  1185. }
  1186. }
  1187. }
  1188. .popupClass {
  1189. position: relative;
  1190. width: 481rpx;
  1191. height: 764rpx;
  1192. img {
  1193. width: 100%;
  1194. height: 665rpx;
  1195. }
  1196. .btn_go {
  1197. position: absolute;
  1198. top: 415rpx;
  1199. left: 40rpx;
  1200. width: 396rpx;
  1201. height: 76rpx;
  1202. border-radius: 43rpx;
  1203. }
  1204. .btn_text {
  1205. position: absolute;
  1206. top: 265rpx;
  1207. left: 40rpx;
  1208. display: flex;
  1209. justify-content: center;
  1210. align-items: center;
  1211. width: 400rpx;
  1212. height: 260rpx;
  1213. color: #0f194d;
  1214. font-size: 28rpx;
  1215. border-radius: 43rpx;
  1216. background-color: #fff;
  1217. }
  1218. .btn_close {
  1219. position: absolute;
  1220. top: 586rpx;
  1221. left: 212rpx;
  1222. width: 58rpx;
  1223. height: 58rpx;
  1224. border-radius: 50%;
  1225. }
  1226. }
  1227. }
  1228. </style>