tag-change-scan.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!-- 更换标签 扫描新Rfid -->
  2. <template>
  3. <view class="container-wrap">
  4. <uni-nav-bar title="扫描添加" :status-bar="true" background-color="#3F92F9" color="#FFF">
  5. <view slot="left">
  6. <u-icon name="account-fill" color="#FFF" size="35"></u-icon>
  7. <span style="padding: 0 5rpx;color: #FFFFFF;">{{ userInfo.name }}</span>
  8. </view>
  9. <view slot="right" @tap="$utils.back()">
  10. <span style="color: #FFFFFF;">返回</span>
  11. </view>
  12. </uni-nav-bar>
  13. <view class="container">
  14. <!-- 扫描rfid -->
  15. <view class="reading">
  16. <view class="title">请扫描新的物料RFID标签</view>
  17. <u-image height="300rpx" mode="aspectFit" src="../../static/images/rfid.png"></u-image>
  18. <view class="title" v-if="isReading">扫描中...</view>
  19. <view class="title" v-if="!isReading">扫描结果</view>
  20. </view>
  21. <view class="btn" v-if="!isReading">
  22. <view class="row">
  23. <u-button throttleTime="300" type="primary" style="width: 100%;" @click="bind">绑定并继续</u-button>
  24. </view>
  25. <view class="row">
  26. <u-button throttleTime="300" type="primary" style="width: 100%;" @click="$utils.back(2)">取消</u-button>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. // #ifdef APP-PLUS
  34. // #endif
  35. export default {
  36. data() {
  37. return {
  38. rfidCode: '',
  39. isReading: true,
  40. option: {}
  41. };
  42. },
  43. methods: {
  44. bind() {
  45. this.$http.SaveReplaceRfidCodeTag({
  46. rfidCode: this.rfidCode,
  47. ...this.option
  48. }).then(res => {
  49. console.log(res)
  50. if(res.code === 0) {
  51. this.$msg.showToast('更换成功!', 'success' )
  52. // 绑定成功后清除上个页面已选择的数据并返回
  53. uni.$emit('clear')
  54. setTimeout(() => {
  55. this.$utils.back()
  56. }, 2000)
  57. } else {
  58. this.isReading = true
  59. this.scanRfid()
  60. }
  61. })
  62. },
  63. /* 扫码贴标 */
  64. scanPaste() {
  65. this.$utils.uniScanCode().then(res => {
  66. console.log(res)
  67. })
  68. },
  69. scanRfid() {
  70. this.$pda.uhfScan().then(res => {
  71. console.log(res)
  72. this.isReading = false
  73. this.rfidCode = res[0].epc
  74. console.log(this.rfidCode)
  75. }).catch(() => {
  76. this.$msg.showToast('未识别到有效RFID标签!')
  77. setTimeout(() => {
  78. this.$utils.back()
  79. }, 1000)
  80. })
  81. }
  82. },
  83. onLoad(option) {
  84. this.option = this.$utils.code2Object(option.data)
  85. this.scanRfid()
  86. },
  87. onUnload() {
  88. this.$pda.uhfStop()
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .container-wrap {
  94. overflow: hidden;
  95. .container {
  96. padding: 0 60rpx;
  97. padding-bottom: 80rpx;
  98. height: calc(100vh - var(--status-bar-height) - 44px);
  99. overflow: auto;
  100. .title {
  101. padding: 20rpx 0;
  102. font-size: 36rpx;
  103. font-weight: bold;
  104. text-align: center;
  105. }
  106. .reading {
  107. padding: 40rpx 0;
  108. }
  109. .info {
  110. padding: 20rpx 60rpx;
  111. border-radius: 10rpx ;
  112. background-color: #FFFFFF;
  113. .row {
  114. align-items: flex-start;
  115. .label {
  116. font-size: 32rpx;
  117. width: 160rpx;
  118. }
  119. .value {
  120. font-size: 32rpx;
  121. flex: 1;
  122. overflow: hidden;
  123. word-wrap: break-word;
  124. }
  125. }
  126. }
  127. .btn {
  128. .row {
  129. padding: 0;
  130. padding-bottom: 10rpx;
  131. width: 100%;
  132. &:last-child {
  133. padding-bottom: 0;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. </style>