index.vue 19 KB

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