index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <div class="page">
  3. <van-list
  4. v-model="isLoadingMore"
  5. :finished="finished"
  6. :immediate-check="false"
  7. :finished-text="total ? '没有更多了' : ''"
  8. @load="onLoadMore"
  9. >
  10. <div class="page-top"></div>
  11. <div class="page-content">
  12. <!-- 搜索区域 -->
  13. <div class="search flex justify-center">
  14. <input
  15. type="text"
  16. placeholder="搜索店铺"
  17. v-model="listQuery.clubName"
  18. @keyup.enter="onSearch"
  19. />
  20. </div>
  21. <!-- 地区筛选 -->
  22. <div class="city">
  23. <LdmCity
  24. @change="onCityChange"
  25. :options="cityList"
  26. labelName="name"
  27. valueName="id"
  28. ></LdmCity>
  29. </div>
  30. <!-- 标题 -->
  31. <div class="title">距你最近...</div>
  32. <!-- 机构列表 -->
  33. <div class="list">
  34. <div
  35. class="section flex items-center"
  36. v-for="item in list"
  37. :key="item.authId"
  38. @click="toDetail(item)"
  39. >
  40. <img class="cover" :src="item.logo || drawLogo(item.clubName)" />
  41. <div class="info">
  42. <div class="name" v-text="item.clubName"></div>
  43. <div class="line"></div>
  44. <div class="mobile">{{ item.mobile || '未知' }}</div>
  45. <div class="address">
  46. {{ formatAddress(item.area, item.address) }}
  47. </div>
  48. <div
  49. class="distance"
  50. v-text="item.distance + 'km'"
  51. v-if="item.distance && item.distance !== 99999"
  52. ></div>
  53. </div>
  54. </div>
  55. </div>
  56. <!-- 列表为空 -->
  57. <LdmEmpty v-if="!total && !isRequest" name="ldm-empty.png"></LdmEmpty>
  58. </div>
  59. </van-list>
  60. </div>
  61. </template>
  62. <script>
  63. import { mapGetters } from 'vuex'
  64. import { loactionSelf } from '@/utils/map-utils'
  65. import { debounce, drawLogo } from '@/utils'
  66. export default {
  67. layout: 'app-ldm',
  68. data() {
  69. return {
  70. isLoadingMore: true,
  71. finished: false,
  72. isRequest: true,
  73. list: [],
  74. listQuery: {
  75. authUserId: '',
  76. lngAndLat: '',
  77. clubName: '',
  78. provinceId: '',
  79. cityId: '',
  80. townId: '',
  81. pageNum: 1,
  82. pageSize: 4,
  83. },
  84. total: 0,
  85. cityList: [],
  86. }
  87. },
  88. computed: {
  89. ...mapGetters(['supplierInfo', 'authUserId']),
  90. emptyList() {
  91. return 3 - (this.list.length % 3)
  92. },
  93. },
  94. mounted() {
  95. this.initData()
  96. this.fetchCityList()
  97. },
  98. methods: {
  99. // 绘制logo的方法
  100. drawLogo,
  101. // 查看详情
  102. toDetail(item) {
  103. localStorage.setItem('clubInfo', JSON.stringify(item))
  104. const authUserId = this.$store.getters.authUserId
  105. this.$router.push(
  106. `/${authUserId}/ldm/approve/club/detail?id=${item.authId}`
  107. )
  108. },
  109. // 初始化页面数据
  110. async initData() {
  111. // 自定义加载图标
  112. this.$toast.loading({
  113. message: '正在获取您附近的机构...',
  114. duration: 0,
  115. })
  116. // 获取定位信息 百度坐标转高德坐标
  117. try {
  118. const location = await loactionSelf()
  119. const result = await this.$http.api.assistant({
  120. key: '1bcc97330f6cf517e8dd9d5278957e67',
  121. locations: `${location.point.lng},${location.point.lat}`,
  122. coordsys: 'baidu',
  123. output: 'JSON',
  124. })
  125. const res = await result.json()
  126. this.listQuery.lngAndLat = res.locations
  127. } catch (error) {
  128. this.$toast.clear()
  129. this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
  130. this.isRequest = false
  131. }
  132. this.listQuery.authUserId = this.authUserId
  133. // 获取机构列表
  134. this.fetchList()
  135. },
  136. // 获取机构列表
  137. fetchList: debounce(async function () {
  138. try {
  139. this.isLoadingMore = true
  140. const res = await this.$http.api.getAuthClubList(this.listQuery)
  141. this.total = res.data.total
  142. this.list = [...this.list, ...res.data.list]
  143. this.finished = !res.data.hasNextPage
  144. } catch (error) {
  145. console.log(error)
  146. } finally {
  147. this.$toast.clear()
  148. this.isRequest = false
  149. this.isLoadingMore = false
  150. }
  151. }, 400),
  152. // 获取地址列表
  153. fetchCityList() {
  154. this.$http.api.fetchAllCityList().then((res) => {
  155. this.cityList = res.data
  156. })
  157. },
  158. // 城市变化
  159. onCityChange(selectValue) {
  160. this.listQuery.provinceId = ''
  161. this.listQuery.cityId = ''
  162. this.listQuery.townId = ''
  163. selectValue.map((item, index) => {
  164. if (index === 0) {
  165. this.listQuery.provinceId = item.id
  166. } else if (index === 1) {
  167. this.listQuery.cityId = item.id
  168. } else {
  169. this.listQuery.townId = item.id
  170. }
  171. })
  172. this.listQuery.pageNum = 1
  173. this.list = []
  174. this.fetchList()
  175. },
  176. // 搜索
  177. onSearch() {
  178. this.listQuery.pageNum = 1
  179. this.list = []
  180. this.fetchList()
  181. },
  182. // 页码变化
  183. onPagiantionChange(index) {},
  184. // 格式化地址
  185. formatAddress(a1, a2) {
  186. let resutl = ''
  187. if (typeof a1 === 'string') {
  188. resutl += a1
  189. }
  190. if (typeof a2 === 'string') {
  191. resutl += a2
  192. }
  193. return resutl || '未知'
  194. },
  195. // 加载更多
  196. onLoadMore() {
  197. if (this.isRequest) return
  198. this.listQuery.pageNum += 1
  199. this.fetchList()
  200. },
  201. },
  202. beforeDestroy() {
  203. this.$toast.clear()
  204. },
  205. }
  206. </script>
  207. <style scoped lang="scss">
  208. @media screen and (min-width: 768px) {
  209. .page-top {
  210. height: 596px;
  211. background: url(https://static.caimei365.com/www/authentic/pc/ldm-bg-club.png)
  212. no-repeat center;
  213. background-size: auto 596px;
  214. }
  215. .page-content {
  216. width: 836px;
  217. margin: 0 auto;
  218. overflow: hidden;
  219. .city {
  220. position: relative;
  221. z-index: 99;
  222. }
  223. .search {
  224. width: 836px;
  225. position: relative;
  226. margin: 69px auto 40px;
  227. input {
  228. display: block;
  229. width: 100%;
  230. height: 56px;
  231. border: 0.1vw solid #000000;
  232. box-sizing: border-box;
  233. padding-left: 80px;
  234. font-size: 24px;
  235. }
  236. &::after {
  237. position: absolute;
  238. left: 33px;
  239. top: 50%;
  240. transform: translateY(-50%);
  241. content: '';
  242. display: block;
  243. width: 37px;
  244. height: 37px;
  245. background: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-search.png)
  246. no-repeat center;
  247. background-size: 37px;
  248. }
  249. }
  250. .title {
  251. text-align: right;
  252. font-size: 22px;
  253. color: #000;
  254. }
  255. .list {
  256. padding-top: 24px;
  257. display: flex;
  258. align-items: center;
  259. justify-content: space-between;
  260. flex-wrap: wrap;
  261. .section {
  262. width: 409px;
  263. background: #f1f1f1;
  264. border-radius: 20px;
  265. padding: 16px;
  266. box-sizing: border-box;
  267. margin-bottom: 20px;
  268. cursor: pointer;
  269. .cover {
  270. width: 92px;
  271. height: 92px;
  272. border-radius: 17px;
  273. }
  274. .info {
  275. position: relative;
  276. width: 263px;
  277. margin-left: 23px;
  278. .name {
  279. width: 200px;
  280. position: relative;
  281. font-size: 15px;
  282. color: #000;
  283. font-weight: bold;
  284. text-overflow: ellipsis;
  285. white-space: nowrap;
  286. overflow: hidden;
  287. padding-left: 20px;
  288. line-height: 20px;
  289. &::after {
  290. content: '';
  291. display: block;
  292. width: 20px;
  293. height: 20px;
  294. position: absolute;
  295. left: 0;
  296. top: 50%;
  297. transform: translateY(-50%);
  298. background-size: 14px 14px;
  299. background-repeat: no-repeat;
  300. background-position: left center;
  301. }
  302. }
  303. .name {
  304. &::after {
  305. background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-store.png);
  306. }
  307. }
  308. .line {
  309. height: 1px;
  310. margin: 14px 0;
  311. background: rgba(0, 0, 0, 0.169);
  312. }
  313. .mobile,
  314. .address {
  315. position: relative;
  316. font-size: 12px;
  317. color: #000000;
  318. padding-left: 20px;
  319. line-height: 20px;
  320. text-overflow: ellipsis;
  321. white-space: nowrap;
  322. overflow: hidden;
  323. &::after {
  324. content: '';
  325. display: block;
  326. width: 20px;
  327. height: 20px;
  328. position: absolute;
  329. left: 0;
  330. top: 50%;
  331. transform: translateY(-50%);
  332. background-size: 14px 14px;
  333. background-repeat: no-repeat;
  334. background-position: left center;
  335. }
  336. }
  337. .mobile {
  338. &::after {
  339. background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-contact.png);
  340. }
  341. }
  342. .address {
  343. &::after {
  344. background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-address.png);
  345. }
  346. }
  347. .distance {
  348. position: absolute;
  349. font-size: 12px;
  350. color: #404040;
  351. top: 0.2vw;
  352. right: 0;
  353. }
  354. }
  355. }
  356. }
  357. }
  358. }
  359. @media screen and (max-width: 768px) {
  360. .page-top {
  361. height: 59.6vw;
  362. background: url(https://static.caimei365.com/www/authentic/h5/ldm-bg-club.png);
  363. background-size: auto 59.6vw;
  364. }
  365. .page-content {
  366. overflow: hidden;
  367. .search {
  368. width: 86vw;
  369. position: relative;
  370. margin: 7.6vw auto 5.6vw;
  371. input {
  372. display: block;
  373. width: 100%;
  374. height: 8vw;
  375. border: 0.1vw solid #000000;
  376. box-sizing: border-box;
  377. padding-left: 10.5vw;
  378. }
  379. &::after {
  380. position: absolute;
  381. left: 2.9vw;
  382. top: 50%;
  383. transform: translateY(-50%);
  384. content: '';
  385. display: block;
  386. width: 5.4vw;
  387. height: 5.4vw;
  388. background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-search.png)
  389. no-repeat center;
  390. background-size: 5.4vw;
  391. }
  392. }
  393. .title {
  394. text-align: right;
  395. padding-right: 6.6vw;
  396. font-size: 3.5vw;
  397. color: #000;
  398. }
  399. .list {
  400. display: flex;
  401. flex-direction: column;
  402. align-items: center;
  403. .section {
  404. width: 95.1vw;
  405. background: #f1f1f1;
  406. border-radius: 2vw;
  407. padding: 3.2vw;
  408. box-sizing: border-box;
  409. margin-top: 5.7vw;
  410. .cover {
  411. width: 21.5vw;
  412. height: 21.5vw;
  413. border-radius: 1.7vw;
  414. }
  415. .info {
  416. position: relative;
  417. width: 61.3vw;
  418. margin-left: 5.8vw;
  419. .name {
  420. width: 46vw;
  421. position: relative;
  422. font-size: 3.5vw;
  423. color: #000;
  424. font-weight: bold;
  425. text-overflow: ellipsis;
  426. white-space: nowrap;
  427. overflow: hidden;
  428. padding-left: 5vw;
  429. line-height: 5vw;
  430. &::after {
  431. content: '';
  432. display: block;
  433. width: 4vw;
  434. height: 4vw;
  435. position: absolute;
  436. left: 0;
  437. top: 50%;
  438. transform: translateY(-50%);
  439. background-size: 3.6vw 3.6vw;
  440. background-repeat: no-repeat;
  441. }
  442. }
  443. .name {
  444. &::after {
  445. background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-store.png);
  446. }
  447. }
  448. .line {
  449. height: 0.1vw;
  450. margin: 2.8vw 0;
  451. background: rgba(0, 0, 0, 0.169);
  452. }
  453. .mobile,
  454. .address {
  455. position: relative;
  456. font-size: 3vw;
  457. color: #000000;
  458. padding-left: 5vw;
  459. line-height: 5vw;
  460. text-overflow: ellipsis;
  461. white-space: nowrap;
  462. overflow: hidden;
  463. &::after {
  464. content: '';
  465. display: block;
  466. width: 4vw;
  467. height: 4vw;
  468. position: absolute;
  469. left: 0;
  470. top: 50%;
  471. transform: translateY(-50%);
  472. background-size: 3.6vw 3.6vw;
  473. background-repeat: no-repeat;
  474. }
  475. }
  476. .mobile {
  477. &::after {
  478. background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact.png);
  479. }
  480. }
  481. .address {
  482. &::after {
  483. background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-address.png);
  484. }
  485. }
  486. .distance {
  487. position: absolute;
  488. font-size: 3vw;
  489. color: #404040;
  490. top: 0.2vw;
  491. right: 0;
  492. }
  493. }
  494. }
  495. }
  496. }
  497. }
  498. </style>