tag-scan.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 style="text-align: center;margin-bottom: 50rpx;">
  22. {{rfidCode}}
  23. </view>
  24. <view class="btn" v-if="!isReading">
  25. <view class="row">
  26. <u-button throttleTime="300" type="primary" style="width: 100%;" @click="bind">绑定并继续</u-button>
  27. </view>
  28. <view class="row">
  29. <u-button throttleTime="300" type="primary" style="width: 100%;" @click="$utils.back(2)">取消</u-button>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. // #ifdef APP-PLUS
  37. // #endif
  38. export default {
  39. data() {
  40. return {
  41. rfidCode: '',
  42. isReading: true,
  43. option: {}
  44. };
  45. },
  46. methods: {
  47. bind() {
  48. const v = this
  49. console.log(this.option)
  50. this.$http.CreateRfidStockTag({
  51. rfidCode: this.rfidCode,
  52. bindingRfidWay: 0,
  53. ...this.option
  54. }).then(res => {
  55. if(res.code === 0) {
  56. this.$msg.showToast('创建成功!', 'success' )
  57. // 绑定成功后清除上个页面已选择的数据并返回
  58. uni.$emit('clear')
  59. uni.getStorage({
  60. key: 'reviewDtl',
  61. success: function (res) {
  62. res.data.checkDetailsInfoList[res.data.index].stockBackDetailsList[res.data.jindex].rfid = v.rfidCode
  63. uni.setStorage({
  64. key: 'reviewDtl',
  65. data: res.data,
  66. success: function () {
  67. v.$utils.open(`/pages/warehouse/reviewDtl`)
  68. v.$msg.showToast('扫描成功!')
  69. },fail() {
  70. v.$msg.showToast('扫描失败!')
  71. }
  72. });
  73. }
  74. });
  75. } else {
  76. this.isReading = true
  77. this.scanRfid()
  78. }
  79. })
  80. },
  81. scanRfid () {
  82. this.$pda.uhfScan().then(res => {
  83. console.log(res)
  84. this.isReading = false
  85. this.rfidCode = res[0].epc
  86. console.log(this.rfidCode)
  87. }).catch(() => {
  88. this.$msg.showToast('未识别到有效RFID标签!')
  89. setTimeout(() => {
  90. this.$utils.back()
  91. }, 1000)
  92. })
  93. }
  94. },
  95. onLoad(option) {
  96. this.option = this.$utils.code2Object(option.data)
  97. console.log(this.option)
  98. this.scanRfid()
  99. },
  100. onUnload() {
  101. this.$pda.uhfStop()
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .container-wrap {
  107. overflow: hidden;
  108. .container {
  109. padding: 0 60rpx;
  110. padding-bottom: 80rpx;
  111. height: calc(100vh - var(--status-bar-height) - 44px);
  112. overflow: auto;
  113. .title {
  114. padding: 20rpx 0;
  115. font-size: 36rpx;
  116. font-weight: bold;
  117. text-align: center;
  118. }
  119. .reading {
  120. padding: 40rpx 0;
  121. }
  122. .info {
  123. padding: 20rpx 60rpx;
  124. border-radius: 10rpx ;
  125. background-color: #FFFFFF;
  126. .row {
  127. align-items: flex-start;
  128. .label {
  129. font-size: 32rpx;
  130. width: 160rpx;
  131. }
  132. .value {
  133. font-size: 32rpx;
  134. flex: 1;
  135. overflow: hidden;
  136. word-wrap: break-word;
  137. }
  138. }
  139. }
  140. .btn {
  141. .row {
  142. padding: 0;
  143. padding-bottom: 10rpx;
  144. width: 100%;
  145. &:last-child {
  146. padding-bottom: 0;
  147. }
  148. }
  149. }
  150. }
  151. }
  152. </style>