index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="page">
  3. <div class="page-top flex flex-col justify-center items-center">
  4. <img class="logo" :src="supplierInfo.logo" />
  5. <div class="mt-2 name">
  6. <span v-text="supplierInfo.shopName"></span>
  7. <span>官方授权机构</span>
  8. </div>
  9. </div>
  10. <div class="page-content">
  11. <!-- 搜索区域 -->
  12. <div class="search">
  13. <simple-search v-model="listQuery.clubName" @search="onSearch" />
  14. </div>
  15. <!-- 地区选择 -->
  16. <div class="city">
  17. <SimpleCity
  18. @change="onCityChange"
  19. :options="cityList"
  20. labelName="name"
  21. valueName="id"
  22. ></SimpleCity>
  23. </div>
  24. <!-- 标题 -->
  25. <div class="title flex justify-between px-4 pt-8 pb-8 md:px-0">
  26. <div>距您最近...</div>
  27. <div>共<span v-text="total"></span>家机构</div>
  28. </div>
  29. <!-- 列表 -->
  30. <div class="list">
  31. <template v-for="item in list">
  32. <div
  33. class="section flex justify-between mb-4"
  34. :key="item.authId"
  35. @click="toDetail(item)"
  36. >
  37. <img class="cover" :src="item.logo || drawLogo(item.clubName)" />
  38. <div class="info">
  39. <div class="name" v-text="item.clubName"></div>
  40. <div class="mobile">{{ item.mobile || '未知' }}</div>
  41. <div class="address">
  42. {{ formatAddress(item.area, item.address) }}
  43. </div>
  44. <div
  45. class="distance"
  46. v-text="item.distance + 'km'"
  47. v-if="item.distance && item.distance !== 99999"
  48. ></div>
  49. </div>
  50. </div>
  51. </template>
  52. <div class="empty" v-for="i in emptyList" :key="i"></div>
  53. </div>
  54. <!-- 列表为空 -->
  55. <SimpleEmpty
  56. v-if="!total && !isRequest"
  57. description="敬请期待~"
  58. ></SimpleEmpty>
  59. <!-- 页码 -->
  60. <SimplePagination
  61. v-if="total > listQuery.pageSize"
  62. :total="total"
  63. :pageItems="listQuery.pageSize"
  64. @change="onPagiantionChange"
  65. ></SimplePagination>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import { mapGetters } from 'vuex'
  71. import { loactionSelf } from '@/utils/map-utils'
  72. import { drawLogo } from '@/utils'
  73. export default {
  74. layout: 'app',
  75. data() {
  76. return {
  77. isRequest: true,
  78. list: [],
  79. listQuery: {
  80. appId: '',
  81. lngAndLat: '',
  82. clubName: '',
  83. provinceId: '',
  84. cityId: '',
  85. townId: '',
  86. pageNum: 1,
  87. pageSize: 10,
  88. },
  89. total: 0,
  90. cityList: [],
  91. }
  92. },
  93. computed: {
  94. ...mapGetters(['supplierInfo', 'appId']),
  95. emptyList() {
  96. return 3 - (this.list.length % 3)
  97. },
  98. },
  99. mounted() {
  100. this.initData()
  101. this.fetchCityList()
  102. },
  103. methods: {
  104. // 绘制logo的方法
  105. drawLogo,
  106. // 查看详情
  107. toDetail(item) {
  108. localStorage.setItem('clubInfo', JSON.stringify(item))
  109. this.$router.push('/ph/approve/club/detail')
  110. },
  111. // 初始化页面数据
  112. async initData() {
  113. // 自定义加载图标
  114. this.$toast.loading({
  115. message: '正在获取您附近的机构...',
  116. duration: 0,
  117. })
  118. // 获取定位信息 百度坐标转高德坐标
  119. try {
  120. const location = await loactionSelf()
  121. const result = await this.$http.api.assistant({
  122. key: '1bcc97330f6cf517e8dd9d5278957e67',
  123. locations: `${location.point.lng},${location.point.lat}`,
  124. coordsys: 'baidu',
  125. output: 'JSON',
  126. })
  127. const res = await result.json()
  128. this.listQuery.lngAndLat = res.locations
  129. } catch (error) {
  130. this.$toast.clear()
  131. this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
  132. this.isRequest = false
  133. }
  134. this.listQuery.appId = this.appId
  135. // 获取机构列表
  136. this.fetchList()
  137. },
  138. // 获取机构列表
  139. async fetchList() {
  140. try {
  141. const res = await this.$http.api.getAuthClubList(this.listQuery)
  142. this.total = res.data.total
  143. this.list = res.data.list
  144. } catch (error) {
  145. console.log(error)
  146. } finally {
  147. this.$toast.clear()
  148. this.isRequest = false
  149. }
  150. },
  151. // 获取地址列表
  152. fetchCityList() {
  153. this.$http.api.fetchAllCityList().then((res) => {
  154. this.cityList = res.data
  155. })
  156. },
  157. // 城市变化
  158. onCityChange(selectValue) {
  159. this.listQuery.provinceId = ''
  160. this.listQuery.cityId = ''
  161. this.listQuery.townId = ''
  162. selectValue.map((item, index) => {
  163. if (index === 0) {
  164. this.listQuery.provinceId = item.id
  165. } else if (index === 1) {
  166. this.listQuery.cityId = item.id
  167. } else {
  168. this.listQuery.townId = item.id
  169. }
  170. })
  171. this.listQuery.pageNum = 1
  172. this.fetchList()
  173. },
  174. // 搜索
  175. onSearch() {
  176. this.listQuery.pageNum = 1
  177. this.fetchList()
  178. },
  179. // 页码变化
  180. onPagiantionChange(index) {
  181. this.listQuery.pageNum = index
  182. this.fetchList()
  183. },
  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. beforeDestroy() {
  197. this.$toast.clear()
  198. },
  199. }
  200. </script>
  201. <style scoped lang="scss">
  202. // pc 端
  203. @media screen and (min-width: 768px) {
  204. .page {
  205. position: relative;
  206. min-height: calc(100vh - 80px - 80px);
  207. background-color: #fff;
  208. }
  209. .page-top {
  210. height: 420px;
  211. background: url(https://static.caimei365.com/www/authentic/pc/bg-club.png);
  212. background-size: auto 420px;
  213. .logo {
  214. display: block;
  215. width: 120px;
  216. height: 120px;
  217. border-radius: 50%;
  218. }
  219. .name {
  220. font-size: 30px;
  221. color: #fff;
  222. }
  223. .logo,
  224. .name {
  225. transform: translateY(-60px);
  226. }
  227. }
  228. .page-content {
  229. width: 1200px;
  230. margin: 0 auto;
  231. .search {
  232. position: absolute;
  233. left: 50%;
  234. top: 260px;
  235. transform: translateX(-50%);
  236. }
  237. .city {
  238. position: absolute;
  239. left: 50%;
  240. top: 320px;
  241. transform: translateX(-50%);
  242. z-index: 9;
  243. }
  244. .title {
  245. font-size: 16px;
  246. color: #404040;
  247. span {
  248. color: #bc1724;
  249. }
  250. }
  251. .list {
  252. display: flex;
  253. align-items: center;
  254. justify-content: space-between;
  255. flex-wrap: wrap;
  256. .empty {
  257. width: 390px;
  258. }
  259. .section {
  260. width: 390px;
  261. height: 108px;
  262. background-color: #f3f5f6;
  263. border-radius: 4px;
  264. box-sizing: border-box;
  265. padding: 12px;
  266. cursor: pointer;
  267. transition: all 0.4s;
  268. &:hover {
  269. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  270. }
  271. .cover {
  272. display: block;
  273. width: 84px;
  274. height: 84px;
  275. }
  276. .info {
  277. position: relative;
  278. margin-left: 12px;
  279. .name {
  280. font-size: 16px;
  281. color: #101010;
  282. font-weight: bold;
  283. margin-bottom: 16px;
  284. text-overflow: ellipsis;
  285. white-space: nowrap;
  286. overflow: hidden;
  287. }
  288. .mobile,
  289. .address {
  290. width: 268px;
  291. position: relative;
  292. font-size: 14px;
  293. color: #404040;
  294. padding-left: 24px;
  295. line-height: 24px;
  296. text-overflow: ellipsis;
  297. white-space: nowrap;
  298. overflow: hidden;
  299. &::after {
  300. content: '';
  301. display: block;
  302. width: 16px;
  303. height: 16px;
  304. position: absolute;
  305. left: 0;
  306. top: 50%;
  307. transform: translateY(-50%);
  308. background-size: 16px;
  309. background-repeat: no-repeat;
  310. }
  311. }
  312. .mobile {
  313. &::after {
  314. background-image: url(https://static.caimei365.com/www/authentic/pc/icon-phone.png);
  315. }
  316. }
  317. .address {
  318. &::after {
  319. background-image: url(https://static.caimei365.com/www/authentic/pc/icon-address.png);
  320. }
  321. }
  322. .distance {
  323. position: absolute;
  324. font-size: 12px;
  325. color: #404040;
  326. top: 2px;
  327. right: 0;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. // 移动 端
  335. @media screen and (max-width: 768px) {
  336. .page-top {
  337. height: 46vw;
  338. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  339. background-size: auto 46vw;
  340. .logo {
  341. display: block;
  342. width: 14.8vw;
  343. height: 14.8vw;
  344. border-radius: 50%;
  345. }
  346. .name {
  347. font-size: 4vw;
  348. color: #fff;
  349. }
  350. }
  351. .page-content {
  352. position: relative;
  353. .search {
  354. position: absolute;
  355. left: 50%;
  356. top: 0;
  357. transform: translate(-50%, -50%);
  358. }
  359. .city {
  360. position: relative;
  361. z-index: 9;
  362. padding-top: 12vw;
  363. }
  364. .title {
  365. font-size: 3.4vw;
  366. color: #404040;
  367. span {
  368. color: #bc1724;
  369. }
  370. }
  371. .list {
  372. display: flex;
  373. align-items: center;
  374. flex-direction: column;
  375. .section {
  376. width: 93.6vw;
  377. height: 26vw;
  378. background-color: #f3f5f6;
  379. border-radius: 4px;
  380. box-sizing: border-box;
  381. padding: 3.2vw;
  382. .cover {
  383. display: block;
  384. width: 19.6vw;
  385. height: 19.6vw;
  386. }
  387. .info {
  388. position: relative;
  389. margin-left: 3.2vw;
  390. .name {
  391. font-size: 4vw;
  392. color: #101010;
  393. font-weight: bold;
  394. margin-bottom: 4vw;
  395. text-overflow: ellipsis;
  396. white-space: nowrap;
  397. overflow: hidden;
  398. }
  399. .mobile,
  400. .address {
  401. width: 66vw;
  402. position: relative;
  403. font-size: 3vw;
  404. color: #404040;
  405. padding-left: 5vw;
  406. line-height: 5vw;
  407. text-overflow: ellipsis;
  408. white-space: nowrap;
  409. overflow: hidden;
  410. &::after {
  411. content: '';
  412. display: block;
  413. width: 4vw;
  414. height: 4vw;
  415. position: absolute;
  416. left: 0;
  417. top: 50%;
  418. transform: translateY(-50%);
  419. background-size: 4vw 4vw;
  420. background-repeat: no-repeat;
  421. }
  422. }
  423. .mobile {
  424. &::after {
  425. background-image: url(https://static.caimei365.com/www/authentic/h5/icon-phone.png);
  426. }
  427. }
  428. .address {
  429. &::after {
  430. background-image: url(https://static.caimei365.com/www/authentic/h5/icon-address.png);
  431. }
  432. }
  433. .distance {
  434. position: absolute;
  435. font-size: 3vw;
  436. color: #404040;
  437. top: 0.8vw;
  438. right: 0;
  439. }
  440. }
  441. }
  442. }
  443. }
  444. }
  445. </style>