index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <template>
  2. <view
  3. :class="'custom-class ' + classPrefix + ' ' + (isImageName ? 'van-icon--image' : classPrefix + '-' + name)"
  4. :style="(color ? 'color: ' + color + ';' : '') + (size ? 'font-size: ' + sizeWithUnit + ';' : '') + customStyle"
  5. @tap="onClick"
  6. >
  7. <van-info :wx:if="info !== null || dot" :dot="dot" :info="info" custom-class="van-icon__info" />
  8. <image :wx:if="isImageName" :src="name" mode="aspectFit" class="van-icon__image" />
  9. </view>
  10. </template>
  11. <script>
  12. import { VantComponent } from '../common/component';
  13. import { addUnit } from '../common/utils';
  14. export default {
  15. data() {
  16. return {
  17. sizeWithUnit: null,
  18. isImageName: ''
  19. };
  20. },
  21. props: {
  22. dot: Boolean,
  23. info: null,
  24. size: {
  25. type: null
  26. },
  27. color: String,
  28. customStyle: String,
  29. classPrefix: {
  30. type: String,
  31. default: 'van-icon'
  32. },
  33. name: {
  34. type: String
  35. }
  36. },
  37. methods: {
  38. onClick() {
  39. this.$emit('click');
  40. },
  41. setSizeWithUnit(size) {
  42. this.setData({
  43. sizeWithUnit: addUnit(size)
  44. });
  45. }
  46. },
  47. watch: {
  48. size: {
  49. handler: function (size) {
  50. this.setData({
  51. sizeWithUnit: addUnit(size)
  52. });
  53. },
  54. immediate: true
  55. },
  56. name: {
  57. handler: function (val) {
  58. this.setData({
  59. isImageName: val.indexOf('/') !== -1
  60. });
  61. },
  62. immediate: true
  63. }
  64. }
  65. };
  66. </script>
  67. <style>
  68. @import '../common/index.ttss';
  69. @font-face {
  70. font-weight: 400;
  71. font-family: vant-icon;
  72. font-style: normal;
  73. font-display: auto;
  74. src: url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff2) format('woff2'), url(https://img.yzcdn.cn/vant/vant-icon-0bc654.woff) format('woff'),
  75. url(https://img.yzcdn.cn/vant/vant-icon-0bc654.ttf) format('truetype');
  76. }
  77. .van-icon {
  78. position: relative;
  79. font: normal normal normal 14px/1 vant-icon;
  80. font-size: inherit;
  81. text-rendering: auto;
  82. -webkit-font-smoothing: antialiased;
  83. }
  84. .van-icon,
  85. .van-icon:before {
  86. display: inline-block;
  87. }
  88. .van-icon-add-o:before {
  89. content: '\F000';
  90. }
  91. .van-icon-add-square:before {
  92. content: '\F001';
  93. }
  94. .van-icon-add:before {
  95. content: '\F002';
  96. }
  97. .van-icon-after-sale:before {
  98. content: '\F003';
  99. }
  100. .van-icon-aim:before {
  101. content: '\F004';
  102. }
  103. .van-icon-alipay:before {
  104. content: '\F005';
  105. }
  106. .van-icon-apps-o:before {
  107. content: '\F006';
  108. }
  109. .van-icon-arrow-down:before {
  110. content: '\F007';
  111. }
  112. .van-icon-arrow-left:before {
  113. content: '\F008';
  114. }
  115. .van-icon-arrow-up:before {
  116. content: '\F009';
  117. }
  118. .van-icon-arrow:before {
  119. content: '\F00A';
  120. }
  121. .van-icon-ascending:before {
  122. content: '\F00B';
  123. }
  124. .van-icon-audio:before {
  125. content: '\F00C';
  126. }
  127. .van-icon-award-o:before {
  128. content: '\F00D';
  129. }
  130. .van-icon-award:before {
  131. content: '\F00E';
  132. }
  133. .van-icon-bag-o:before {
  134. content: '\F00F';
  135. }
  136. .van-icon-bag:before {
  137. content: '\F010';
  138. }
  139. .van-icon-balance-list-o:before {
  140. content: '\F011';
  141. }
  142. .van-icon-balance-list:before {
  143. content: '\F012';
  144. }
  145. .van-icon-balance-o:before {
  146. content: '\F013';
  147. }
  148. .van-icon-balance-pay:before {
  149. content: '\F014';
  150. }
  151. .van-icon-bar-chart-o:before {
  152. content: '\F015';
  153. }
  154. .van-icon-bars:before {
  155. content: '\F016';
  156. }
  157. .van-icon-bell:before {
  158. content: '\F017';
  159. }
  160. .van-icon-bill-o:before {
  161. content: '\F018';
  162. }
  163. .van-icon-bill:before {
  164. content: '\F019';
  165. }
  166. .van-icon-birthday-cake-o:before {
  167. content: '\F01A';
  168. }
  169. .van-icon-bookmark-o:before {
  170. content: '\F01B';
  171. }
  172. .van-icon-bookmark:before {
  173. content: '\F01C';
  174. }
  175. .van-icon-browsing-history-o:before {
  176. content: '\F01D';
  177. }
  178. .van-icon-browsing-history:before {
  179. content: '\F01E';
  180. }
  181. .van-icon-brush-o:before {
  182. content: '\F01F';
  183. }
  184. .van-icon-bulb-o:before {
  185. content: '\F020';
  186. }
  187. .van-icon-bullhorn-o:before {
  188. content: '\F021';
  189. }
  190. .van-icon-calender-o:before {
  191. content: '\F022';
  192. }
  193. .van-icon-card:before {
  194. content: '\F023';
  195. }
  196. .van-icon-cart-circle-o:before {
  197. content: '\F024';
  198. }
  199. .van-icon-cart-circle:before {
  200. content: '\F025';
  201. }
  202. .van-icon-cart-o:before {
  203. content: '\F026';
  204. }
  205. .van-icon-cart:before {
  206. content: '\F027';
  207. }
  208. .van-icon-cash-back-record:before {
  209. content: '\F028';
  210. }
  211. .van-icon-cash-on-deliver:before {
  212. content: '\F029';
  213. }
  214. .van-icon-cashier-o:before {
  215. content: '\F02A';
  216. }
  217. .van-icon-certificate:before {
  218. content: '\F02B';
  219. }
  220. .van-icon-chart-trending-o:before {
  221. content: '\F02C';
  222. }
  223. .van-icon-chat-o:before {
  224. content: '\F02D';
  225. }
  226. .van-icon-chat:before {
  227. content: '\F02E';
  228. }
  229. .van-icon-checked:before {
  230. content: '\F02F';
  231. }
  232. .van-icon-circle:before {
  233. content: '\F030';
  234. }
  235. .van-icon-clear:before {
  236. content: '\F031';
  237. }
  238. .van-icon-clock-o:before {
  239. content: '\F032';
  240. }
  241. .van-icon-clock:before {
  242. content: '\F033';
  243. }
  244. .van-icon-close:before {
  245. content: '\F034';
  246. }
  247. .van-icon-closed-eye:before {
  248. content: '\F035';
  249. }
  250. .van-icon-cluster-o:before {
  251. content: '\F036';
  252. }
  253. .van-icon-cluster:before {
  254. content: '\F037';
  255. }
  256. .van-icon-column:before {
  257. content: '\F038';
  258. }
  259. .van-icon-comment-circle-o:before {
  260. content: '\F039';
  261. }
  262. .van-icon-comment-circle:before {
  263. content: '\F03A';
  264. }
  265. .van-icon-comment-o:before {
  266. content: '\F03B';
  267. }
  268. .van-icon-comment:before {
  269. content: '\F03C';
  270. }
  271. .van-icon-completed:before {
  272. content: '\F03D';
  273. }
  274. .van-icon-contact:before {
  275. content: '\F03E';
  276. }
  277. .van-icon-coupon-o:before {
  278. content: '\F03F';
  279. }
  280. .van-icon-coupon:before {
  281. content: '\F040';
  282. }
  283. .van-icon-credit-pay:before {
  284. content: '\F041';
  285. }
  286. .van-icon-cross:before {
  287. content: '\F042';
  288. }
  289. .van-icon-debit-pay:before {
  290. content: '\F043';
  291. }
  292. .van-icon-delete:before {
  293. content: '\F044';
  294. }
  295. .van-icon-descending:before {
  296. content: '\F045';
  297. }
  298. .van-icon-description:before {
  299. content: '\F046';
  300. }
  301. .van-icon-desktop-o:before {
  302. content: '\F047';
  303. }
  304. .van-icon-diamond-o:before {
  305. content: '\F048';
  306. }
  307. .van-icon-diamond:before {
  308. content: '\F049';
  309. }
  310. .van-icon-discount:before {
  311. content: '\F04A';
  312. }
  313. .van-icon-down:before {
  314. content: '\F04B';
  315. }
  316. .van-icon-ecard-pay:before {
  317. content: '\F04C';
  318. }
  319. .van-icon-edit:before {
  320. content: '\F04D';
  321. }
  322. .van-icon-ellipsis:before {
  323. content: '\F04E';
  324. }
  325. .van-icon-empty:before {
  326. content: '\F04F';
  327. }
  328. .van-icon-envelop-o:before {
  329. content: '\F050';
  330. }
  331. .van-icon-exchange:before {
  332. content: '\F051';
  333. }
  334. .van-icon-expand-o:before {
  335. content: '\F052';
  336. }
  337. .van-icon-expand:before {
  338. content: '\F053';
  339. }
  340. .van-icon-eye-o:before {
  341. content: '\F054';
  342. }
  343. .van-icon-eye:before {
  344. content: '\F055';
  345. }
  346. .van-icon-fail:before {
  347. content: '\F056';
  348. }
  349. .van-icon-failure:before {
  350. content: '\F057';
  351. }
  352. .van-icon-filter-o:before {
  353. content: '\F058';
  354. }
  355. .van-icon-fire-o:before {
  356. content: '\F059';
  357. }
  358. .van-icon-fire:before {
  359. content: '\F05A';
  360. }
  361. .van-icon-flag-o:before {
  362. content: '\F05B';
  363. }
  364. .van-icon-flower-o:before {
  365. content: '\F05C';
  366. }
  367. .van-icon-free-postage:before {
  368. content: '\F05D';
  369. }
  370. .van-icon-friends-o:before {
  371. content: '\F05E';
  372. }
  373. .van-icon-friends:before {
  374. content: '\F05F';
  375. }
  376. .van-icon-gem-o:before {
  377. content: '\F060';
  378. }
  379. .van-icon-gem:before {
  380. content: '\F061';
  381. }
  382. .van-icon-gift-card-o:before {
  383. content: '\F062';
  384. }
  385. .van-icon-gift-card:before {
  386. content: '\F063';
  387. }
  388. .van-icon-gift-o:before {
  389. content: '\F064';
  390. }
  391. .van-icon-gift:before {
  392. content: '\F065';
  393. }
  394. .van-icon-gold-coin-o:before {
  395. content: '\F066';
  396. }
  397. .van-icon-gold-coin:before {
  398. content: '\F067';
  399. }
  400. .van-icon-good-job-o:before {
  401. content: '\F068';
  402. }
  403. .van-icon-good-job:before {
  404. content: '\F069';
  405. }
  406. .van-icon-goods-collect-o:before {
  407. content: '\F06A';
  408. }
  409. .van-icon-goods-collect:before {
  410. content: '\F06B';
  411. }
  412. .van-icon-graphic:before {
  413. content: '\F06C';
  414. }
  415. .van-icon-home-o:before {
  416. content: '\F06D';
  417. }
  418. .van-icon-hot-o:before {
  419. content: '\F06E';
  420. }
  421. .van-icon-hot-sale-o:before {
  422. content: '\F06F';
  423. }
  424. .van-icon-hot-sale:before {
  425. content: '\F070';
  426. }
  427. .van-icon-hot:before {
  428. content: '\F071';
  429. }
  430. .van-icon-hotel-o:before {
  431. content: '\F072';
  432. }
  433. .van-icon-idcard:before {
  434. content: '\F073';
  435. }
  436. .van-icon-info-o:before {
  437. content: '\F074';
  438. }
  439. .van-icon-info:before {
  440. content: '\F075';
  441. }
  442. .van-icon-invition:before {
  443. content: '\F076';
  444. }
  445. .van-icon-label-o:before {
  446. content: '\F077';
  447. }
  448. .van-icon-label:before {
  449. content: '\F078';
  450. }
  451. .van-icon-like-o:before {
  452. content: '\F079';
  453. }
  454. .van-icon-like:before {
  455. content: '\F07A';
  456. }
  457. .van-icon-live:before {
  458. content: '\F07B';
  459. }
  460. .van-icon-location-o:before {
  461. content: '\F07C';
  462. }
  463. .van-icon-location:before {
  464. content: '\F07D';
  465. }
  466. .van-icon-lock:before {
  467. content: '\F07E';
  468. }
  469. .van-icon-logistics:before {
  470. content: '\F07F';
  471. }
  472. .van-icon-manager-o:before {
  473. content: '\F080';
  474. }
  475. .van-icon-manager:before {
  476. content: '\F081';
  477. }
  478. .van-icon-map-marked:before {
  479. content: '\F082';
  480. }
  481. .van-icon-medel-o:before {
  482. content: '\F083';
  483. }
  484. .van-icon-medel:before {
  485. content: '\F084';
  486. }
  487. .van-icon-more-o:before {
  488. content: '\F085';
  489. }
  490. .van-icon-more:before {
  491. content: '\F086';
  492. }
  493. .van-icon-music-o:before {
  494. content: '\F087';
  495. }
  496. .van-icon-music:before {
  497. content: '\F088';
  498. }
  499. .van-icon-new-arrival-o:before {
  500. content: '\F089';
  501. }
  502. .van-icon-new-arrival:before {
  503. content: '\F08A';
  504. }
  505. .van-icon-new-o:before {
  506. content: '\F08B';
  507. }
  508. .van-icon-new:before {
  509. content: '\F08C';
  510. }
  511. .van-icon-newspaper-o:before {
  512. content: '\F08D';
  513. }
  514. .van-icon-notes-o:before {
  515. content: '\F08E';
  516. }
  517. .van-icon-orders-o:before {
  518. content: '\F08F';
  519. }
  520. .van-icon-other-pay:before {
  521. content: '\F090';
  522. }
  523. .van-icon-paid:before {
  524. content: '\F091';
  525. }
  526. .van-icon-passed:before {
  527. content: '\F092';
  528. }
  529. .van-icon-pause-circle-o:before {
  530. content: '\F093';
  531. }
  532. .van-icon-pause-circle:before {
  533. content: '\F094';
  534. }
  535. .van-icon-pause:before {
  536. content: '\F095';
  537. }
  538. .van-icon-peer-pay:before {
  539. content: '\F096';
  540. }
  541. .van-icon-pending-payment:before {
  542. content: '\F097';
  543. }
  544. .van-icon-phone-circle-o:before {
  545. content: '\F098';
  546. }
  547. .van-icon-phone-circle:before {
  548. content: '\F099';
  549. }
  550. .van-icon-phone-o:before {
  551. content: '\F09A';
  552. }
  553. .van-icon-phone:before {
  554. content: '\F09B';
  555. }
  556. .van-icon-photo-o:before {
  557. content: '\F09C';
  558. }
  559. .van-icon-photo:before {
  560. content: '\F09D';
  561. }
  562. .van-icon-photograph:before {
  563. content: '\F09E';
  564. }
  565. .van-icon-play-circle-o:before {
  566. content: '\F09F';
  567. }
  568. .van-icon-play-circle:before {
  569. content: '\F0A0';
  570. }
  571. .van-icon-play:before {
  572. content: '\F0A1';
  573. }
  574. .van-icon-plus:before {
  575. content: '\F0A2';
  576. }
  577. .van-icon-point-gift-o:before {
  578. content: '\F0A3';
  579. }
  580. .van-icon-point-gift:before {
  581. content: '\F0A4';
  582. }
  583. .van-icon-points:before {
  584. content: '\F0A5';
  585. }
  586. .van-icon-printer:before {
  587. content: '\F0A6';
  588. }
  589. .van-icon-qr-invalid:before {
  590. content: '\F0A7';
  591. }
  592. .van-icon-qr:before {
  593. content: '\F0A8';
  594. }
  595. .van-icon-question-o:before {
  596. content: '\F0A9';
  597. }
  598. .van-icon-question:before {
  599. content: '\F0AA';
  600. }
  601. .van-icon-records:before {
  602. content: '\F0AB';
  603. }
  604. .van-icon-refund-o:before {
  605. content: '\F0AC';
  606. }
  607. .van-icon-replay:before {
  608. content: '\F0AD';
  609. }
  610. .van-icon-scan:before {
  611. content: '\F0AE';
  612. }
  613. .van-icon-search:before {
  614. content: '\F0AF';
  615. }
  616. .van-icon-send-gift-o:before {
  617. content: '\F0B0';
  618. }
  619. .van-icon-send-gift:before {
  620. content: '\F0B1';
  621. }
  622. .van-icon-service-o:before {
  623. content: '\F0B2';
  624. }
  625. .van-icon-service:before {
  626. content: '\F0B3';
  627. }
  628. .van-icon-setting-o:before {
  629. content: '\F0B4';
  630. }
  631. .van-icon-setting:before {
  632. content: '\F0B5';
  633. }
  634. .van-icon-share:before {
  635. content: '\F0B6';
  636. }
  637. .van-icon-shop-collect-o:before {
  638. content: '\F0B7';
  639. }
  640. .van-icon-shop-collect:before {
  641. content: '\F0B8';
  642. }
  643. .van-icon-shop-o:before {
  644. content: '\F0B9';
  645. }
  646. .van-icon-shop:before {
  647. content: '\F0BA';
  648. }
  649. .van-icon-shopping-cart-o:before {
  650. content: '\F0BB';
  651. }
  652. .van-icon-shopping-cart:before {
  653. content: '\F0BC';
  654. }
  655. .van-icon-shrink:before {
  656. content: '\F0BD';
  657. }
  658. .van-icon-sign:before {
  659. content: '\F0BE';
  660. }
  661. .van-icon-smile-comment-o:before {
  662. content: '\F0BF';
  663. }
  664. .van-icon-smile-comment:before {
  665. content: '\F0C0';
  666. }
  667. .van-icon-smile-o:before {
  668. content: '\F0C1';
  669. }
  670. .van-icon-smile:before {
  671. content: '\F0C2';
  672. }
  673. .van-icon-star-o:before {
  674. content: '\F0C3';
  675. }
  676. .van-icon-star:before {
  677. content: '\F0C4';
  678. }
  679. .van-icon-stop-circle-o:before {
  680. content: '\F0C5';
  681. }
  682. .van-icon-stop-circle:before {
  683. content: '\F0C6';
  684. }
  685. .van-icon-stop:before {
  686. content: '\F0C7';
  687. }
  688. .van-icon-success:before {
  689. content: '\F0C8';
  690. }
  691. .van-icon-thumb-circle-o:before {
  692. content: '\F0C9';
  693. }
  694. .van-icon-thumb-circle:before {
  695. content: '\F0CA';
  696. }
  697. .van-icon-todo-list-o:before {
  698. content: '\F0CB';
  699. }
  700. .van-icon-todo-list:before {
  701. content: '\F0CC';
  702. }
  703. .van-icon-tosend:before {
  704. content: '\F0CD';
  705. }
  706. .van-icon-tv-o:before {
  707. content: '\F0CE';
  708. }
  709. .van-icon-umbrella-circle:before {
  710. content: '\F0CF';
  711. }
  712. .van-icon-underway-o:before {
  713. content: '\F0D0';
  714. }
  715. .van-icon-underway:before {
  716. content: '\F0D1';
  717. }
  718. .van-icon-upgrade:before {
  719. content: '\F0D2';
  720. }
  721. .van-icon-user-circle-o:before {
  722. content: '\F0D3';
  723. }
  724. .van-icon-user-o:before {
  725. content: '\F0D4';
  726. }
  727. .van-icon-video-o:before {
  728. content: '\F0D5';
  729. }
  730. .van-icon-video:before {
  731. content: '\F0D6';
  732. }
  733. .van-icon-vip-card-o:before {
  734. content: '\F0D7';
  735. }
  736. .van-icon-vip-card:before {
  737. content: '\F0D8';
  738. }
  739. .van-icon-volume-o:before {
  740. content: '\F0D9';
  741. }
  742. .van-icon-volume:before {
  743. content: '\F0DA';
  744. }
  745. .van-icon-wap-home-o:before {
  746. content: '\F0DB';
  747. }
  748. .van-icon-wap-home:before {
  749. content: '\F0DC';
  750. }
  751. .van-icon-wap-nav:before {
  752. content: '\F0DD';
  753. }
  754. .van-icon-warn-o:before {
  755. content: '\F0DE';
  756. }
  757. .van-icon-warning-o:before {
  758. content: '\F0DF';
  759. }
  760. .van-icon-warning:before {
  761. content: '\F0E0';
  762. }
  763. .van-icon-weapp-nav:before {
  764. content: '\F0E1';
  765. }
  766. .van-icon-wechat:before {
  767. content: '\F0E2';
  768. }
  769. .van-icon-youzan-shield:before {
  770. content: '\F0E3';
  771. }
  772. :host {
  773. display: -webkit-inline-flex;
  774. display: inline-flex;
  775. -webkit-align-items: center;
  776. align-items: center;
  777. -webkit-justify-content: center;
  778. justify-content: center;
  779. }
  780. .van-icon--image {
  781. width: 1em;
  782. height: 1em;
  783. }
  784. .van-icon__image {
  785. width: 100%;
  786. height: 100%;
  787. }
  788. .van-icon__info {
  789. z-index: 1;
  790. }
  791. </style>