index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="settledMerchantList">
  3. <my-nav v-model="Query.name" @send="navSearch" />
  4. <view class="next-search-history" v-if="oldKeywordList.length && !Query.name">
  5. <view class="history-title">
  6. <view class="title-name"><text>搜索历史</text></view>
  7. <view class="history-delete" v-if="isDelete">
  8. <view class="delete-all" @click="deleteAll"><text>全部删除</text></view>
  9. <view class="delete-line"></view>
  10. <view class="delete-complete" @click="deleteHistory"><text>完成</text></view>
  11. </view>
  12. <view v-else class="icon-block" @click="deleteHistory"><text class="iconfont" style="font-size: 36rpx;">&#xe601;</text></view>
  13. </view>
  14. <view class="next-history-list">
  15. <view class="history-name" v-for="(item,index) in oldKeywordList" :key="index" @click="historyItemClick(item,index)">
  16. {{item}}
  17. <text v-if="isDelete" class="iconfont" style="font-size: 30rpx;">&#xe609;</text>
  18. </view>
  19. </view>
  20. <view class="history-title">
  21. <view class="title-name"><text>附近商家</text></view>
  22. </view>
  23. </view>
  24. <div class="list">
  25. <div class="li_item" v-for="(i,s) in list" :key="s" @click="goMerchant(i)">
  26. <!-- <div class="li_title">{{ i.name }}</div> -->
  27. <div class="logo_img">
  28. <img :src="i.logo" alt="">
  29. </div>
  30. <div class="con_box">
  31. <div class="p1 ellipsis">{{ i.name }}</div>
  32. <div class="p2">{{ i.address }}</div>
  33. <div class="p3">{{ $h.Div(i.distance, 1000).toFixed(2) }} km</div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import { post } from "@/request/api.js";
  41. import myNav from "@/pagesC/components/nav/nav"
  42. export default {
  43. name: "settledMerchantList",
  44. props: {},
  45. components: { myNav },
  46. data() {
  47. return {
  48. list: [],
  49. Query: {
  50. latitude: 113.9367,
  51. longitude: 22.5325,
  52. page: 1,
  53. rows: 20
  54. },
  55. pageData: {},
  56. oldKeywordList: [],
  57. isDelete: false,
  58. };
  59. },
  60. methods: {
  61. navSearch(va) {
  62. if(va){
  63. this.Query.name = va
  64. if (!this.oldKeywordList.includes(va)) this.oldKeywordList.push(va);
  65. this.setLS("oldKeywords", this.oldKeywordList)
  66. }
  67. else delete this.Query.name
  68. this.getList(1);
  69. },
  70. goMerchant(da){
  71. this.setLS("merchant",da)
  72. this.goto("/pagesC/settledMerchant/merchant",{id:da.id})
  73. },
  74. // 获取当前位置
  75. async getLocation() {
  76. let adres = await uni.Location();
  77. this.Query.longitude = adres.lng;
  78. this.Query.latitude = adres.lat;
  79. },
  80. getList(page) {
  81. if (page) {
  82. this.list = []
  83. this.Query.page = 1
  84. }
  85. post("v1/merchant/list", this.Query).then(res => {
  86. if (res.code == 0) {
  87. let da = res.data.data
  88. delete res.data.data
  89. this.pageData = res.data
  90. this.list = [...this.list, ...da]
  91. this.Query.page++
  92. }
  93. })
  94. },
  95. deleteHistory() {
  96. this.isDelete = !this.isDelete
  97. },
  98. deleteAll() {
  99. this.setLS("oldKeywords", [])
  100. this.oldKeywordList = []
  101. },
  102. historyItemClick(name, index) {
  103. if (this.isDelete) {
  104. this.oldKeywordList.splice(index, 1)
  105. this.setLS("oldKeywords", this.oldKeywordList)
  106. } else {
  107. this.Query.name = name
  108. this.getList(1);
  109. }
  110. },
  111. },
  112. onLoad(da) {
  113. this.getLocation();
  114. if(da.key) this.navSearch(da.key)
  115. else this.getList();
  116. this.oldKeywordList = this.getLS("oldKeywords") || [];
  117. },
  118. onShow() {},
  119. mounted() {},
  120. onReachBottom() {
  121. if (this.Query.page < this.pageData.last_page) this.getList();
  122. },
  123. };
  124. </script>
  125. <style scoped lang='scss'>
  126. .settledMerchantList {
  127. min-height: 100vh;
  128. background-color: #F5F5F5;
  129. }
  130. .next-search-history {
  131. padding: 0 20rpx;
  132. margin-top: 24rpx;
  133. .history-title {
  134. display: flex;
  135. align-items: center;
  136. justify-content: space-between;
  137. .title-name {
  138. font-size: 30rpx;
  139. color: #666666;
  140. font-weight: bold;
  141. margin-left: 12rpx;
  142. }
  143. .history-delete {
  144. height: auto;
  145. display: flex;
  146. align-items: center;
  147. justify-content: flex-end;
  148. .delete-all {
  149. font-size: 26rpx;
  150. color: #666666;
  151. }
  152. .delete-line {
  153. width: 1px;
  154. height: 20rpx;
  155. background-color: #999999;
  156. margin: 0 12rpx;
  157. }
  158. .delete-complete {
  159. font-size: 26rpx;
  160. color: #F71E1E;
  161. }
  162. }
  163. }
  164. .next-history-list {
  165. width: 100%;
  166. display: flex;
  167. align-items: flex-start;
  168. justify-content: flex-start;
  169. flex-wrap: wrap;
  170. padding: 12rpx 0;
  171. .history-name {
  172. background-color: #FFFFFF;
  173. border-radius: 25rpx;
  174. margin: 10rpx 12rpx;
  175. font-size: 26rpx;
  176. height: 48rpx;
  177. line-height: 48rpx;
  178. padding: 0 24rpx;
  179. color: #666666;
  180. overflow: hidden;
  181. text-overflow: ellipsis;
  182. display: -webkit-box;
  183. -webkit-box-orient: vertical;
  184. -webkit-line-clamp: 1;
  185. position: relative;
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. }
  190. }
  191. }
  192. .list {
  193. padding: 30rpx;
  194. .li_item {
  195. margin-bottom: 20rpx;
  196. padding: 28rpx 32rpx;
  197. background-color: #fff;
  198. border-radius: 10rpx;
  199. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  200. }
  201. .li_title {
  202. font-size: 36rpx;
  203. margin-bottom: 16rpx;
  204. }
  205. .logo_img,
  206. .con_box {
  207. display: inline-block;
  208. vertical-align: top;
  209. }
  210. .logo_img {
  211. img {
  212. height: 180rpx;
  213. width: 180rpx;
  214. border-radius: 10rpx;
  215. }
  216. }
  217. .con_box {
  218. height: 180rpx;
  219. width: calc(100% - 180rpx - 28rpx);
  220. margin-left: 28rpx;
  221. position: relative;
  222. .p1 {
  223. font-size: 32rpx;
  224. font-weight: bold;
  225. color: #333;
  226. margin-bottom: 6rpx;
  227. }
  228. .p2 {
  229. font-size: 24rpx;
  230. color: #999;
  231. }
  232. .p3 {
  233. font-size: 24rpx;
  234. color: #666;
  235. position: absolute;
  236. right: 0;
  237. bottom: 0;
  238. }
  239. }
  240. }
  241. </style>