index.vue 16 KB

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