list.vue 7.1 KB

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