scancodeout.vue 17 KB

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