index.vue 17 KB

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