init.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="window-box dis-flex flex-y-center">
  3. <view class="steps h100 w30 flex-center-center">
  4. <uv-steps :current="current" :customStyle="[{
  5. width:'70%',
  6. height:'90vh',
  7. }]" activeIcon="checkmark" direction="column" inactiveIcon="arrow-right">
  8. <uv-steps-item :iconSize="60" title="网络检测"></uv-steps-item>
  9. <uv-steps-item :iconSize="60" title="登录"></uv-steps-item>
  10. <uv-steps-item :iconSize="60" title="运行"></uv-steps-item>
  11. </uv-steps>
  12. </view>
  13. <view class="form-box h100 w60 flex-start-center flex-dir-column">
  14. <view class="w100 h90 flex-start-center">
  15. <view v-if="current === 0" class="flex-dir-column">
  16. <view v-if="pd.network.search" class="f-42 col-c t-a-c">
  17. 网络检测中。。。
  18. </view>
  19. <view v-if="pd.network.type === 'none'" class="" @click="network">重新检测网络</view>
  20. <template v-else>
  21. <view class="f-42 col-green t-a-c">
  22. 当前网络:{{ pd.network.type === 'unknown' ? '未知网络但可用' : pd.network.type }}
  23. </view>
  24. <view class="btn btn" @click="currentAdd">下一步</view>
  25. </template>
  26. </view>
  27. <view v-if="current === 1" class="flex-dir-column">
  28. <view v-if="pd.login" class="f-42 col-c t-a-c">
  29. 自动登录中。。。
  30. </view>
  31. <view v-else class="">
  32. <uv-form ref="form" :model="pd.loginForm" labelPosition="left">
  33. <uv-form-item borderBottom label="设备码" prop="pd.loginForm.mac">
  34. <uv-input v-model="pd.loginForm.mac" border="none"/>
  35. </uv-form-item>
  36. <uv-form-item borderBottom label="密码" prop="pd.loginForm.pwd">
  37. <uv-input v-model="pd.loginForm.pwd" border="none" type="password"/>
  38. </uv-form-item>
  39. <uv-form-item borderBottom label=" " prop="pd.loginForm.mac">
  40. <view class="w100">
  41. <view class="btn btn-primary" @click="loginHandle">登录</view>
  42. </view>
  43. </uv-form-item>
  44. </uv-form>
  45. </view>
  46. </view>
  47. <view v-if="current === 2" class="f-42 col-green t-a-c ">
  48. <uv-icon name="checkmark-circle" size="80"/>
  49. 检测完成,正在进入系统
  50. </view>
  51. </view>
  52. <view class="btn-box">
  53. <view class="btn btn-su" @click="restartCheck">重新检测</view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script setup>
  59. import {onActivated, onMounted, reactive, ref} from "vue";
  60. import {getNetworkType} from "@/utils/uniFunction";
  61. import {useUserStore} from "@/store/useUserStore";
  62. import {sleep} from "@/utils/util";
  63. import {machineTypeList} from "@/utils/machine/config";
  64. import {useConfigStore} from "@/store/useConfigStore";
  65. import {getBeforePage, redirectTo} from "@/utils/app";
  66. const userStore = useUserStore()
  67. const configStore = useConfigStore()
  68. const current = ref(0)
  69. const pd = reactive({
  70. network: {
  71. search: false,
  72. type: 'none',
  73. },
  74. login: false,
  75. loginForm: {
  76. mac: '',
  77. pwd: '',
  78. },
  79. })
  80. const machineList = ref(JSON.parse(JSON.stringify(machineTypeList)))
  81. const currentAdd = async () => {
  82. if (current.value < 2) current.value++
  83. if (current.value === 1 && pd.login) {
  84. await sleep(1000)
  85. current.value++
  86. }
  87. if (current.value === 2 && pd.login) {
  88. await sleep(1000)
  89. redirectTo('pages/index/index', {}, 2)
  90. }
  91. }
  92. const restartCheck = () => {
  93. current.value = 0
  94. }
  95. const loginHandle = () => {
  96. pd.login = true
  97. currentAdd()
  98. }
  99. const network = async () => {
  100. pd.network.search = true
  101. try {
  102. let network = await getNetworkType()
  103. pd.network.type = network.networkType
  104. pd.network.search = false
  105. } catch (e) {
  106. pd.network.search = false
  107. }
  108. }
  109. const machineChange = (item) => {
  110. configStore.setMachineType(item)
  111. currentAdd()
  112. }
  113. // 挂载完成之后
  114. onMounted(() => {
  115. let beforePage = getBeforePage(0)
  116. network()
  117. })
  118. // 激活页面时
  119. onActivated(() => {
  120. })
  121. </script>
  122. <style lang="scss" scoped>
  123. .window-box {
  124. background: #398CFF;
  125. }
  126. .steps {
  127. background: red;
  128. > > > .uv-steps-item {
  129. background: green;
  130. &__line--column {
  131. width: 30rpx;
  132. }
  133. }
  134. }
  135. .form-box {
  136. padding-left: 10vw;
  137. }
  138. </style>