index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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: 113.9367,
  45. longitude: 22.5325,
  46. page: 1,
  47. rows: 20
  48. },
  49. pageData: {},
  50. LocationCity: "深圳",
  51. showAddress: false,
  52. };
  53. },
  54. methods: {
  55. goMerchant(da) {
  56. this.setLS("merchant", da)
  57. this.goto("/pagesC/settledMerchant/merchant", { id: da.id })
  58. },
  59. // 获取当前位置
  60. async getLocation() {
  61. let adres = await uni.Location();
  62. this.Query.longitude = adres.lng;
  63. this.Query.latitude = adres.lat;
  64. },
  65. getList(page) {
  66. if (page) {
  67. this.list = []
  68. this.Query.page = 1
  69. }
  70. post("v1/merchant/list", this.Query).then(res => {
  71. if (res.code == 0) {
  72. let da = res.data.data
  73. delete res.data.data
  74. this.pageData = res.data
  75. this.list = [...this.list, ...da]
  76. this.Query.page++
  77. }
  78. })
  79. },
  80. // 搜索
  81. navSearch() {
  82. if (!this.Query.name) delete this.Query.name
  83. this.getList(1);
  84. },
  85. // 获取当前城市
  86. async getToCity() {
  87. let { lat, lng } = await uni.Location();
  88. post("local/hotel/city", { longitude: lng, latitude: lat }).then(res => {
  89. if (res.code == 0) {
  90. let da = res.data
  91. this.LocationCity = da.cityName;
  92. }
  93. })
  94. },
  95. // 选择城市
  96. selectaddress(da) {
  97. this.LocationCity = da.cityName;
  98. this.showAddress = false;
  99. },
  100. },
  101. onLoad(da) {
  102. this.getLocation();
  103. this.getList();
  104. this.getToCity();
  105. },
  106. onShow() {},
  107. mounted() {},
  108. onReachBottom() {
  109. if (this.Query.page < this.pageData.last_page) this.getList();
  110. },
  111. };
  112. </script>
  113. <style scoped lang='scss'>
  114. .search-box {
  115. width: 100%;
  116. padding: 30rpx 32rpx 0;
  117. .district {
  118. font-size: 32rpx;
  119. font-weight: 600;
  120. color: #333;
  121. .iconfont {
  122. font-size: 20rpx;
  123. margin-left: 12rpx;
  124. }
  125. }
  126. .search {
  127. border: 1px solid #D78C2E;
  128. height: 60rpx;
  129. line-height: 60rpx;
  130. padding-left: 20rpx;
  131. border-radius: 31rpx;
  132. .iconfont {
  133. font-size: 30rpx;
  134. }
  135. .inp {
  136. font-size: 25rpx;
  137. padding: 0 8rpx;
  138. width: 336rpx;
  139. }
  140. .search_btn {
  141. background-color: #D78C2E;
  142. height: 100%;
  143. color: #fff;
  144. border-radius: 31rpx;
  145. font-size: 28rpx;
  146. padding: 0 28rpx;
  147. }
  148. }
  149. .scan-ico {
  150. font-size: 55rpx;
  151. }
  152. }
  153. .list {
  154. padding: 30rpx;
  155. .li_item {
  156. margin-bottom: 20rpx;
  157. padding: 28rpx 32rpx;
  158. background-color: #fff;
  159. border-radius: 10rpx;
  160. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  161. }
  162. .li_title {
  163. font-size: 36rpx;
  164. margin-bottom: 16rpx;
  165. }
  166. .logo_img,
  167. .con_box {
  168. display: inline-block;
  169. vertical-align: top;
  170. }
  171. .logo_img {
  172. img {
  173. height: 180rpx;
  174. width: 180rpx;
  175. border-radius: 10rpx;
  176. }
  177. }
  178. .con_box {
  179. height: 180rpx;
  180. width: calc(100% - 180rpx - 28rpx);
  181. margin-left: 28rpx;
  182. position: relative;
  183. .p1 {
  184. font-size: 32rpx;
  185. font-weight: bold;
  186. color: #333;
  187. margin-bottom: 6rpx;
  188. }
  189. .p2 {
  190. font-size: 24rpx;
  191. color: #999;
  192. }
  193. .p3 {
  194. font-size: 24rpx;
  195. color: #666;
  196. position: absolute;
  197. right: 0;
  198. bottom: 0;
  199. }
  200. }
  201. }
  202. </style>