移动端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="scan">
  3. <div class="nav">
  4. <a class="close" @click="() => $router.go(-1)"></a>
  5. <p class="title">扫一扫</p>
  6. </div>
  7. <div class="scroll-container">
  8. <Scaner
  9. v-on:code-scanned="codeScanned"
  10. v-on:error-captured="errorCaptured"
  11. :stop-on-scanned="true"
  12. :draw-on-found="true"
  13. :responsive="false"
  14. />
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import Scaner from '@/components/qrcode//Scaner';
  20. import Cookies from "js-cookie";
  21. export default {
  22. name: 'Scan',
  23. components: {
  24. Scaner
  25. },
  26. data () {
  27. return {
  28. errorMessage: "",
  29. scanned: ""
  30. }
  31. },
  32. methods: {
  33. codeScanned(code) {
  34. this.scanned = code;
  35. setTimeout(() => {
  36. // alert(`扫码解析成功: ${code}`);
  37. Cookies.remove('scanLink')
  38. Cookies.set("scanLink", code);
  39. history.back(-1);
  40. }, 200)
  41. },
  42. errorCaptured(error) {
  43. switch (error.name) {
  44. case "NotAllowedError":
  45. this.errorMessage = "Camera permission denied.";
  46. break;
  47. case "NotFoundError":
  48. this.errorMessage = "There is no connected camera.";
  49. break;
  50. case "NotSupportedError":
  51. this.errorMessage =
  52. "Seems like this page is served in non-secure context.";
  53. break;
  54. case "NotReadableError":
  55. this.errorMessage =
  56. "Couldn't access your camera. Is it already in use?";
  57. break;
  58. case "OverconstrainedError":
  59. this.errorMessage = "Constraints don't match any installed camera.";
  60. break;
  61. default:
  62. this.errorMessage = "UNKNOWN ERROR: " + error.message;
  63. }
  64. console.error(this.errorMessage);
  65. alert('相机调用失败');
  66. }
  67. },
  68. mounted () {
  69. var str = navigator.userAgent.toLowerCase();
  70. var ver = str.match(/cpu iphone os (.*?) like mac os/);
  71. if (ver && ver[1].replace(/_/g,".") < '10.3.3') {
  72. alert('相机调用失败');
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="css" scoped>
  78. .scan {
  79. height: 100%;
  80. width: 100%;
  81. }
  82. .scan .nav {
  83. height: 116px;
  84. background: url('../../../../static/images/lawEnforcement/new/list_head.png') no-repeat;
  85. background-size: 100% 100%;
  86. position: fixed;
  87. top: 0;
  88. left: 0;
  89. width: 100%;
  90. font-size: 36px;
  91. line-height: 116px;
  92. text-align: center;
  93. color: #fff;
  94. z-index: 999;
  95. }
  96. .scan .nav .title {
  97. padding: 0;
  98. margin: 0;
  99. font-size: 16PX;
  100. color: #FFFFFF;
  101. text-align: center;
  102. }
  103. .scan .nav .close {
  104. width: 24px;
  105. height: 43.2px;
  106. background: url('../../../assets/images/sunVillage_info/list_icon_5.png') center center no-repeat;
  107. background-size: 20px 36px;
  108. position: absolute;
  109. left: 38px;
  110. top: 36px;
  111. }
  112. </style>