printScan.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div class="saleSelfMachine">
  3. <div class="background">
  4. <img :src="backgroundImgURL" width="100%" height="100%"/>
  5. </div>
  6. <div class="orderNumberData">
  7. <el-input placeholder="请将二维码放置在扫描区" v-model="orderNumber" :focus="true" ref="inputs">
  8. </el-input>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. data(){
  15. return{
  16. orderNumber:null,
  17. backgroundImgURL:require('@/assets/saleSelfMachine/scanCode.jpg'),
  18. }
  19. },
  20. created(){
  21. this.changfouce();
  22. },
  23. // watch:{
  24. // data:"toSaleSelfMachine"
  25. // },
  26. methods:{
  27. //输入框自动聚焦
  28. changfouce(){
  29. this.$nextTick((x)=>{
  30. this.$refs.inputs.focus();
  31. })
  32. },
  33. //失去焦点后自动执行获得焦点事件
  34. // onInputBlur(){
  35. // console.log("获取焦点")
  36. // this.changfouce();
  37. // }
  38. // toSaleSelfMachine(){
  39. // this.$router.push({
  40. // path:'/saleSelfMachine',
  41. // })
  42. // }
  43. },
  44. mounted(){
  45. // this.changfouce();
  46. const timer = setInterval(()=>{
  47. // if(this.$refs.inputs.focus==false){
  48. // console.log("false")
  49. this.changfouce();
  50. //}
  51. if(this.orderNumber!=null&&this.orderNumber.length==21){
  52. if(this.orderNumber.startsWith('WYSDD')==true||this.orderNumber.startsWith('wysdd')==true){
  53. this.$router.push({
  54. path:"/saleSelfMachine?orderNumber="+this.orderNumber,
  55. })
  56. }
  57. }
  58. },3000)
  59. this.$once('hook:beforeDestroy', ()=>{
  60. clearInterval(timer)
  61. })
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. .saleSelfMachine{
  67. width: 100vh;
  68. height: 100vh;
  69. .background {
  70. width: 100%;
  71. height: 100%;
  72. z-index: -1;
  73. position: absolute;
  74. overflow: hidden;
  75. }
  76. .orderNumberData{
  77. width: 20%;height: 30%;
  78. color: #fff;
  79. position: absolute;
  80. display: flex;
  81. justify-content: center;
  82. align-items: center;
  83. margin-left: 27rem;
  84. }
  85. }
  86. </style>