printScan1.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template xmlns="http://www.w3.org/1999/html">
  2. <div class="saleSelfMachine">
  3. <div class="background">
  4. <img :src="backgroundImgURL" width="100%" height="100%" />
  5. </div>
  6. <el-button @click.native="fullScreen" id="full" v-show="false"></el-button>
  7. <div class="orderNumberData">
  8. <!--v-show="false" disabled="!isEdit"-->
  9. <el-input
  10. placeholder="请将二维码放置在扫描区"
  11. v-model="orderNumber"
  12. :focus="true"
  13. ref="inputs"
  14. >
  15. </el-input>
  16. <!--style="display:block;width:120px"-->
  17. <div v-show="false">
  18. 手动输入开关:
  19. </div>
  20. <!-- <i class="el-icon-full-screen" @click="fullScreen"
  21. v-show="edit1"></i>-->
  22. <!-- <el-switch
  23. =======
  24. <i class="el-icon-full-screen" @click="fullScreen" v-show="edit1"></i>
  25. <el-switch
  26. :disabled="!isEdit"
  27. v-show="false"
  28. >
  29. </el-input>style="display:block;width:120px"-->
  30. <div v-show="false">
  31. 手动输入开关:
  32. </div>
  33. <i class="el-icon-full-screen" @click="fullScreen" v-show="edit1"></i>
  34. <!-- <el-switch
  35. v-model="isEdit"
  36. active-color="#66ccff"
  37. inactive-color="#ffffff"
  38. >
  39. </el-switch>-->
  40. </div>
  41. <!-- <div class="tip">
  42. 手机二维码对准下方摄像头<br />
  43. <div class="arrowDown">⇩</div>
  44. &lt;!&ndash; <i
  45. class="el-icon-bottom"
  46. style="padding-left: 450px;font-size: 300px;color: red"
  47. ></i> &ndash;&gt;
  48. </div>-->
  49. <div class="emg"><span style="">紧急联系人:0818-2521703</span></div>
  50. </div>
  51. </template>
  52. <script>
  53. import screenfull from 'screenfull'
  54. export default {
  55. data() {
  56. return {
  57. orderNumber: null,
  58. isEdit: true,
  59. edit1: true,
  60. backgroundImgURLList:[require('@/assets/saleSelfMachine/00.png'),
  61. require('@/assets/saleSelfMachine/01.png'),
  62. require('@/assets/saleSelfMachine/02.png'),
  63. require('@/assets/saleSelfMachine/03.png')],
  64. backgroundImgURL: require('@/assets/saleSelfMachine/00.png')
  65. }
  66. },
  67. created() {
  68. this.changfouce()
  69. },
  70. // watch:{
  71. // data:"toSaleSelfMachine"
  72. // },
  73. methods: {
  74. //打印函数
  75. printing(){
  76. console.log("进入了打印方法")
  77. this.backgroundImgURL=this.backgroundImgURLList[2];
  78. setTimeout(()=>{
  79. console.log("进入了第一层定时器")
  80. this.backgroundImgURL=this.backgroundImgURLList[3]
  81. setTimeout(()=>{
  82. console.log("进入了第二层定时器")
  83. this.backgroundImgURL=this.backgroundImgURLList[0]
  84. this.$route.params.index=0
  85. },2000)
  86. },30000);
  87. },
  88. //全屏函数
  89. fullScreen() {
  90. // screenfull.request()
  91. // console.log('wbei')
  92. // // documentElement 属性以一个元素对象返回一个文档的文档元素
  93. // // var el = document.documentElement
  94. // // el.requestFullscreen ||
  95. // // el.mozRequestFullScreen ||
  96. // // el.webkitRequestFullscreen ||
  97. // // el.msRequestFullScreen
  98. // // ? el.requestFullscreen() ||
  99. // // el.mozRequestFullScreen() ||
  100. // // el.webkitRequestFullscreen() ||
  101. // // el.msRequestFullscreen()
  102. // // : null
  103. var wscript = new ActiveXObject('WScript.Shell') //创建ActiveX
  104. if (wscript !== null) {
  105. //创建成功
  106. wscript.SendKeys('{F11}') //触发f11
  107. }
  108. },
  109. //输入框自动聚焦
  110. changfouce() {
  111. this.$nextTick(x => {
  112. this.$refs.inputs.focus()
  113. })
  114. },
  115. /*fullScreen() {
  116. if (screenfull.isEnabled && !screenfull.isFullscreen) {
  117. screenfull.request()
  118. this.edit1 = false
  119. }
  120. },*/
  121. /*async querynumber(){
  122. console.log(this.orderNumber)
  123. let orderNumber=this.orderNumber
  124. let i=0
  125. await this.axios.post("/api/v1/tms/queryNumber?orderNumber=" + orderNumber)
  126. .then((res)=>{
  127. console.log("查找出来的数据")
  128. console.log(res.data)
  129. console.log("-------------------------")
  130. if (res.data.printnumber==1){
  131. i=1
  132. }
  133. })
  134. console.log(i)
  135. return i
  136. this.edit1 = false;
  137. }
  138. },*/
  139. async querynumber() {
  140. console.log(this.orderNumber)
  141. let orderNumber = this.orderNumber
  142. let i = 0
  143. await this.axios
  144. .post('/api/v1/tms/queryNumber?orderNumber=' + orderNumber)
  145. .then(res => {
  146. console.log('查找出来的数据')
  147. console.log(res.data)
  148. console.log('-------------------------')
  149. if (res.data.printnumber == 1) {
  150. i = 1
  151. }
  152. })
  153. console.log(i)
  154. return i
  155. }
  156. //失去焦点后自动执行获得焦点事件
  157. // onInputBlur(){
  158. // console.log("获取焦点")
  159. // this.changfouce();
  160. // }
  161. // toSaleSelfMachine(){
  162. // this.$router.push({
  163. // path:'/saleSelfMachine',
  164. // })
  165. // }
  166. },
  167. mounted() {
  168. document.getElementById('full').click()
  169. console.log(screenfull.isFullscreen)
  170. console.log(this.$route.params.index)
  171. if (this.$route.params.index==1){
  172. this.printing();
  173. }
  174. /*const timer1 = setInterval(async ()=>{
  175. this.backgroundImgURL=this.backgroundImgURLList[0]
  176. },3000)*/
  177. const timer = setInterval(async () => {
  178. // if(this.$refs.inputs.focus==false){
  179. // console.log("false")
  180. this.changfouce()
  181. //}
  182. if (
  183. this.orderNumber != null &&
  184. this.orderNumber != '' &&
  185. this.orderNumber.length == 21
  186. ) {
  187. if (
  188. this.orderNumber.startsWith('WYSDD') == true ||
  189. this.orderNumber.startsWith('wysdd') == true
  190. ) {
  191. let promise = await this.querynumber(this.orderNumber)
  192. console.log(promise)
  193. if (promise == 1) {
  194. this.backgroundImgURL=this.backgroundImgURLList[1]
  195. this.orderNumber = null
  196. setTimeout(()=>{
  197. this.backgroundImgURL=this.backgroundImgURLList[0]
  198. console.log("进入该方法了")
  199. },4000)
  200. return
  201. }
  202. this.$router.push({
  203. path: '/printReceipt1?orderNumber=' + this.orderNumber
  204. })
  205. }
  206. } else if (
  207. this.orderNumber != null &&
  208. this.orderNumber != '' &&
  209. this.orderNumber.length > 21
  210. ) {
  211. //清空输入框,免得一次多个重复订单还无法删除
  212. this.orderNumber = null
  213. }
  214. }, 3000)
  215. this.$once('hook:beforeDestroy', () => {
  216. clearInterval(timer)
  217. })
  218. }
  219. }
  220. </script>
  221. <style lang="scss">
  222. .saleSelfMachine {
  223. width: 100vh;
  224. height: 100vh;
  225. .background {
  226. width: 100%;
  227. height: 100%;
  228. margin-top: 30px;
  229. z-index: -1;
  230. position: absolute;
  231. overflow: hidden;
  232. }
  233. .orderNumberData {
  234. width: 100%;
  235. color: #fff;
  236. position: absolute;
  237. display: flex;
  238. justify-content: center;
  239. align-items: center;
  240. }
  241. .tip {
  242. width: 1800px;
  243. height: 600px;
  244. font-size: 100px;
  245. padding-left: 350px;
  246. padding-top: 500px;
  247. color: #4cc9e9;
  248. .arrowDown {
  249. margin-top: 150px;
  250. padding-left: 450px;
  251. font-size: 300px;
  252. color: red;
  253. }
  254. }
  255. .emg {
  256. position: fixed;
  257. right: 20px;
  258. bottom: 20px;
  259. font-size: 30px;
  260. color: red;
  261. font-weight: 500;
  262. }
  263. }
  264. </style>