scancodeout.vue 18 KB

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