list.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. background: url(https://static.caimei365.com/www/authentic/pc/bg-device.png);
  153. background-size: auto 420px;
  154. .logo {
  155. display: block;
  156. width: 120px;
  157. height: 120px;
  158. border-radius: 50%;
  159. background: #fff;
  160. }
  161. .name {
  162. font-size: 30px;
  163. color: #fff;
  164. }
  165. .logo,
  166. .name {
  167. transform: translateY(-30px);
  168. }
  169. }
  170. .page-content {
  171. width: 1200px;
  172. margin: 0 auto;
  173. .search {
  174. position: absolute;
  175. left: 50%;
  176. top: 300px;
  177. transform: translateX(-50%);
  178. }
  179. .title {
  180. font-size: 16px;
  181. color: #404040;
  182. span {
  183. color: #bc1724;
  184. }
  185. }
  186. .list {
  187. display: flex;
  188. align-items: center;
  189. flex-wrap: wrap;
  190. justify-content: space-between;
  191. .empty {
  192. width: 390px;
  193. }
  194. .section {
  195. width: 390px;
  196. height: 108px;
  197. background-color: #f3f5f6;
  198. border-radius: 4px;
  199. box-sizing: border-box;
  200. padding: 12px;
  201. cursor: pointer;
  202. transition: all 0.4s;
  203. &:hover {
  204. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  205. }
  206. .cover {
  207. display: block;
  208. width: 84px;
  209. height: 84px;
  210. }
  211. .info {
  212. width: 270px;
  213. position: relative;
  214. .name {
  215. font-size: 16px;
  216. color: #101010;
  217. font-weight: bold;
  218. margin-bottom: 16px;
  219. text-overflow: ellipsis;
  220. white-space: nowrap;
  221. overflow: hidden;
  222. }
  223. .code,
  224. .club-name {
  225. position: relative;
  226. font-size: 14px;
  227. color: #404040;
  228. line-height: 24px;
  229. text-overflow: ellipsis;
  230. white-space: nowrap;
  231. overflow: hidden;
  232. span {
  233. color: #6d9eff;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. // 移动 端
  242. @media screen and (max-width: 768px) {
  243. .page-top {
  244. height: 46vw;
  245. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  246. background-size: auto 46vw;
  247. .logo {
  248. display: block;
  249. width: 14.8vw;
  250. height: 14.8vw;
  251. border-radius: 50%;
  252. background: #fff;
  253. }
  254. .name {
  255. font-size: 4vw;
  256. color: #fff;
  257. }
  258. }
  259. .page-content {
  260. position: relative;
  261. .search {
  262. position: absolute;
  263. left: 50%;
  264. top: 0;
  265. transform: translate(-50%, -50%);
  266. }
  267. .title {
  268. font-size: 3.4vw;
  269. color: #404040;
  270. span {
  271. color: #bc1724;
  272. }
  273. }
  274. .list {
  275. display: flex;
  276. align-items: center;
  277. flex-direction: column;
  278. .section {
  279. width: 93.6vw;
  280. height: 26vw;
  281. background-color: #f3f5f6;
  282. border-radius: 4px;
  283. box-sizing: border-box;
  284. padding: 3.2vw;
  285. .cover {
  286. display: block;
  287. width: 19.6vw;
  288. height: 19.6vw;
  289. }
  290. .info {
  291. position: relative;
  292. margin-left: 3.2vw;
  293. .name {
  294. font-size: 4vw;
  295. color: #101010;
  296. font-weight: bold;
  297. margin-bottom: 4vw;
  298. text-overflow: ellipsis;
  299. white-space: nowrap;
  300. overflow: hidden;
  301. }
  302. .code,
  303. .club-name {
  304. width: 66vw;
  305. position: relative;
  306. font-size: 3vw;
  307. color: #404040;
  308. line-height: 5vw;
  309. text-overflow: ellipsis;
  310. white-space: nowrap;
  311. overflow: hidden;
  312. span {
  313. color: #6d9eff;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. </style>