info.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="window-box dis-flex" style="background-color: #E9ECF2">
  3. <ly-back :autoBack="false" @backClick="backClick"/>
  4. <view v-if="countDown >= 0" class="countDown">{{ formatZero(countDown, 2) }}</view>
  5. <view class="w100 flex-center-center flex-dir-column">
  6. <view class="baseMessage w80 p-r">
  7. <view class="p-a avatar">
  8. <student-info :student="student"/>
  9. </view>
  10. <view class="dis-flex flex-wrap flex-y-center m-40" style="height: 80px;text-align: center">
  11. <view class="flex-three p-10">姓名:{{ pageData.studentInfo.name }}</view>
  12. <view class="flex-three p-10">性别:{{ pageData.studentInfo.gender }}</view>
  13. <view class="flex-three p-10">班级:{{ pageData.studentInfo.class }}</view>
  14. <view class="flex-three p-10">模式:{{ pageData.studentInfo.model }}</view>
  15. <view class="flex-three p-10">学校:{{ pageData.studentInfo.school }}</view>
  16. <view class="flex-three p-10">卡号:{{ pageData.studentInfo.mac || '手动选择' }}</view>
  17. </view>
  18. </view>
  19. <view class="dis-flex w80">
  20. <!-- <view v-if="pageData.status == 1" class="m-t-50 p-r-20">-->
  21. <!-- <view v-for="(item,index) in pageData.card" :key="index" :class="['cardbg-'+index]" class="cardbg b-r-15"-->
  22. <!-- @click="showDetail(item)">-->
  23. <!-- <view class="f-u-35 dis-flex flex-y-center checkCard p-l-20 p-r-20 p-t-20 p-b-5">-->
  24. <!-- <view :class="['circle-'+index]" class="circle"></view>-->
  25. <!-- <view class="flex-grow t-a-c">-->
  26. <!-- <view class="f-w-b">{{ item.name }}</view>-->
  27. <!-- <view class="f-u-32 font-color p-10">-->
  28. <!-- <view v-if="pageData.status == 1" class="t-a-c f-w-5 f-u-29">-->
  29. <!-- <view v-if="item.value1">{{ item.title1 }}:{{ item.value1 }}</view>-->
  30. <!-- <view v-if="item.value2" class="m-t-10">{{ item.title2 }}:{{ item.value2 }}</view>-->
  31. <!-- </view>-->
  32. <!-- </view>-->
  33. <!-- </view>-->
  34. <!-- </view>-->
  35. <!-- </view>-->
  36. <!-- </view>-->
  37. <view class="checkMessage p-40 m-t-50 b-r-15 flex-center-center flex-dir-column flex-grow"
  38. style="min-height: 500rpx">
  39. <view class="f-u-35 col-f p-20">{{ pageData.status == 1 ? '检测结果展示' : '待检测项目' }}</view>
  40. <view class="w-bg w100 b-r-15 m-t-10 flex-y-start flex-wrap flex-grow ">
  41. <view v-for="(item,index) in card" :key="index" class="flex-two t-a-c p-20 f-u-32 f-w-b">
  42. <view class="flex-center-center">
  43. <view :class="['circleBg-'+index]" class="circle1"></view>
  44. <view class="p-l-10">{{ item.name }}</view>
  45. </view>
  46. <view v-for="(it,ind) in item.val" :key="ind"
  47. class="t-a-c f-w-5 p-l-50 p-t-20 font-color flex-start-end">
  48. <view class="m-r-10">{{ it.title }}:</view>
  49. <template v-if="it.value">
  50. {{ it.value || '待检测' }}{{}}
  51. </template>
  52. <view v-else class="col-red f-u-21">
  53. 待检测
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="dis-flex flex-x-center w100 m-t-50">
  61. <view v-if="pageData.status == -1" class="w10">
  62. <template v-if="configStore.mType === 7">
  63. <view v-if="!machineFun.machine.bmi" class="col-red">体重秤设备未连接</view>
  64. </template>
  65. </view>
  66. <view v-if="pageData.status == 0" class="w10" @click="toTask(10)">
  67. <view class="btn btn-primary w100">进入测试</view>
  68. </view>
  69. <view v-if="pageData.status == 1" class="w10">
  70. <view class="btn btn-primary w100">重新检测</view>
  71. </view>
  72. <view v-if="pageData.status == 1" class="w10 m-l-50" @click="logout">
  73. <view class="btn btn-primary w100">完成</view>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- <view class="window w40 flex-center-center flex-dir-column">-->
  78. <!-- <student-info :student="student"/>-->
  79. <!-- </view>-->
  80. <!-- <view class="w60 h100 dis-flex flex-x-center flex-dir-column">-->
  81. <!-- <template v-if="configStore.mType === 7">-->
  82. <!-- <view class="info-item">-->
  83. <!-- <view class="info-item-label">身高</view>-->
  84. <!-- <view class="">-->
  85. <!-- <view class="col-checked f-64">{{ queryForm.value1 }}</view>-->
  86. <!-- </view>-->
  87. <!-- </view>-->
  88. <!-- <view class="info-item">-->
  89. <!-- <view class="info-item-label">体重</view>-->
  90. <!-- <view class="">-->
  91. <!-- <view class="col-checked f-64">{{ queryForm.value2 }}</view>-->
  92. <!-- </view>-->
  93. <!-- </view>-->
  94. <!-- </template>-->
  95. <!-- <view v-if="configStore.mType === 8" class="info-item">-->
  96. <!-- <view class="info-item-label">肺活量</view>-->
  97. <!-- <view class="">-->
  98. <!-- <view class="btn btn-primary">进入肺活量</view>-->
  99. <!-- </view>-->
  100. <!-- </view>-->
  101. <!-- <view v-if="configStore.mType === 9" class="info-item">-->
  102. <!-- <view class="info-item-label">视力</view>-->
  103. <!-- <view class="">-->
  104. <!-- <view class="btn btn-primary">进入视力</view>-->
  105. <!-- </view>-->
  106. <!-- </view>-->
  107. <!-- </view>-->
  108. <ly-modal ref="modelRef"></ly-modal>
  109. </view>
  110. </template>
  111. <script setup>
  112. import {inject, onActivated, onBeforeUnmount, onMounted, reactive, ref} from "vue";
  113. import {array_column, formatZero, logs, sleep} from "@/utils/util";
  114. import {useConfigStore} from "@/store/useConfigStore";
  115. import {redirectTo} from "@/utils/app";
  116. import debounce from "@/utils/debounce";
  117. import storage from "@/utils/storage";
  118. import {onShow, onHide} from "@dcloudio/uni-app";
  119. import {machineFun} from "@/utils/machine/machineFun"
  120. const configStore = useConfigStore()
  121. const countDown = ref(0)
  122. const debounces = new debounce()
  123. const modelRef = ref()
  124. const $machine = inject('$machine')
  125. const pD = reactive({
  126. value2: '',
  127. value3: '',
  128. })
  129. let student = reactive({
  130. jname: '未识别',
  131. gender: 1,
  132. })
  133. const queryForm = reactive({
  134. student_id: 0,
  135. value1: 0,
  136. value2: 0,
  137. })
  138. const defaultCard = {
  139. 7: {
  140. name: 'BMI',
  141. img: '/card-bg1.png',
  142. val: [
  143. {
  144. id: 1,
  145. title: '身高',
  146. value: '',
  147. unit: 'Cm',
  148. },
  149. {
  150. id: 2,
  151. title: '体重',
  152. value: '',
  153. unit: 'Kg',
  154. },
  155. ],
  156. },
  157. 8: {
  158. name: '肺活量',
  159. img: '/card-bg2.png',
  160. val: [
  161. {
  162. id: 1,
  163. title: '身高',
  164. value: '',
  165. unit: 'ml',
  166. },
  167. ]
  168. },
  169. 9: {
  170. name: '视力',
  171. img: '/card-bg3.png',
  172. val: [
  173. {
  174. id: 1,
  175. title: '左眼',
  176. value: '',
  177. unit: '',
  178. },
  179. {
  180. id: 2,
  181. title: '右眼',
  182. value: '',
  183. unit: '',
  184. },
  185. ]
  186. },
  187. }
  188. const pageData = reactive({
  189. status: 0,
  190. studentInfo: {
  191. name: '测试',
  192. gender: '男',
  193. class: 'xx年级xx班',
  194. model: '机器录入',
  195. school: 'xxxx学校',
  196. mac: '',
  197. },
  198. card: []
  199. })
  200. const card = reactive([])
  201. const search = () => {
  202. queryForm.student_id = 2260
  203. }
  204. const backClick = () => {
  205. console.log('modelRef', modelRef, modelRef.value.open)
  206. modelRef.value.open({
  207. title: '温馨提示',
  208. content: '确认要退出吗?',
  209. showCancelButton: true,
  210. confirm: () => {
  211. logout()
  212. }
  213. })
  214. // confirmModal('请认要退出吗?').then(() => {
  215. // redirectTo('pages/index/index')
  216. // }, () => {
  217. // })
  218. }
  219. const logout = () => {
  220. storage.remove(`student-${student.id}`)
  221. redirectTo('pages/index/index')
  222. }
  223. const countDownHandle = () => {
  224. countDown.value = 30
  225. debounces.countDown('countDown', {
  226. duration: 30000,
  227. callback: () => {
  228. countDown.value--
  229. },
  230. endCallback: () => {
  231. // 清空缓存学生信息
  232. // logout()
  233. },
  234. })
  235. }
  236. const showDetail = (item) => {
  237. console.log(item)
  238. }
  239. const toTask = () => {
  240. pageData.status = 1
  241. }
  242. const bmiWatch = ({kg, cm}) => {
  243. // console.log('bmiWatch123', res)
  244. countDownHandle()
  245. pD.value2 = kg
  246. pD.value3 = cm
  247. }
  248. const setWatch = (open = false) => {
  249. if (open) {
  250. $machine.bmi().setWatch(bmiWatch)
  251. } else {
  252. $machine.bmi().setWatch(null)
  253. }
  254. }
  255. onShow(async () => {
  256. setWatch(true)
  257. })
  258. onHide(async () => {
  259. setWatch()
  260. })
  261. // 页面卸载前
  262. onBeforeUnmount(() => {
  263. setWatch()
  264. machineFun.setUsbNotify(false)
  265. })
  266. // 挂载完成之后
  267. onMounted(async (r) => {
  268. await sleep(1000)
  269. // student = storage.getKey(`student-${r.id}`)
  270. card.push(defaultCard[configStore.mType])
  271. countDownHandle()
  272. machineFun.getOnlineUsb($machine, (list = []) => {
  273. if (list.indexOf('bmi') === -1) pageData.status = -1
  274. })
  275. machineFun.setUsbNotify()
  276. })
  277. // 激活页面时
  278. onActivated(() => {
  279. })
  280. </script>
  281. <style lang="scss" scoped>
  282. .container {
  283. width: 100vw;
  284. height: 100vh;
  285. max-width: 100vw;
  286. max-height: 100vh;
  287. overflow: hidden;
  288. }
  289. .info-item {
  290. display: flex;
  291. align-items: center;
  292. margin-bottom: 30rpx;
  293. &-label {
  294. margin-right: 50rpx;
  295. }
  296. }
  297. .countDown {
  298. width: 130rpx;
  299. height: 130rpx;
  300. position: fixed;
  301. top: 20rpx;
  302. right: 20rpx;
  303. border: 6rpx solid green;
  304. color: green;
  305. border-radius: 50%;
  306. display: flex;
  307. justify-content: center;
  308. align-items: center;
  309. font-size: 60rpx;
  310. }
  311. .baseMessage {
  312. background: linear-gradient(180deg, #FFFFFF 0%, #E0EDF8 100%);
  313. box-shadow: 0px 0px 8px 1px #498CFC;
  314. }
  315. .avatar {
  316. border: 8rpx solid #498CFC;
  317. border-radius: 50%;
  318. top: 0;
  319. transform: translateY(-50%);
  320. left: 60rpx;
  321. }
  322. .checkMessage {
  323. background: linear-gradient(180deg, #498CFC 0%, #E0EDF8 100%);
  324. }
  325. .cardbg {
  326. width: 500rpx;
  327. height: 230rpx;
  328. background-size: 100%;
  329. border-radius: 15rpx;
  330. margin-bottom: 20rpx;
  331. &-0 {
  332. background: url('static/image/card-bg1.png') no-repeat center center;
  333. }
  334. &-1 {
  335. background: url('static/image/card-bg2.png') no-repeat center center;
  336. }
  337. &-2 {
  338. background: url('static/image/card-bg3.png') no-repeat center center;
  339. }
  340. }
  341. .checkCard {
  342. height: 80%;
  343. background-color: #FFFFFF;
  344. border-radius: 15rpx 15rpx 25rpx 25rpx;
  345. .circle {
  346. width: 130rpx;
  347. height: 130rpx;
  348. border-radius: 50%;
  349. &-0 {
  350. background-color: #027EEC;
  351. }
  352. &-1 {
  353. background-color: #F7B03C;
  354. }
  355. &-2 {
  356. background-color: #17ACC3;
  357. }
  358. }
  359. }
  360. .circle1 {
  361. width: 35rpx;
  362. height: 35rpx;
  363. border-radius: 50%;
  364. }
  365. .circleBg {
  366. &-0 {
  367. background-color: #027EEC;
  368. }
  369. &-1 {
  370. background-color: #F7B03C;
  371. }
  372. &-2 {
  373. background-color: #17ACC3;
  374. }
  375. }
  376. .font-color {
  377. color: #153269;
  378. }
  379. </style>