getCode.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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/index.css">
  7. <!-- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> -->
  8. <script src="../js/babel.min.js"></script>
  9. <script src="../js/vue.js"></script>
  10. <script src="../js/axios.min.js"></script>
  11. <script src="../js/index.js"></script>
  12. <title>大卫博士-退货信息登记</title>
  13. <script type="text/javascript">
  14. document.addEventListener('plusready', function() {
  15. //console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。")
  16. });
  17. </script>
  18. <style>
  19. .el-input__prefix {
  20. display: none;
  21. }
  22. .el-input__suffix {
  23. display: none;
  24. }
  25. .el-input__inner {
  26. border: none !important;
  27. background-color: #F8F8F8 !important;
  28. padding: 0 !important;
  29. }
  30. * {
  31. margin: 0;
  32. padding: 0;
  33. }
  34. #app {
  35. /* width: 100%; */
  36. padding: 36px 15px 0 15px;
  37. height: 100%;
  38. color: #333;
  39. }
  40. .title {
  41. font-size: 21px;
  42. font-weight: bold;
  43. margin-bottom: 27px;
  44. }
  45. .flex {
  46. display: flex;
  47. align-items: center;
  48. }
  49. .flex2 {
  50. display: flex;
  51. /* justify-content: space-between; */
  52. align-items: center;
  53. margin-top: 15px;
  54. }
  55. img {
  56. width: 24px;
  57. height: 24px;
  58. }
  59. .flex-title {
  60. font-size: 18px;
  61. font-weight: bold;
  62. width: 72px;
  63. }
  64. .flex-title2 {
  65. font-size: 18px;
  66. font-weight: bold;
  67. }
  68. .flex-span {
  69. font-size: 18px;
  70. margin-left: 5px;
  71. }
  72. .flex-one {
  73. border-radius: 6px;
  74. display: flex;
  75. justify-content: space-between;
  76. align-items: center;
  77. background: #F8F8F8;
  78. align-items: center;
  79. padding-right: 5px;
  80. }
  81. .flex-danhao {
  82. height: 45px;
  83. background: #F8F8F8;
  84. border-radius: 6px;
  85. line-height: 45px;
  86. padding: 0 15px;
  87. font-size: 18px;
  88. border: none;
  89. outline: none;
  90. flex: 1;
  91. overflow: hidden;
  92. /* margin-left: 10px; */
  93. }
  94. .bg {
  95. height: 45px;
  96. background: #F8F8F8;
  97. border-radius: 6px;
  98. line-height: 45px;
  99. flex: 1;
  100. padding: 0 10px 0 15px;
  101. }
  102. .inputBg {
  103. width: 90%;
  104. background: #F8F8F8;
  105. font-size: 18px;
  106. border: none;
  107. outline: none;
  108. overflow: hidden;
  109. }
  110. .submit-flex {
  111. padding: 0 9px;
  112. display: flex;
  113. justify-content: space-between;
  114. align-items: center;
  115. margin-top: 51px;
  116. }
  117. .submit {
  118. width: 144px;
  119. height: 47px;
  120. background: linear-gradient(93deg, #A080FF 0%, #5D6BFF 100%);
  121. border-radius: 33px;
  122. color: #fff;
  123. font-size: 18px;
  124. text-align: center;
  125. line-height: 47px;
  126. }
  127. input::-webkit-input-placeholder{
  128. font-size: 18px;
  129. color: #BFBFBF;
  130. }
  131. </style>
  132. </head>
  133. <body>
  134. <div id="app">
  135. <div class="title">
  136. 信息登记
  137. </div>
  138. <div class="flex">
  139. <div class="flex-title2">
  140. 方式:
  141. </div>
  142. <div class="flex">
  143. <img :src="!type?'../img/true.png': '../img/false.png'" @click="type = false,onFocus(), clear() ">
  144. <span class="flex-span"> 扫码</span>
  145. <img style="margin-left: 30px;" :src="type?'../img/true.png': '../img/false.png'" @click="type = true, clear()">
  146. <span class="flex-span"> 输入</span>
  147. </div>
  148. </div>
  149. <div class="flex2" v-show="!type">
  150. <div class="flex-title">
  151. 防伪码:
  152. </div>
  153. <div class="flex-one bg">
  154. <input class="inputBg" ref="qrcode_text" v-model="form.qrcode" @focus="preventKeyBord" @input="onInput" type="text" placeholder="扫描防伪码" />
  155. <img src="../img/error.png" class="Content-error" @click="clear">
  156. </div>
  157. <!-- <div class="flex-one">
  158. <input class="flex-danhao" v-model="qrcode" ref="qrcode_text" @focus="preventKeyBord" @input="onInput" type="text" :disabled="!disCode" />
  159. <img src="../img/error.png" class="Content-error" @click="clear">
  160. </div> -->
  161. </div>
  162. <div class="flex2">
  163. <div class="flex-title">
  164. 类型:
  165. </div>
  166. <input v-if="!type" v-model="form.name" type="text" class="flex-danhao" :disabled="!type" />
  167. <el-select v-if="type" v-model="form.name" placeholder="请选择类型" class="flex-danhao">
  168. <el-option
  169. v-for="item in nameList"
  170. :key="item"
  171. :label="item"
  172. :value="item"
  173. />
  174. </el-select>
  175. </div>
  176. <div class="flex2">
  177. <div class="flex-title">
  178. 款式:
  179. </div>
  180. <input v-if="!type" v-model="form.type" ref="qrcodeOne" type="text" class="flex-danhao" @focus="preventKeyBord" @input="onInputTwo" :placeholder="type?'':'扫描款式'" />
  181. <el-select v-if="type" v-model="form.type" placeholder="请选择款式" class="flex-danhao">
  182. <el-option
  183. v-for="item in typeList"
  184. :key="item"
  185. :label="item"
  186. :value="item"
  187. />
  188. </el-select>
  189. </div>
  190. <div class="flex2">
  191. <div class="flex-title">
  192. 尺码:
  193. </div>
  194. <input v-if="!type" v-model="form.size" ref="qrcodeTwo" type="text" class="flex-danhao" @focus="preventKeyBord" @input="onInputThree" :placeholder="type?'':'扫描尺码'" />
  195. <el-select v-if="type" v-model="form.size" placeholder="请选择尺码" class="flex-danhao">
  196. <el-option
  197. v-for="item in sizeList"
  198. :key="item"
  199. :label="item"
  200. :value="item"
  201. />
  202. </el-select>
  203. </div>
  204. <div class="flex2">
  205. <div class="flex-title">
  206. 数量:
  207. </div>
  208. <input v-model.number="form.num" type="number" class="flex-danhao" :disabled="!type" />
  209. </div>
  210. <div class="flex2">
  211. <div class="flex-title">
  212. 时间:
  213. </div>
  214. <el-date-picker
  215. v-model="form.time"
  216. type="date"
  217. class="flex-danhao"
  218. :disabled="!type"
  219. value-format="yyyy-MM-dd"
  220. format="yyyy-MM-dd"
  221. :editable="false"
  222. />
  223. <!-- <input v-model="form.num" type="text" class="flex-danhao" :disabled="!type" /> -->
  224. </div>
  225. <div class="submit-flex">
  226. <div class="submit" @click="saveData">
  227. 下一个
  228. </div>
  229. <div class="submit" @click="next">
  230. 完成
  231. </div>
  232. </div>
  233. </div>
  234. <script type="text/babel">
  235. var app = new Vue({
  236. el: '#app',
  237. data() {
  238. return {
  239. timeOut: true,
  240. type: false,
  241. disCode: true,
  242. prev_qrcode: '',
  243. productList: [],
  244. nameList: ['精装版', '简约版', '高腰版', '纯棉版', '精装赠', '青春版'],
  245. typeList: ['男款', '女款'],
  246. sizeList: ['M', 'L', 'XL', '2XL', '3XL', '4XL', '5XL'],
  247. id: '',
  248. form: {
  249. name: '',
  250. num: '',
  251. size: '',
  252. type: '',
  253. qrcode: '',
  254. time: ''
  255. },
  256. noClick: true
  257. }
  258. },
  259. mounted() {
  260. this.onFocus()
  261. var url = location.search //获取url中"?"符后的字串
  262. if (url.indexOf("?") != -1) {
  263. var str = url.substr(1)
  264. var strs = str.split("=")
  265. this.id = strs[1]
  266. }
  267. },
  268. methods: {
  269. // 款式
  270. getStyle(v) {
  271. if (v == 1) {
  272. return '精装版'
  273. } else if (v === 2) {
  274. return '简约版'
  275. } else if (v === 3) {
  276. return '高腰版'
  277. } else if (v === 4) {
  278. return '纯棉版'
  279. } else if (v === 5) {
  280. return '精装赠'
  281. } else if (v === 6) {
  282. return '青春版'
  283. }
  284. },
  285. // 获取焦点
  286. onFocus() {
  287. this.$nextTick(() => {
  288. this.$refs.qrcode_text.focus()
  289. })
  290. },
  291. onFocusOne() {
  292. this.$nextTick(() => {
  293. this.$refs.qrcodeOne.focus()
  294. })
  295. },
  296. onFocusTwo() {
  297. this.$nextTick(() => {
  298. this.$refs.qrcodeTwo.focus()
  299. })
  300. },
  301. preventKeyBord(e) {
  302. e.target.setAttribute("readonly", true);
  303. setTimeout(() => {
  304. e.target.removeAttribute("readonly")
  305. }, 100)
  306. },
  307. onInput(e) {
  308. let _this = this
  309. // _this.form.qrcode = ''
  310. _this.form.name = ''
  311. _this.form.num = ''
  312. _this.form.time = ''
  313. _this.form.type = ''
  314. _this.form.size = ''
  315. let qrcode = e.target.value
  316. qrcode.replace(this.form.qrcode, '')
  317. const productList = JSON.parse(window.localStorage.getItem("productList"))
  318. if (productList) {
  319. let index = productList.findIndex(item => item.qrcode == qrcode)
  320. if (index != -1) {
  321. this.$message.error('请勿重复扫描')
  322. _this.form.qrcode = ''
  323. return
  324. } else {
  325. _this.request()
  326. }
  327. } else {
  328. _this.request()
  329. }
  330. // if (this.timeOut === true) {
  331. // this.timeOut = false
  332. // setTimeout(function(){
  333. // _this.request()
  334. // }, 2000)
  335. // }
  336. // console.log(333,qrcode)
  337. // this.qrcode = this.prev_qrcode
  338. // var obj = this.qrcode
  339. // var index = obj.lastIndexOf("\/")
  340. // obj = obj.substring(index+1, obj.length)
  341. // console.log(qrcode)
  342. // axios.get('http://api.admin.app.cliu.cc/api/ReturnGood/GetCodeInfo', {
  343. // params: {
  344. // code: _this.qrcode.substring(_this.qrcode.lastIndexOf("\/")+1, _this.qrcode.length)
  345. // }
  346. // }).then(res => {
  347. // if (res.code === 200) {
  348. // let data = res.data
  349. // _this.form.name = _this.getStyle(data.goods_id)
  350. // _this.form.num = data.num
  351. // _this.form.time = data.time
  352. // } else {
  353. // window.ELEMENT.Message.error(res.message || '获取信息失败')
  354. // }
  355. // }).catch((err) => {
  356. // window.ELEMENT.Message.error('获取失败')
  357. // })
  358. },
  359. request() {
  360. let _this = this
  361. _this.timeOut = true
  362. axios.get('http://api.admin.app.cliu.cc/api/ReturnGood/GetCodeInfo', {
  363. params: {
  364. code: _this.form.qrcode
  365. },
  366. // code: _this.form.qrcode.substring(_this.form.qrcode.lastIndexOf("\/")+1, _this.form.qrcode.length)
  367. }).then(res => {
  368. if (res.code === 200) {
  369. _this.onFocusOne()
  370. let data = res.data
  371. _this.form.name = data.name
  372. _this.form.num = data.num
  373. _this.form.time = data.time
  374. _this.disCode = false
  375. } else {
  376. window.ELEMENT.Message.error(res.message || '获取信息失败')
  377. }
  378. }).catch((err) => {
  379. window.ELEMENT.Message.error('获取失败')
  380. })
  381. },
  382. onInputTwo(e) {
  383. let style = e.target.value
  384. style.replace(this.form.type, '')
  385. this.onFocusTwo()
  386. },
  387. onInputThree(e) {
  388. let size = e.target.value
  389. size.replace(this.form.size, '')
  390. this.$nextTick(() => {
  391. this.$refs.qrcodeTwo.blur()
  392. })
  393. },
  394. // 下一个
  395. saveData() {
  396. if (this.form.name && this.form.size && this.form.num && this.form.type && this.form.time) {
  397. const productList = JSON.parse(window.localStorage.getItem("productList"))
  398. if (productList && productList.length > 0) {
  399. this.productList = productList
  400. }
  401. this.productList.push(this.form)
  402. window.localStorage.setItem('productList', JSON.stringify(this.productList))
  403. this.clear()
  404. this.$message.success('保存成功')
  405. } else {
  406. this.$message.error('请登记信息')
  407. }
  408. this.onFocus()
  409. },
  410. clear() {
  411. this.form.qrcode = ''
  412. this.form.name = ''
  413. this.form.num = ''
  414. this.form.time = ''
  415. this.form.type = ''
  416. this.form.size = ''
  417. this.disCode = true
  418. this.onFocus()
  419. },
  420. // 完成
  421. next() {
  422. if (window.localStorage.getItem("productList")) {
  423. window.location= "./product.html?id=" + this.id
  424. let { name, size, num, type, time } = this.form
  425. if (name && size && num && type && time) {
  426. let productList = JSON.parse(window.localStorage.getItem("productList"))
  427. if (productList && productList.length > 0) {
  428. this.productList = productList
  429. }
  430. this.productList.push(this.form)
  431. window.localStorage.setItem('productList', JSON.stringify(this.productList))
  432. // // this.clear()
  433. }
  434. } else {
  435. this.$message.error('未登记信息')
  436. }
  437. }
  438. }
  439. })
  440. </script>
  441. </body>
  442. </html>