scancodeout.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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. if (res.data.code == 513) {
  239. let name = 'regular'
  240. this.tipss(res, name)
  241. return
  242. }
  243. if (res.data.code == 514) {
  244. let name = 'nonoperating'
  245. this.tipss(res, name)
  246. return
  247. }
  248. if (res.data.code == 515) {
  249. let name = 'warehousing'
  250. this.tipss(res, name)
  251. return
  252. }
  253. if (res.data.code == 516) {
  254. let name = 'prohibit'
  255. this.tipss(res, name)
  256. return
  257. }
  258. if (res.data.code == 517) {
  259. let name = 'atypism'
  260. this.tipss(res, name)
  261. return
  262. }
  263. if (res.data.code == 518) {
  264. let name = 'gobeyond'
  265. this.tipss(res, name)
  266. return
  267. }
  268. if (res.data.code == 519) {
  269. let name = 'notallow'
  270. this.tipss(res, name)
  271. return
  272. }
  273. if (res.data.code == 500) {
  274. let name = 'error'
  275. this.tipss(res, name)
  276. return
  277. }
  278. if (res.data.code == 0) {
  279. this.res = res
  280. for (let i = 0; i < this.lisi.length; i++) {
  281. if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  282. let err = {
  283. "data": {
  284. "msg": "请勿重复录入",
  285. }
  286. }
  287. let name = 'duplicateentry'
  288. this.tipss(err, name)
  289. return
  290. }
  291. }
  292. this.container()
  293. }
  294. }).catch(err => {
  295. // this.$refs.repeat.show({
  296. // title: "网络繁忙,请稍后再试",
  297. // type: 'default',
  298. // position: 'bottom'
  299. // })
  300. })
  301. .finally(() => {
  302. // Loading.close()
  303. })
  304. }
  305. } else {
  306. this.$refs.repeat.show({
  307. title: '请输入胎号',
  308. type: 'default',
  309. position: 'bottom'
  310. })
  311. }
  312. },
  313. tipss(res, name) {
  314. this.$refs.repeat.show({
  315. title: res.data.msg,
  316. type: 'default',
  317. position: 'bottom'
  318. })
  319. //提示语音
  320. const innerAudioContext = uni.createInnerAudioContext();
  321. innerAudioContext.autoplay = true;
  322. innerAudioContext.src = '../../../static/mp3/' + name + '.mp3';
  323. innerAudioContext.onPlay(() => {
  324. });
  325. innerAudioContext.onError((res) => {
  326. });
  327. },
  328. container() {
  329. this.$refs.repeat.show({
  330. title: '录入成功',
  331. type: 'success',
  332. position: 'bottom'
  333. })
  334. //录入成功语音
  335. const innerAudioContext = uni.createInnerAudioContext();
  336. innerAudioContext.autoplay = true;
  337. innerAudioContext.src = '../../../static/mp3/entered.mp3';
  338. innerAudioContext.onPlay(() => {
  339. });
  340. innerAudioContext.onError((res) => {
  341. });
  342. this.show_s = false
  343. this.number_a = ''
  344. this.lisi.push({
  345. specs: this.res.data.data[0].specs,
  346. flagRegular: this.res.data.data[0].isRegular,
  347. diameter: this.res.data.data[0].diameter,
  348. maktx: this.res.data.data[0].maktx,
  349. pattern: this.res.data.data[0].pattern,
  350. soldToPartyKunnr: this.res.data.data[0].soldToPartyKunnr,
  351. matnr: this.res.data.data[0].matnr,
  352. tireNumber: this.res.data.data[0].tirenumber,
  353. brand: this.res.data.data[0].brand,
  354. shippedDate: this.res.data.data[0].shippedDate,
  355. plyRating: this.res.data.data[0].plyRating,
  356. scanWay: '0'
  357. })
  358. },
  359. //获取扫码控件
  360. getScanCode(val) {
  361. uni.getNetworkType({
  362. success: function(res) {
  363. let none = res.networkType
  364. if (none == 'none') {
  365. uni.showToast({
  366. icon: 'none',
  367. title: '无网络,请连接网络后再试',
  368. position: "bottom"
  369. })
  370. const innerAudioContext = uni.createInnerAudioContext();
  371. innerAudioContext.autoplay = true;
  372. innerAudioContext.src = '../../../static/mp3/failure.mp3';
  373. innerAudioContext.onPlay(() => {
  374. });
  375. innerAudioContext.onError((res) => {
  376. });
  377. }
  378. }
  379. });
  380. this.number = val
  381. this.number_s = val
  382. if (this.degree == undefined) {
  383. uni.showToast({
  384. icon: 'none',
  385. title: '获取地址失败, 请检查是否开启定位权限~~',
  386. position: "bottom"
  387. })
  388. return
  389. } else {
  390. request({
  391. url: '/storeScan/storeScanGetTyre',
  392. method: 'Post',
  393. data: {
  394. storeId: this.$store.state.storeInfo.storeId,
  395. userId: this.$store.state.storeInfo.userId,
  396. tyreNum: val,
  397. scanType: 2,
  398. scanWay: 1,
  399. longitude: this.degree.x,
  400. latitude: this.degree.y,
  401. scanAddress: this.address
  402. }
  403. }).then(res => {
  404. this.res_s = res
  405. this.tips = "胎号"
  406. if (res.data.code == 513) {
  407. let name = 'regular'
  408. this.tipss(res, name)
  409. return
  410. }
  411. if (res.data.code == 514) {
  412. let name = 'nonoperating'
  413. this.tipss(res, name)
  414. return
  415. }
  416. if (res.data.code == 515) {
  417. let name = 'warehousing'
  418. this.tipss(res, name)
  419. return
  420. }
  421. if (res.data.code == 517) {
  422. let name = 'atypism'
  423. this.tipss(res, name)
  424. return
  425. }
  426. if (res.data.code == 518) {
  427. let name = 'gobeyond'
  428. this.tipss(res, name)
  429. return
  430. }
  431. if (res.data.code == 519) {
  432. let name = 'notallow'
  433. this.tipss(res, name)
  434. return
  435. }
  436. if (res.data.code == 500) {
  437. let name = 'error'
  438. this.tipss(res, name)
  439. return
  440. }
  441. if (res.data.code == 0) {
  442. this.res = res
  443. for (let i = 0; i < this.lisi.length; i++) {
  444. if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  445. let err = {
  446. "data": {
  447. "msg": "请勿重复扫码",
  448. }
  449. }
  450. let name = 'repeatcode'
  451. this.tipss(err, name)
  452. return
  453. }
  454. }
  455. this.container_s()
  456. }
  457. //
  458. }).catch(err => {
  459. if (err.code == 400) { //谁给我删了......
  460. this.$refs.repeat.show({
  461. title: "无网络",
  462. type: 'default',
  463. position: 'bottom'
  464. })
  465. } else {
  466. this.$refs.repeat.show({
  467. title: "请重新扫码",
  468. type: 'default',
  469. position: 'bottom'
  470. })
  471. this.repeated()
  472. }
  473. })
  474. .finally(() => {
  475. // Loading.close()
  476. })
  477. }
  478. },
  479. container_s() {
  480. this.show_d = false
  481. this.number_s = ''
  482. this.lisi.push({
  483. specs: this.res_s.data.data[0].specs,
  484. flagRegular: this.res_s.data.data[0].isRegular,
  485. diameter: this.res_s.data.data[0].diameter,
  486. maktx: this.res_s.data.data[0].maktx,
  487. pattern: this.res_s.data.data[0].pattern,
  488. soldToPartyKunnr: this.res_s.data.data[0].soldToPartyKunnr,
  489. matnr: this.res_s.data.data[0].matnr,
  490. tireNumber: this.res_s.data.data[0].tirenumber,
  491. brand: this.res_s.data.data[0].brand,
  492. shippedDate: this.res_s.data.data[0].shippedDate,
  493. plyRating: this.res_s.data.data[0].plyRating,
  494. scanWay: '1'
  495. })
  496. const innerAudioContext = uni.createInnerAudioContext();
  497. innerAudioContext.autoplay = true;
  498. innerAudioContext.src = '../../../static/mp3/scansuccess.mp3';
  499. innerAudioContext.onPlay(() => {
  500. });
  501. innerAudioContext.onError((res) => {
  502. });
  503. this.$refs.repeat.show({
  504. title: '扫码成功',
  505. type: 'success',
  506. position: 'bottom'
  507. })
  508. },
  509. confirm(index) {
  510. this.lisi.splice(index, 1)
  511. },
  512. scancodein() {
  513. if (this.lisi == '') {
  514. this.$refs.repeat.show({
  515. title: '请扫码或录入后再点击!',
  516. type: 'default',
  517. position: 'bottom'
  518. })
  519. } else {
  520. this.$u.route({
  521. type: 'redirectTo',
  522. url: 'pages/home/Scan-code-out/index'
  523. })
  524. uni.$emit('update', {
  525. materialList: this.lisi
  526. })
  527. }
  528. },
  529. repeated() {
  530. const innerAudioContext = uni.createInnerAudioContext();
  531. innerAudioContext.autoplay = true;
  532. innerAudioContext.src = '../../../static/mp3/rescan.mp3';
  533. innerAudioContext.onPlay(() => {
  534. });
  535. innerAudioContext.onError((res) => {
  536. });
  537. }
  538. }
  539. }
  540. </script>
  541. <style lang="scss" scoped>
  542. .lnput>input {
  543. background-color: none;
  544. width: 60%;
  545. font-size: 42rpx;
  546. float: left;
  547. margin-top: 10rpx;
  548. margin-left: 20rpx;
  549. }
  550. .generate {
  551. width: 98%;
  552. height: 300rpx;
  553. overflow: auto;
  554. margin: 0 auto;
  555. margin-top: 120rpx;
  556. }
  557. .determine {
  558. width: 690rpx;
  559. margin-top: 30rpx;
  560. }
  561. .content {
  562. display: flex;
  563. flex-direction: column;
  564. align-items: center;
  565. justify-content: center;
  566. // background-color: #F29100;
  567. padding-top: 400px;
  568. }
  569. .content_s {
  570. padding: 24rpx;
  571. text-align: center;
  572. }
  573. .logo {
  574. height: 200rpx;
  575. width: 200rpx;
  576. margin-top: 200rpx;
  577. margin-left: auto;
  578. margin-right: auto;
  579. margin-bottom: 50rpx;
  580. }
  581. .stripe {
  582. width: 740rpx;
  583. height: 30rpx;
  584. background-color: #00A0EA;
  585. border-radius: 12rpx;
  586. margin: 0 auto;
  587. margin-top: -100rpx;
  588. }
  589. .text-area {
  590. width: 100%;
  591. display: flex;
  592. background-color: #000000;
  593. position: static;
  594. justify-content: center;
  595. padding-top: 180rpx;
  596. }
  597. .title {
  598. font-size: 36rpx;
  599. color: #8f8f94;
  600. }
  601. .roll {
  602. width: 710rpx;
  603. height: auto;
  604. background: #FFFFFF;
  605. margin: 0 auto;
  606. margin-top: -15rpx;
  607. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(101, 176, 249, 0.3);
  608. border-bottom-left-radius: 10rpx;
  609. border-bottom-right-radius: 10rpx;
  610. padding-top: 50rpx;
  611. padding-bottom: 50rpx;
  612. }
  613. .roll>view:nth-child(1)>view:nth-child(2) {
  614. font-size: 42rpx;
  615. font-weight: bold;
  616. color: #0192FD;
  617. text-align: center;
  618. margin-bottom: 50rpx;
  619. }
  620. .roll>view:nth-child(1)>view:nth-child(1) {
  621. width: 200rpx;
  622. color: #0094FE;
  623. position: relative;
  624. top: -40rpx;
  625. left: 500rpx;
  626. font-size: 32rpx;
  627. text-align: center;
  628. }
  629. .roll>view:nth-child(2)>view {
  630. width: 40rpx;
  631. height: 40rpx;
  632. background-color: #F4F4F4;
  633. border-radius: 100%;
  634. float: right;
  635. margin-right: -20rpx;
  636. }
  637. .roll>view:nth-child(2)>view:nth-child(1) {
  638. float: left;
  639. margin-left: -20rpx;
  640. }
  641. .status_bar {
  642. height: var(--status-bar-height);
  643. width: 100%;
  644. background-color: #0095FF;
  645. }
  646. </style>