index.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  6. <link rel="stylesheet" href="./css/element.css">
  7. <script src="./js/babel.min.js"></script>
  8. <script src="./js/vue.js"></script>
  9. <script src="./js/axios.min.js"></script>
  10. <script src="./js/element.js"></script>
  11. <title>扫码查询</title>
  12. <script type="text/javascript">
  13. </script>
  14. <style>
  15. .info {
  16. margin: 30px 12px;
  17. }
  18. .info div {
  19. font-size: 16px;
  20. font-weight: bold;
  21. margin-top: 24px;
  22. }
  23. .hint {
  24. width: 100%;
  25. text-align: center;
  26. font-size: 18px;
  27. }
  28. .ProductItem {
  29. width: 100%;
  30. display: flex;
  31. align-items: center;
  32. justify-content: space-between;
  33. margin-bottom: 10px;
  34. }
  35. .ProductItem-label {
  36. color: #333333;
  37. font-size: 19px;
  38. width: 80px;
  39. text-align: left;
  40. }
  41. .ProductItem-content {
  42. flex: 1;
  43. overflow: hidden;
  44. margin-left: 10px;
  45. background-color: #F8F8F8;
  46. border-radius: 6px;
  47. height: 40px;
  48. padding: 6px 15px;
  49. box-sizing: border-box;
  50. display: flex;
  51. align-items: center;
  52. justify-content: space-between;
  53. color: #333333;
  54. }
  55. .qrcode-text {
  56. background-color: transparent;
  57. border: none;
  58. outline: none;
  59. width: 100%;
  60. height: 100%;
  61. border: none;
  62. outline: none;
  63. font-size: 16px;
  64. }
  65. .GoodSelect {
  66. border: none;
  67. }
  68. </style>
  69. </head>
  70. <body>
  71. <div id="app">
  72. <div class="ProductItem Qrcode-main">
  73. <p class="ProductItem-label">防伪码:</p>
  74. <div class="ProductItem-content">
  75. <input type="text" class="qrcode-text" ref="qrcode_text" v-model="qrcode" @focus="preventKeyBord"
  76. @blur="onBlur" @input="onInput" />
  77. </div>
  78. </div>
  79. <div class="info" v-if="scanInfo">
  80. <div>昵称:{{scanInfo.nickname}}</div>
  81. <div>手机号:{{scanInfo.phone}}</div>
  82. <div>款式:{{scanInfo.style}}</div>
  83. <div>价格:{{scanInfo.price}}</div>
  84. <div>出库时间:{{scanInfo.time}}</div>
  85. </div>
  86. </div>
  87. <script type="text/babel">
  88. var app = new Vue({
  89. el: '#app',
  90. data() {
  91. return {
  92. scanInfo:'', //扫码获取的信息
  93. qrcode:'' ,//code码
  94. code:''
  95. }
  96. },
  97. mounted() {
  98. this.onFocus()
  99. },
  100. watch: {
  101. 'qrcode': {
  102. deep: true,
  103. handler(newVal, oldVal) {
  104. this.debounce(this.getInfo, 200)
  105. }
  106. }
  107. },
  108. methods: {
  109. //防抖
  110. debounce(fn, wait) {
  111. if (this.timer !== null) {
  112. clearTimeout(this.timer)
  113. }
  114. this.timer = setTimeout(fn, wait)
  115. },
  116. preventKeyBord(e) {
  117. e.target.setAttribute("readonly", true);
  118. setTimeout(() => {
  119. e.target.removeAttribute("readonly")
  120. }, 100)
  121. },
  122. onInput(e) {
  123. let val = e.target.value
  124. let _a = val.split('/')
  125. let _v = _a[_a.length - 1]
  126. this.qrcode = _v
  127. },
  128. onFocus() {
  129. this.$nextTick(() => {
  130. this.$refs.qrcode_text.focus()
  131. })
  132. },
  133. onBlur() {
  134. this.onFocus()
  135. },
  136. getInfo(){
  137. let data = {code:this.qrcode}
  138. axios.post('http://fangwei.cliu.cc/api/LookTime',data).then(res => {
  139. if(res.code==200){
  140. this.scanInfo = res.data
  141. }else{
  142. window.ELEMENT.Message.error(res.msg||res.message)
  143. }
  144. }).catch(() => {
  145. window.ELEMENT.Message.error('获取信息失败')
  146. })
  147. },
  148. }
  149. })
  150. </script>
  151. </body>
  152. </html>