list.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. import { mapGetters } from 'vuex'
  61. export default {
  62. layout: 'app',
  63. data() {
  64. return {
  65. isLoadingMore: true,
  66. finished: false,
  67. isRequest: true,
  68. listQuery: {
  69. productTypeId: '',
  70. snCode: '',
  71. pageNum: 1,
  72. pageSize: 10,
  73. },
  74. list: [],
  75. total: 0,
  76. }
  77. },
  78. computed: {
  79. ...mapGetters(['routePrefix']),
  80. isEmpty() {
  81. return this.list.length === 0
  82. },
  83. emptyList() {
  84. return 3 - (this.list.length % 3)
  85. },
  86. },
  87. mounted() {
  88. this.initData()
  89. },
  90. methods: {
  91. initData() {
  92. this.listQuery.productTypeId = parseInt(this.$route.query.id)
  93. this.fetchList()
  94. },
  95. fetchList: debounce(async function () {
  96. try {
  97. this.isLoadingMore = true
  98. const res = await this.$http.api.getAuthProductList(this.listQuery)
  99. this.list = [...this.list, ...res.data.list]
  100. this.finished = !res.data.hasNextPage
  101. this.total = res.data.total
  102. this.isLoadingMore = false
  103. this.listQuery.pageNum += 1
  104. } catch (error) {
  105. console.log(error)
  106. } finally {
  107. this.isRequest = false
  108. }
  109. }, 400),
  110. // 搜索
  111. onSearch() {
  112. this.listQuery.pageNum = 1
  113. this.fetchList()
  114. },
  115. // 设备详情
  116. toDetail(item) {
  117. window.location.href = `${process.env.CIMEI_LOCAL}/product/auth/product-${item.productId}.html`
  118. },
  119. // 机构详情
  120. toClubDetail(item) {
  121. const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
  122. this.$router.push(url)
  123. },
  124. // 加载更多
  125. onLoadMore() {
  126. this.fetchList()
  127. },
  128. },
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. // pc 端
  133. @media screen and (min-width: 768px) {
  134. .page {
  135. position: relative;
  136. min-height: calc(100vh - 80px - 80px);
  137. background-color: #fff;
  138. }
  139. .page-top {
  140. height: 420px;
  141. background: url(https://static.caimei365.com/www/authentic/pc/bg-device.png);
  142. background-size: auto 420px;
  143. .logo {
  144. display: block;
  145. width: 120px;
  146. height: 120px;
  147. border-radius: 50%;
  148. }
  149. .name {
  150. font-size: 30px;
  151. color: #fff;
  152. }
  153. .logo,
  154. .name {
  155. transform: translateY(-30px);
  156. }
  157. }
  158. .page-content {
  159. width: 1200px;
  160. margin: 0 auto;
  161. .search {
  162. position: absolute;
  163. left: 50%;
  164. top: 300px;
  165. transform: translateX(-50%);
  166. }
  167. .title {
  168. font-size: 16px;
  169. color: #404040;
  170. span {
  171. color: #bc1724;
  172. }
  173. }
  174. .list {
  175. display: flex;
  176. align-items: center;
  177. flex-wrap: wrap;
  178. justify-content: space-between;
  179. .empty {
  180. width: 390px;
  181. }
  182. .section {
  183. width: 390px;
  184. height: 108px;
  185. background-color: #f3f5f6;
  186. border-radius: 4px;
  187. box-sizing: border-box;
  188. padding: 12px;
  189. cursor: pointer;
  190. transition: all 0.4s;
  191. &:hover {
  192. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  193. }
  194. .cover {
  195. display: block;
  196. width: 84px;
  197. height: 84px;
  198. }
  199. .info {
  200. width: 270px;
  201. position: relative;
  202. .name {
  203. font-size: 16px;
  204. color: #101010;
  205. font-weight: bold;
  206. margin-bottom: 16px;
  207. text-overflow: ellipsis;
  208. white-space: nowrap;
  209. overflow: hidden;
  210. }
  211. .code,
  212. .club-name {
  213. position: relative;
  214. font-size: 14px;
  215. color: #404040;
  216. line-height: 24px;
  217. text-overflow: ellipsis;
  218. white-space: nowrap;
  219. overflow: hidden;
  220. span {
  221. color: #6d9eff;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228. }
  229. // 移动 端
  230. @media screen and (max-width: 768px) {
  231. .page-top {
  232. height: 46vw;
  233. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  234. background-size: auto 46vw;
  235. .logo {
  236. display: block;
  237. width: 14.8vw;
  238. height: 14.8vw;
  239. border-radius: 50%;
  240. }
  241. .name {
  242. font-size: 4vw;
  243. color: #fff;
  244. }
  245. }
  246. .page-content {
  247. position: relative;
  248. .search {
  249. position: absolute;
  250. left: 50%;
  251. top: 0;
  252. transform: translate(-50%, -50%);
  253. }
  254. .title {
  255. font-size: 3.4vw;
  256. color: #404040;
  257. span {
  258. color: #bc1724;
  259. }
  260. }
  261. .list {
  262. display: flex;
  263. align-items: center;
  264. flex-direction: column;
  265. .section {
  266. width: 93.6vw;
  267. height: 26vw;
  268. background-color: #f3f5f6;
  269. border-radius: 4px;
  270. box-sizing: border-box;
  271. padding: 3.2vw;
  272. .cover {
  273. display: block;
  274. width: 19.6vw;
  275. height: 19.6vw;
  276. }
  277. .info {
  278. position: relative;
  279. margin-left: 3.2vw;
  280. .name {
  281. font-size: 4vw;
  282. color: #101010;
  283. font-weight: bold;
  284. margin-bottom: 4vw;
  285. text-overflow: ellipsis;
  286. white-space: nowrap;
  287. overflow: hidden;
  288. }
  289. .code,
  290. .club-name {
  291. width: 66vw;
  292. position: relative;
  293. font-size: 3vw;
  294. color: #404040;
  295. line-height: 5vw;
  296. text-overflow: ellipsis;
  297. white-space: nowrap;
  298. overflow: hidden;
  299. span {
  300. color: #6d9eff;
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. }
  308. </style>