index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="window-box">
  3. <ly-back :showBack="false"/>
  4. <view class="search w100 h100 flex-center-center main flex-dir-column">
  5. <!-- <view class="w60 h60 bg2 flex-center-center flex-wrap flex-dir-column">-->
  6. <!-- <view>请将卡片放入感应区</view>-->
  7. <!-- <view>-->
  8. <!-- <uv-image :src="pD.imgUrl+ '/index-card.png'" height="306px" width="500px"></uv-image>-->
  9. <!-- </view>-->
  10. <!-- </view>-->
  11. <!-- <view class="flex-start-center" @click="clearList">-->
  12. <!-- 卡号:-->
  13. <!-- &lt;!&ndash; <view class="col-checked">{{ pD.value1 || '&#45;&#45;' }}</view>&ndash;&gt;-->
  14. <!-- <view class="btn btn-danger" @click="clearList">清空</view>-->
  15. <!-- </view>-->
  16. <!-- <view class="flex-dir-column f-u-21" style="max-height: 50vh;overflow-y: auto">-->
  17. <!-- <view v-for="(item,index) in list" :key="index" class="">-->
  18. <!-- {{ item.time }}:{{ item.str }}-->
  19. <!-- </view>-->
  20. <!-- </view>-->
  21. <!-- <view class="btn btn-primary" @click="search">扫码</view>-->
  22. <!-- <view class="btn btn-primary" @click="next">下一页</view>-->
  23. <view class="btn btn-primary" @click="toSelect">手动选择</view>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup>
  28. import {getCurrentInstance, inject, onActivated, onBeforeUnmount, onMounted, reactive, ref} from "vue";
  29. import {onShow, onHide} from "@dcloudio/uni-app";
  30. import {navTo, showToast} from "@/utils/app";
  31. import {cradToStudentInfo} from "@/api/student";
  32. import storage from "@/utils/storage";
  33. import {getAllMethods, logs, sleep} from "@/utils/util";
  34. import * as ASCIIUtils from "@/uni_modules/wrs-js-modbusCRCHex/js_sdk/wrs-ASCIIUtils";
  35. import * as HexUtils from "@/uni_modules/wrs-js-modbusCRCHex/js_sdk/wrs-HexUtils";
  36. import {orderToData} from "@/utils/ble/hex";
  37. import dayjs from "dayjs";
  38. const $machine = inject('$machine')
  39. const pD = reactive({
  40. title: '学生未激活',
  41. select: 0,
  42. selectMax: 1,
  43. imgUrl: '/static',
  44. value1: '',
  45. })
  46. const queryForm = reactive({
  47. student_id: 0,
  48. })
  49. const list = ref([])
  50. const clearList = async () => {
  51. list.value = []
  52. }
  53. const addList = async (data) => {
  54. list.value.push(data)
  55. }
  56. const search = async (mac) => {
  57. // const {code, msg, data} = await cradToStudentInfo({
  58. // mac
  59. // })
  60. // if (code === 1) {
  61. // queryForm.student_id = data.student.id
  62. // storage.setKey(`student-${data.student.id}`)
  63. // navTo('pages/task/info', {
  64. // id: queryForm.student_id,
  65. // })
  66. // } else {
  67. // showToast(msg)
  68. // }
  69. navTo('pages/task/info')
  70. }
  71. const next = () => {
  72. navTo('pages/task/info', {
  73. id: queryForm.student_id,
  74. })
  75. }
  76. const toSelect = () => {
  77. navTo('pages/classes/select')
  78. }
  79. const scanWatch = (value) => {
  80. // console.log('scanWatch123', value)
  81. // pD.value1 = value
  82. // search(value)
  83. addList({
  84. time: dayjs().format('YYYY-MM-DD HH:mm:ss:SSS'),
  85. str: value
  86. })
  87. }
  88. const setWatch = (open = false) => {
  89. if (open) {
  90. $machine.scan().setWatch(scanWatch)
  91. } else {
  92. $machine.scan().setWatch(null)
  93. }
  94. }
  95. // 挂载完成之后
  96. onMounted(async (r) => {
  97. })
  98. onShow(async () => {
  99. setWatch(true)
  100. })
  101. onHide(async () => {
  102. setWatch()
  103. })
  104. // 页面卸载前
  105. onBeforeUnmount(() => {
  106. setWatch()
  107. })
  108. // 激活页面时
  109. onActivated(async () => {
  110. })
  111. </script>
  112. <style lang="scss" scoped>
  113. .main {
  114. //background-image: url('static/image/index-bg.png');
  115. width: 100%;
  116. height: 100%;
  117. background-position: center center;
  118. background-size: 100%;
  119. background-repeat: no-repeat;
  120. }
  121. .bg2 {
  122. //background-image: url('static/image/index-bg2.png');
  123. width: 80%;
  124. height: 80%;
  125. background-position: center center;
  126. background-size: 100%;
  127. background-repeat: no-repeat;
  128. }
  129. .info-item {
  130. display: flex;
  131. align-items: center;
  132. margin-bottom: 30rpx;
  133. &-label {
  134. margin-right: 50rpx;
  135. }
  136. }
  137. </style>