init.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="window-box container-box">
  3. <view class="flow-box" @click="changeStep">
  4. <view class="flow-info">
  5. <view class="flow-info-item">
  6. <image :src="`${imgUrl}/start_img_web.png`" />
  7. <view>网络检测</view>
  8. </view>
  9. <view class="flow-info-item">
  10. <image :src="curStep > 1 ? `${imgUrl}/start_img_log_selected.png` : `${imgUrl}/start_img_log_disabled.png`" />
  11. <view>登陆</view>
  12. </view>
  13. <view class="flow-info-item">
  14. <image
  15. :src="curStep > 2 ? `${imgUrl}/start_img_system_selected.png` : `${imgUrl}/start_img_system_disabled.png`" />
  16. <view>进入系统</view>
  17. </view>
  18. </view>
  19. <view class="flow-step">
  20. <view v-if="curStep == 1" class="flow-step-item flow-step-item1">1</view>
  21. <image v-else :src="`${imgUrl}/start_icon_done_blue.png`" />
  22. <view class="flow-step-point" :class="curStep > 1 ? 'flow-step-point-active1' : ''">········</view>
  23. <view v-if="curStep <= 1" class="flow-step-item">2</view>
  24. <view v-else-if="curStep == 2" class="flow-step-item flow-step-item2">2</view>
  25. <image v-else :src="`${imgUrl}/start_icon_done_green.png`" />
  26. <view class="flow-step-point" :class="curStep > 2 ? 'flow-step-point-active2' : ''">········</view>
  27. <view v-if="curStep < 3" class="flow-step-item">3</view>
  28. <view v-else-if="curStep == 3" class="flow-step-item flow-step-item3">3</view>
  29. <image v-else :src="`${imgUrl}/start_icon_done_yellow.png`" />
  30. </view>
  31. </view>
  32. <view class="info-box">
  33. <view v-if="curStep == 1" class="step1-box">
  34. <image :src="`${imgUrl}/start_img_default.png`" />
  35. <view class="tips-box">
  36. <view class="tips">暂无网络连接,请重试</view>
  37. <view class="btn btn-primary" @click="initNetwork">重新检测</view>
  38. </view>
  39. </view>
  40. <view v-else-if="curStep == 2" class="step2-box">
  41. <uv-input placeholder="请输入设备码" border="surround" fontSize="28upx" height="97upx" v-model="loginForm.mac"
  42. class="step2-input"></uv-input>
  43. <uv-input placeholder="请输入密码" border="surround" fontSize="28upx" v-model="loginForm.pwd" password="true"
  44. class="step2-input"></uv-input>
  45. <view style="display: flex;">
  46. <view class="btn btn-green" @click="handleLogin">登录</view>
  47. </view>
  48. </view>
  49. <view v-else class="step3-box">
  50. <image :src="`${imgUrl}/start_img_system.png`" />
  51. <view class="tips-box">
  52. <view class="tips">正在进入系统中,请耐心等待...</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script setup>
  59. import { onActivated, onMounted, reactive, ref } from "vue";
  60. import { navTo, showToast } from "@/utils/app";
  61. import {useUserStore} from "@/store/useUserStore";
  62. import {logs, sleep} from "@/utils/util";
  63. import { onLoad } from '@dcloudio/uni-app';
  64. const userStore = useUserStore()
  65. const imgUrl = ref('/static/image/bmi-init')
  66. const curStep = ref(0)
  67. const loginForm = ref({
  68. mac: '',
  69. pwd: ''
  70. })
  71. const networkType = ref({})
  72. const changeStep = () => {
  73. curStep.value += 1
  74. if(curStep.value == 5){
  75. navTo('pages/index/index', {
  76. })
  77. }
  78. }
  79. const initNetwork = () =>{
  80. uni.getNetworkType({
  81. success: async (res) => {
  82. networkType.value = res.networkType
  83. if (res.networkType == 'none') {
  84. showToast('无网络连接')
  85. curStep.value = 1
  86. } else {
  87. await sleep(1100)
  88. curStep.value = 2
  89. }
  90. }
  91. })
  92. }
  93. const handleLogin = async () =>{
  94. if(loginForm.value.mac == ''){
  95. return showToast('请输入设备码')
  96. }
  97. if(loginForm.value.pwd == ''){
  98. return showToast('请输入密码')
  99. }
  100. userStore.login(loginForm.value).then(async (data)=>{
  101. curStep.value += 1
  102. await sleep(1000)
  103. curStep.value += 1
  104. await sleep(1000)
  105. navTo('pages/index/index', {})
  106. }).catch(()=>{
  107. })
  108. }
  109. onLoad(() => {
  110. initNetwork()
  111. })
  112. </script>
  113. <style scoped>
  114. .btn {
  115. width: 480upx;
  116. border-radius: 21upx;
  117. margin: 0 auto;
  118. }
  119. .flow-box {
  120. margin: 50upx auto 0;
  121. width: 650upx;
  122. }
  123. .flow-info {
  124. display: flex;
  125. justify-content: space-between;
  126. }
  127. .flow-info-item {
  128. width: 200upx;
  129. height: 230upx;
  130. position: relative;
  131. border-radius: 21upx;
  132. }
  133. .flow-info-item view {
  134. text-align: center;
  135. font-weight: bold;
  136. font-size: 35upx;
  137. color: #FFF;
  138. margin-top: 24upx;
  139. z-index: 9;
  140. width: 200upx;
  141. height: 230upx;
  142. position: absolute;
  143. }
  144. .flow-info image {
  145. width: 200upx;
  146. height: 230upx;
  147. position: absolute;
  148. border-radius: 21upx;
  149. }
  150. .flow-step {
  151. display: flex;
  152. width: 550upx;
  153. line-height: 70upx;
  154. justify-content: space-around;
  155. margin: 20upx auto 0;
  156. }
  157. .flow-step-item {
  158. width: 70upx;
  159. height: 70upx;
  160. text-align: center;
  161. font-weight: bold;
  162. font-size: 35upx;
  163. border-radius: 50%;
  164. border: 8upx solid #D9D9D9;
  165. background: #fff;
  166. color: #D9D9D9;
  167. }
  168. .flow-step image {
  169. height: 86upx;
  170. width: 86upx;
  171. position: relative;
  172. }
  173. .flow-step-item1 {
  174. border: 8upx solid rgb(205, 223, 252);
  175. background: #2F87F5;
  176. color: #fff;
  177. }
  178. .flow-step-item2 {
  179. border: 8upx solid rgb(183, 232, 227);
  180. background: #01CF7A;
  181. color: #fff;
  182. }
  183. .flow-step-item3 {
  184. border: 8upx solid rgb(236, 230, 218);
  185. background: #FFC64D;
  186. color: #fff;
  187. }
  188. .flow-step-point {
  189. font-size: 40upx;
  190. font-weight: 700;
  191. position: relative;
  192. top: 10upx;
  193. color: #D9D9D9;
  194. }
  195. .flow-step-point-active1 {
  196. color: #0369E8;
  197. }
  198. .flow-step-point-active2 {
  199. color: #01CF7A;
  200. }
  201. .info-box {
  202. background: #fff;
  203. width: 650upx;
  204. height: 650upx;
  205. border-radius: 35upx;
  206. margin: 20upx auto 0;
  207. }
  208. .container-box {
  209. background-image: url('/static/image/bmi-init/img_bg.png');
  210. background-repeat: repeat-x;
  211. }
  212. .step2-box {
  213. width: 650upx;
  214. height: 650upx;
  215. padding-top: 60upx;
  216. box-sizing: border-box;
  217. }
  218. .step1-box image {
  219. width: 490upx;
  220. height: 313upx;
  221. margin: 0 auto 0;
  222. padding-top: 40upx;
  223. display: block;
  224. }
  225. .step3-box image {
  226. width: 479upx;
  227. height: 479upx;
  228. margin: 0 auto 0;
  229. padding-top: 40upx;
  230. display: block;
  231. }
  232. .tips-box {
  233. display: flex;
  234. flex-direction: column;
  235. }
  236. .tips {
  237. font-size: 21rpx;
  238. color: #6F6F6F;
  239. text-align: center;
  240. margin: 30upx 0;
  241. }
  242. .step2-box .step2-input {
  243. width: 547upx;
  244. height: 97upx !important;
  245. background: #FFFFFF;
  246. border-width: 3upx !important;
  247. border-color: #01CF7A !important;
  248. font-size: 28upx;
  249. color: #6F6F6F;
  250. border-radius: 20upx !important;
  251. line-height: 97upx !important;
  252. margin: 0 auto 60upx;
  253. }
  254. .btn-green {
  255. color: #FFFFFF;
  256. background: #01CF7A;
  257. border-color: #01CF7A;
  258. margin: 0 auto;
  259. }
  260. </style>