index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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="img-saoma-box">
  24. <text class="img-saoma-text">请将卡片放进感应区</text>
  25. <image src="@/static/image/bmi/img_saoma.png" alt="" class="img-saoma"></image>
  26. </view>
  27. <view class="btn btn-primary hand-select" @click="toSelect">手动选择</view>
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import {getCurrentInstance, inject, onActivated, onBeforeUnmount, onMounted, reactive, ref} from "vue";
  33. import {onShow, onHide} from "@dcloudio/uni-app";
  34. import {navTo, showToast} from "@/utils/app";
  35. import {cradToStudentInfo} from "@/api/student";
  36. import storage from "@/utils/storage";
  37. import {getAllMethods, logs, sleep} from "@/utils/util";
  38. import * as ASCIIUtils from "@/uni_modules/wrs-js-modbusCRCHex/js_sdk/wrs-ASCIIUtils";
  39. import * as HexUtils from "@/uni_modules/wrs-js-modbusCRCHex/js_sdk/wrs-HexUtils";
  40. import {orderToData} from "@/utils/ble/hex";
  41. import * as dayjs from "@/utils/dayjs";
  42. const $machine = inject('$machine')
  43. const pD = reactive({
  44. title: '学生未激活',
  45. select: 0,
  46. selectMax: 1,
  47. imgUrl: '/static',
  48. value1: '',
  49. })
  50. const queryForm = reactive({
  51. student_id: 0,
  52. })
  53. const list = ref([])
  54. const clearList = async () => {
  55. list.value = []
  56. }
  57. const addList = async (data) => {
  58. list.value.push(data)
  59. }
  60. const search = async (mac) => {
  61. // const {code, msg, data} = await cradToStudentInfo({
  62. // mac
  63. // })
  64. // if (code === 1) {
  65. // queryForm.student_id = data.student.id
  66. // storage.setKey(`student-${data.student.id}`)
  67. // navTo('pages/task/info', {
  68. // id: queryForm.student_id,
  69. // })
  70. // } else {
  71. // showToast(msg)
  72. // }
  73. navTo('pages/task/info')
  74. }
  75. const next = () => {
  76. navTo('pages/task/info', {
  77. id: queryForm.student_id,
  78. })
  79. }
  80. const toSelect = () => {
  81. navTo('pages/classes/select')
  82. }
  83. const scanWatch = (value) => {
  84. // console.log('scanWatch123', value)
  85. // pD.value1 = value
  86. // search(value)
  87. addList({
  88. time: dayjs().format('YYYY-MM-DD HH:mm:ss:SSS'),
  89. str: value
  90. })
  91. }
  92. const setWatch = (open = false) => {
  93. if (open) {
  94. $machine.scan().setWatch(scanWatch)
  95. } else {
  96. $machine.scan().setWatch(null)
  97. }
  98. }
  99. // 挂载完成之后
  100. onMounted(async (r) => {
  101. })
  102. onShow(async () => {
  103. setWatch(true)
  104. })
  105. onHide(async () => {
  106. setWatch()
  107. })
  108. // 页面卸载前
  109. onBeforeUnmount(() => {
  110. setWatch()
  111. })
  112. // 激活页面时
  113. onActivated(async () => {
  114. })
  115. </script>
  116. <style lang="scss" scoped>
  117. .main {
  118. //background-image: url('static/image/index-bg.png');
  119. width: 100%;
  120. height: 100%;
  121. background-position: center center;
  122. background-size: 100%;
  123. background-repeat: no-repeat;
  124. }
  125. .bg2 {
  126. //background-image: url('static/image/index-bg2.png');
  127. width: 80%;
  128. height: 80%;
  129. background-position: center center;
  130. background-size: 100%;
  131. background-repeat: no-repeat;
  132. }
  133. .info-item {
  134. display: flex;
  135. align-items: center;
  136. margin-bottom: 30rpx;
  137. &-label {
  138. margin-right: 50rpx;
  139. }
  140. }
  141. .img-saoma-box{
  142. display: flex;
  143. flex-direction: column;
  144. }
  145. .img-saoma-text{
  146. text-align: center;
  147. font-weight: bold;
  148. font-size: 35upx;
  149. color: #2F3C42;
  150. line-height: 41upx;
  151. margin-bottom: 40upx;
  152. }
  153. .img-saoma{
  154. width: 520upx;
  155. height: 400upx;
  156. }
  157. .hand-select{
  158. width: 480upx;
  159. border-radius: 21upx;
  160. }
  161. </style>