star-list.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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-content">
  11. <!-- 标题 -->
  12. <div class="title flex justify-between px-4 pt-8 pb-8 md:px-0">
  13. <div>明星机构</div>
  14. <div>共<span v-text="total"></span>家明星机构</div>
  15. </div>
  16. <!-- 列表 -->
  17. <div class="list">
  18. <template v-for="item in list">
  19. <div
  20. class="section flex justify-between mb-4"
  21. :key="item.authId"
  22. @click="toDetail(item)"
  23. >
  24. <img class="cover" :src="item.logo || drawLogo(item.clubName)" />
  25. <div class="info">
  26. <div class="name" v-text="item.clubName"></div>
  27. <div class="mobile">{{ item.mobile || '暂无' }}</div>
  28. <div class="address">
  29. {{ formatAddress(item.area, item.address) }}
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <div class="empty" v-for="i in emptyList" :key="'empty-' + i"></div>
  35. </div>
  36. <!-- 列表为空 -->
  37. <SimpleEmpty
  38. v-if="!total && !isRequest"
  39. name="icon-empty-club.png"
  40. description="敬请期待~"
  41. ></SimpleEmpty>
  42. </div>
  43. </van-list>
  44. </div>
  45. </template>
  46. <script>
  47. import { mapGetters } from 'vuex'
  48. import { drawLogo, debounce } from '@/utils'
  49. export default {
  50. layout: 'app',
  51. data() {
  52. return {
  53. finished: false,
  54. isRequest: true,
  55. list: [],
  56. }
  57. },
  58. computed: {
  59. ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
  60. emptyList() {
  61. return 3 - (this.list.length % 3)
  62. },
  63. total() {
  64. return this.list.length
  65. },
  66. },
  67. mounted() {
  68. this.initData()
  69. },
  70. beforeDestroy() {
  71. this.$toast.clear()
  72. },
  73. methods: {
  74. // 绘制logo的方法
  75. drawLogo,
  76. // 查看详情
  77. toDetail(item) {
  78. const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
  79. this.$router.push(url)
  80. },
  81. // 初始化页面数据
  82. async initData() {
  83. // 获取机构列表
  84. this.fetchList()
  85. },
  86. fetchList: debounce(async function () {
  87. try {
  88. // 自定义加载图标
  89. this.$toast.loading({
  90. message: '正在获取明星机构...',
  91. duration: 0,
  92. })
  93. const res = await this.$http.api.getAuthClubStarList({
  94. authUserId: this.authUserId,
  95. })
  96. this.list = res.data
  97. } catch (error) {
  98. console.log(error)
  99. } finally {
  100. this.$toast.clear()
  101. }
  102. }, 400),
  103. // 格式化地址
  104. formatAddress(a1, a2) {
  105. let resutl = ''
  106. if (typeof a1 === 'string') {
  107. resutl += a1
  108. }
  109. if (typeof a2 === 'string') {
  110. resutl += a2
  111. }
  112. return resutl || '暂无'
  113. },
  114. },
  115. }
  116. </script>
  117. <style scoped lang="scss">
  118. // pc 端
  119. @media screen and (min-width: 768px) {
  120. .page {
  121. position: relative;
  122. min-height: calc(100vh - 80px - 80px);
  123. background-color: #fff;
  124. }
  125. .page-top {
  126. height: 420px;
  127. @include themify($themes) {
  128. background: themed('pc-banner-club');
  129. }
  130. background-size: auto 420px;
  131. .logo {
  132. display: block;
  133. width: 120px;
  134. height: 120px;
  135. border-radius: 50%;
  136. background: #fff;
  137. }
  138. .name {
  139. font-size: 30px;
  140. color: #fff;
  141. }
  142. .logo,
  143. .name {
  144. transform: translateY(-60px);
  145. }
  146. }
  147. .page-content {
  148. width: 1200px;
  149. margin: 0 auto;
  150. .search {
  151. position: absolute;
  152. left: 50%;
  153. top: 260px;
  154. transform: translateX(-50%);
  155. }
  156. .city {
  157. position: absolute;
  158. left: 50%;
  159. top: 320px;
  160. transform: translateX(-50%);
  161. z-index: 9;
  162. }
  163. .title {
  164. font-size: 16px;
  165. color: #404040;
  166. span {
  167. @include themify($themes) {
  168. color: themed('color');
  169. }
  170. }
  171. }
  172. .list {
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. flex-wrap: wrap;
  177. .empty {
  178. width: 390px;
  179. }
  180. .section {
  181. width: 390px;
  182. height: 108px;
  183. background-color: #f3f5f6;
  184. border-radius: 4px;
  185. box-sizing: border-box;
  186. padding: 12px;
  187. cursor: pointer;
  188. transition: all 0.4s;
  189. &:hover {
  190. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  191. }
  192. .cover {
  193. display: block;
  194. width: 84px;
  195. height: 84px;
  196. }
  197. .info {
  198. position: relative;
  199. margin-left: 12px;
  200. .name {
  201. width: 200px;
  202. font-size: 16px;
  203. color: #101010;
  204. font-weight: bold;
  205. margin-bottom: 16px;
  206. text-overflow: ellipsis;
  207. white-space: nowrap;
  208. overflow: hidden;
  209. }
  210. .mobile,
  211. .address {
  212. width: 268px;
  213. position: relative;
  214. font-size: 14px;
  215. color: #404040;
  216. padding-left: 24px;
  217. line-height: 24px;
  218. text-overflow: ellipsis;
  219. white-space: nowrap;
  220. overflow: hidden;
  221. &::after {
  222. content: '';
  223. display: block;
  224. width: 16px;
  225. height: 16px;
  226. position: absolute;
  227. left: 0;
  228. top: 50%;
  229. transform: translateY(-50%);
  230. background-size: 16px;
  231. background-repeat: no-repeat;
  232. }
  233. }
  234. .mobile {
  235. &::after {
  236. background-image: url(~assets/theme-images/common/pc-icon-mobile.png);
  237. }
  238. }
  239. .address {
  240. &::after {
  241. background-image: url(~assets/theme-images/common/pc-icon-address.png);
  242. }
  243. }
  244. .distance {
  245. position: absolute;
  246. font-size: 12px;
  247. color: #404040;
  248. top: 2px;
  249. right: 0;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. // 移动 端
  257. @media screen and (max-width: 768px) {
  258. .page-top {
  259. height: 46vw;
  260. @include themify($themes) {
  261. background: themed('h5-banner-club');
  262. }
  263. background-size: auto 46vw;
  264. .logo {
  265. display: block;
  266. width: 14.8vw;
  267. height: 14.8vw;
  268. border-radius: 50%;
  269. background: #fff;
  270. }
  271. .name {
  272. font-size: 4vw;
  273. color: #fff;
  274. }
  275. }
  276. .page-content {
  277. position: relative;
  278. .search {
  279. position: absolute;
  280. left: 50%;
  281. top: 0;
  282. transform: translate(-50%, -50%);
  283. }
  284. .city {
  285. position: relative;
  286. z-index: 9;
  287. padding-top: 12vw;
  288. }
  289. .title {
  290. font-size: 3.4vw;
  291. color: #404040;
  292. span {
  293. @include themify($themes) {
  294. color: themed('color');
  295. }
  296. }
  297. }
  298. .list {
  299. display: flex;
  300. align-items: center;
  301. flex-direction: column;
  302. .section {
  303. width: 93.6vw;
  304. height: 26vw;
  305. background-color: #f3f5f6;
  306. border-radius: 4px;
  307. box-sizing: border-box;
  308. padding: 3.2vw;
  309. .cover {
  310. display: block;
  311. width: 19.6vw;
  312. height: 19.6vw;
  313. }
  314. .info {
  315. position: relative;
  316. margin-left: 3.2vw;
  317. .name {
  318. width: 48vw;
  319. font-size: 4vw;
  320. color: #101010;
  321. font-weight: bold;
  322. margin-bottom: 4vw;
  323. text-overflow: ellipsis;
  324. white-space: nowrap;
  325. overflow: hidden;
  326. }
  327. .mobile,
  328. .address {
  329. width: 66vw;
  330. position: relative;
  331. font-size: 3vw;
  332. color: #404040;
  333. padding-left: 5vw;
  334. line-height: 5vw;
  335. text-overflow: ellipsis;
  336. white-space: nowrap;
  337. overflow: hidden;
  338. &::after {
  339. content: '';
  340. display: block;
  341. width: 4vw;
  342. height: 4vw;
  343. position: absolute;
  344. left: 0;
  345. top: 50%;
  346. transform: translateY(-50%);
  347. background-size: 4vw 4vw;
  348. background-repeat: no-repeat;
  349. }
  350. }
  351. .mobile {
  352. &::after {
  353. background-image: url(~assets/theme-images/common/h5-icon-mobile.png);
  354. }
  355. }
  356. .address {
  357. &::after {
  358. background-image: url(~assets/theme-images/common/h5-icon-address.png);
  359. }
  360. }
  361. .distance {
  362. position: absolute;
  363. font-size: 3vw;
  364. color: #404040;
  365. top: 0.8vw;
  366. right: 0;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. }
  373. </style>