uni_android_plugin_project
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.

116 lines
2.7 KiB

3 years ago
  1. <template>
  2. <view class="main">
  3. <!-- <barcode id='1' class="barcode" autostart="true" ref="barcode" background="rgb(0,0,0)" frameColor="#1C86EE" scanbarColor="#1C86EE" :filters="fil" @marked="success1" @error="fail1"></barcode> -->
  4. <button class="btn" @click="toStart">
  5. 开始扫码识别</button>
  6. <button class="btn" @click="tocancel">取消扫码识别</button>
  7. <button class="btn" @click="toFlash">开启闪光灯</button>
  8. <button class="btn" @click="toscan">预览</button>
  9. <button class="btn" @click="toback">
  10. <view class="dot"></view>
  11. 3s后返回</button>
  12. <!-- <view class="box">
  13. <view class="dot">5515</view>
  14. </view> -->
  15. <view class="bottom-dot"></view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. onLoad() {
  21. },
  22. data() {
  23. return {
  24. fil: [0, 2, 1]
  25. }
  26. },
  27. methods: {
  28. toback(){
  29. setTimeout(()=>{
  30. this.tocancel()
  31. uni.navigateBack()
  32. },3000)
  33. },
  34. success1(e) {
  35. console.log("success1:" + JSON.stringify(e));
  36. },
  37. fail1(e) {
  38. console.log("fail1:" + JSON.stringify(e));
  39. },
  40. toStart: function() {
  41. this.$refs.barcode.start({
  42. conserve: true,
  43. filename: '_doc/barcode/'
  44. });
  45. },
  46. tocancel:function(){
  47. this.$refs.barcode.cancel();
  48. },
  49. toFlash: function() {
  50. this.$refs.barcode.setFlash(true);
  51. },
  52. toscan: function() {
  53. console.log("scan:");
  54. const barcodeModule = uni.requireNativePlugin('barcodeScan');
  55. barcodeModule.scan("/static/barcode1.png"
  56. ,(e)=>{
  57. console.log("scan_error:"+JSON.stringify(e));
  58. });
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .main{
  65. .barcode {
  66. width: 750rpx;
  67. height: 700rpx;
  68. background-color: #808080;
  69. }
  70. .btn {
  71. top: 20rpx;
  72. width: 730rpx;
  73. margin-left: 10rpx;
  74. margin-top: 10rpx;
  75. background-color: #458B00;
  76. border-radius: 10rpx;
  77. position: relative;
  78. .dot{
  79. top: 20rpx;
  80. left: 20rpx;
  81. z-index:99;
  82. position: fixed;
  83. background-color: red;
  84. width: 30rpx;
  85. height: 30rpx;
  86. border-radius: 50%;
  87. }
  88. }
  89. .box{
  90. position: relative;
  91. width: 750rpx;
  92. height: 300rpx;
  93. background-color: #009874;
  94. }
  95. .bottom-dot{
  96. bottom: 0;
  97. // left: 100rpx;
  98. z-index:10;
  99. position: fixed;
  100. background-color: lightgray;
  101. width: 750rpx;
  102. height: 130rpx;
  103. // border-radius: 50%;
  104. }
  105. }
  106. </style>