index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. <div
  22. class="section flex items-center mb-4"
  23. v-for="item in list"
  24. :key="item.productTypeId"
  25. @click="toDetail(item)"
  26. >
  27. <img class="cover" :src="item.image" />
  28. <div class="name" v-text="item.name"></div>
  29. </div>
  30. <div class="empty" v-for="i in emptyList" :key="'empty-' + 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. authUserId: '',
  57. productName: '',
  58. pageNum: 1,
  59. pageSize: 10,
  60. },
  61. list: [],
  62. total: 0,
  63. }
  64. },
  65. computed: {
  66. ...mapGetters(['supplierInfo', 'authUserId', 'authUserId']),
  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.authUserId = this.authUserId
  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. toDetail(item) {
  90. localStorage.setItem(
  91. 'deviceInfo',
  92. JSON.stringify({ productTypeId: item.productTypeId })
  93. )
  94. this.$router.push(`/${this.authUserId}/app/approve/device/list`)
  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. }
  108. </script>
  109. <style scoped lang="scss">
  110. // pc 端
  111. @media screen and (min-width: 768px) {
  112. .page {
  113. position: relative;
  114. min-height: calc(100vh - 80px - 80px);
  115. background-color: #fff;
  116. }
  117. .page-top {
  118. height: 420px;
  119. background: url(https://static.caimei365.com/www/authentic/pc/bg-device.png);
  120. background-size: auto 420px;
  121. .logo {
  122. display: block;
  123. width: 120px;
  124. height: 120px;
  125. border-radius: 50%;
  126. }
  127. .name {
  128. font-size: 30px;
  129. color: #fff;
  130. }
  131. .logo,
  132. .name {
  133. transform: translateY(-30px);
  134. }
  135. }
  136. .page-content {
  137. width: 1200px;
  138. margin: 0 auto;
  139. .search {
  140. position: absolute;
  141. left: 50%;
  142. top: 300px;
  143. transform: translateX(-50%);
  144. }
  145. .title {
  146. font-size: 16px;
  147. color: #404040;
  148. span {
  149. color: #bc1724;
  150. }
  151. }
  152. .list {
  153. display: flex;
  154. align-items: center;
  155. flex-wrap: wrap;
  156. justify-content: space-between;
  157. .empty {
  158. width: 390px;
  159. }
  160. .section {
  161. width: 390px;
  162. height: 108px;
  163. background-color: #f3f5f6;
  164. border-radius: 4px;
  165. box-sizing: border-box;
  166. padding: 16px;
  167. cursor: pointer;
  168. transition: all 0.4s;
  169. &:hover {
  170. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  171. }
  172. .cover {
  173. display: block;
  174. width: 84px;
  175. height: 84px;
  176. }
  177. .name {
  178. width: 260px;
  179. font-size: 16px;
  180. color: #101010;
  181. text-overflow: ellipsis;
  182. white-space: nowrap;
  183. overflow: hidden;
  184. margin-left: 16px;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. // 移动 端
  191. @media screen and (max-width: 768px) {
  192. .page-top {
  193. height: 46vw;
  194. background: url(https://static.caimei365.com/www/authentic/h5/bg-device.png);
  195. background-size: auto 46vw;
  196. .logo {
  197. display: block;
  198. width: 14.8vw;
  199. height: 14.8vw;
  200. border-radius: 50%;
  201. }
  202. .name {
  203. font-size: 4vw;
  204. color: #fff;
  205. }
  206. }
  207. .page-content {
  208. position: relative;
  209. .search {
  210. position: absolute;
  211. left: 50%;
  212. top: 0;
  213. transform: translate(-50%, -50%);
  214. }
  215. .title {
  216. font-size: 3.4vw;
  217. color: #404040;
  218. span {
  219. color: #bc1724;
  220. }
  221. }
  222. .list {
  223. display: flex;
  224. align-items: center;
  225. flex-direction: column;
  226. .section {
  227. width: 93.6vw;
  228. height: 26vw;
  229. background-color: #f3f5f6;
  230. border-radius: 4px;
  231. box-sizing: border-box;
  232. padding: 3.2vw;
  233. .cover {
  234. display: block;
  235. width: 19.6vw;
  236. height: 19.6vw;
  237. }
  238. .name {
  239. width: 66vw;
  240. font-size: 4vw;
  241. color: #101010;
  242. text-overflow: ellipsis;
  243. white-space: nowrap;
  244. overflow: hidden;
  245. margin-left: 3.2vw;
  246. }
  247. }
  248. }
  249. }
  250. }
  251. </style>