index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="settledMerchantList">
  3. <div class="search-box flex_r flex_jb flex_ac">
  4. <div class="district" @click="showAddress = !showAddress">
  5. <span>{{ LocationCity }}</span>
  6. <span class="iconfont">&#xe62f;</span>
  7. </div>
  8. <div class="search flex_r flex_jb flex_ac">
  9. <span class="iconfont">&#xe661;</span>
  10. <input v-model="Query.name" @confirm="navSearch" class="inp" placeholder="搜索你要的内容">
  11. <span class="search_btn" @click="navSearch">搜索</span>
  12. </div>
  13. <!-- <div class="scan-ico iconfont">&#xe8cf;</div> -->
  14. </div>
  15. <div class="list" v-if="list.length">
  16. <div class="li_item" v-for="(i,s) in list" :key="s" @click="goMerchant(i)">
  17. <div class="logo_img">
  18. <img :src="i.logo" alt="">
  19. </div>
  20. <div class="con_box">
  21. <div class="p1 ellipsis">{{ i.name }}</div>
  22. <div class="p2">{{ i.address }}</div>
  23. <div class="p3">{{ $h.Div(i.distance, 1000).toFixed(2) }} km</div>
  24. </div>
  25. </div>
  26. </div>
  27. <not-goods v-else textStr="暂无附近商家"></not-goods>
  28. <!-- 城市选择 -->
  29. <h-address @select="selectaddress" :visible.sync="showAddress" />
  30. </div>
  31. </template>
  32. <script>
  33. import hAddress from "@/components/h-address/address.vue"; //城市选择
  34. import notGoods from "@/components/not-goods/index.vue";
  35. import { post } from "@/request/api.js";
  36. export default {
  37. name: "settledMerchantList",
  38. props: {},
  39. components: { hAddress,notGoods },
  40. data() {
  41. return {
  42. list: [],
  43. Query: {
  44. latitude: "",
  45. longitude: "",
  46. page: 1,
  47. rows: 20,
  48. city: ""
  49. },
  50. pageData: {},
  51. LocationCity: "中国",
  52. showAddress: false,
  53. };
  54. },
  55. methods: {
  56. goMerchant(da) {
  57. this.setLS("merchant", da)
  58. this.goto("/pagesC/settledMerchant/merchant", { id: da.id })
  59. },
  60. // 获取当前位置
  61. async getLocation() {
  62. let adres = await uni.Location();
  63. this.Query.latitude = adres.lat;
  64. this.Query.longitude = adres.lng;
  65. this.getList();
  66. },
  67. getList(page) {
  68. if (page) {
  69. this.list = []
  70. this.Query.page = 1
  71. }
  72. post("v1/merchant/list", this.Query).then(res => {
  73. if (res.code == 0) {
  74. let da = res.data.data
  75. delete res.data.data
  76. this.pageData = res.data
  77. this.list = [...this.list, ...da]
  78. this.Query.page++
  79. }
  80. })
  81. },
  82. // 搜索
  83. navSearch() {
  84. if (!this.Query.name) delete this.Query.name
  85. this.getList(1);
  86. },
  87. // 获取当前城市
  88. async getToCity() {
  89. let { lat, lng } = await uni.Location();
  90. post("local/hotel/city", { longitude: lng, latitude: lat }).then(res => {
  91. if (res.code == 0) {
  92. let da = res.data
  93. // this.LocationCity = da.cityName;
  94. }
  95. })
  96. },
  97. // 选择城市
  98. selectaddress(da) {
  99. this.LocationCity = da.cityName;
  100. this.showAddress = false;
  101. this.Query.latitude = da.lat;
  102. this.Query.longitude = da.lng;
  103. this.Query.page = 1
  104. this.Query.city = da.cityName
  105. this.list = []
  106. this.getList()
  107. },
  108. },
  109. onLoad(da) {
  110. this.getToCity();
  111. },
  112. onShow() {
  113. this.getLocation();
  114. },
  115. mounted() {},
  116. onReachBottom() {
  117. if (this.Query.page < this.pageData.last_page) this.getList();
  118. },
  119. };
  120. </script>
  121. <style scoped lang='scss'>
  122. .search-box {
  123. width: 100%;
  124. padding: 30rpx 32rpx 0;
  125. .district {
  126. font-size: 32rpx;
  127. font-weight: 600;
  128. color: #333;
  129. .iconfont {
  130. font-size: 20rpx;
  131. margin-left: 12rpx;
  132. }
  133. }
  134. .search {
  135. border: 1px solid #D78C2E;
  136. height: 60rpx;
  137. line-height: 60rpx;
  138. padding-left: 20rpx;
  139. border-radius: 31rpx;
  140. .iconfont {
  141. font-size: 30rpx;
  142. }
  143. .inp {
  144. font-size: 25rpx;
  145. padding: 0 8rpx;
  146. width: 336rpx;
  147. }
  148. .search_btn {
  149. background-color: #D78C2E;
  150. height: 100%;
  151. color: #fff;
  152. border-radius: 31rpx;
  153. font-size: 28rpx;
  154. padding: 0 28rpx;
  155. }
  156. }
  157. .scan-ico {
  158. font-size: 55rpx;
  159. }
  160. }
  161. .list {
  162. padding: 30rpx;
  163. .li_item {
  164. margin-bottom: 20rpx;
  165. padding: 28rpx 32rpx;
  166. background-color: #fff;
  167. border-radius: 10rpx;
  168. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  169. }
  170. .li_title {
  171. font-size: 36rpx;
  172. margin-bottom: 16rpx;
  173. }
  174. .logo_img,
  175. .con_box {
  176. display: inline-block;
  177. vertical-align: top;
  178. }
  179. .logo_img {
  180. img {
  181. height: 180rpx;
  182. width: 180rpx;
  183. border-radius: 10rpx;
  184. }
  185. }
  186. .con_box {
  187. height: 180rpx;
  188. width: calc(100% - 180rpx - 28rpx);
  189. margin-left: 28rpx;
  190. position: relative;
  191. .p1 {
  192. font-size: 32rpx;
  193. font-weight: bold;
  194. color: #333;
  195. margin-bottom: 6rpx;
  196. }
  197. .p2 {
  198. font-size: 24rpx;
  199. color: #999;
  200. }
  201. .p3 {
  202. font-size: 24rpx;
  203. color: #666;
  204. position: absolute;
  205. right: 0;
  206. bottom: 0;
  207. }
  208. }
  209. }
  210. </style>