index.vue 13 KB

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