addPlace.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="container" v-if="townList.length && hotelList.length">
  3. <view class="title">选择乡镇</view>
  4. <!-- 乡镇列表区域 -->
  5. <view class="town_list">
  6. <!-- 每一个乡镇 -->
  7. <view class="town_box" :class="{active:activeIndex ===index}" v-for="(item, index) in townList" :key="index"
  8. @click="handleChange(index)">{{ item.name }}</view>
  9. </view>
  10. <view class="title2">关联民宿</view>
  11. <!-- 民宿列表区域 -->
  12. <view class="hotel_list">
  13. <!-- 每一个民宿 -->
  14. <view class="hotel_box" v-for="item in hotelList" :key="item.id">
  15. <view class="box_radio">
  16. <radio style="transform:scale(1.2)" color="#096562" :checked="item.is_collect_hotel"
  17. @click="handleClickRadio(item)" /></label>
  18. </view>
  19. <view class="box_info">
  20. <img mode="aspectFill" :src="item.coverImg">
  21. <view class="info_detail">
  22. <view class="detail_name">
  23. {{item.hotel_name}}
  24. </view>
  25. <view class="detail_leave">
  26. {{item.hTypeName}}
  27. </view>
  28. <view class="detail_rate">
  29. {{item.score.toFixed(1)}}分
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 确定按钮区域 -->
  36. <view class="btn" @click="handleClickBtn">
  37. 确定
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. // 乡镇数组
  46. townList: [],
  47. // 民宿列表
  48. hotelList: [],
  49. // 当前高亮索引
  50. activeIndex: 0
  51. }
  52. },
  53. onLoad() {
  54. this.getTownList()
  55. this.getHotelList()
  56. },
  57. methods: {
  58. // 获取乡镇列表数组
  59. async getTownList() {
  60. const res = await this.$myRequest({
  61. url: '/mhotel/ahpgetResidueCount.action'
  62. })
  63. // console.log(res)
  64. if (res.code === 200) {
  65. this.townList = res.data
  66. }
  67. },
  68. // 获取民宿列表数组
  69. async getHotelList() {
  70. const res = await this.$myRequest({
  71. url: '/mhotel/ahphomePage.action',
  72. data: {
  73. page: 1,
  74. rows: 4,
  75. type: 3,
  76. userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
  77. }
  78. })
  79. // console.log(res)
  80. if (res.code === 200) {
  81. this.hotelList = res.data.pageList
  82. }
  83. },
  84. // 切换乡镇回调
  85. handleChange(index) {
  86. this.activeIndex = index
  87. },
  88. // 点击radio回调
  89. handleClickRadio(item) {
  90. item.is_collect_hotel = !item.is_collect_hotel
  91. },
  92. // 确定按钮点击回调
  93. handleClickBtn() {
  94. let temList = this.hotelList.filter(ele => ele.is_collect_hotel)
  95. if (temList.length) {
  96. uni.$emit('add', {
  97. list: temList
  98. })
  99. uni.navigateBack(1)
  100. } else {
  101. uni.showToast({
  102. title: "请关联至少一个民宿",
  103. icon: 'none',
  104. mask: true
  105. })
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .container {
  113. padding: 0 19rpx 80rpx;
  114. min-height: 100vh;
  115. background-color: #fff;
  116. .title {
  117. height: 90rpx;
  118. line-height: 90rpx;
  119. font-size: 32rpx;
  120. font-weight: bold;
  121. }
  122. .town_list {
  123. display: flex;
  124. flex-wrap: wrap;
  125. .town_box {
  126. display: flex;
  127. justify-content: center;
  128. align-items: center;
  129. padding: 0 39rpx;
  130. margin-right: 19rpx;
  131. margin-bottom: 24rpx;
  132. height: 65rpx;
  133. color: #808080;
  134. font-size: 28rpx;
  135. border-radius: 74rpx;
  136. background-color: #e6e6e6;
  137. }
  138. .active {
  139. color: #fff;
  140. background-color: #096562;
  141. }
  142. }
  143. .title2 {
  144. height: 80rpx;
  145. font-size: 32rpx;
  146. font-weight: bold;
  147. }
  148. .hotel_list {
  149. .hotel_box {
  150. display: flex;
  151. margin-bottom: 20rpx;
  152. width: 710rpx;
  153. height: 150rpx;
  154. .box_radio {
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. width: 95rpx;
  159. }
  160. .box_info {
  161. flex: 1;
  162. display: flex;
  163. background-color: #F2F2F2;
  164. overflow: hidden;
  165. img {
  166. width: 126rpx;
  167. height: 150rpx;
  168. }
  169. .info_detail {
  170. flex: 1;
  171. display: flex;
  172. flex-direction: column;
  173. justify-content: space-evenly;
  174. padding: 0 23rpx;
  175. overflow: hidden;
  176. .detail_name {
  177. font-size: 28rpx;
  178. font-weight: bold;
  179. overflow: hidden;
  180. text-overflow: ellipsis;
  181. white-space: nowrap;
  182. }
  183. .detail_leave {
  184. color: #808080;
  185. font-size: 24rpx;
  186. }
  187. .detail_rate {
  188. color: #FF5733;
  189. font-size: 24rpx;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. .btn {
  196. display: flex;
  197. justify-content: center;
  198. align-items: center;
  199. margin: 200rpx auto 0;
  200. width: 710rpx;
  201. height: 100rpx;
  202. color: #fff;
  203. font-size: 32rpx;
  204. border-radius: 64rpx;
  205. background-color: #096562;
  206. }
  207. }
  208. </style>