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" 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">
  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.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: '/cloud-mall/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. getLocation() {
  408. uni.getSetting({
  409. success: (res) => {
  410. if (!res.authSetting['scope.userLocation']) {
  411. uni.authorize({
  412. scope: 'scope.userLocation',
  413. success: (res) => {
  414. // 授权成功
  415. uni.getLocation({
  416. type: 'gcj02',
  417. success: (res) => {
  418. this.myLat = res.latitude
  419. this.myLng = res.longitude
  420. this.showdDistance = true
  421. this.getHotelList()
  422. }
  423. })
  424. },
  425. fail: () => {
  426. uni.showModal({
  427. content: '获取定位权限失败将会影响使用部分功能,是否去设置打开?',
  428. confirmText: '确认',
  429. cancelText: '取消',
  430. success: (res) => {
  431. if (res.confirm) {
  432. uni.openSetting({
  433. success: (res) => {
  434. console.log(res)
  435. this.getLocation()
  436. }
  437. })
  438. } else {
  439. this.showdDistance = false
  440. this.getHotelList()
  441. uni.showToast({
  442. title: '获取定位权限失败',
  443. icon: 'none'
  444. })
  445. }
  446. }
  447. })
  448. }
  449. })
  450. } else {
  451. uni.getLocation({
  452. type: 'gcj02',
  453. success: (res) => {
  454. this.myLat = res.latitude
  455. this.myLng = res.longitude
  456. this.showdDistance = true
  457. this.getHotelList()
  458. }
  459. })
  460. }
  461. },
  462. fail: () => {
  463. uni.showToast({
  464. title: '获取用户设置权限失败',
  465. icon: 'none',
  466. mask: true
  467. })
  468. }
  469. })
  470. },
  471. handleGoDetail(info) {
  472. let openid = uni.getStorageSync('openid')
  473. if (openid) {
  474. uni.navigateTo({
  475. url: `/pages/tweetDetail/tweetDetail?id=${info.id}&townId=${info.townId}`
  476. })
  477. } else {
  478. uni.showToast({
  479. title: '请先登录',
  480. icon: 'none',
  481. mask: true
  482. })
  483. setTimeout(() => {
  484. uni.navigateTo({
  485. url: '/pages/login/login'
  486. })
  487. }, 1500)
  488. }
  489. },
  490. // 获取民宿列表
  491. async getHotelList() {
  492. const res = await this.$myRequest({
  493. url: '/mhotel/ahphomePage.action',
  494. data: {
  495. // queryValue: this.keywords,
  496. page: this.page,
  497. rows: this.rows,
  498. type: 3,
  499. // hotel_township: this.placeList[this.placeIndex].id || '',
  500. userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
  501. }
  502. })
  503. // console.log(res)
  504. if (res.code === 200) {
  505. this.hotelList = [...this.hotelList, ...res.data.pageList]
  506. this.total = res.data.total
  507. // 如果定位成功则获取和民宿之间的距离
  508. if (this.showdDistance && this.hotelList.length) {
  509. this.hotelList.forEach((ele) => {
  510. let lat = ele.hpositionWens.split(',')[0]
  511. let lng = ele.hpositionWens.split(',')[1]
  512. ele.distance = this.calculateDistance(lat, lng)
  513. })
  514. }
  515. this.$refs.popup_sale.open()
  516. }
  517. },
  518. handleOpen() {
  519. this.$refs.popup.open()
  520. },
  521. // 获取乡镇
  522. async getResidueCount() {
  523. const res = await this.$myRequest({
  524. url: '/mhotel/ahpgetResidueCount.action'
  525. })
  526. // console.log(res)
  527. if (res.code === 200) {
  528. let temNum = 0
  529. res.data.forEach((ele) => {
  530. temNum += ele.residueNumber
  531. })
  532. res.data.unshift({
  533. name: '靖安县',
  534. residueNumber: temNum
  535. })
  536. this.popList = res.data
  537. this.townList = this.changeList(this.popList, 3)
  538. }
  539. },
  540. // 变成二维数组
  541. changeList(arr, num) {
  542. let newArr = []
  543. const total = Math.ceil(arr.length / num)
  544. for (let i = 0; i < total; i++) {
  545. let a = arr.slice(i * num, (i + 1) * num)
  546. newArr.push(a)
  547. }
  548. return newArr
  549. },
  550. // 弹窗点击选择乡镇地址回调
  551. handleChooseTown(name) {
  552. this.town = name
  553. this.$refs.popup.close()
  554. },
  555. handleChooseTown2(name) {
  556. // this.town = name
  557. uni.navigateTo({
  558. url: `/pages/home/home?town=${name}&keywords=${this.keywords}&level=${this.level}`
  559. })
  560. },
  561. handleChooseLv() {
  562. uni.showActionSheet({
  563. itemList: ['白金', '金宿', '银宿'],
  564. success: (res) => {
  565. if (res.tapIndex === 0) {
  566. this.level = '白金'
  567. } else if (res.tapIndex === 1) {
  568. this.level = '金宿'
  569. } else if (res.tapIndex === 2) {
  570. this.level = '银宿'
  571. }
  572. }
  573. })
  574. },
  575. handleSearch() {
  576. uni.navigateTo({
  577. url: `/pages/home/home?town=${this.town}&keywords=${this.keywords}&level=${this.level}`
  578. })
  579. },
  580. goPageDetail(item) {
  581. uni.navigateTo({
  582. url: `/pages/detail/detail?id=${item.id}&distance=${item.distance}`
  583. })
  584. },
  585. // 弹窗关闭按钮回调
  586. handleClose() {
  587. this.$refs.popup_sale.close()
  588. },
  589. // 立即前往按钮回调
  590. handleGo() {
  591. console.log(111)
  592. },
  593. // 计算两个点之间的距离
  594. calculateDistance(lat, lng) {
  595. let centerLat = lat
  596. let centerLng = lng
  597. let red1 = (this.myLat * Math.PI) / 180.0
  598. let red2 = (centerLat * Math.PI) / 180.0
  599. let a = red1 - red2
  600. let b = (this.myLng * Math.PI) / 180.0 - (centerLng * Math.PI) / 180.0
  601. let R = 6378137
  602. 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)))
  603. let res = (distance / 1000).toFixed(2) * 1
  604. return res
  605. },
  606. handleGoPage() {
  607. uni.switchTab({
  608. url: '/pages/community/community'
  609. })
  610. },
  611. handleGoNews(item) {
  612. let info = encodeURIComponent(JSON.stringify(item))
  613. uni.navigateTo({
  614. url: `/pages/newsDetail/newsDetail?info=${info}`
  615. })
  616. },
  617. handleGoNewsList() {
  618. uni.navigateTo({
  619. url: '/pages/newsList/newsList'
  620. })
  621. },
  622. htmlLoad(item) {
  623. let id = item.id + 'html'
  624. let ctx = this.$refs[id][0]
  625. let text = ctx.getText()
  626. let imgs = ctx.imgList[0]
  627. item.showHtml = false
  628. item.desc = text
  629. item.url = imgs
  630. },
  631. handleGoHome() {
  632. uni.navigateTo({
  633. url: '/pages/home/home'
  634. })
  635. },
  636. changeDot(e) {
  637. this.current = e.detail.current
  638. }
  639. }
  640. }
  641. </script>
  642. <style lang="scss" scoped>
  643. .container {
  644. display: flex;
  645. flex-direction: column;
  646. min-height: 100vh;
  647. overflow-y: auto;
  648. background-color: #f2f2f2;
  649. .header {
  650. position: relative;
  651. height: 505rpx;
  652. img {
  653. width: 100%;
  654. height: 100%;
  655. border-radius: 0 0 20rpx 20rpx;
  656. }
  657. .img {
  658. position: absolute;
  659. top: 135rpx;
  660. left: 61rpx;
  661. width: 160rpx;
  662. height: 40rpx;
  663. }
  664. .img2 {
  665. position: absolute;
  666. top: 193rpx;
  667. left: 38rpx;
  668. width: 268rpx;
  669. height: 88rpx;
  670. }
  671. .header_msg {
  672. position: absolute;
  673. top: 283rpx;
  674. left: 38rpx;
  675. display: flex;
  676. justify-content: center;
  677. align-items: center;
  678. width: 291rpx;
  679. height: 65rpx;
  680. font-size: 31rpx;
  681. color: #fff;
  682. border-radius: 16rpx;
  683. background: rgba(255, 255, 255, 0.2);
  684. }
  685. }
  686. .header2 {
  687. z-index: 999;
  688. position: fixed;
  689. top: 0;
  690. left: 0;
  691. right: 0;
  692. text-align: center;
  693. background-color: #fff;
  694. .title {
  695. font-size: 34rpx;
  696. }
  697. }
  698. .content {
  699. z-index: 1;
  700. margin: -102rpx auto 0;
  701. width: 690rpx;
  702. border-radius: 12rpx 12rpx 0 0;
  703. background-color: #f2f2f2;
  704. .search {
  705. box-sizing: border-box;
  706. padding: 0 28rpx;
  707. width: 690rpx;
  708. height: 353rpx;
  709. border-radius: 12rpx;
  710. background-color: #fff;
  711. .search_town {
  712. display: flex;
  713. justify-content: space-between;
  714. align-items: center;
  715. height: 89rpx;
  716. color: #a6a6a6;
  717. font-size: 32rpx;
  718. border-bottom: 1rpx solid #e6e6e6;
  719. img {
  720. width: 40rpx;
  721. height: 40rpx;
  722. }
  723. }
  724. .active {
  725. font-weight: bold;
  726. color: #000;
  727. }
  728. .search_center {
  729. display: flex;
  730. align-items: center;
  731. height: 89rpx;
  732. color: #a6a6a6;
  733. font-size: 28rpx;
  734. img {
  735. width: 40rpx;
  736. height: 40rpx;
  737. }
  738. .center_input {
  739. margin-right: 12rpx;
  740. width: 250rpx;
  741. color: #000;
  742. font-weight: bold;
  743. }
  744. .img {
  745. margin-right: 12rpx;
  746. }
  747. .center_level {
  748. flex: 1;
  749. margin-left: 24rpx;
  750. font-weight: 400;
  751. }
  752. .active {
  753. font-weight: bold;
  754. color: #000;
  755. }
  756. .img2 {
  757. margin-left: auto;
  758. }
  759. }
  760. .search_btn {
  761. display: flex;
  762. justify-content: center;
  763. align-items: center;
  764. margin-top: 23rpx;
  765. width: 623rpx;
  766. height: 100rpx;
  767. border-radius: 57rpx;
  768. color: #fff;
  769. font-size: 32rpx;
  770. background: linear-gradient(90deg, #2697ef 0%, #5e35eb 100%);
  771. }
  772. }
  773. .swiper {
  774. margin: 20rpx auto 0;
  775. width: 690rpx;
  776. height: 214rpx;
  777. border-radius: 12rpx;
  778. background-color: #fff;
  779. .swiper_item {
  780. display: flex;
  781. justify-content: space-around;
  782. align-items: center;
  783. width: 100%;
  784. height: 100%;
  785. .item_box {
  786. position: relative;
  787. width: 195rpx;
  788. height: 128rpx;
  789. border-radius: 12rpx;
  790. color: #fff;
  791. img {
  792. width: 195rpx;
  793. height: 128rpx;
  794. border-radius: 12rpx;
  795. }
  796. .box_town {
  797. position: absolute;
  798. top: 30rpx;
  799. left: 0;
  800. right: 0;
  801. text-align: center;
  802. font-size: 28rpx;
  803. font-weight: bold;
  804. }
  805. .box_count {
  806. position: absolute;
  807. top: 75rpx;
  808. left: 0;
  809. right: 0;
  810. text-align: center;
  811. font-size: 18rpx;
  812. }
  813. }
  814. }
  815. }
  816. .body {
  817. margin: 0 auto;
  818. width: 690rpx;
  819. .body_top {
  820. display: flex;
  821. align-items: center;
  822. height: 89rpx;
  823. .circle {
  824. width: 30rpx;
  825. height: 30rpx;
  826. border-radius: 50%;
  827. background-color: #485bed;
  828. }
  829. .color {
  830. margin-left: -15rpx;
  831. opacity: 0.5;
  832. background-color: #fff;
  833. }
  834. .top_title {
  835. margin-left: 15rpx;
  836. font-size: 32rpx;
  837. font-weight: bold;
  838. }
  839. .top_msg {
  840. margin-top: 5rpx;
  841. margin-left: 12rpx;
  842. color: #666666;
  843. font-size: 24rpx;
  844. }
  845. .top_more {
  846. display: flex;
  847. align-items: center;
  848. margin-left: auto;
  849. color: #a6a6a6;
  850. font-size: 24rpx;
  851. img {
  852. width: 32rpx;
  853. height: 32rpx;
  854. }
  855. }
  856. }
  857. .body_strategy {
  858. display: flex;
  859. box-sizing: border-box;
  860. padding: 20rpx;
  861. margin-bottom: 10rpx;
  862. width: 690rpx;
  863. height: 235rpx;
  864. border-radius: 12rpx;
  865. background-color: #fff;
  866. .strategy_cover {
  867. width: 253rpx;
  868. height: 190rpx;
  869. border-radius: 7rpx;
  870. }
  871. .strategy_info {
  872. flex: 1;
  873. display: flex;
  874. flex-direction: column;
  875. justify-content: space-between;
  876. margin-left: 20rpx;
  877. width: 500rpx;
  878. height: 170rpx;
  879. font-size: 24rpx;
  880. color: #666666;
  881. overflow: hidden;
  882. .info_title {
  883. font-size: 32rpx;
  884. font-weight: bold;
  885. color: #000;
  886. overflow: hidden;
  887. text-overflow: ellipsis;
  888. white-space: nowrap;
  889. }
  890. .info_title2 {
  891. font-size: 32rpx;
  892. font-weight: bold;
  893. color: #000;
  894. display: -webkit-box;
  895. -webkit-box-orient: vertical;
  896. -webkit-line-clamp: 2;
  897. overflow: hidden;
  898. }
  899. .info_tags {
  900. display: flex;
  901. .tag {
  902. margin-right: 10rpx;
  903. box-sizing: border-box;
  904. padding: 0 12rpx;
  905. height: 35rpx;
  906. color: #1e7dfb;
  907. font-size: 20rpx;
  908. border-radius: 30rpx;
  909. border: 1rpx solid #1e7dfb;
  910. }
  911. }
  912. .info_desc {
  913. display: -webkit-box;
  914. -webkit-box-orient: vertical;
  915. -webkit-line-clamp: 2;
  916. overflow: hidden;
  917. }
  918. }
  919. }
  920. .body_list {
  921. display: flex;
  922. flex-wrap: wrap;
  923. justify-content: space-between;
  924. .list_item {
  925. width: 335rpx;
  926. box-sizing: border-box;
  927. margin-bottom: 20rpx;
  928. .item-img {
  929. width: 100%;
  930. height: 223rpx;
  931. border-radius: 18rpx 18rpx 0 0;
  932. box-sizing: border-box;
  933. }
  934. .descrition {
  935. display: flex;
  936. flex-direction: column;
  937. width: 100%;
  938. border-radius: 0 0 18rpx 18rpx;
  939. box-sizing: border-box;
  940. background: rgba(255, 255, 255, 1);
  941. margin-top: -10rpx;
  942. .title {
  943. font-size: 28rpx;
  944. font-weight: 600;
  945. padding: 20rpx 20rpx 10rpx;
  946. color: rgba(0, 0, 0, 1);
  947. overflow: hidden;
  948. white-space: nowrap;
  949. text-overflow: ellipsis;
  950. }
  951. .type {
  952. padding: 5rpx 20rpx;
  953. height: 40rpx;
  954. font-size: 24rpx;
  955. color: #a6a6a6;
  956. }
  957. .distance {
  958. padding: 10rpx 20rpx;
  959. font-size: 24rpx;
  960. color: #a6a6a6;
  961. }
  962. .detail {
  963. display: flex;
  964. flex-direction: row;
  965. justify-content: space-between;
  966. align-items: center;
  967. padding: 0 20rpx 20rpx 20rpx;
  968. color: rgba(0, 0, 0, 1);
  969. .img {
  970. width: 40rpx;
  971. height: 40rpx;
  972. }
  973. .price {
  974. .txt1 {
  975. font-size: 36rpx;
  976. font-weight: 600;
  977. color: rgba(255, 87, 51, 1);
  978. }
  979. .txt2 {
  980. font-size: 24rpx;
  981. font-weight: 400;
  982. color: #a6a6a6;
  983. }
  984. }
  985. .score {
  986. font-size: 24rpx;
  987. font-weight: 400;
  988. padding-top: 10rpx;
  989. color: rgba(166, 166, 166, 1);
  990. }
  991. }
  992. }
  993. }
  994. .item_goods {
  995. margin-bottom: 20rpx;
  996. width: 335rpx;
  997. height: 367rpx;
  998. border-radius: 10rpx;
  999. background-color: #fff;
  1000. overflow: hidden;
  1001. .goods_img {
  1002. width: 335rpx;
  1003. height: 223rpx;
  1004. border-bottom: 1rpx solid #eee;
  1005. }
  1006. .goods_name {
  1007. margin: 18rpx 5rpx 18rpx 30rpx;
  1008. font-size: 28rpx;
  1009. font-weight: bold;
  1010. overflow: hidden;
  1011. white-space: nowrap;
  1012. text-overflow: ellipsis;
  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>