index.vue 16 KB

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