index1.vue 5.7 KB

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