index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  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: 1,
  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. let datats = {
  409. storeId: this.$store.state.storeInfo.storeId,
  410. userId: this.$store.state.storeInfo.userId,
  411. tyreNum: this.number_s,
  412. scanType: 1,
  413. scanWay: 1,
  414. longitude: this.degree.x,
  415. latitude: this.degree.y,
  416. scanAddress: this.address
  417. }
  418. console.log(datats)
  419. console.log(val)
  420. this.number = val
  421. this.number_s = val
  422. request({
  423. url: '/storeScan/storeScanGetTyre',
  424. method: 'Post',
  425. data: {
  426. storeId: this.$store.state.storeInfo.storeId,
  427. userId: this.$store.state.storeInfo.userId,
  428. tyreNum: this.number_s,
  429. scanType: 1,
  430. scanWay: 1,
  431. longitude: this.degree.x,
  432. latitude: this.degree.y,
  433. scanAddress: this.address
  434. }
  435. }).then(res => {
  436. this.res_s = res
  437. this.tips = "胎号"
  438. if (res.data.code == 513) {
  439. console.log(res.data.msg)
  440. let name = 'regular'
  441. this.tipss(res, name)
  442. return
  443. }
  444. if (res.data.code == 514) {
  445. console.log(res.data.msg)
  446. let name = 'nonoperating'
  447. this.tipss(res, name)
  448. return
  449. }
  450. if (res.data.code == 515) {
  451. console.log(res.data.msg)
  452. let name = 'warehousing'
  453. this.tipss(res, name)
  454. return
  455. }
  456. if (res.data.code == 517) {
  457. console.log(res.data.msg)
  458. let name = 'atypism'
  459. this.tipss(res, name)
  460. return
  461. }
  462. if (res.data.code == 518) {
  463. console.log(res.data.msg)
  464. let name = 'gobeyond'
  465. this.tipss(res, name)
  466. return
  467. }
  468. if (res.data.code == 519) {
  469. console.log(res.data.msg)
  470. let name = 'notallow'
  471. this.tipss(res, name)
  472. return
  473. }
  474. if (res.data.code == 500) {
  475. console.log(res.data.msg)
  476. let name = 'error'
  477. this.tipss(res, name)
  478. return
  479. }
  480. if (res.data.code == 0) {
  481. console.log(res)
  482. this.res = res
  483. console.log(res.data.data[0].isRegular)
  484. for (let i = 0; i < this.lisi.length; i++) {
  485. if (this.lisi[i].tireNumber == res.data.data[0].tirenumber) {
  486. console.log(res)
  487. let err = {
  488. "data": {
  489. "msg": "请勿重复扫码",
  490. }
  491. }
  492. console.log(err.data.msg)
  493. let name = 'repeatcode'
  494. this.tipss(err, name)
  495. return
  496. }
  497. }
  498. this.container_s()
  499. }
  500. // console.log(this.lisi)
  501. }).catch(err => {
  502. if (err.code == 400) {//谁给我删了......
  503. this.$refs.repeat.show({
  504. title: "无网络",
  505. type: 'default',
  506. position: 'bottom'
  507. })
  508. } else {
  509. this.$refs.repeat.show({
  510. title: "请重新扫码",
  511. type: 'default',
  512. position: 'bottom'
  513. })
  514. this.repeated()
  515. }
  516. console.log(err)
  517. })
  518. .finally(() => {
  519. // Loading.close()
  520. })
  521. },
  522. container_s() {
  523. this.show_d = false
  524. console.log(this.show_s)
  525. console.log("什么????")
  526. this.number_s = ''
  527. console.log("我成功啦")
  528. console.log(this.res_s)
  529. this.lisi.push({
  530. specs: this.res_s.data.data[0].specs,
  531. flagRegular: this.res_s.data.data[0].isRegular,
  532. diameter: this.res_s.data.data[0].diameter,
  533. maktx: this.res_s.data.data[0].maktx,
  534. pattern: this.res_s.data.data[0].pattern,
  535. soldToPartyKunnr: this.res_s.data.data[0].soldToPartyKunnr,
  536. matnr: this.res_s.data.data[0].matnr,
  537. tireNumber: this.res_s.data.data[0].tirenumber,
  538. brand: this.res_s.data.data[0].brand,
  539. shippedDate: this.res_s.data.data[0].shippedDate,
  540. plyRating: this.res_s.data.data[0].plyRating,
  541. scanWay: '1'
  542. })
  543. console.log(this.lisi)
  544. const innerAudioContext = uni.createInnerAudioContext();
  545. innerAudioContext.autoplay = true;
  546. innerAudioContext.src = '../../../static/mp3/scansuccess.mp3';
  547. innerAudioContext.onPlay(() => {
  548. console.log('开始播放');
  549. });
  550. innerAudioContext.onError((res) => {
  551. console.log(res.errMsg);
  552. console.log(res.errCode);
  553. });
  554. this.$refs.repeat.show({
  555. title: '扫码成功',
  556. type: 'success',
  557. position: 'bottom'
  558. })
  559. },
  560. confirm(index) {
  561. console.log(index + "什么情况")
  562. this.lisi.splice(index, 1)
  563. },
  564. scancodein() {
  565. if (this.lisi == '') {
  566. this.$refs.repeat.show({
  567. title: '请扫码或录入后再点击!',
  568. type: 'default',
  569. position: 'bottom'
  570. })
  571. } else {
  572. this.$u.route({
  573. type: 'redirectTo',
  574. url: 'pages/home/Scan-code-in/index'
  575. })
  576. uni.$emit('update', {
  577. materialList: this.lisi
  578. })
  579. }
  580. },
  581. repeated() {
  582. const innerAudioContext = uni.createInnerAudioContext();
  583. innerAudioContext.autoplay = true;
  584. innerAudioContext.src = '../../../static/mp3/rescan.mp3';
  585. innerAudioContext.onPlay(() => {
  586. console.log('开始播放');
  587. });
  588. innerAudioContext.onError((res) => {
  589. console.log(res.errMsg);
  590. console.log(res.errCode);
  591. });
  592. }
  593. }
  594. }
  595. </script>
  596. <style lang="scss" scoped>
  597. .lnput>input {
  598. background-color: none;
  599. width: 60%;
  600. font-size: 42rpx;
  601. float: left;
  602. margin-top: 10rpx;
  603. margin-left: 20rpx;
  604. }
  605. .generate {
  606. width: 98%;
  607. height: 300rpx;
  608. overflow: auto;
  609. margin: 0 auto;
  610. margin-top: 120rpx;
  611. }
  612. .determine {
  613. width: 690rpx;
  614. margin-top: 30rpx;
  615. }
  616. .content {
  617. display: flex;
  618. flex-direction: column;
  619. align-items: center;
  620. justify-content: center;
  621. // background-color: #F29100;
  622. padding-top: 400px;
  623. }
  624. .content_s {
  625. padding: 24rpx;
  626. text-align: center;
  627. }
  628. .logo {
  629. height: 200rpx;
  630. width: 200rpx;
  631. margin-top: 200rpx;
  632. margin-left: auto;
  633. margin-right: auto;
  634. margin-bottom: 50rpx;
  635. }
  636. .stripe {
  637. width: 740rpx;
  638. height: 30rpx;
  639. background-color: #00A0EA;
  640. border-radius: 12rpx;
  641. margin: 0 auto;
  642. margin-top: -100rpx;
  643. }
  644. .text-area {
  645. width: 100%;
  646. display: flex;
  647. background-color: #000000;
  648. position: static;
  649. justify-content: center;
  650. padding-top: 180rpx;
  651. }
  652. .title {
  653. font-size: 36rpx;
  654. color: #8f8f94;
  655. }
  656. .roll {
  657. width: 710rpx;
  658. height: auto;
  659. background: #FFFFFF;
  660. margin: 0 auto;
  661. margin-top: -15rpx;
  662. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(101, 176, 249, 0.3);
  663. border-bottom-left-radius: 10rpx;
  664. border-bottom-right-radius: 10rpx;
  665. padding-top: 50rpx;
  666. padding-bottom: 50rpx;
  667. }
  668. .roll>view:nth-child(1)>view:nth-child(2) {
  669. font-size: 42rpx;
  670. font-weight: bold;
  671. color: #0192FD;
  672. text-align: center;
  673. margin-bottom: 50rpx;
  674. }
  675. .roll>view:nth-child(1)>view:nth-child(1) {
  676. width: 200rpx;
  677. color: #0094FE;
  678. position: relative;
  679. top: -40rpx;
  680. left: 500rpx;
  681. font-size: 32rpx;
  682. text-align: center;
  683. }
  684. .roll>view:nth-child(2)>view {
  685. width: 40rpx;
  686. height: 40rpx;
  687. background-color: #F4F4F4;
  688. border-radius: 100%;
  689. float: right;
  690. margin-right: -20rpx;
  691. }
  692. .roll>view:nth-child(2)>view:nth-child(1) {
  693. float: left;
  694. margin-left: -20rpx;
  695. }
  696. .status_bar {
  697. height: var(--status-bar-height);
  698. width: 100%;
  699. background-color: #0095FF;
  700. }
  701. </style>