list.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. this.$router.push(
  120. `${this.routePrefix}/approve/device/detail?id=${item.productId}`
  121. )
  122. },
  123. // 机构详情
  124. toClubDetail(item) {
  125. const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
  126. this.$router.push(url)
  127. },
  128. // 加载更多
  129. onLoadMore() {
  130. this.fetchList()
  131. },
  132. },
  133. }
  134. </script>
  135. <style scoped lang="scss">
  136. // pc 端
  137. @media screen and (min-width: 768px) {
  138. .page {
  139. position: relative;
  140. min-height: calc(100vh - 80px - 80px);
  141. background-color: #fff;
  142. }
  143. .page-top {
  144. height: 420px;
  145. @include themify($themes) {
  146. background: themed('pc-banner-device');
  147. }
  148. background-size: auto 420px;
  149. .logo {
  150. display: block;
  151. width: 120px;
  152. height: 120px;
  153. border-radius: 50%;
  154. background: #fff;
  155. }
  156. .name {
  157. font-size: 30px;
  158. color: #fff;
  159. }
  160. }
  161. .page-content {
  162. width: 1000px;
  163. margin: 0 auto;
  164. .title {
  165. font-size: 16px;
  166. color: #404040;
  167. span {
  168. @include themify($themes) {
  169. color: themed('color');
  170. }
  171. }
  172. }
  173. .list {
  174. display: flex;
  175. align-items: center;
  176. flex-wrap: wrap;
  177. justify-content: space-between;
  178. .empty {
  179. width: 390px;
  180. }
  181. .section {
  182. width: 490px;
  183. height: 136px;
  184. background-color: #f3f5f6;
  185. border-radius: 4px;
  186. box-sizing: border-box;
  187. padding: 16px;
  188. cursor: pointer;
  189. transition: all 0.4s;
  190. &:hover {
  191. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  192. }
  193. .cover {
  194. display: block;
  195. width: 104px;
  196. height: 104px;
  197. }
  198. .info {
  199. width: 336px;
  200. position: relative;
  201. .name {
  202. font-size: 18px;
  203. color: #101010;
  204. font-weight: bold;
  205. margin-bottom: 16px;
  206. margin-top: 4px;
  207. text-overflow: ellipsis;
  208. white-space: nowrap;
  209. overflow: hidden;
  210. }
  211. .code,
  212. .club-name {
  213. position: relative;
  214. font-size: 14px;
  215. color: #666;
  216. line-height: 24px;
  217. text-overflow: ellipsis;
  218. white-space: nowrap;
  219. overflow: hidden;
  220. margin-top: 6px;
  221. span {
  222. color: #1890ff;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. // 移动 端
  231. @media screen and (max-width: 768px) {
  232. .page-top {
  233. height: 46vw;
  234. @include themify($themes) {
  235. background: themed('h5-banner-device');
  236. background-size: auto 46vw;
  237. }
  238. .logo {
  239. display: block;
  240. width: 14.8vw;
  241. height: 14.8vw;
  242. border-radius: 50%;
  243. background: #fff;
  244. }
  245. .name {
  246. font-size: 4vw;
  247. color: #fff;
  248. }
  249. }
  250. .page-content {
  251. position: relative;
  252. .title {
  253. font-size: 3.4vw;
  254. color: #404040;
  255. span {
  256. @include themify($themes) {
  257. color: themed('color');
  258. }
  259. }
  260. }
  261. .list {
  262. display: flex;
  263. align-items: center;
  264. flex-direction: column;
  265. .section {
  266. width: 93.6vw;
  267. height: 26vw;
  268. background-color: #f3f5f6;
  269. border-radius: 4px;
  270. box-sizing: border-box;
  271. padding: 3.2vw;
  272. .cover {
  273. display: block;
  274. width: 19.6vw;
  275. height: 19.6vw;
  276. }
  277. .info {
  278. position: relative;
  279. margin-left: 3.2vw;
  280. .name {
  281. font-size: 4vw;
  282. color: #101010;
  283. font-weight: bold;
  284. margin-bottom: 4vw;
  285. text-overflow: ellipsis;
  286. white-space: nowrap;
  287. overflow: hidden;
  288. }
  289. .code,
  290. .club-name {
  291. width: 66vw;
  292. position: relative;
  293. font-size: 3vw;
  294. color: #404040;
  295. line-height: 5vw;
  296. text-overflow: ellipsis;
  297. white-space: nowrap;
  298. overflow: hidden;
  299. span {
  300. color: #6d9eff;
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. }
  308. </style>