init.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="window-box dis-flex flex-y-center">
  3. <view class="steps w40 form-box">
  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 class="h90 dis-flex flex-wrap flex-y-center step">
  13. <view v-for="(item,index) in pd.steps" class="w100">
  14. <view class="dis-flex flex-y-center flex-x-evenly p-r" :class="[current < index? 'opacity' :'']">
  15. <view class="circle dis-flex flex-center-center f-u-41 f-w-b p-r" :class="['circle-'+index]">
  16. <text>{{index+1}}</text>
  17. <view v-if="item.next" class="p-a next">
  18. <uv-image :src="pd.imgUrl+item.next" width="22px" height="97px" mode="widthFix"></uv-image>
  19. </view>
  20. </view>
  21. <view class="dian" :class="['dian-'+index]"></view>
  22. <view class="content dis-flex flex-center-center col-f f-u-51 f-w-b">
  23. <view class="w80 p-b-20 b-b p-l-20">{{item.title}}</view>
  24. </view>
  25. <view v-if="item.img" class="p-a bg">
  26. <uv-image :src="pd.imgUrl+item.img" width="86px" height="97px"></uv-image>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="form-box w60 flex-center-center flex-dir-column">
  33. <view class="w100 h70 flex-center-center w-bg b-r-15 p-r">
  34. <view v-if="current === 0" class="w100">
  35. <view v-if="pd.network.search" class="f-42 col-c t-a-c">
  36. 网络检测中。。。
  37. </view>
  38. <!-- <view @click="network">重新检测网络</view>-->
  39. <template v-else>
  40. <view class="dis-flex flex-wrap flex-dir-column flex-center-center ">
  41. <view>
  42. <uv-image :src="pd.imgUrl+ '/login-wifi.png'" width="150px" height="150px"></uv-image>
  43. </view>
  44. <view class="f-u-35 col-9 t-a-c p-t-10">
  45. 当前网络:{{ pd.network.type === 'unknown' ? '未知网络但可用' : pd.network.type }}
  46. </view>
  47. </view>
  48. </template>
  49. <view class="p-a btns">
  50. <view class="btn btn-primary w100" @click="next">{{pd.network.type === 'none' ? '重新检测网络':'下一步'}}</view>
  51. </view>
  52. </view>
  53. <view v-if="current === 1" class="flex-dir-column w100">
  54. <view class=" dis-flex flex-center-center w100">
  55. <view v-if="pd.login" class="f-42 col-c t-a-c">
  56. 自动登录中。。。
  57. </view>
  58. <view v-else class="w50">
  59. <uv-form ref="form" :model="pd.loginForm" labelPosition="left" label-width="80px">
  60. <uv-form-item borderBottom label="设备码" leftIcon="order" prop="pd.loginForm.mac">
  61. <uv-input v-model="pd.loginForm.mac" border="none"/>
  62. </uv-form-item>
  63. <uv-form-item borderBottom label="密码" leftIcon="lock-fill" prop="pd.loginForm.pwd">
  64. <uv-input v-model="pd.loginForm.pwd" border="none" type="password"/>
  65. </uv-form-item>
  66. </uv-form>
  67. </view>
  68. </view>
  69. <view class=" p-a btns">
  70. <view class="btn btn-primary w100" @click="loginHandle">登录</view>
  71. </view>
  72. </view>
  73. <view v-if="current === 2" class="f-42 col-green t-a-c flex-center-center">
  74. <uv-icon name="checkmark-circle" size="80"/>
  75. 检测完成,正在进入系统
  76. </view>
  77. </view>
  78. <view class="btn-box">
  79. <view class="btn btn-su" @click="restartCheck">重新检测</view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script setup>
  85. import {onActivated, onMounted, reactive, ref} from "vue";
  86. import {getNetworkType} from "@/utils/uniFunction";
  87. import {useUserStore} from "@/store/useUserStore";
  88. import {sleep} from "@/utils/util";
  89. import {machineTypeList} from "@/utils/machine/config";
  90. import {useConfigStore} from "@/store/useConfigStore";
  91. import {getBeforePage, redirectTo} from "@/utils/app";
  92. const userStore = useUserStore()
  93. const configStore = useConfigStore()
  94. const current = ref(0)
  95. const pd = reactive({
  96. network: {
  97. search: false,
  98. type: 'none',
  99. },
  100. login: false,
  101. loginForm: {
  102. mac: '',
  103. pwd: '',
  104. },
  105. imgUrl:'/static/image',
  106. steps:[{title:'网络检测',img:'/login-image1.png',next:'/login-next1.png'},{title:'登陆',next:'/login-next1.png'},{title:'进入系统'}],
  107. })
  108. const machineList = ref(JSON.parse(JSON.stringify(machineTypeList)))
  109. const currentAdd = async () => {
  110. if (current.value < 2) current.value++
  111. if (current.value === 1 && pd.login) {
  112. await sleep(1000)
  113. current.value++
  114. }
  115. if (current.value === 2 && pd.login) {
  116. await sleep(1000)
  117. redirectTo('pages/index/index', {}, 2)
  118. }
  119. }
  120. const network = async () => {
  121. pd.network.search = true
  122. try {
  123. let network = await getNetworkType()
  124. pd.network.type = network.networkType
  125. pd.network.search = false
  126. } catch (e) {
  127. pd.network.search = false
  128. }
  129. }
  130. const next = async ()=>{
  131. if(current.value === 0){
  132. if(pd.network.type === 'none'){
  133. await network()
  134. }else {
  135. await currentAdd()
  136. }
  137. }
  138. }
  139. const restartCheck = () => {
  140. current.value = 0
  141. }
  142. const loginHandle = () => {
  143. pd.login = true
  144. currentAdd()
  145. }
  146. const machineChange = (item) => {
  147. configStore.setMachineType(item)
  148. currentAdd()
  149. }
  150. // 挂载完成之后
  151. onMounted(() => {
  152. let beforePage = getBeforePage(0)
  153. network()
  154. })
  155. // 激活页面时
  156. onActivated(() => {
  157. })
  158. </script>
  159. <style lang="scss" scoped>
  160. .window-box {
  161. background: #EBEDF4;
  162. }
  163. .steps {
  164. > > > .uv-steps-item {
  165. background: green;
  166. &__line--column {
  167. width: 30rpx;
  168. }
  169. }
  170. }
  171. .form-box {
  172. padding: 2.5vw;
  173. }
  174. .step{
  175. .circle{
  176. width: 90rpx;
  177. height: 90rpx;
  178. border-radius: 50%;
  179. &-0{
  180. background-color: #FFFFFF;
  181. border: 8rpx solid #027EEC;
  182. color: #027EEC;
  183. }
  184. &-1{
  185. background-color: #FFFFFF;
  186. border: 8rpx solid #17ACC3;
  187. color: #17ACC3;
  188. }
  189. &-2{
  190. background-color: #FFFFFF;
  191. border: 8rpx solid #F7B03C;
  192. color: #F7B03C;
  193. }
  194. }
  195. .dian{
  196. width: 28rpx;
  197. height: 28rpx;
  198. border-radius: 50%;
  199. &-0{
  200. background-color: #027EEC;
  201. }
  202. &-1{
  203. background-color: #17ACC3;
  204. }
  205. &-2{
  206. background-color: #F7B03C;
  207. }
  208. }
  209. .content{
  210. background-image: url('static/image/login-bg1.png');
  211. width: 500rpx;
  212. height: 200rpx;
  213. background-position: center center;
  214. background-size: 100%;
  215. background-repeat: no-repeat;
  216. }
  217. .bg{
  218. right: 7%;
  219. top: -35%;
  220. }
  221. .next{
  222. top: 100%;
  223. transform: translateY(60%)
  224. }
  225. }
  226. .opacity{
  227. opacity: 0.5;
  228. }
  229. .btns{
  230. bottom: 10px;
  231. left: 50%;
  232. transform: translateX(-50%);
  233. width: 200rpx;
  234. }
  235. </style>