index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 alt="" class="img-saoma" src="@/static/image/bmi/img_saoma.png"></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. // const machine = $machine[`machine0${}`]
  102. setTimeout(() => {
  103. // $machine.machine03().getList()
  104. }, 5000)
  105. })
  106. onShow(async () => {
  107. setWatch(true)
  108. })
  109. onHide(async () => {
  110. setWatch()
  111. })
  112. // 页面卸载前
  113. onBeforeUnmount(() => {
  114. setWatch()
  115. })
  116. // 激活页面时
  117. onActivated(async () => {
  118. })
  119. </script>
  120. <style lang="scss" scoped>
  121. .main {
  122. //background-image: url('static/image/index-bg.png');
  123. width: 100%;
  124. height: 100%;
  125. background-position: center center;
  126. background-size: 100%;
  127. background-repeat: no-repeat;
  128. }
  129. .bg2 {
  130. //background-image: url('static/image/index-bg2.png');
  131. width: 80%;
  132. height: 80%;
  133. background-position: center center;
  134. background-size: 100%;
  135. background-repeat: no-repeat;
  136. }
  137. .info-item {
  138. display: flex;
  139. align-items: center;
  140. margin-bottom: 30rpx;
  141. &-label {
  142. margin-right: 50rpx;
  143. }
  144. }
  145. .img-saoma-box {
  146. display: flex;
  147. flex-direction: column;
  148. }
  149. .img-saoma-text {
  150. text-align: center;
  151. font-weight: bold;
  152. font-size: 35upx;
  153. color: #2F3C42;
  154. line-height: 41upx;
  155. margin-bottom: 40upx;
  156. }
  157. .img-saoma {
  158. width: 520upx;
  159. height: 400upx;
  160. }
  161. .hand-select {
  162. width: 480upx;
  163. border-radius: 21upx;
  164. }
  165. </style>