index.vue 5.4 KB

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