list.vue 6.9 KB

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