scancodeout.vue 17 KB

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