scancodeout.vue 18 KB

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