saomachuku.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <!DOCTYPE html>
  2. <html>
  3. <!--STATUS OK-->
  4. <head>
  5. <meta name="referrer" content="always" />
  6. <meta charset='utf-8' />
  7. <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="x-dns-prefetch-control" content="on">
  9. <meta name="description" content="">
  10. <meta name="format-detection" content="telephone=no" />
  11. <link rel="stylesheet" type="text/css" href="css/vant-ui.css" />
  12. <link rel="stylesheet" type="text/css" href="css/iconfont.css">
  13. <link rel="stylesheet" type="text/css" href="css/main.css" />
  14. <script src="js/vue.js"></script>
  15. <script src="js/vant-ui.js"></script>
  16. <script src="js/main.js"></script>
  17. <title></title>
  18. </head>
  19. <style>
  20. .QRcode {
  21. color: #fff;
  22. font-size: .5rem;
  23. text-align: center;
  24. padding-top: 1.5rem;
  25. }
  26. .inputCode {
  27. width: 85%;
  28. background-color: #E2E2E2;
  29. border: none;
  30. border-radius: 5px;
  31. padding: .15rem .1rem;
  32. margin-left: 5px;
  33. }
  34. .inputBtn {
  35. margin: 7px;
  36. }
  37. .initInput {
  38. background-color: #fff;
  39. padding: .1rem;
  40. justify-content: flex-start !important;
  41. position: absolute;
  42. width: 100%;
  43. left: 0;
  44. right: 0;
  45. bottom: -10px;
  46. }
  47. </style>
  48. <body>
  49. <div class="shaomachuku" id="input" v-cloak>
  50. <div class="QRcode" v-on:click="startScan">
  51. 点击扫码
  52. </div>
  53. <div class="addCount flex a-center j-center" v-on:click="setQueryInputLoction">
  54. <i></i> 手工录入
  55. </div>
  56. <div class="addCount a-center j-center initInput" id="inputCode" v-show="showInput == 'show'">
  57. <input class="inputCode" id="inputCode_input" type="number" placeholder="请输入条形码号" v-model="code" />
  58. <div class="inputBtn" style="float: right" v-on:click="doneSearch">
  59. 确定
  60. </div>
  61. </div>
  62. <table>
  63. <tr>
  64. <td>胎号</td>
  65. <td>物料</td>
  66. </tr>
  67. <tr v-for="store in inputStore">
  68. <td>{{ store.tirenumber }}</td>
  69. <td>{{ store.maktx }}</td>
  70. </tr>
  71. </table>
  72. <!-- <div class="QRsend flex a-center j-center">
  73. 扫码<br/>完成
  74. </div>-->
  75. <div class="paisheBtn flex a-center j-center" v-on:click="doneScan" v-if="showInput == 'hide'">
  76. 扫码确认
  77. </div>
  78. </div>
  79. </body>
  80. <script type="text/javascript" src="../script/jquery-1.11.0.min.js"></script>
  81. <script type="text/javascript" src="../script/api.js"></script>
  82. <script type="text/javascript" src="../script/httpRequest.js"></script>
  83. <script type="text/javascript" src="../script/vue_plugins.js"></script>
  84. <script type="text/javascript">
  85. apiready = function() {
  86. new Vue({
  87. el: '#input',
  88. data: {
  89. list: [],
  90. FNScanner: '', // 扫码插件
  91. code: '',
  92. UIinput: '', // 输入框
  93. showInput: 'hide',
  94. inputStore: [], // 扫码入库的商品
  95. codes: [],
  96. },
  97. methods: {
  98. init: function() {
  99. var _this = this;
  100. this.userId = $api.getStorage('userid');
  101. var winHeight = $(window).height();
  102. //获取当前页面高度
  103. $(window).resize(function() {
  104. var thisHeight = $(this).height();
  105. if (winHeight - thisHeight > 50) {
  106. //当软键盘弹出,在这里面操作
  107. } else {
  108. //当软键盘收起,在此处操作
  109. _this.showInput = 'hide';
  110. }
  111. });
  112. this.scanCode = api.require('FNScanner');
  113. this.startScan();
  114. this.addEvent('refushku', function() {
  115. _this.inputStore = new Array();
  116. })
  117. },
  118. // 开始扫码
  119. startScan: function() {
  120. if (api.systemType != 'ios') {
  121. api.require('audioStreamer').openPlayer({
  122. path: 'widget://res/startscan.mp3',
  123. }, function(ret) {
  124. if (ret.status) {
  125. //api.alert({ msg: JSON.stringify(ret) });
  126. }
  127. });
  128. }
  129. var _this = this;
  130. this.ifHasPrme('camera', function(ret) {
  131. if (ret == true) {
  132. _this.scan(_this.scanCode, function(res) {
  133. if (res) {
  134. _this.code = res;
  135. _this.doneSearch2();
  136. }
  137. })
  138. // _this.scanCode.scan(function(ret, err) {
  139. // if (ret.status) {
  140. // _this.code = ret.code;
  141. // _this.doneSearch();
  142. // }
  143. // });
  144. }
  145. })
  146. // this.scanCode.scan(function(ret, err) {
  147. // if (ret.status) {
  148. // _this.code = ret.code;
  149. // _this.doneSearch();
  150. // }
  151. // });
  152. },
  153. // 获取输入框的高度,然后调整input输入框的位置
  154. setQueryInputLoction: function() {
  155. var _this = this;
  156. this.showInput = 'show';
  157. this.$nextTick(function() {
  158. document.getElementById('inputCode_input').focus();
  159. })
  160. },
  161. doneSearch2: function() {
  162. if (this.codes.indexOf(this.code) >= 0) {
  163. if (api.systemType != 'ios') {
  164. api.require('audioStreamer').openPlayer({
  165. path: 'widget://res/rescan.mp3',
  166. }, function(ret) {
  167. if (ret.status) {
  168. //api.alert({ msg: JSON.stringify(ret) });
  169. }
  170. });
  171. }
  172. api.toast({
  173. msg: '请勿重复扫码'
  174. });
  175. return;
  176. }
  177. var data = {
  178. "tireNumber": this.code,
  179. "id": this.userId,
  180. "scanWay": 1,
  181. "version":this.getVersion(),
  182. "type": "body",
  183. "url": "json"
  184. },
  185. url = "getStoreByScan",
  186. _this = this;
  187. this.$post(url, data, function(ret) {
  188. if (api.systemType != 'ios') {
  189. api.require('audioStreamer').openPlayer({
  190. path: 'widget://res/scansuccess.mp3',
  191. }, function(ret) {
  192. if (ret.status) {
  193. //api.alert({ msg: JSON.stringify(ret) });
  194. }
  195. });
  196. }
  197. if (ret.code == 0 || ret.code == '0') {
  198. // if(ret.Data[0].isRegular == 1 || ret.Data[0].isRegular == '1'){
  199. // api.toast({msg : "该物料是非正规渠道"});
  200. // return;
  201. // }
  202. if (ret.Data[0].maktx != null) {
  203. ret.Data[0].tireNumber = _this.code
  204. ret.Data[0].scanWay = 1
  205. _this.inputStore.push(ret.Data[0]);
  206. _this.codes.push(_this.code);
  207. }
  208. }
  209. })
  210. },
  211. // 点击确定根据条形码获取商品
  212. doneSearch: function() {
  213. if (this.codes.indexOf(this.code) >= 0) {
  214. if (api.systemType != 'ios') {
  215. api.require('audioStreamer').openPlayer({
  216. path: 'widget://res/rescan.mp3',
  217. }, function(ret) {
  218. if (ret.status) {
  219. //api.alert({ msg: JSON.stringify(ret) });
  220. }
  221. });
  222. }
  223. api.toast({
  224. msg: '请勿重复扫码'
  225. });
  226. return;
  227. }
  228. var data = {
  229. "tireNumber": this.code,
  230. "id": this.userId,
  231. "scanWay": 0,
  232. "version":this.getVersion(),
  233. "type": "body",
  234. "url": "json"
  235. },
  236. url = "getStoreByScan",
  237. _this = this;
  238. this.$post(url, data, function(ret) {
  239. if (api.systemType != 'ios') {
  240. api.require('audioStreamer').openPlayer({
  241. path: 'widget://res/scansuccess.mp3',
  242. }, function(ret) {
  243. if (ret.status) {
  244. //api.alert({ msg: JSON.stringify(ret) });
  245. }
  246. });
  247. }
  248. if (ret.code == 0 || ret.code == '0') {
  249. // if(ret.Data[0].isRegular == 1 || ret.Data[0].isRegular == '1'){
  250. // api.toast({msg : "该物料是非正规渠道"});
  251. // return;
  252. // }
  253. if (ret.Data[0].maktx != null) {
  254. ret.Data[0].tireNumber = _this.code
  255. ret.Data[0].scanWay = 0
  256. _this.inputStore.push(ret.Data[0]);
  257. _this.codes.push(_this.code);
  258. }
  259. }
  260. })
  261. },
  262. // 扫码确认
  263. doneScan: function() {
  264. if (this.code == '') {
  265. api.toast({
  266. msg: "胎号不能为空"
  267. })
  268. return;
  269. }
  270. if (this.inputStore.length == 0) {
  271. api.toast({
  272. msg: "请完善扫码物料"
  273. })
  274. return;
  275. }
  276. var param = {
  277. store: JSON.stringify(this.inputStore),
  278. type: 2
  279. }
  280. this.goWin('chukutongji_win', 'chukutongji_win.html', param);
  281. // var data = {
  282. // "materialList" : this.inputStore,
  283. // "url" : 'json',
  284. // "type" : 'body'
  285. // },_this = this,url = "scanDoneU";
  286. // this.$post(url,data,function(ret){
  287. // if(ret.code == 0 || ret.code == '0'){
  288. // api.toast({
  289. // msg:'预入库成功'
  290. // });
  291. // _this.goWin('rukutongji_win', 'rukutongji_win.html', '');
  292. // }
  293. // })
  294. }
  295. },
  296. mounted: function() {
  297. this.init();
  298. }
  299. })
  300. }
  301. </script>
  302. </html>