index.vue 13 KB

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