tag-scan.vue 3.5 KB

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