list.vue 7.7 KB

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