scancodeout.vue 17 KB

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