network.vue 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view>
  3. <form ref="form" @submit="handleSubmit">
  4. <view class="login-panel">
  5. <view>
  6. <input class="input-cube" ref="ssid" v-model="ssid" type="text" maxlength="32"
  7. placeholder="请输入路由器名称" name="ssid" />
  8. <input class="input-cube" maxlength="20" type="text" v-model="password" placeholder="请输入密码"
  9. name="password" />
  10. <button class="input-btn" form-type="submit" :disabled="startDisabled">开始配网</button>
  11. </view>
  12. </view>
  13. <view class="message">1. 请确保手机WiFi连接到2.4GHz频段路由器</view>
  14. <view class="message">2. 设备仅支持2.4GHz网络</view>
  15. </form>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. ssid:'',
  23. password:'',
  24. }
  25. },
  26. onLoad() {
  27. const _this = this
  28. wx.startWifi({
  29. success(res) {
  30. _this.getWifiInfo();
  31. },
  32. fail: function (res) {
  33. console.log('获取网络fail',res);
  34. // _this.showPopIs5G();
  35. // uni.showToast({
  36. // title: "请连接路由器",
  37. // duration: 2000,
  38. // });
  39. },
  40. });
  41. },
  42. methods: {
  43. handleSubmit(){
  44. },
  45. getWifiInfo(){
  46. wx.getConnectedWifi({
  47. success(res){
  48. console.log('连接网络成功',res)
  49. if ("getConnectedWifi:ok" === res.errMsg) {
  50. this.ssid = res.wifi.SSID
  51. }
  52. },
  53. fail(res){
  54. console.log('连接的网络失败',res);
  55. }
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. .login-panel {
  63. margin: 60rpx;
  64. }
  65. .input-cube {
  66. border: solid 3rpx #65ceac;
  67. border-radius: 40rpx;
  68. margin: 30rpx 0;
  69. height: 80rpx;
  70. padding: 0 40rpx;
  71. font-size: 30rpx;
  72. }
  73. .input-btn {
  74. border-radius: 40rpx;
  75. height: 80rpx;
  76. background-color: #65ceac;
  77. color: white;
  78. font-size: 30rpx;
  79. }
  80. </style>