saomachuku.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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 (ret.code == 0 || ret.code == '0') {
  189. // if(ret.Data[0].isRegular == 1 || ret.Data[0].isRegular == '1'){
  190. // api.toast({msg : "该物料是非正规渠道"});
  191. // return;
  192. // }
  193. if (!ret.message) {
  194. if (api.systemType != 'ios') {
  195. api.require('audioStreamer').openPlayer({
  196. path: 'widget://res/scansuccess.mp3',
  197. }, function (ret) {
  198. if (ret.status) {
  199. //api.alert({ msg: JSON.stringify(ret) });
  200. }
  201. });
  202. }
  203. if (ret.Data[0].maktx != null) {
  204. ret.Data[0].tireNumber = _this.code
  205. ret.Data[0].scanWay = 1
  206. _this.inputStore.push(ret.Data[0]);
  207. _this.codes.push(_this.code);
  208. }
  209. } else {
  210. api.toast({
  211. msg: ret.message,
  212. });
  213. return
  214. }
  215. }
  216. })
  217. },
  218. // 点击确定根据条形码获取商品
  219. doneSearch: function () {
  220. if (this.codes.indexOf(this.code) >= 0) {
  221. if (api.systemType != 'ios') {
  222. api.require('audioStreamer').openPlayer({
  223. path: 'widget://res/rescan.mp3',
  224. }, function (ret) {
  225. if (ret.status) {
  226. //api.alert({ msg: JSON.stringify(ret) });
  227. }
  228. });
  229. }
  230. api.toast({
  231. msg: '请勿重复扫码'
  232. });
  233. return;
  234. }
  235. var data = {
  236. "tireNumber": this.code,
  237. "id": this.userId,
  238. "scanWay": 0,
  239. "version": this.getVersion(),
  240. "type": "body",
  241. "url": "json"
  242. },
  243. url = "getStoreByScan",
  244. _this = this;
  245. this.$post(url, data, function (ret) {
  246. if (!ret.message) {
  247. if (api.systemType != 'ios') {
  248. api.require('audioStreamer').openPlayer({
  249. path: 'widget://res/scansuccess.mp3',
  250. }, function (ret) {
  251. if (ret.status) {
  252. //api.alert({ msg: JSON.stringify(ret) });
  253. }
  254. });
  255. }
  256. if (ret.code == 0 || ret.code == '0') {
  257. // if(ret.Data[0].isRegular == 1 || ret.Data[0].isRegular == '1'){
  258. // api.toast({msg : "该物料是非正规渠道"});
  259. // return;
  260. // }
  261. if (ret.Data[0].maktx != null) {
  262. ret.Data[0].tireNumber = _this.code
  263. ret.Data[0].scanWay = 0
  264. _this.inputStore.push(ret.Data[0]);
  265. _this.codes.push(_this.code);
  266. }
  267. }
  268. } else {
  269. api.toast({
  270. msg: ret.message,
  271. });
  272. return
  273. }
  274. })
  275. },
  276. // 扫码确认
  277. doneScan: function () {
  278. if (this.code == '') {
  279. api.toast({
  280. msg: "胎号不能为空"
  281. })
  282. return;
  283. }
  284. if (this.inputStore.length == 0) {
  285. api.toast({
  286. msg: "请完善扫码物料"
  287. })
  288. return;
  289. }
  290. var param = {
  291. store: JSON.stringify(this.inputStore),
  292. type: 2
  293. }
  294. this.goWin('chukutongji_win', 'chukutongji_win.html', param);
  295. // var data = {
  296. // "materialList" : this.inputStore,
  297. // "url" : 'json',
  298. // "type" : 'body'
  299. // },_this = this,url = "scanDoneU";
  300. // this.$post(url,data,function(ret){
  301. // if(ret.code == 0 || ret.code == '0'){
  302. // api.toast({
  303. // msg:'预入库成功'
  304. // });
  305. // _this.goWin('rukutongji_win', 'rukutongji_win.html', '');
  306. // }
  307. // })
  308. }
  309. },
  310. mounted: function () {
  311. this.init();
  312. }
  313. })
  314. }
  315. </script>
  316. </html>