saomaruku.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. },
  147. // 获取输入框的高度,然后调整input输入框的位置
  148. setQueryInputLoction: function () {
  149. var _this = this;
  150. this.showInput = 'show';
  151. this.$nextTick(function () {
  152. document.getElementById('inputCode_input').focus();
  153. })
  154. },
  155. // 点击确定根据条形码获取商品
  156. doneSearch2: function () {
  157. if (this.codes.indexOf(this.code) >= 0) {
  158. if (api.systemType != 'ios') {
  159. api.require('audioStreamer').openPlayer({
  160. path: 'widget://res/rescan.mp3',
  161. }, function (ret) {
  162. if (ret.status) {
  163. //api.alert({ msg: JSON.stringify(ret) });
  164. }
  165. });
  166. }
  167. api.toast({
  168. msg: '请勿重复扫码'
  169. });
  170. return;
  171. }
  172. var data = {
  173. "tireNumber": this.code,
  174. "id": this.userId,
  175. "scanWay": 1,
  176. "version": this.getVersion(),
  177. "type": "body",
  178. "url": "json"
  179. },
  180. url = "getStoreByScan",
  181. _this = this;
  182. this.$post(url, data, function (ret) {
  183. if (ret.code == 0 || ret.code == '0') {
  184. // if (ret.Data[0].isRegular == 1 || ret.Data[0].isRegular == '1') {
  185. // api.toast({
  186. // msg: "该物料是非正规渠道"
  187. // });
  188. // return;
  189. // }
  190. if (!ret.message) {
  191. if (api.systemType != 'ios') {
  192. api.require('audioStreamer').openPlayer({
  193. path: 'widget://res/scansuccess.mp3',
  194. }, function (ret) {
  195. if (ret.status) {
  196. //api.alert({ msg: JSON.stringify(ret) });
  197. }
  198. });
  199. }
  200. if (ret.Data[0].maktx != null) {
  201. ret.Data[0].tireNumber = _this.code
  202. ret.Data[0].scanWay = 1
  203. _this.inputStore.push(ret.Data[0]);
  204. _this.codes.push(_this.code);
  205. }
  206. } else {
  207. api.toast({
  208. msg: ret.message,
  209. });
  210. return
  211. }
  212. }
  213. })
  214. },
  215. doneSearch: function () {
  216. if (this.codes.indexOf(this.code) >= 0) {
  217. if (api.systemType != 'ios') {
  218. api.require('audioStreamer').openPlayer({
  219. path: 'widget://res/rescan.mp3',
  220. }, function (ret) {
  221. if (ret.status) {
  222. //api.alert({ msg: JSON.stringify(ret) });
  223. }
  224. });
  225. }
  226. // this.inInput=false;
  227. this.showInput = 'hide';
  228. api.toast({
  229. msg: '请勿重复输入'
  230. });
  231. return;
  232. }
  233. // this.inInput=false;
  234. this.showInput = 'hide';
  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({
  259. // msg: "该物料是非正规渠道"
  260. // });
  261. // return;
  262. // }
  263. if (ret.Data[0].maktx != null) {
  264. ret.Data[0].tireNumber = _this.code
  265. ret.Data[0].scanWay = 0
  266. _this.inputStore.push(ret.Data[0]);
  267. _this.codes.push(_this.code);
  268. }
  269. }
  270. } else {
  271. api.toast({
  272. msg: ret.message,
  273. });
  274. return
  275. }
  276. })
  277. },
  278. // 扫码确认
  279. doneScan: function () {
  280. if (this.codes.length == 0) {
  281. api.toast({
  282. msg: "胎号不能为空"
  283. })
  284. return;
  285. }
  286. if (this.inputStore.length == 0) {
  287. api.toast({
  288. msg: "请完善扫码物料"
  289. })
  290. return;
  291. }
  292. var param = {
  293. store: JSON.stringify(this.inputStore),
  294. type: 1
  295. }
  296. this.goWin('rukutongji_win', 'rukutongji_win.html', param);
  297. var data = {
  298. "storeId": this.userId,
  299. "url": 'json',
  300. "type": 'body'
  301. }, _this = this, url = "CouponupdateStatus";
  302. this.$post(url, data, function (ret) {
  303. })
  304. }
  305. },
  306. mounted: function () {
  307. this.init();
  308. }
  309. })
  310. }
  311. </script>
  312. </html>