ly-back.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template xmlns="">
  2. <view class="">
  3. <view v-if="props.showBack" :class="{'action':select === 0}" class="p-f back-box" @click="clickHandle">
  4. <ly-icon :color="color" :size="60" name="icon-fanhui"/>
  5. </view>
  6. <view class="p-f bottom-right">
  7. <view class="flex-between-center w50">
  8. <view class="">
  9. <ly-icon :color="machineStore.scan?'#00ce48':'red'" :size="50" name="icon-shuakaqi"/>
  10. </view>
  11. <view v-if="configStore.mType === 7" class="m-l-20">
  12. <ly-icon :color="machineStore.bmi?'#00CE48':'red'" :size="45" name="icon-dianzicheng"/>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="p-f mac-info" @click="toSetting">
  17. MAC:{{ userStore.mac || '未登录' }}
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import {inject, onBeforeUnmount, onMounted, reactive} from "vue";
  23. import {navigateBack, navTo, showToast} from "@/utils/app";
  24. import {useUserStore} from "@/store/useUserStore";
  25. import debounce from "@/utils/debounce";
  26. import {machineFun} from "@/utils/machine/machineFun";
  27. import {useConfigStore} from "@/store/useConfigStore";
  28. import {useMachineStore} from "@/store/useMachineStore";
  29. const $machine = inject('$machine')
  30. const debounces = new debounce()
  31. const userStore = useUserStore()
  32. const configStore = useConfigStore()
  33. const machineStore = useMachineStore()
  34. const emits = defineEmits(['backClick'])
  35. const props = defineProps({
  36. showBack: {
  37. type: Boolean,
  38. default: true,
  39. },
  40. autoBack: {
  41. type: Boolean,
  42. default: true
  43. },
  44. color: {
  45. type: String,
  46. default: '#000'
  47. },
  48. select: {
  49. type: [String, Number],
  50. default: -1
  51. },
  52. })
  53. const clickHandle = () => {
  54. if (props.autoBack) {
  55. navigateBack()
  56. } else {
  57. emits('backClick')
  58. }
  59. }
  60. const toSetting = () => {
  61. debounces.secondCountDown('toSetting', {
  62. time: 5000,
  63. limit: 10,
  64. repetition_time: 0,
  65. run: (num, count, statue) => {
  66. if (count > 5) showToast(`再点击${10 - count}次`)
  67. },
  68. success: () => {
  69. console.log('success')
  70. navTo('pages/setting/index')
  71. },
  72. fail: () => {
  73. console.log('fail')
  74. },
  75. })
  76. }
  77. // 挂载完成之后
  78. onMounted(async (r) => {
  79. // machineFun.setUsbNotify(true)
  80. // machineFun.getOnlineUsb($machine)
  81. })
  82. // 页面卸载前
  83. onBeforeUnmount(() => {
  84. // machineFun.setUsbNotify(false)
  85. })
  86. </script>
  87. <style lang="scss" scoped>
  88. .mac-info {
  89. bottom: 10rpx;
  90. right: 20rpx;
  91. font-size: 25rpx;
  92. color: #cccccc;
  93. }
  94. .bottom-right {
  95. bottom: 10rpx;
  96. left: 20rpx;
  97. }
  98. .back-box {
  99. //width: 30vw;
  100. height: 200px;
  101. z-index: 99;
  102. }
  103. </style>