list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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 flex flex-col justify-center items-center">
  11. <img class="logo" src="https://picsum.photos/200/200" />
  12. <span class="name mt-2">上海品辉医疗科技有限公司官方授权设备</span>
  13. </div>
  14. <div class="page-content">
  15. <!-- 搜索区域 -->
  16. <div class="search">
  17. <SimpleSearch
  18. v-model="listQuery.snCode"
  19. @search="onSearch"
  20. placeholder="搜索设备SN码后四位"
  21. />
  22. </div>
  23. <!-- 标题 -->
  24. <div class="title px-4 pt-12 pb-6 md:px-0">
  25. 共<span v-text="total"></span>台设备
  26. </div>
  27. <!-- 列表 -->
  28. <div class="list">
  29. <div
  30. class="section flex justify-between mb-4"
  31. v-for="item in list"
  32. :key="item.productId"
  33. @click="toDetail(item)"
  34. >
  35. <img class="cover" :src="item.productImage" />
  36. <div class="info">
  37. <div class="name" v-text="item.productName"></div>
  38. <div class="code">SN码:{{ item.snCode }}</div>
  39. <div class="club-name">
  40. 所属机构:<span @click.stop="toClubDetail(item)">{{
  41. item.clubName
  42. }}</span>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="empty" v-for="i in emptyList" :key="'empty-' + i"></div>
  47. </div>
  48. <!-- 列表为空 -->
  49. <SimpleEmpty
  50. v-if="!total && !isRequest"
  51. name="icon-empty-device.png"
  52. description="敬请期待~"
  53. ></SimpleEmpty>
  54. </div>
  55. </van-list>
  56. </div>
  57. </template>
  58. <script>
  59. import { debounce } from '@/utils'
  60. export default {
  61. layout: 'app',
  62. data() {
  63. return {
  64. isLoadingMore: true,
  65. finished: false,
  66. isRequest: true,
  67. listQuery: {
  68. productTypeId: '',
  69. snCode: '',
  70. pageNum: 1,
  71. pageSize: 10,
  72. },
  73. list: [],
  74. total: 0,
  75. }
  76. },
  77. computed: {
  78. isEmpty() {
  79. return this.list.length === 0
  80. },
  81. emptyList() {
  82. return 3 - (this.list.length % 3)
  83. },
  84. },
  85. mounted() {
  86. this.initData()
  87. },
  88. methods: {
  89. initData() {
  90. this.listQuery.productTypeId = this.$route.query.id
  91. this.fetchList()
  92. },
  93. fetchList: debounce(async function () {
  94. try {
  95. this.isLoadingMore = true
  96. const res = await this.$http.api.getAuthProductList(this.listQuery)
  97. this.list = [...this.list, ...res.data.list]
  98. this.finished = !res.data.hasNextPage
  99. this.total = res.data.total
  100. } catch (error) {
  101. console.log(error)
  102. } finally {
  103. this.isRequest = false
  104. this.isLoadingMore = false
  105. }
  106. }, 400),
  107. // 搜索
  108. onSearch() {
  109. this.listQuery.pageNum = 1
  110. this.fetchList()
  111. },
  112. // 页码变化
  113. onPagiantionChange(index) {
  114. this.listQuery.pageNum = index
  115. this.fetchList()
  116. },
  117. // 设备详情
  118. toDetail(item) {
  119. window.location.href = `${process.env.CIMEI_LOCAL}/product/auth/product-${item.productId}.html`
  120. },
  121. // 机构详情
  122. toClubDetail(item) {
  123. localStorage.setItem('clubInfo', JSON.stringify({ authId: item.authId }))
  124. const authUserId = this.$store.getters.authUserId
  125. const url = `/${authUserId}/app/approve/club/detail?id=${item.authId}`
  126. this.$router.push(url)
  127. },
  128. // 加载更多
  129. onLoadMore() {
  130. this.listQuery.pageNum += 1
  131. this.fetchList()
  132. },
  133. },
  134. }
  135. </script>
  136. <style scoped lang="scss">
  137. // pc 端
  138. @media screen and (min-width: 768px) {
  139. .page {
  140. position: relative;
  141. min-height: calc(100vh - 80px - 80px);
  142. background-color: #fff;
  143. }
  144. .page-top {
  145. height: 420px;
  146. background: url(https://static.caimei365.com/www/authentic/pc/bg-device.png);
  147. background-size: auto 420px;
  148. .logo {
  149. display: block;
  150. width: 120px;
  151. height: 120px;
  152. border-radius: 50%;
  153. }
  154. .name {
  155. font-size: 30px;
  156. color: #fff;
  157. }
  158. .logo,
  159. .name {
  160. transform: translateY(-30px);
  161. }
  162. }
  163. .page-content {
  164. width: 1200px;
  165. margin: 0 auto;
  166. .search {
  167. position: absolute;
  168. left: 50%;
  169. top: 300px;
  170. transform: translateX(-50%);
  171. }
  172. .title {
  173. font-size: 16px;
  174. color: #404040;
  175. span {
  176. color: #bc1724;
  177. }
  178. }
  179. .list {
  180. display: flex;
  181. align-items: center;
  182. flex-wrap: wrap;
  183. justify-content: space-between;
  184. .empty {
  185. width: 390px;
  186. }
  187. .section {
  188. width: 390px;
  189. height: 108px;
  190. background-color: #f3f5f6;
  191. border-radius: 4px;
  192. box-sizing: border-box;
  193. padding: 12px;
  194. cursor: pointer;
  195. transition: all 0.4s;
  196. &:hover {
  197. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  198. }
  199. .cover {
  200. display: block;
  201. width: 84px;
  202. height: 84px;
  203. }
  204. .info {
  205. width: 270px;
  206. position: relative;
  207. .name {
  208. font-size: 16px;
  209. color: #101010;
  210. font-weight: bold;
  211. margin-bottom: 16px;
  212. text-overflow: ellipsis;
  213. white-space: nowrap;
  214. overflow: hidden;
  215. }
  216. .code,
  217. .club-name {
  218. position: relative;
  219. font-size: 14px;
  220. color: #404040;
  221. line-height: 24px;
  222. text-overflow: ellipsis;
  223. white-space: nowrap;
  224. overflow: hidden;
  225. span {
  226. color: #6d9eff;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. // 移动 端
  235. @media screen and (max-width: 768px) {
  236. .page-top {
  237. height: 46vw;
  238. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  239. background-size: auto 46vw;
  240. .logo {
  241. display: block;
  242. width: 14.8vw;
  243. height: 14.8vw;
  244. border-radius: 50%;
  245. }
  246. .name {
  247. font-size: 4vw;
  248. color: #fff;
  249. }
  250. }
  251. .page-content {
  252. position: relative;
  253. .search {
  254. position: absolute;
  255. left: 50%;
  256. top: 0;
  257. transform: translate(-50%, -50%);
  258. }
  259. .title {
  260. font-size: 3.4vw;
  261. color: #404040;
  262. span {
  263. color: #bc1724;
  264. }
  265. }
  266. .list {
  267. display: flex;
  268. align-items: center;
  269. flex-direction: column;
  270. .section {
  271. width: 93.6vw;
  272. height: 26vw;
  273. background-color: #f3f5f6;
  274. border-radius: 4px;
  275. box-sizing: border-box;
  276. padding: 3.2vw;
  277. .cover {
  278. display: block;
  279. width: 19.6vw;
  280. height: 19.6vw;
  281. }
  282. .info {
  283. position: relative;
  284. margin-left: 3.2vw;
  285. .name {
  286. font-size: 4vw;
  287. color: #101010;
  288. font-weight: bold;
  289. margin-bottom: 4vw;
  290. text-overflow: ellipsis;
  291. white-space: nowrap;
  292. overflow: hidden;
  293. }
  294. .code,
  295. .club-name {
  296. width: 66vw;
  297. position: relative;
  298. font-size: 3vw;
  299. color: #404040;
  300. line-height: 5vw;
  301. text-overflow: ellipsis;
  302. white-space: nowrap;
  303. overflow: hidden;
  304. span {
  305. color: #6d9eff;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. }
  313. </style>