index.vue 7.3 KB

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