init copy.vue 7.6 KB

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