index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="page">
  3. <div class="page-content">
  4. <div class="title">设备认证信息</div>
  5. <template v-if="!isAuth">
  6. <div class="tip">抱歉,您暂未认证设备</div>
  7. <div class="btn" @click="toAuth">去认证</div>
  8. </template>
  9. <div class="device-list" v-else>
  10. <div
  11. class="device"
  12. @click="toDetail(product)"
  13. v-for="product in list"
  14. :key="product.productId"
  15. >
  16. <div class="cover">
  17. <img :src="product.image" :alt="product.productName" />
  18. </div>
  19. <div class="content">
  20. <div class="name">{{ product.productName }}</div>
  21. <div class="sncode">SN码:{{ product.snCode | formatSnCode }}</div>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="to-auth-btn" v-if="isAuth && !isPc" @click="toAuth">去认证</div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { mapGetters } from 'vuex'
  31. export default {
  32. layout: 'app-normal',
  33. data() {
  34. return {
  35. list: [],
  36. clubInfo: {},
  37. }
  38. },
  39. filters: {
  40. formatSnCode(code) {
  41. if (!code) return ''
  42. return code.replace(/^(\w{2})\w+(\w{4})$/, '$1******$2')
  43. },
  44. },
  45. computed: {
  46. ...mapGetters(['routePrefix', 'userInfo', 'authUserId', 'isPc']),
  47. isAuth() {
  48. return this.clubInfo.auditStatus === 1 && this.list.length > 0
  49. },
  50. },
  51. created() {
  52. this.fetchProductList()
  53. this.fetchAuthDetail()
  54. },
  55. methods: {
  56. // 产看详情
  57. toDetail(row) {
  58. const path = `${this.routePrefix}/center/device/detail?productId=${row.productId}&relationId=${row.relationId}`
  59. this.$router.push(path)
  60. },
  61. // 获取机构信息
  62. async fetchAuthDetail() {
  63. try {
  64. if (this.userInfo && !this.userInfo.authId) return
  65. const res = await this.$http.api.fetchClubAuthInfoData({
  66. authId: this.userInfo.authId,
  67. })
  68. this.clubInfo = res.data
  69. } catch (error) {
  70. console.log(error)
  71. }
  72. },
  73. // 获取已认证设备列表
  74. async fetchProductList() {
  75. try {
  76. const authId = this.userInfo.authId
  77. if (!authId) return
  78. const res = await this.$http.api.fetchClubAuthProductList({
  79. authId,
  80. authUserId: this.authUserId,
  81. })
  82. if (res.data) {
  83. this.list = res.data
  84. }
  85. } catch (error) {
  86. console.log(error)
  87. }
  88. },
  89. // 去认证
  90. toAuth() {
  91. this.$router.push(`${this.routePrefix}/form/club-register`)
  92. },
  93. },
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. @media screen and (min-width: 768px) {
  98. .page-content {
  99. width: 1000px;
  100. margin: 0 auto;
  101. .title {
  102. font-size: 24px;
  103. text-align: center;
  104. font-weight: bold;
  105. padding: 60px 0;
  106. }
  107. .tip {
  108. font-size: 16px;
  109. color: #b2b2b2;
  110. margin-top: 200px;
  111. margin-bottom: 24px;
  112. text-align: center;
  113. }
  114. .btn {
  115. width: 98px;
  116. height: 36px;
  117. background: #BC1724;
  118. border-radius: 4px;
  119. text-align: center;
  120. line-height: 36px;
  121. color: #fff;
  122. font-size: 16px;
  123. margin: 0 auto;
  124. cursor: pointer;
  125. }
  126. .device-list {
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. flex-wrap: wrap;
  131. .device {
  132. width: 490px;
  133. height: 136px;
  134. background: #f3f5f6;
  135. border-radius: 8px;
  136. display: flex;
  137. align-items: center;
  138. box-sizing: border-box;
  139. padding: 16px;
  140. margin-bottom: 20px;
  141. cursor: pointer;
  142. .cover {
  143. img {
  144. display: block;
  145. width: 106px;
  146. height: 106px;
  147. }
  148. }
  149. .content {
  150. width: 320px;
  151. margin-left: 16px;
  152. .name {
  153. font-size: 18px;
  154. color: #282828;
  155. font-weight: bold;
  156. margin-bottom: 24px;
  157. @include ellipsis(1);
  158. }
  159. .sncode {
  160. font-size: 16px;
  161. color: #666666;
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. @media screen and (max-width: 768px) {
  169. .page-content {
  170. .title {
  171. font-size: 4.2vw;
  172. text-align: center;
  173. font-weight: bold;
  174. padding: 8vw 0;
  175. }
  176. .to-auth-btn {
  177. width: 85.2vw;
  178. height: 12vw;
  179. background: #BC1724;
  180. border-radius: 0.2vw;
  181. text-align: center;
  182. line-height: 12vw;
  183. color: #ffffff;
  184. font-size: 3.6vw;
  185. position: fixed;
  186. bottom: 24vw;
  187. left: 50%;
  188. transform: translateX(-50%);
  189. }
  190. .tip {
  191. font-size: 3vw;
  192. color: #b2b2b2;
  193. margin-top: 60vw;
  194. margin-bottom: 4.8vw;
  195. text-align: center;
  196. }
  197. .btn {
  198. width: 36vw;
  199. height: 8.8vw;
  200. background: #BC1724;
  201. border-radius: 0.4vw;
  202. text-align: center;
  203. line-height: 8.8vw;
  204. color: #fff;
  205. font-size: 3.4vw;
  206. margin: 0 auto;
  207. }
  208. .device-list {
  209. padding: 0 3.2vw;
  210. padding-bottom: 26vw;
  211. .device {
  212. height: 26vw;
  213. background: #f3f5f6;
  214. border-radius: 0.8vw;
  215. display: flex;
  216. align-items: center;
  217. box-sizing: border-box;
  218. padding: 3.2vw;
  219. margin-bottom: 3.2vw;
  220. cursor: pointer;
  221. .cover {
  222. img {
  223. display: block;
  224. width: 19.6vw;
  225. height: 19.6vw;
  226. }
  227. }
  228. .content {
  229. width: 59vw;
  230. margin-left: 3.2vw;
  231. .name {
  232. font-size: 3.6vw;
  233. color: #282828;
  234. font-weight: bold;
  235. margin-bottom: 3.2vw;
  236. @include ellipsis(1);
  237. }
  238. .sncode {
  239. font-size: 3.6vw;
  240. color: #666666;
  241. }
  242. }
  243. }
  244. }
  245. }
  246. }
  247. </style>