scancodeout.vue 19 KB

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