index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. <!-- 入库扫码 -->
  2. <template>
  3. <view class="content">
  4. <view class="text-area">
  5. <scan @getCode="getScanCode" />
  6. </view>
  7. <view class="stripe"></view>
  8. <view class="roll">
  9. <view>
  10. <view @click="show =! show">
  11. <u-icon name="edit-pen"></u-icon>手动录入
  12. </view>
  13. <view class="lnput" v-if="show==false">
  14. <input type="text" v-model="number_a" :placeholder="content" clearable="true" focus="true" />
  15. <u-button type="primary" size="medium" @click="manualentry" throttle-time="2000">确认录入</u-button>
  16. </view>
  17. <view class="" v-else>
  18. <view>{{tips}}:{{number}}</view>
  19. </view>
  20. </view>
  21. <view>
  22. <view></view>
  23. <view></view>
  24. <view style="width: 94%;height: 20px;background-color: #FFFFFF;margin: 0 auto;margin-top: -3rpx;border-radius: 0;">
  25. <image src="../../../static/sailun/line.png" style="width: 96%;height: 1rpx;;" mode=""></image>
  26. </view>
  27. </view>
  28. <view class="generate">
  29. <u-table font-size="24" border-color="#ffffff" bg-color="#fff">
  30. <u-tr class="u-tr">
  31. <u-th class="u-th" width="30%">胎号</u-th>
  32. <u-th class="u-th">规格</u-th>
  33. <u-th class="u-th" width="15%">操作</u-th>
  34. </u-tr>
  35. <u-tr class="u-tr" v-for="(item, index) in lisi" :key="index">
  36. <u-td class="u-td" width="30%">{{item.tireNumber}}</u-td>
  37. <u-td class="u-td">{{item.maktx}}</u-td>
  38. <u-td class="u-td" width="15%"><text @click="confirm(index)" style="color: #FA3534;">删除</text></u-td>
  39. </u-tr>
  40. </u-table>
  41. <u-divider color="rgb(144, 147, 153)" half-width="200" border-color="rgb(144, 147, 153)" margin-top="40">没有更多啦</u-divider>
  42. </view>
  43. </view>
  44. <view class="determine">
  45. <u-button type="primary" shape="circle" @click="scancodein">扫码确认</u-button>
  46. </view>
  47. <view>
  48. </view>
  49. <u-toast ref="repeat" position="bottom" />
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. request
  55. } from '../../../common/request/request'
  56. require("promise.prototype.finally").shim()
  57. var QQMapWX = require('../../../components/mi-map/qqmap-wx-jssdk.min.js')
  58. var qqmapsdk = new QQMapWX({
  59. key: 'LXCBZ-NNIKD-UZ64F-H6AFI-UNJLH-OCFGE'
  60. })
  61. export default {
  62. data() {
  63. return {
  64. tips: '提示',
  65. number: '请扫码入库',
  66. nbTitle: '扫码标题',
  67. content: '请输入轮胎胎号',
  68. number_s: '',
  69. number_a: '',
  70. // regular: '轮胎非正规是否入库',
  71. lisi: [],
  72. background: {
  73. backgroundColor: '#0094fe',
  74. },
  75. show: true,
  76. show_s: false,
  77. show_d: false,
  78. res: '',
  79. position: '',
  80. point: '',
  81. coord: '',
  82. address: '',
  83. }
  84. },
  85. onBackPress(options) {
  86. if (options.from == 'backbutton') {
  87. this.$u.route({
  88. type: 'switchTab',
  89. url: 'pages/home/index'
  90. })
  91. }
  92. return true;
  93. },
  94. onLaunch() {
  95. uni.$on('update', data => {
  96. this.lisi = data.lisi
  97. })
  98. },
  99. created() {
  100. uni.getNetworkType({
  101. success: function(res) {
  102. let none = res.networkType
  103. if (none == 'none') {
  104. uni.showToast({
  105. icon: 'none',
  106. title: '无网络,请连接网络后再试~',
  107. position: "bottom"
  108. })
  109. }
  110. }
  111. });
  112. uni.$on('data', res => {
  113. this.lisi = res.lisi
  114. })
  115. //开始扫码
  116. const innerAudioContext = uni.createInnerAudioContext();
  117. innerAudioContext.autoplay = true;
  118. innerAudioContext.src = '../../../static/mp3/start.mp3';
  119. innerAudioContext.onPlay(() => {
  120. });
  121. innerAudioContext.onError((res) => {
  122. });
  123. this.coord = ''
  124. },
  125. onShow() {
  126. this.mounteds()
  127. },
  128. methods: {
  129. mounteds() {
  130. let that = this
  131. uni.getLocation({
  132. type: 'gcj02', // 返回国测局坐标
  133. geocode: true,
  134. success: function(res) {
  135. that.tishi(res)
  136. },
  137. fail: function(e) {
  138. uni.showToast({
  139. icon: 'none',
  140. title: '获取地址失败, 请检查是否开启定位权限~'
  141. })
  142. }
  143. })
  144. },
  145. async tishi(res) {
  146. let this_ = this
  147. this_.baidu = res
  148. qqmapsdk.reverseGeocoder({
  149. location: {
  150. latitude: res.latitude,
  151. longitude: res.longitude
  152. },
  153. success(res) {
  154. var newCity = ''
  155. // 取到用户的定位地址,赋值传递出去
  156. let aress = res.result.address_component.nation + res.result.address_component.province + res.result.address_component
  157. .city + res.result.formatted_addresses.recommend
  158. request({
  159. url: '/baseReq/getBaiDuMapMsg',
  160. method: 'get',
  161. params: {
  162. longitude: this_.baidu.longitude,
  163. latitude: this_.baidu.latitude
  164. }
  165. }).then(res => {
  166. if (res.data.code != 0) {
  167. uni.showToast({
  168. icon: 'none',
  169. title: '获取定位失败,请稍后再试~'
  170. })
  171. } else {
  172. this_.baidu = res.data.data.result
  173. this_.addreev(this_.baidu, aress)
  174. }
  175. }).catch(err => {
  176. uni.showToast({
  177. icon: 'none',
  178. title: '网络繁忙请稍后再试~'
  179. })
  180. }).finally(() => {
  181. // Loading.close()
  182. })
  183. }
  184. })
  185. },
  186. async addreev(res, x) {
  187. this.address = x
  188. this.degree = res
  189. },
  190. //手动录入调用
  191. manualentry() {
  192. if (this.number_a.length != 0) {
  193. if (this.degree == undefined) {
  194. uni.showToast({
  195. icon: 'none',
  196. title: '获取地址失败, 请检查是否开启定位权限~~',
  197. position: "bottom"
  198. })
  199. return
  200. } else {
  201. request({
  202. url: '/storeScan/storeScanGetTyre',
  203. method: 'Post',
  204. data: {
  205. storeId: this.$store.state.storeInfo.storeId,
  206. userId: this.$store.state.storeInfo.userId,
  207. tyreNum: this.number_a,
  208. scanType: 1,
  209. scanWay: 0,
  210. longitude: this.degree.x,
  211. latitude: this.degree.y,
  212. scanAddress: this.address
  213. }
  214. }).then(res => {
  215. this.tips = "胎号"
  216. switch (res.data.code) {
  217. case 513:
  218. {
  219. let name = 'regular'
  220. this.tipss(res, name)
  221. break;
  222. }
  223. case 514:
  224. {
  225. let name = 'nonoperating'
  226. this.tipss(res, name)
  227. break
  228. }
  229. case 515:
  230. {
  231. let name = 'warehousing'
  232. this.tipss(res, name)
  233. break
  234. }
  235. case 517:
  236. {
  237. let name = 'atypism'
  238. this.tipss(res, name)
  239. break
  240. }
  241. case 518:
  242. {
  243. let name = 'gobeyond'
  244. this.tipss(res, name)
  245. break
  246. }
  247. case 519:
  248. {
  249. let name = 'notallow'
  250. this.tipss(res, name)
  251. break
  252. }
  253. case 520:
  254. {
  255. let name = 'repeat-out'
  256. this.tipss(res, name)
  257. break
  258. }
  259. case 500:
  260. {
  261. let name = 'error'
  262. this.tipss(res, name)
  263. break
  264. }
  265. case 0:
  266. {
  267. this.res = res
  268. for (let i = 0; i < this.lisi.length; i++) {
  269. if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  270. let err = {
  271. "data": {
  272. "msg": "请勿重复录入",
  273. }
  274. }
  275. let name = 'duplicateentry'
  276. this.tipss(err, name)
  277. return
  278. }
  279. }
  280. this.container()
  281. break
  282. }
  283. }
  284. // if (res.data.code == 513) {
  285. // let name = 'regular'
  286. // this.tipss(res, name)
  287. // return
  288. // }
  289. // if (res.data.code == 514) {
  290. // let name = 'nonoperating'
  291. // this.tipss(res, name)
  292. // return
  293. // }
  294. // if (res.data.code == 515) {
  295. // let name = 'warehousing'
  296. // this.tipss(res, name)
  297. // return
  298. // }
  299. // if (res.data.code == 517) {
  300. // let name = 'atypism'
  301. // this.tipss(res, name)
  302. // return
  303. // }
  304. // if (res.data.code == 518) {
  305. // let name = 'gobeyond'
  306. // this.tipss(res, name)
  307. // return
  308. // }
  309. // if (res.data.code == 519) {
  310. // let name = 'notallow'
  311. // this.tipss(res, name)
  312. // return
  313. // }
  314. // if (res.data.code == 500) {
  315. // let name = 'error'
  316. // this.tipss(res, name)
  317. // return
  318. // }
  319. // if (res.data.code == 0) {
  320. // this.res = res
  321. // for (let i = 0; i < this.lisi.length; i++) {
  322. // if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  323. // let err = {
  324. // "data": {
  325. // "msg": "请勿重复录入",
  326. // }
  327. // }
  328. // let name = 'duplicateentry'
  329. // this.tipss(err, name)
  330. // return
  331. // }
  332. // }
  333. // this.container()
  334. // }
  335. }).catch(err => {
  336. // this.$refs.repeat.show({
  337. // title: "网络繁忙,请稍后再试",
  338. // type: 'default',
  339. // position: 'bottom'
  340. // })
  341. })
  342. .finally(() => {
  343. // Loading.close()
  344. })
  345. }
  346. } else {
  347. this.$refs.repeat.show({
  348. title: '请输入胎号',
  349. type: 'default',
  350. position: 'bottom'
  351. })
  352. }
  353. },
  354. tipss(res, name) {
  355. this.$refs.repeat.show({
  356. title: res.data.msg,
  357. type: 'default',
  358. position: 'bottom'
  359. })
  360. //提示语音
  361. const innerAudioContext = uni.createInnerAudioContext();
  362. innerAudioContext.autoplay = true;
  363. innerAudioContext.src = '../../../static/mp3/' + name + '.mp3';
  364. innerAudioContext.onPlay(() => {
  365. });
  366. innerAudioContext.onError((res) => {
  367. });
  368. },
  369. container() {
  370. this.$refs.repeat.show({
  371. title: '录入成功',
  372. type: 'success',
  373. position: 'bottom'
  374. })
  375. //录入成功语音
  376. const innerAudioContext = uni.createInnerAudioContext();
  377. innerAudioContext.autoplay = true;
  378. innerAudioContext.src = '../../../static/mp3/entered.mp3';
  379. innerAudioContext.onPlay(() => {
  380. });
  381. innerAudioContext.onError((res) => {
  382. });
  383. this.show_s = false
  384. this.number_a = ''
  385. this.lisi.push({
  386. specs: this.res.data.data[0].specs,
  387. flagRegular: this.res.data.data[0].isRegular,
  388. diameter: this.res.data.data[0].diameter,
  389. maktx: this.res.data.data[0].maktx,
  390. pattern: this.res.data.data[0].pattern,
  391. soldToPartyKunnr: this.res.data.data[0].soldToPartyKunnr,
  392. matnr: this.res.data.data[0].matnr,
  393. tireNumber: this.res.data.data[0].tirenumber,
  394. brand: this.res.data.data[0].brand,
  395. shippedDate: this.res.data.data[0].shippedDate,
  396. plyRating: this.res.data.data[0].plyRating,
  397. scanWay: '0'
  398. })
  399. },
  400. //获取扫码控件
  401. getScanCode(val) {
  402. uni.getNetworkType({
  403. success: function(res) {
  404. let none = res.networkType
  405. if (none == 'none') {
  406. uni.showToast({
  407. icon: 'none',
  408. title: '无网络,请连接网络后再试',
  409. position: "bottom"
  410. })
  411. const innerAudioContext = uni.createInnerAudioContext();
  412. innerAudioContext.autoplay = true;
  413. innerAudioContext.src = '../../../static/mp3/failure.mp3';
  414. innerAudioContext.onPlay(() => {
  415. });
  416. innerAudioContext.onError((res) => {
  417. });
  418. }
  419. }
  420. });
  421. this.number = val
  422. this.number_s = val
  423. if (val.length != 0) {
  424. this.tips = "胎号"
  425. }
  426. if (this.degree == undefined) {
  427. uni.showToast({
  428. icon: 'none',
  429. title: '正在转换坐标,请稍候~',
  430. position: "bottom"
  431. })
  432. return
  433. } else {
  434. request({
  435. url: '/storeScan/storeScanGetTyre',
  436. method: 'Post',
  437. data: {
  438. storeId: this.$store.state.storeInfo.storeId,
  439. userId: this.$store.state.storeInfo.userId,
  440. tyreNum: val,
  441. scanType: 1,
  442. scanWay: 0,
  443. longitude: this.degree.x,
  444. latitude: this.degree.y,
  445. scanAddress: this.address
  446. }
  447. }).then(res => {
  448. this.tips = "胎号"
  449. switch (res.data.code) {
  450. case 513:
  451. {
  452. let name = 'regular'
  453. this.tipss(res, name)
  454. break;
  455. }
  456. case 514:
  457. {
  458. let name = 'nonoperating'
  459. this.tipss(res, name)
  460. break
  461. }
  462. case 515:
  463. {
  464. let name = 'warehousing'
  465. this.tipss(res, name)
  466. break
  467. }
  468. case 517:
  469. {
  470. let name = 'atypism'
  471. this.tipss(res, name)
  472. break
  473. }
  474. case 518:
  475. {
  476. let name = 'gobeyond'
  477. this.tipss(res, name)
  478. break
  479. }
  480. case 519:
  481. {
  482. let name = 'notallow'
  483. this.tipss(res, name)
  484. break
  485. }
  486. case 520:
  487. {
  488. let name = 'repeat-out'
  489. this.tipss(res, name)
  490. break
  491. }
  492. case 500:
  493. {
  494. let name = 'error'
  495. this.tipss(res, name)
  496. break
  497. }
  498. case 0:
  499. {
  500. this.res = res
  501. for (let i = 0; i < this.lisi.length; i++) {
  502. if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  503. let err = {
  504. "data": {
  505. "msg": "请勿重复录入",
  506. }
  507. }
  508. let name = 'duplicateentry'
  509. this.tipss(err, name)
  510. return
  511. }
  512. }
  513. this.container()
  514. break
  515. }
  516. }
  517. // if (res.data.code == 513) {
  518. // let name = 'regular'
  519. // this.tipss(res, name)
  520. // return
  521. // }
  522. // if (res.data.code == 514) {
  523. // let name = 'nonoperating'
  524. // this.tipss(res, name)
  525. // return
  526. // }
  527. // if (res.data.code == 515) {
  528. // let name = 'warehousing'
  529. // this.tipss(res, name)
  530. // return
  531. // }
  532. // if (res.data.code == 517) {
  533. // let name = 'atypism'
  534. // this.tipss(res, name)
  535. // return
  536. // }
  537. // if (res.data.code == 518) {
  538. // let name = 'gobeyond'
  539. // this.tipss(res, name)
  540. // return
  541. // }
  542. // if (res.data.code == 519) {
  543. // let name = 'notallow'
  544. // this.tipss(res, name)
  545. // return
  546. // }
  547. // if (res.data.code == 500) {
  548. // let name = 'error'
  549. // this.tipss(res, name)
  550. // return
  551. // }
  552. // if (res.data.code == 0) {
  553. // this.res = res
  554. // for (let i = 0; i < this.lisi.length; i++) {
  555. // if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  556. // let err = {
  557. // "data": {
  558. // "msg": "请勿重复录入",
  559. // }
  560. // }
  561. // let name = 'duplicateentry'
  562. // this.tipss(err, name)
  563. // return
  564. // }
  565. // }
  566. // this.container()
  567. // }
  568. }).catch(err => {
  569. this.$refs.repeat.show({
  570. title: "网络繁忙,请稍后再试",
  571. type: 'default',
  572. position: 'bottom'
  573. })
  574. })
  575. .finally(() => {
  576. // Loading.close()
  577. })
  578. }
  579. },
  580. container_s() {
  581. this.show_d = false
  582. this.number_s = ''
  583. this.lisi.push({
  584. specs: this.res_s.data.data[0].specs,
  585. flagRegular: this.res_s.data.data[0].isRegular,
  586. diameter: this.res_s.data.data[0].diameter,
  587. maktx: this.res_s.data.data[0].maktx,
  588. pattern: this.res_s.data.data[0].pattern,
  589. soldToPartyKunnr: this.res_s.data.data[0].soldToPartyKunnr,
  590. matnr: this.res_s.data.data[0].matnr,
  591. tireNumber: this.res_s.data.data[0].tirenumber,
  592. brand: this.res_s.data.data[0].brand,
  593. shippedDate: this.res_s.data.data[0].shippedDate,
  594. plyRating: this.res_s.data.data[0].plyRating,
  595. scanWay: '1'
  596. })
  597. const innerAudioContext = uni.createInnerAudioContext();
  598. innerAudioContext.autoplay = true;
  599. innerAudioContext.src = '../../../static/mp3/scansuccess.mp3';
  600. innerAudioContext.onPlay(() => {
  601. });
  602. innerAudioContext.onError((res) => {
  603. });
  604. this.$refs.repeat.show({
  605. title: '扫码成功',
  606. type: 'success',
  607. position: 'bottom'
  608. })
  609. },
  610. confirm(index) {
  611. this.lisi.splice(index, 1)
  612. },
  613. scancodein() {
  614. if (this.lisi == '') {
  615. this.$refs.repeat.show({
  616. title: '请扫码或录入后再点击!',
  617. type: 'default',
  618. position: 'bottom'
  619. })
  620. } else {
  621. this.$u.route({
  622. type: 'redirectTo',
  623. url: 'pages/home/Scan-code-in/index'
  624. })
  625. uni.$emit('update', {
  626. materialList: this.lisi,
  627. address: this.address,
  628. degree: this.degree
  629. })
  630. }
  631. },
  632. repeated() {
  633. const innerAudioContext = uni.createInnerAudioContext();
  634. innerAudioContext.autoplay = true;
  635. innerAudioContext.src = '../../../static/mp3/rescan.mp3';
  636. innerAudioContext.onPlay(() => {
  637. });
  638. innerAudioContext.onError((res) => {
  639. });
  640. }
  641. }
  642. }
  643. </script>
  644. <style lang="scss" scoped>
  645. .lnput>input {
  646. background-color: none;
  647. width: 60%;
  648. font-size: 42rpx;
  649. float: left;
  650. margin-top: 10rpx;
  651. margin-left: 20rpx;
  652. }
  653. .generate {
  654. width: 98%;
  655. height: 300rpx;
  656. overflow: auto;
  657. margin: 0 auto;
  658. margin-top: 120rpx;
  659. }
  660. .determine {
  661. width: 690rpx;
  662. margin-top: 30rpx;
  663. }
  664. .content {
  665. display: flex;
  666. flex-direction: column;
  667. align-items: center;
  668. justify-content: center;
  669. // background-color: #F29100;
  670. padding-top: 400px;
  671. }
  672. .content_s {
  673. padding: 24rpx;
  674. text-align: center;
  675. }
  676. .logo {
  677. height: 200rpx;
  678. width: 200rpx;
  679. margin-top: 200rpx;
  680. margin-left: auto;
  681. margin-right: auto;
  682. margin-bottom: 50rpx;
  683. }
  684. .stripe {
  685. width: 740rpx;
  686. height: 30rpx;
  687. background-color: #00A0EA;
  688. border-radius: 12rpx;
  689. margin: 0 auto;
  690. margin-top: -100rpx;
  691. }
  692. .text-area {
  693. width: 100%;
  694. display: flex;
  695. background-color: #000000;
  696. position: static;
  697. justify-content: center;
  698. padding-top: 180rpx;
  699. }
  700. .title {
  701. font-size: 36rpx;
  702. color: #8f8f94;
  703. }
  704. .roll {
  705. width: 710rpx;
  706. height: auto;
  707. background: #FFFFFF;
  708. margin: 0 auto;
  709. margin-top: -15rpx;
  710. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(101, 176, 249, 0.3);
  711. border-bottom-left-radius: 10rpx;
  712. border-bottom-right-radius: 10rpx;
  713. padding-top: 50rpx;
  714. padding-bottom: 50rpx;
  715. }
  716. .roll>view:nth-child(1)>view:nth-child(2) {
  717. font-size: 42rpx;
  718. font-weight: bold;
  719. color: #0192FD;
  720. text-align: center;
  721. margin-bottom: 50rpx;
  722. }
  723. .roll>view:nth-child(1)>view:nth-child(1) {
  724. width: 200rpx;
  725. color: #0094FE;
  726. position: relative;
  727. top: -40rpx;
  728. left: 500rpx;
  729. font-size: 32rpx;
  730. text-align: center;
  731. }
  732. .roll>view:nth-child(2)>view {
  733. width: 40rpx;
  734. height: 40rpx;
  735. background-color: #F4F4F4;
  736. border-radius: 100%;
  737. float: right;
  738. margin-right: -20rpx;
  739. }
  740. .roll>view:nth-child(2)>view:nth-child(1) {
  741. float: left;
  742. margin-left: -20rpx;
  743. }
  744. .status_bar {
  745. height: var(--status-bar-height);
  746. width: 100%;
  747. background-color: #0095FF;
  748. }
  749. </style>