camera.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  4. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png" :isBack="true">
  5. <block slot="content">快速检测</block>
  6. </cu-custom>
  7. <camera device-position="back" flash="off" @error="error" style="width: 100%; height: 89.5vh;">
  8. <cover-view class="float-content">
  9. <cover-view class="out-border">
  10. <cover-view class="title">二维码</cover-view>
  11. <cover-view class="inside-border">
  12. <cover-view class="thick-line">
  13. <cover-view class="flag">C</cover-view>
  14. </cover-view>
  15. <cover-view class="thin-line"></cover-view>
  16. <cover-view class="thick-line">
  17. <cover-view class="flag">T</cover-view>
  18. </cover-view>
  19. </cover-view>
  20. </cover-view>
  21. <cover-view class="desc">请将显色区域放入框内</cover-view>
  22. </cover-view>
  23. <cover-view class="control">
  24. <cover-view class="take-photo" @click="takePhoto">
  25. <cover-view class="white-circle"></cover-view>
  26. </cover-view>
  27. </cover-view>
  28. </camera>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. }
  36. },
  37. methods: {
  38. takePhoto() {
  39. const ctx = uni.createCameraContext();
  40. ctx.takePhoto({
  41. quality: 'high',
  42. success: (res) => {
  43. uni.redirectTo({
  44. url: '/pages/quick-task/result?pic=' + res.tempImagePath
  45. });
  46. }
  47. });
  48. }
  49. }
  50. }
  51. </script>
  52. <style scoped>
  53. .control{
  54. position: absolute;
  55. bottom: 0;
  56. height: 15vh;
  57. width: 100%;
  58. background: rgba(0, 0, 0, 0.42);
  59. display: flex;
  60. justify-content: center;
  61. align-items: center;
  62. }
  63. .take-photo{
  64. width: 10vh;
  65. height: 10vh;
  66. border-radius: 50%;
  67. background: #b4b4b4;
  68. display: flex;
  69. justify-content: center;
  70. align-items: center;
  71. }
  72. .white-circle{
  73. width: 8vh;
  74. height: 8vh;
  75. border-radius: 50%;
  76. background: #fff;
  77. }
  78. .float-content{
  79. width: 100%;
  80. height: 75vh;
  81. display: flex;
  82. flex-direction: column;
  83. align-items: center;
  84. justify-content: center;
  85. }
  86. .out-border{
  87. width: 40%;
  88. height: 55vh;
  89. border: 2px solid #FFF;
  90. display: flex;
  91. flex-direction: column;
  92. align-items: center;
  93. justify-content: center;
  94. }
  95. .out-border .title{
  96. margin-top: -40%;
  97. color: red;
  98. font-size: 26px;
  99. margin-bottom: 5vh;
  100. font-weight: bold;
  101. }
  102. .desc{
  103. color: red;
  104. font-size: 16px;
  105. margin-top: 3vh;
  106. font-weight: bold;
  107. }
  108. .inside-border{
  109. border: 2px solid red;
  110. width: 40%;
  111. height: 10vh;
  112. display: flex;
  113. flex-direction: column;
  114. align-items: center;
  115. justify-content: center;
  116. }
  117. .thick-line{
  118. width: 80%;
  119. height: 2px;
  120. background: red;
  121. position: relative;
  122. }
  123. .thick-line .flag{
  124. font-size: 20px;
  125. position: absolute;
  126. right: -25px;
  127. top: -12px;
  128. margin-top: 0;
  129. font-weight: bold;
  130. }
  131. .thin-line{
  132. width: 80%;
  133. height: 1px;
  134. background: red;
  135. margin: 2.5vh 0;
  136. }
  137. </style>