list.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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 md:px-0">
  19. 共<span v-text="total"></span>台设备
  20. </div>
  21. <!-- 列表 -->
  22. <div class="list">
  23. <div
  24. class="section flex justify-between mb-4"
  25. v-for="item in list"
  26. :key="item.productId"
  27. @click="toDetail(item)"
  28. >
  29. <img class="cover" :src="item.productImage" />
  30. <div class="info">
  31. <div class="name" v-text="item.productName"></div>
  32. <div class="code">SN码:{{ item.snCode | formatSnCode }}</div>
  33. <div class="club-name">
  34. 所属机构:<span @click.stop="toClubDetail(item)">{{
  35. item.clubName
  36. }}</span>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 列表为空 -->
  42. <SimpleEmpty
  43. v-if="!total && !isRequest"
  44. name="icon-empty-device.png"
  45. description="敬请期待~"
  46. ></SimpleEmpty>
  47. </div>
  48. </van-list>
  49. </div>
  50. </template>
  51. <script>
  52. import { debounce } from '@/utils'
  53. import { mapGetters } from 'vuex'
  54. export default {
  55. layout: 'app-ross',
  56. filters: {
  57. formatSnCode(code) {
  58. if (!code) return ''
  59. return code.replace(/^(\w{2})\w+(\w{4})$/, '$1******$2')
  60. },
  61. },
  62. data() {
  63. return {
  64. isLoadingMore: true,
  65. finished: false,
  66. isRequest: true,
  67. listQuery: {
  68. productTypeId: '',
  69. snCode: '',
  70. authParty: '',
  71. pageNum: 1,
  72. pageSize: 10,
  73. },
  74. list: [],
  75. total: 0,
  76. }
  77. },
  78. computed: {
  79. ...mapGetters(['routePrefix', 'supplierInfo']),
  80. },
  81. mounted() {
  82. this.initData()
  83. },
  84. methods: {
  85. initData() {
  86. const { id, keyword, type } = this.$route.query
  87. this.listQuery.productTypeId = parseInt(id)
  88. if (type === '1') {
  89. this.listQuery.snCode = decodeURIComponent(keyword)
  90. } else {
  91. this.listQuery.authParty = decodeURIComponent(keyword)
  92. }
  93. this.fetchList()
  94. },
  95. fetchList: debounce(async function () {
  96. try {
  97. this.isLoadingMore = true
  98. const res = await this.$http.api.getAuthProductList(this.listQuery)
  99. this.list = [...this.list, ...res.data.list]
  100. this.finished = !res.data.hasNextPage
  101. this.total = res.data.total
  102. this.isLoadingMore = false
  103. this.listQuery.pageNum += 1
  104. } catch (error) {
  105. console.log(error)
  106. } finally {
  107. this.isRequest = false
  108. }
  109. }, 400),
  110. // 搜索
  111. onSearch() {
  112. this.list = []
  113. this.listQuery.pageNum = 1
  114. this.fetchList()
  115. },
  116. // 设备详情
  117. toDetail(item) {
  118. window.location.href = `${process.env.CIMEI_LOCAL}/product/auth/product-${item.productId}.html`
  119. },
  120. // 机构详情
  121. toClubDetail(item) {
  122. const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
  123. this.$router.push(url)
  124. },
  125. // 加载更多
  126. onLoadMore() {
  127. this.fetchList()
  128. },
  129. },
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. // pc 端
  134. @media screen and (min-width: 768px) {
  135. .page {
  136. position: relative;
  137. min-height: calc(100vh - 80px - 80px);
  138. background-color: #fff;
  139. }
  140. .page-top {
  141. height: 420px;
  142. @include themify($themes) {
  143. background: themed('pc-banner-device');
  144. }
  145. background-size: auto 420px;
  146. .logo {
  147. display: block;
  148. width: 120px;
  149. height: 120px;
  150. border-radius: 50%;
  151. background: #fff;
  152. }
  153. .name {
  154. font-size: 30px;
  155. color: #fff;
  156. }
  157. }
  158. .page-content {
  159. width: 1000px;
  160. margin: 0 auto;
  161. .title {
  162. font-size: 16px;
  163. color: #404040;
  164. span {
  165. @include themify($themes) {
  166. color: themed('color');
  167. }
  168. }
  169. }
  170. .list {
  171. display: flex;
  172. align-items: center;
  173. flex-wrap: wrap;
  174. justify-content: space-between;
  175. .empty {
  176. width: 390px;
  177. }
  178. .section {
  179. width: 490px;
  180. height: 136px;
  181. background-color: #f3f5f6;
  182. border-radius: 4px;
  183. box-sizing: border-box;
  184. padding: 16px;
  185. cursor: pointer;
  186. transition: all 0.4s;
  187. &:hover {
  188. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  189. }
  190. .cover {
  191. display: block;
  192. width: 104px;
  193. height: 104px;
  194. }
  195. .info {
  196. width: 336px;
  197. position: relative;
  198. .name {
  199. font-size: 18px;
  200. color: #101010;
  201. font-weight: bold;
  202. margin-bottom: 16px;
  203. margin-top: 4px;
  204. text-overflow: ellipsis;
  205. white-space: nowrap;
  206. overflow: hidden;
  207. }
  208. .code,
  209. .club-name {
  210. position: relative;
  211. font-size: 14px;
  212. color: #666;
  213. line-height: 24px;
  214. text-overflow: ellipsis;
  215. white-space: nowrap;
  216. overflow: hidden;
  217. margin-top: 6px;
  218. span {
  219. color: #1890ff;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. // 移动 端
  228. @media screen and (max-width: 768px) {
  229. .page-top {
  230. height: 46vw;
  231. @include themify($themes) {
  232. background: themed('h5-banner-device');
  233. background-size: auto 46vw;
  234. }
  235. .logo {
  236. display: block;
  237. width: 14.8vw;
  238. height: 14.8vw;
  239. border-radius: 50%;
  240. background: #fff;
  241. }
  242. .name {
  243. font-size: 4vw;
  244. color: #fff;
  245. }
  246. }
  247. .page-content {
  248. position: relative;
  249. .title {
  250. font-size: 3.4vw;
  251. color: #404040;
  252. span {
  253. @include themify($themes) {
  254. color: themed('color');
  255. }
  256. }
  257. }
  258. .list {
  259. display: flex;
  260. align-items: center;
  261. flex-direction: column;
  262. .section {
  263. width: 93.6vw;
  264. height: 26vw;
  265. background-color: #f3f5f6;
  266. border-radius: 4px;
  267. box-sizing: border-box;
  268. padding: 3.2vw;
  269. .cover {
  270. display: block;
  271. width: 19.6vw;
  272. height: 19.6vw;
  273. }
  274. .info {
  275. position: relative;
  276. margin-left: 3.2vw;
  277. .name {
  278. font-size: 4vw;
  279. color: #101010;
  280. font-weight: bold;
  281. margin-bottom: 4vw;
  282. text-overflow: ellipsis;
  283. white-space: nowrap;
  284. overflow: hidden;
  285. }
  286. .code,
  287. .club-name {
  288. width: 66vw;
  289. position: relative;
  290. font-size: 3vw;
  291. color: #404040;
  292. line-height: 5vw;
  293. text-overflow: ellipsis;
  294. white-space: nowrap;
  295. overflow: hidden;
  296. span {
  297. color: #6d9eff;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. </style>