wifiConnect.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='配置网络'></cus-header>
  4. <div class="title">设备配网&绑定</div>
  5. <div class="tip">服务器需要对设备进行配置,网络不好的情况,可能需要写时间,请耐心等待。</div>
  6. <div class="box adffcacjc">
  7. <!-- <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/04/22b84dc0-14f7-40eb-94bd-04908bd0db42.png"></image> -->
  8. <image src="@/static/connect.png"></image>
  9. <div class="text">正在连接设备</div>
  10. <div class="memo">连接过程请勿关闭小程序或者设备</div>
  11. </div>
  12. <u-popup :show="show" :round="56" mode="center" @close="close">
  13. <div class="fail_box adffcacjc">
  14. <!-- <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/3b872bd3-d82f-4f0a-802e-dde0df547f0d.png"></image> -->
  15. <image src="@/static/connect_off.png"></image>
  16. <text>网络连接失败</text>
  17. <p>请检查你的网络连接后重试</p>
  18. <div class="btns adfacjb">
  19. <div class="qx_btn" @tap="goBack">返回</div>
  20. <div class="zt_btn" @tap="toTryAgain">重试</div>
  21. </div>
  22. </div>
  23. </u-popup>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data(){
  29. return {
  30. wifiSSID:'',
  31. wifiPWD:'',
  32. show:false
  33. }
  34. },
  35. onLoad(option) {
  36. this.wifiSSID = option?.wifiSSID;
  37. this.wifiPWD = option?.wifiPWD;
  38. this.connectWifi();
  39. },
  40. methods:{
  41. connectWifi(){
  42. let that = this;
  43. wx.request({
  44. url:'http://192.168.4.1/submit',
  45. method:'POST',
  46. data:{
  47. ssid:that.wifiSSID,
  48. password:that.wifiPWD
  49. },
  50. success:res=>{
  51. if(res.errMsg!=='request:ok'||!res.data.success){
  52. that.show = true;
  53. return
  54. }
  55. wx.request({
  56. url:'http://192.168.4.1/reboot',
  57. method:'POST',
  58. success:res2=>{
  59. if(res2.errMsg!=='request:ok'){
  60. that.$showToast('设备重启失败')
  61. return
  62. }
  63. setTimeout(()=>{
  64. uni.navigateTo({
  65. url:'/pagesMy/wifiSuccess'
  66. })
  67. },1000)
  68. },
  69. fail:err2=>{
  70. that.$showModal("reboot:err:"+JSON.stringify(err2))
  71. }
  72. })
  73. },
  74. fail:err=>{
  75. that.show = true;
  76. that.$showModal("submit:err:"+JSON.stringify(err))
  77. }
  78. })
  79. },
  80. goBack(){
  81. uni.redirectTo({
  82. url:'/pagesMy/wifiSearch'
  83. })
  84. },
  85. toTryAgain(){
  86. this.show = false;
  87. this.connectWifi();
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped lang="less">
  93. .page{
  94. padding: 0 40rpx 40rpx;
  95. box-sizing: border-box;
  96. background: #FFFFFF;
  97. .title{
  98. font-family: PingFang-SC, PingFang-SC;
  99. font-weight: bold;
  100. font-size: 36rpx;
  101. color: #111111;
  102. line-height: 36rpx;
  103. margin-top: 64rpx;
  104. }
  105. .tip{
  106. font-family: PingFangSC, PingFang SC;
  107. font-weight: 400;
  108. font-size: 26rpx;
  109. color: #111111;
  110. line-height: 40rpx;
  111. margin-top: 30rpx;
  112. }
  113. .box{
  114. margin-top: 154rpx;
  115. image{
  116. width: 240rpx;
  117. height: 309rpx;
  118. }
  119. .text{
  120. font-family: PingFang-SC, PingFang-SC;
  121. font-weight: bold;
  122. font-size: 36rpx;
  123. color: #111111;
  124. line-height: 36rpx;
  125. text-align: center;
  126. margin-top: 43rpx;
  127. }
  128. .memo{
  129. font-family: PingFangSC, PingFang SC;
  130. font-weight: 400;
  131. font-size: 28rpx;
  132. color: #7C8592;
  133. line-height: 42rpx;
  134. text-align: center;
  135. margin-top: 30rpx;
  136. }
  137. }
  138. .fail_box{
  139. width: 670rpx;
  140. background: #FFFFFF;
  141. border-radius: 28rpx;
  142. padding: 34rpx 60rpx 54rpx;
  143. box-sizing: border-box;
  144. image{
  145. width: 232rpx;
  146. height: 232rpx;
  147. }
  148. text{
  149. font-family: PingFangSC, PingFang SC;
  150. font-weight: 400;
  151. font-size: 30rpx;
  152. color: #333333;
  153. line-height: 42rpx;
  154. margin-top: 10rpx;
  155. }
  156. p{
  157. font-family: PingFangSC, PingFang SC;
  158. font-weight: 400;
  159. font-size: 24rpx;
  160. color: #A6A6A6;
  161. line-height: 24rpx;
  162. margin-top: 24rpx;
  163. text-align: center;
  164. }
  165. .btns{
  166. width: 100%;
  167. margin-top: 40rpx;
  168. &>div{
  169. width: calc(50% - 15rpx);
  170. }
  171. }
  172. }
  173. }
  174. </style>