index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="page">
  3. <div class="page-top flex flex-col justify-center items-center">
  4. <img class="logo" :src="supplierInfo.logo" />
  5. <div class="mt-2 name">
  6. <span v-text="supplierInfo.shopName"></span>
  7. <span>官方认证设备</span>
  8. </div>
  9. </div>
  10. <div class="page-content">
  11. <!-- 搜索区域 -->
  12. <div class="search">
  13. <SimpleSearch v-model="listQuery.productName" @search="onSearch" />
  14. </div>
  15. <!-- 标题 -->
  16. <div class="title px-4 pt-12 pb-6">
  17. 共<span v-text="total"></span>种设备
  18. </div>
  19. <!-- 列表 -->
  20. <div class="list">
  21. <nuxt-link
  22. class="section flex items-center mb-4"
  23. v-for="item in list"
  24. :key="item.productTypeId"
  25. :to="'/ph/approve/device/' + item.productTypeId"
  26. >
  27. <img class="cover" :src="item.image" />
  28. <div class="name" v-text="item.name"></div>
  29. </nuxt-link>
  30. <div class="empty" v-for="i in emptyList" :key="i"></div>
  31. </div>
  32. <!-- 列表为空 -->
  33. <SimpleEmpty
  34. v-if="!total && !isRequest"
  35. description="敬请期待~"
  36. ></SimpleEmpty>
  37. <!-- 页码 -->
  38. <SimplePagination
  39. v-if="total > listQuery.pageSize"
  40. :total="total"
  41. :pageItems="listQuery.pageSize"
  42. @change="onPagiantionChange"
  43. ></SimplePagination>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import { mapGetters } from 'vuex'
  49. export default {
  50. layout: 'app',
  51. data() {
  52. return {
  53. isRequest: true,
  54. listQuery: {
  55. appId: '',
  56. productName: '',
  57. pageNum: 1,
  58. pageSize: 10,
  59. },
  60. list: [],
  61. total: 0,
  62. }
  63. },
  64. computed: {
  65. ...mapGetters(['supplierInfo', 'appId']),
  66. emptyList() {
  67. return 3 - (this.list.length % 3)
  68. },
  69. },
  70. mounted() {
  71. this.fetchList()
  72. },
  73. methods: {
  74. // 获取设备分类
  75. async fetchList() {
  76. try {
  77. this.listQuery.appId = this.appId
  78. const res = await this.$http.api.getAuthProductCateList(this.listQuery)
  79. this.list = res.data.list
  80. this.total = res.data.total
  81. } catch (error) {
  82. console.log(error)
  83. } finally {
  84. this.isRequest = false
  85. }
  86. },
  87. // 搜索
  88. onSearch() {
  89. this.listQuery.pageNum = 1
  90. this.fetchList()
  91. },
  92. // 页码变化
  93. onPagiantionChange(index) {
  94. this.listQuery.pageNum = index
  95. this.fetchList()
  96. },
  97. },
  98. }
  99. </script>
  100. <style scoped lang="scss">
  101. // pc 端
  102. @media screen and (min-width: 768px) {
  103. .page {
  104. position: relative;
  105. min-height: calc(100vh - 80px - 80px);
  106. background-color: #fff;
  107. }
  108. .page-top {
  109. height: 420px;
  110. background: url(https://static.caimei365.com/www/authentic/pc/bg-device.png);
  111. background-size: auto 420px;
  112. .logo {
  113. display: block;
  114. width: 120px;
  115. height: 120px;
  116. border-radius: 50%;
  117. }
  118. .name {
  119. font-size: 30px;
  120. color: #fff;
  121. }
  122. .logo,
  123. .name {
  124. transform: translateY(-30px);
  125. }
  126. }
  127. .page-content {
  128. width: 1200px;
  129. margin: 0 auto;
  130. .search {
  131. position: absolute;
  132. left: 50%;
  133. top: 300px;
  134. transform: translateX(-50%);
  135. }
  136. .title {
  137. font-size: 16px;
  138. color: #404040;
  139. span {
  140. color: #bc1724;
  141. }
  142. }
  143. .list {
  144. display: flex;
  145. align-items: center;
  146. flex-wrap: wrap;
  147. justify-content: space-between;
  148. .empty {
  149. width: 390px;
  150. }
  151. .section {
  152. width: 390px;
  153. height: 108px;
  154. background-color: #f3f5f6;
  155. border-radius: 4px;
  156. box-sizing: border-box;
  157. padding: 16px;
  158. cursor: pointer;
  159. transition: all 0.4s;
  160. &:hover {
  161. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  162. }
  163. .cover {
  164. display: block;
  165. width: 84px;
  166. height: 84px;
  167. }
  168. .name {
  169. width: 260px;
  170. font-size: 16px;
  171. color: #101010;
  172. text-overflow: ellipsis;
  173. white-space: nowrap;
  174. overflow: hidden;
  175. margin-left: 16px;
  176. }
  177. }
  178. }
  179. }
  180. }
  181. // 移动 端
  182. @media screen and (max-width: 768px) {
  183. .page-top {
  184. height: 46vw;
  185. background: url(https://static.caimei365.com/www/authentic/h5/bg-device.png);
  186. background-size: auto 46vw;
  187. .logo {
  188. display: block;
  189. width: 14.8vw;
  190. height: 14.8vw;
  191. border-radius: 50%;
  192. }
  193. .name {
  194. font-size: 4vw;
  195. color: #fff;
  196. }
  197. }
  198. .page-content {
  199. position: relative;
  200. .search {
  201. position: absolute;
  202. left: 50%;
  203. top: 0;
  204. transform: translate(-50%, -50%);
  205. }
  206. .title {
  207. font-size: 3.4vw;
  208. color: #404040;
  209. span {
  210. color: #bc1724;
  211. }
  212. }
  213. .list {
  214. display: flex;
  215. align-items: center;
  216. flex-direction: column;
  217. .section {
  218. width: 93.6vw;
  219. height: 26vw;
  220. background-color: #f3f5f6;
  221. border-radius: 4px;
  222. box-sizing: border-box;
  223. padding: 3.2vw;
  224. .cover {
  225. display: block;
  226. width: 19.6vw;
  227. height: 19.6vw;
  228. }
  229. .name {
  230. width: 66vw;
  231. font-size: 4vw;
  232. color: #101010;
  233. text-overflow: ellipsis;
  234. white-space: nowrap;
  235. overflow: hidden;
  236. margin-left: 3.2vw;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. </style>