From 8e40a69fcfe8bc799fee141fec953a2b0892dbd4 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期一, 09 十月 2023 15:54:26 +0800
Subject: [PATCH] 修改wifi扫描的交互

---
 src/pages/settings/views/NetSettings.vue |  784 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 426 insertions(+), 358 deletions(-)

diff --git a/src/pages/settings/views/NetSettings.vue b/src/pages/settings/views/NetSettings.vue
index 5d283e1..042ec4d 100644
--- a/src/pages/settings/views/NetSettings.vue
+++ b/src/pages/settings/views/NetSettings.vue
@@ -17,31 +17,18 @@
           <!-- <span v-if="showStatus && i == 2" class="status">宸茶繛鎺�</span> -->
         </div>
       </div>
-      <div class="net-right">
+      <div class="net-right" v-loading="configLoading">
         <div class="net-set" v-if="activePage == 0">
           <div class="title">缃戠粶璁剧疆</div>
-          <el-form
-            :model="ruleForm"
-            :rules="rules"
-            ref="joinForm"
-            class="join-form"
-          >
+          <el-form :model="ruleForm" :rules="rules" ref="joinForm" class="join-form">
             <el-form-item prop="deviceName">
               <div class="p-title">璁惧鍚嶇О</div>
-              <el-input
-                v-model="ruleForm.deviceName"
-                size="small"
-                placeholder="蹇呭~"
-              ></el-input>
+              <el-input v-model="ruleForm.deviceName" size="small" placeholder="蹇呭~"></el-input>
             </el-form-item>
 
             <el-form-item prop="port">
               <div class="p-title">绔彛</div>
-              <el-input
-                v-model="ruleForm.port"
-                placeholder="閫夊~锛屽閮ㄨ闂殑绔彛"
-                size="small"
-              ></el-input>
+              <el-input v-model="ruleForm.port" placeholder="閫夊~锛屽閮ㄨ闂殑绔彛" size="small"></el-input>
             </el-form-item>
           </el-form>
           <!-- <div class="save-btn" @click="saveServerName">淇濆瓨</div> -->
@@ -53,84 +40,61 @@
         <div class="wifi-set" v-if="activePage == 1 && !inWifiDetail">
           <div class="title">鏃犵嚎缃戠粶</div>
 
-          <switchBar
-            :barName="`鏃犵嚎缃戝崱`"
-            @switchChange="wifiControl"
-            :value="isOpenWifi"
-          ></switchBar>
+          <switchBar :barName="`鏃犵嚎缃戝崱`" @switchChange="wifiControl" :value="true"></switchBar>
 
-          <div class="wifi-option" v-for="(item, i) in wifiList" :key="i">
+          <div class="wifi-option" v-for="(item, i) in wifiList" :key="i" @click="checkWifi(item)">
             <div class="name">
-              <span class="icon iconfont" v-if="item.isConnected"
-                >&#xe676;</span
-              >
-              <span
-                :style="!item.isConnected ? { 'margin-left': '24px' } : {}"
-                >{{ item.name }}</span
-              >
+              <span class="icon iconfont" v-if="item.connected">&#xe676;</span>
+              <span :style="!item.connected ? { 'margin-left': '24px' } : {}">{{ item.essid | escape }}</span>
             </div>
 
             <div class="more-detail">
-              <span class="icon iconfont lock">&#xe726;</span>
+              <span class="icon iconfont lock" v-if="item.encryption_key">&#xe726;</span>
               <span class="icon iconfont signal">&#xe6e5;</span>
-              <span class="icon iconfont more-icon" @click="checkWifi(item)"
-                >&#xe640;</span
-              >
+              <span class="icon iconfont more-icon">&#xe640;</span>
             </div>
           </div>
+
+          <el-button type="text" @click="wirelessScan" :loading="wifiScanning">鎵弿鏃犵嚎缃戠粶</el-button>
         </div>
         <div class="wifi-detail" v-if="activePage == 1 && inWifiDetail" ref="ipvHolder">
           <div class="title">鏃犵嚎缃戠粶</div>
-          <div class="btns">
-            <div class="cancel">鍒犻櫎</div>
-            <div class="ok">鏂紑杩炴帴</div>
-          </div>
-
           <div class="general-box">
-            <div class="in-title">閫氱敤</div>
+            <!-- <div class="in-title">閫氱敤</div> -->
 
-            <el-form
-              :model="wifiForm"
-              ref="wifiForm"
-              class="join-form"
-            >
+            <el-form :model="selectedWifi" ref="wifiForm" class="join-form">
               <el-form-item prop="name">
                 <div class="p-title">鍚嶇О</div>
                 <!-- <div class="wifi-name">{{ 12123 }}</div> -->
-                <el-input
-                  v-model="wifiForm.name"
-                  placeholder=""
-                  size="small"
-                ></el-input>
+                <el-input v-model="selectedWifi.essid" placeholder="" size="small"></el-input>
               </el-form-item>
 
               <el-form-item prop="password">
                 <div class="p-title">瀵嗙爜</div>
+                <el-input value="******" v-if="selectedWifi.connected"></el-input>
                 <el-input
-                  v-model="wifiForm.password"
+                  v-model="selectedWifi.password"
                   placeholder="璇疯緭鍏ュ瘑鐮�"
                   size="small"
                   show-password
+                  v-else
                 ></el-input>
               </el-form-item>
             </el-form>
           </div>
 
-          <switchBar
-            :barName="`楂樼骇璁剧疆`"
-            :value="isHighClass"
-          ></switchBar>
+          <!-- <switchBar :barName="`楂樼骇璁剧疆`" :value="isHighClass"></switchBar>
 
-          <div class="general-box fold" :class="{'hidden':IPV4_hid}" >
-            <div class="in-title">IPV4 
-              <span class="icon iconfont icon-fold"
-               @click="toggleFold('IPV4_hid')">&#xe757;</span>
+          <div class="general-box fold" :class="{ hidden: IPV4_hid }">
+            <div class="in-title">
+              IPV4
+              <span class="icon iconfont icon-fold" @click="toggleFold('IPV4_hid')">&#xe757;</span>
             </div>
 
             <el-form :model="ipv4Form" :rules="ipv4FormRules" ref="ipv4Form">
               <el-form-item>
                 <div class="p-title">鏂规硶</div>
-                <el-select v-model="value" placeholder="璇烽�夋嫨" size="small">
+                <el-select v-model="value" placeholder="璇烽�夋嫨" size="small" :popper-append-to-body="false">
                   <el-option
                     v-for="item in options"
                     :key="item.value"
@@ -141,138 +105,43 @@
               </el-form-item>
               <el-form-item prop="ip">
                 <div class="p-title">IP</div>
-                <ip-input
-                  :ip="ipv4Form.ip"
-                  @on-blur="ipv4Form.ip = arguments[0]"
-                ></ip-input>
+                <ip-input :ip="ipv4Form.ip" @on-blur="ipv4Form.ip = arguments[0]"></ip-input>
               </el-form-item>
               <el-form-item prop="subMask">
                 <div class="p-title">瀛愮綉鎺╃爜</div>
-                <ip-input
-                  :ip="ipv4Form.subMask"
-                  @on-blur="ipv4Form.subMask = arguments[0]"
-                ></ip-input>
+                <ip-input :ip="ipv4Form.subMask" @on-blur="ipv4Form.subMask = arguments[0]"></ip-input>
               </el-form-item>
 
               <el-form-item prop="gateway">
                 <div class="p-title">缃戝叧</div>
-                <ip-input
-                  :ip="ipv4Form.gateway"
-                  @on-blur="ipv4Form.gateway = arguments[0]"
-                ></ip-input>
+                <ip-input :ip="ipv4Form.gateway" @on-blur="ipv4Form.gateway = arguments[0]"></ip-input>
               </el-form-item>
               <el-form-item prop="dns">
                 <div class="p-title">棣栭�塂NS</div>
-                <ip-input
-                  :ip="ipv4Form.dns1"
-                  @on-blur="ipv4Form.dns1 = arguments[0]"
-                ></ip-input>
+                <ip-input :ip="ipv4Form.dns1" @on-blur="ipv4Form.dns1 = arguments[0]"></ip-input>
               </el-form-item>
               <el-form-item prop="dns">
                 <div class="p-title">澶囩敤DNS</div>
-                <ip-input
-                  :ip="ipv4Form.dns2"
-                  @on-blur="ipv4Form.dns2 = arguments[0]"
-                ></ip-input>
+                <ip-input :ip="ipv4Form.dns2" @on-blur="ipv4Form.dns2 = arguments[0]"></ip-input>
               </el-form-item>
             </el-form>
-          </div>
-
-          <div class="general-box fold" :class="{'hidden':IPV6_hid}" ref="ipv6Holder">
-            <div class="in-title">IPV6 
-              <span class="icon iconfont icon-fold"
-              @click="toggleFold('IPV6_hid')">&#xe757;</span>
-            </div>
-
-            <el-form :model="ipv6Form" :rules="ipv6FormRules" ref="ipv6Form">
-              <el-form-item>
-                <div class="p-title">鏂规硶</div>
-                <el-select v-model="value" placeholder="璇烽�夋嫨" size="small">
-                  <el-option
-                    v-for="item in options"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-              <el-form-item prop="ip">
-                <div class="p-title">IP</div>
-                <ip-input
-                  :ip="ipv6Form.ip"
-                  @on-blur="ipv6Form.ip = arguments[0]"
-                ></ip-input>
-              </el-form-item>
-              <el-form-item prop="subMask">
-                <div class="p-title">鍓嶇紑</div>
-                <div style="display: flex; width: 100%">
-                  <el-input
-                    v-model="wifiForm.password"
-                    placeholder
-                    size="small"
-                  ></el-input>
-
-                  <div class="ad">
-                    <i class="el-icon-remove-outline"></i>
-                  </div>
-                  <div class="ad">
-                    <i class="el-icon-circle-plus-outline"></i>
-                  </div>
-                  <div class="ad"><i class="el-icon-refresh-left"></i></div>
-                </div>
-              </el-form-item>
-
-              <el-form-item prop="gateway">
-                <div class="p-title">缃戝叧</div>
-                <ip-input
-                  :ip="ipv6Form.gateway"
-                  @on-blur="ipv6Form.gateway = arguments[0]"
-                ></ip-input>
-              </el-form-item>
-              <el-form-item prop="dns">
-                <div class="p-title">棣栭�塂NS</div>
-                <ip-input
-                  :ip="ipv6Form.dns1"
-                  @on-blur="ipv6Form.dns1 = arguments[0]"
-                ></ip-input>
-              </el-form-item>
-              <el-form-item prop="dns">
-                <div class="p-title">澶囩敤DNS</div>
-                <ip-input
-                  :ip="ipv6Form.dns2"
-                  @on-blur="ipv6Form.dns2 = arguments[0]"
-                ></ip-input>
-              </el-form-item>
-            </el-form>
-          </div>
+          </div> -->
 
           <div class="btns">
             <div class="cancel" @click="inWifiDetail = false">鍙栨秷</div>
-            <div class="ok">淇濆瓨</div>
+            <div class="ok" v-if="selectedWifi.connected" @click="disconectedWifi">鏂紑杩炴帴</div>
+            <div class="ok" v-else @click="saveWifi">淇濆瓨</div>
           </div>
         </div>
 
         <div class="wire" v-if="activePage == 2 && !inWireDetail">
           <div class="title">鏈夌嚎缃戠粶</div>
-          <div
-            class="wire-bar"
-            v-for="(item, i) in wireArr"
-            :key="i"
-            @click.self="checkWire(item)"
-          >
+          <div class="wire-bar" v-for="(item, i) in wireArr" :key="i" @click.self="checkWire(item)">
             <div class="name">{{ "缃戠粶" + item.index }}</div>
 
             <div class="right">
-              <span
-                class="icon iconfont good"
-                v-if="item.lower_up && item.active"
-                >&#xe6f1;</span
-              >
-              <span
-                class="icon iconfont bad"
-                v-if="!item.lower_up && item.active"
-                >&#xe6e6;</span
-              >
+              <span class="icon iconfont good" v-if="item.lower_up && item.active">&#xe6f1;</span>
+              <span class="icon iconfont bad" v-if="!item.lower_up && item.active">&#xe6e6;</span>
               <el-switch
                 v-model="item.active"
                 active-color="#4E94FF"
@@ -285,42 +154,30 @@
         <div class="wire-detail" v-if="activePage == 2 && inWireDetail">
           <div class="title">缃戠粶璁剧疆</div>
           <el-form :model="wireForm" :rules="wireFormRules" ref="wireForm">
-            <el-form-item  prop="name">
-                <div class="p-title">缃戠粶鍚嶇О</div>
+            <el-form-item prop="name">
+              <div class="p-title">缃戠粶鍚嶇О</div>
               <div class="wifi-name">{{ "缃戠粶" + activeWireItem.index }}</div>
             </el-form-item>
-            <el-form-item  prop="ifname">
-                <div class="p-title">缃戝崱</div>
+            <el-form-item prop="ifname">
+              <div class="p-title">缃戝崱</div>
               <div class="wifi-name">{{ activeWireItem.name }}</div>
             </el-form-item>
-            <el-form-item  prop="ip">
-                <div class="p-title">IP</div>
-              <ip-input
-                :ip="wireForm.ip"
-                @on-blur="wireForm.ip = arguments[0]"
-              ></ip-input>
+            <el-form-item prop="ip">
+              <div class="p-title">IP</div>
+              <ip-input :ip="wireForm.ip" @on-blur="wireForm.ip = arguments[0]"></ip-input>
             </el-form-item>
             <el-form-item prop="subMask">
-                <div class="p-title">瀛愮綉鎺╃爜</div>
-              <ip-input
-                :ip="wireForm.subMask"
-                @on-blur="wireForm.subMask = arguments[0]"
-              ></ip-input>
+              <div class="p-title">瀛愮綉鎺╃爜</div>
+              <ip-input :ip="wireForm.subMask" @on-blur="wireForm.subMask = arguments[0]"></ip-input>
             </el-form-item>
 
-            <el-form-item  prop="gateway">
-                <div class="p-title">缃戝叧</div>
-              <ip-input
-                :ip="wireForm.gateway"
-                @on-blur="wireForm.gateway = arguments[0]"
-              ></ip-input>
+            <el-form-item prop="gateway">
+              <div class="p-title">缃戝叧</div>
+              <ip-input :ip="wireForm.gateway" @on-blur="wireForm.gateway = arguments[0]"></ip-input>
             </el-form-item>
-            <el-form-item  prop="dns">
-                <div class="p-title">DNS</div>
-              <ip-input
-                :ip="wireForm.dns"
-                @on-blur="wireForm.dns = arguments[0]"
-              ></ip-input>
+            <el-form-item prop="dns">
+              <div class="p-title">DNS</div>
+              <ip-input :ip="wireForm.dns" @on-blur="wireForm.dns = arguments[0]"></ip-input>
             </el-form-item>
           </el-form>
 
@@ -329,6 +186,9 @@
             <div class="ok" @click="saveWire">淇濆瓨</div>
           </div>
         </div>
+        <WifiGateway v-if="activePage == 3"></WifiGateway>
+        <LoraGateway v-if="activePage == 4"></LoraGateway>
+        <MqttGateway v-if="activePage == 5"></MqttGateway>
       </div>
     </div>
   </div>
@@ -343,60 +203,110 @@
   getDevInfo,
   downNetCard,
   upNetCard,
-} from "@/api/system";
+  getWifiList,
+  connectWifi
+} from "@/api/system"
 
-import ipInput from "../components/IPInput";
-import switchBar from "../components/switchBar";
+import ipInput from "../components/IPInput"
+import switchBar from "../components/switchBar"
+
+import WifiGateway from "../components/WifiGateway"
+import LoraGateway from "../components/LoraGateway"
+import MqttGateway from "../components/MqttGateway"
+
+import { isIPv4 } from "@/scripts/validate"
 
 export default {
   components: {
     ipInput,
     switchBar,
+    WifiGateway,
+    LoraGateway,
+    MqttGateway
+  },
+  filters: {
+    escape(val) {
+      return unescape(val)
+    }
   },
   data() {
     const checkPwd = (rule, value, callback) => {
       if (!value) {
-        return callback(new Error("瀵嗙爜涓嶈兘涓虹┖"));
+        return callback(new Error("瀵嗙爜涓嶈兘涓虹┖"))
       }
       setTimeout(() => {
         if (value.length != 6) {
-          callback(new Error("瀵嗙爜搴斾负6浣�!"));
+          callback(new Error("瀵嗙爜搴斾负6浣�!"))
         } else {
-          callback();
+          callback()
         }
-      }, 1000);
-    };
+      }, 1000)
+    }
     return {
       isHighClass: false,
       ruleForm: {
         deviceName: "",
-        port: "",
+        port: ""
       },
       wifiForm: {
         name: "",
-        password: "",
+        password: ""
       },
       wireArr: [],
       inWifiDetail: false,
-      wifiList: [
-        { name: "鏃犵嚎缃戠粶1", isConnected: false },
-        { name: "鏃犵嚎缃戠粶2", isConnected: true },
-      ],
+      selectedWifi: {},
+      wifiList: [],
+      wifiScanning: false,
       isOpenWifi: false,
+      wifiIfname: "",
       inWireDetail: false,
       wireForm: {
         dns: "",
         subMask: "",
         gateway: "",
-        ip: "",
+        ip: ""
       },
-      wireFormRules: {},
+      originalConfig: {},
+      wireFormRules: {
+        ip: [
+          {
+            required: true,
+            message: "璇疯緭鍏P鍦板潃",
+            trigger: "change"
+          },
+          { validator: isIPv4, trigger: "change" }
+        ],
+
+        gateway: [
+          {
+            required: true,
+            message: "璇疯緭鍏ョ綉鍏�",
+            trigger: "change"
+          },
+          { validator: isIPv4, trigger: "change" }
+        ],
+        dns: [
+          {
+            required: true,
+            message: "璇疯緭鍏ns鍦板潃",
+            trigger: "change"
+          },
+          { validator: isIPv4, trigger: "change" }
+        ],
+
+        subMask: [
+          {
+            required: true,
+            message: "璇疯緭鍏ュ瓙缃戞帺鐮�",
+            trigger: "change"
+          },
+          { validator: isIPv4, trigger: "change" }
+        ]
+      },
       activePage: 0,
       activeWireItem: {},
       rules: {
-        deviceName: [
-          { required: true, message: "璇疯緭鍏ヨ澶囧悕绉�", trigger: "change" },
-        ],
+        deviceName: [{ required: true, message: "璇疯緭鍏ヨ澶囧悕绉�", trigger: "change" }]
       },
       ipv4Form: {},
       ipv6Form: {},
@@ -405,200 +315,337 @@
         { name: "缃戠粶璁剧疆", icon: "\ue6dd" },
         { name: "鏃犵嚎缃戠粶", icon: "\uea13" },
         { name: "鏈夌嚎缃戠粶", icon: "\ue73b" },
+        { name: "WiFi缃戝叧", icon: "\ue73b" },
+        { name: "LORA缃戝叧", icon: "\ue73b" },
+        { name: "MQTT缃戝叧", icon: "\ue73b" }
       ],
       ipv6FormRules: {},
       options: [
         {
           value: "閫夐」1",
-          label: "鑷姩",
+          label: "鑷姩"
         },
         {
           value: "閫夐」2",
-          label: "鎵嬪姩",
-        },
+          label: "鎵嬪姩"
+        }
       ],
       value: "",
-      IPV4_hid: false,
-      IPV6_hid: false
-    };
-  },
-  components: {
-    ipInput,
-    switchBar,
+      IPV4_hid: true,
+      IPV6_hid: false,
+      configLoading: false
+    }
   },
   mounted() {
-    this.getCurServer();
-    this.fetchWireList();
+    this.getCurServer()
+    this.fetchWireList()
   },
   methods: {
+    wirelessScan() {
+      this.wifiList = []
+      this.wifiScanning = true
+      getWifiList({ ifname: this.wifiIfname })
+        .then((rsp) => {
+          if (rsp && rsp.success) {
+            this.wifiList = rsp.data.filter((e) => {
+              return e.essid != ""
+            })
+          }
+
+          this.wifiScanning = false
+        })
+        .catch(() => {
+          this.wifiScanning = false
+        })
+    },
+    minusPrefix() {
+      this.ipv6Form.prefix
+    },
     switchNetCard(item) {
       if (item.active) {
         upNetCard({ ifname: item.name }).then(
           (res) => {
             if (res.success) {
-              this.$message.success(res.data);
-              this.fetchWireList();
+              this.$message.success(res.data)
+              this.fetchWireList()
             }
           },
           (err) => {
-            item.active = false;
-            this.$message.error(err.msg);
+            item.active = false
+            this.$message.error(err.msg)
           }
-        );
+        )
       } else {
         downNetCard({ ifname: item.name }).then(
           (res) => {
             if (res.success) {
-              this.$message.success(res.data);
-              this.fetchWireList();
+              this.$message.success(res.data)
+              this.fetchWireList()
             }
           },
           (err) => {
-            item.active = true;
-            this.$message.error(err.msg);
+            item.active = true
+            this.$message.error(err.msg)
           }
-        );
+        )
       }
     },
     getCurServer() {
       getDevInfo().then((res) => {
-        this.ruleForm.deviceName = res.data.server_name;
-        this.ruleForm.port = res.data.server_port;
-      });
+        this.ruleForm.deviceName = res.data.server_name
+        this.ruleForm.port = res.data.server_port
+      })
     },
     fetchWireList() {
       getWireList().then((res) => {
         if (res && res.success) {
-          this.wireArr = res.data;
+          this.wireArr = res.data
+
+          // 杩囨护缃戠粶鎺ュ彛鐘舵��
           this.wireArr.forEach((x) => {
-            let t = x.flags.split("|")[0] == "up";
-            this.$set(x, "active", t);
-          });
+            let t = x.flags.split("|")[0] == "up"
+            this.$set(x, "active", t)
+
+            if (x.wireless) {
+              this.wifiIfname = x.name
+            }
+          })
+
+          // 杩囨护鎺墂ifi鎺ュ彛
+          this.wireArr = res.data.filter((e) => {
+            return !e.wireless
+          })
         }
-      });
+      })
     },
     cancelSaveWire() {
-      this.inWireDetail = false;
-      this.wireForm.ip = "";
-      this.wireForm.gateway = "";
-      this.wireForm.dns = "";
-      this.wireForm.subMask = "";
+      this.inWireDetail = false
+      this.wireForm.ip = ""
+      this.wireForm.gateway = ""
+      this.wireForm.dns = ""
+      this.wireForm.subMask = ""
+      this.originalConfig = this.wireForm
     },
     saveServerName() {
       setServerName({
         server_name: this.ruleForm.deviceName,
-        server_port: this.ruleForm.port,
+        server_port: this.ruleForm.port
       }).then((res) => {
         if (res && res.success) {
-          this.$message.success(res.data);
+          this.$message.success(res.data)
         }
-      });
+      })
     },
     openRight(i) {
       if (i == 0) {
-        this.ruleForm.deviceName = "";
-        this.ruleForm.port = "";
+        this.ruleForm.deviceName = ""
+        this.ruleForm.port = ""
         this.getCurServer()
-      }      
-      if (i == 1) {
-        this.inWifiDetail = false;
       }
-      this.activePage = i;
+      if (i == 1) {
+        this.inWifiDetail = false
+        this.wirelessScan()
+      }
+      this.activePage = i
     },
     saveWire(ifname) {
-      let data = {
-        ip: this.wireForm.ip,
-        gateway: this.wireForm.gateway,
-        dns: this.wireForm.dns,
-        subMask: this.wireForm.subMask,
-        ifname: this.activeWireItem.name,
-      };
-      setNetWorkCard(data).then(
-        (res) => {
-          if (res && res.success) {
-            this.$message.success(res.data);
+      this.$refs["wireForm"].validate((valid) => {
+        if (valid) {
+          let data = {
+            ip: this.wireForm.ip,
+            gateway: this.wireForm.gateway,
+            dns: this.wireForm.dns,
+            subMask: this.wireForm.subMask,
+            ifname: this.activeWireItem.name
           }
-        },
-        (err) => {
-          this.$message.error("淇濆瓨澶辫触锛�" + err.msg);
+
+          let newUri = location.protocol + "//" + data.ip + (location.port == 80 ? "" : ":" + location.port)
+
+          this.$confirm("纭闇�瑕佷慨鏀规湇鍔″櫒閰嶇疆鍚楋紵", {
+            center: true,
+            cancelButtonClass: "comfirm-class-cancle",
+            confirmButtonClass: "comfirm-class-sure"
+          })
+            .then(() => {
+              this.configLoading = true
+              if (this.wireForm.ip !== this.originalConfig.ip) {
+                this.configLoading = false
+                console.log("set time out")
+                var changeIPTimer = setTimeout(() => {
+                  this.$alert(
+                    '<strong>鎮ㄥ凡淇敼浜嗘湇鍔″櫒ip, 璇烽噸鏂扮櫥褰�</strong><a target="_parent" href="' +
+                      newUri +
+                      '"> ' +
+                      newUri +
+                      "<a/>",
+                    "鎻愮ず",
+                    {
+                      dangerouslyUseHTMLString: true,
+                      customClass: "noticeBox"
+                    }
+                  )
+                }, 10000)
+              }
+
+              setNetWorkCard(data)
+                .then((rsp) => {
+                  this.configLoading = false
+                  if (rsp && rsp.success) {
+                    this.$notify({
+                      type: "success",
+                      message: "鏈嶅姟鍣ㄩ厤缃垚鍔�"
+                    })
+                  }
+                })
+                .catch((err) => {})
+              this.$message({
+                message: "鎿嶄綔瀹屾垚,璇风◢鍚�",
+                type: "success"
+              })
+            })
+            .catch((err) => {})
+        } else {
+          return false
         }
-      );
+      })
     },
     wifiControl(val) {},
-    checkWifi() {
-      this.inWifiDetail = true;
+    checkWifi(item) {
+      this.inWifiDetail = true
+      this.selectedWifi = item
     },
     openWireDetail(item) {
-      this.inWireDetail = true;
-      this.activeWireItem = item;
+      this.inWireDetail = true
+      this.activeWireItem = item
       getNetWorkCardInfo({
-        ifname: item.name,
+        ifname: item.name
       }).then(
         (res) => {
           if (res && res.success) {
-            this.wireForm.ip = res.data.ip;
-            this.wireForm.gateway = res.data.gateway;
-            this.wireForm.dns = res.data.dns;
-            this.wireForm.subMask = res.data.subMask;
+            this.wireForm.ip = res.data.ip
+            this.wireForm.gateway = res.data.gateway
+            this.wireForm.dns = res.data.dns
+            this.wireForm.subMask = res.data.subMask
+            this.originalConfig = JSON.parse(JSON.stringify(this.wireForm))
           }
         },
         (err) => {
-          this.$message.error("鏌ユ壘涓嶅埌鏁版嵁: " + err.msg);
+          this.$message.error("鏌ユ壘涓嶅埌鏁版嵁: " + err.msg)
         }
-      );
+      )
     },
     checkWire(item) {
       if (item.addrs) {
-        this.openWireDetail(item);
-        return;
+        this.openWireDetail(item)
+        return
       }
       this.$confirm("鎮ㄨ繕鏈厤缃綉缁滀俊鎭紝鏄惁鐜板湪閰嶇疆锛�", "鎻愮ず", {
         confirmButtonText: "纭畾",
         cancelButtonText: "鍙栨秷",
         type: "warning",
+        customClass: "confirmBox"
       }).then(() => {
-        this.openWireDetail(item);
-      });
+        this.openWireDetail(item)
+      })
     },
     toggleFold(tog) {
-    const demo = this.$refs.ipvHolder
-    if(!(this.IPV4_hid&&!this.IPV6_hid)){
-       setTimeout(() => {
-       demo.scrollIntoView({block: "end", inline: "nearest",behavior: 'smooth'})
-       }, 300);
+      const demo = this.$refs.ipvHolder
+      if (!(this.IPV4_hid && !this.IPV6_hid)) {
+        setTimeout(() => {
+          demo.scrollIntoView({
+            block: "end",
+            inline: "nearest",
+            behavior: "smooth"
+          })
+        }, 300)
+      }
+      this[tog] = !this[tog]
+    },
+    disconectedWifi() {
+      let param = {
+        ifname: this.wifiIfname,
+        ssid: "del",
+        passwd: ""
+      }
+
+      this.configLoading = true
+      connectWifi(param)
+        .then((rsp) => {
+          if (rsp && rsp.success) {
+            this.$message.success("閰嶇疆鎴愬姛")
+          } else {
+            this.$message.error("閰嶇疆澶辫触")
+          }
+
+          this.configLoading = false
+          this.wirelessScan()
+        })
+        .catch(() => {
+          this.configLoading = false
+        })
+    },
+    saveWifi() {
+      let param = {
+        ifname: this.wifiIfname,
+        ssid: this.selectedWifi.essid,
+        passwd: this.selectedWifi.password
+      }
+
+      if (this.selectedWifi.password.length < 8) {
+        this.$message.warning("瀵嗙爜涓嶈兘灏戜簬8浣�")
+        return
+      }
+
+      this.configLoading = true
+      connectWifi(param)
+        .then((rsp) => {
+          if (rsp && rsp.success) {
+            this.$message.success("閰嶇疆鎴愬姛")
+          } else {
+            this.$message.error("閰嶇疆澶辫触")
+          }
+
+          this.configLoading = false
+          this.wirelessScan()
+        })
+        .catch(() => {
+          this.configLoading = false
+        })
     }
-    this[tog] = !this[tog]
-     
-     
-     }
   },
   computed: {
     showStatus() {
-      return this.wireArr.some((item) => item.lower_up == true);
-    },
-  },
-};
+      return this.wireArr.some((item) => item.lower_up == true)
+    }
+  }
+}
 </script>
 <style lang="scss">
 .all {
   width: 100%;
 }
+.wire {
+  //  width: 456px;
+  margin: 0 auto;
+}
 .wire-detail {
+  //  width: 456px;
+  margin: 0 auto;
   .title {
     font-size: 16px;
     margin-bottom: 10px;
   }
   .ip-input-container {
-          max-width: none !important;
-          height: 32px;
-          line-height: normal;
-          box-sizing: border-box;
-          // background-color: #f2f2f7;
-          text-align: left;
-          border-radius: 20px;
-          border: 2px solid transparent;    display: flex;
-
-        }
+    max-width: none !important;
+    height: 32px;
+    line-height: normal;
+    box-sizing: border-box;
+    // background-color: #f2f2f7;
+    text-align: left;
+    border-radius: 20px;
+    border: 2px solid transparent;
+    display: flex;
+  }
   .btns {
     display: flex;
     justify-content: space-between;
@@ -620,7 +667,7 @@
   }
 }
 .net-set {
-  max-width: 600px;
+  // max-width: 456px;
   margin: 0 auto;
   .title {
     font-size: 16px;
@@ -653,10 +700,11 @@
     box-sizing: border-box;
     flex-shrink: 0;
     padding: 10px;
+    padding-top: 6px;
     border-right: 4px solid #f2f2f7;
     border-left: 4px solid #f2f2f7;
+    border-top: 4px solid #f2f2f7;
     .menu-item {
-      background: #f2f2f7;
       height: 56px;
       margin-bottom: 4px;
       border-radius: 8px;
@@ -667,6 +715,11 @@
       padding: 0 20px;
       display: flex;
       justify-content: space-between;
+
+      &:hover {
+        background: #f2f2f7;
+      }
+
       .item-left {
         display: flex;
         align-items: center;
@@ -681,7 +734,7 @@
       }
     }
     .menu-item-active {
-      background-color: var(--colorCard);
+      background-color: var(--colorCard) !important;
       color: #ffffff;
     }
   }
@@ -692,25 +745,30 @@
     box-sizing: border-box;
     position: relative;
     padding: 10px;
+    padding-top: 6px;
+    border-top: 4px solid #f2f2f7;
+    overflow-y: overlay;
+    overflow-x: hidden;
+
     .title {
       height: 48px;
       font-size: 16px;
       line-height: 48px;
-      color: #333333;
+      color: #4f4f4f;
       font-weight: bold;
+      background: #f2f2f7;
+      border-radius: 8px;
+      margin-bottom: 4px;
     }
-    .el-form-item.is-required:not(.is-no-asterisk)
-      > .el-form-item__label:before,
-    .el-form-item.is-required:not(.is-no-asterisk)
-      .el-form-item__label-wrap
-      > .el-form-item__label:before {
+    .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label:before,
+    .el-form-item.is-required:not(.is-no-asterisk) .el-form-item__label-wrap > .el-form-item__label:before {
       display: none;
     }
     .el-select {
       width: 100%;
     }
     .el-form-item {
-      margin-bottom: 16px;
+      margin-bottom: 14px;
     }
     .el-form-item__content {
       line-height: 48px;
@@ -724,7 +782,7 @@
         border: 2px solid #409eff !important;
       }
       .el-select-dropdown__item {
-        color: #333333;
+        color: #4f4f4f;
         height: 32px;
         font-size: 12px;
         line-height: 32px;
@@ -758,11 +816,10 @@
         background-color: #ffffff;
         border: 2px solid transparent;
         border-radius: 20px;
-        height: 32px;
+        height: 32px !important;
         padding: 0 15px;
         font-size: 14px;
         line-height: 32px;
-
         font-weight: bold;
       }
       .el-input__inner::placeholder {
@@ -774,7 +831,7 @@
         width: 100%;
       }
       .el-select .el-input .el-select__caret {
-        color: #333333;
+        color: #4f4f4f;
         font-size: 14px;
         font-weight: 600;
       }
@@ -783,7 +840,7 @@
       max-width: none !important;
     }
     .wifi-set {
-      max-width: 600px;
+      //   max-width: 456px;
       margin: 0 auto;
       .switch-bar {
         background: #f2f2f7;
@@ -791,7 +848,7 @@
       }
       .switch-bar .name {
         font-size: 14px;
-        color: #333;
+        color: #4f4f4f;
         font-weight: bold;
       }
       .wifi-option {
@@ -802,12 +859,13 @@
         align-items: center;
         box-sizing: border-box;
         padding: 0 20px;
-        margin-bottom: 10px;
+        margin-bottom: 4px;
         background: #f2f2f7;
         border-radius: 8px;
+        cursor: pointer;
         .name {
           font-size: 14px;
-          color: #333;
+          color: #4f4f4f;
           font-weight: bold;
           .icon {
             color: #4e94ff;
@@ -834,7 +892,7 @@
       }
     }
     .wifi-detail {
-      max-width: 600px;
+      //  max-width: 454px;
       margin: 0 auto;
       transition: all 0.3s linear 0s;
       .general-box {
@@ -845,20 +903,25 @@
         padding-bottom: 10px;
         margin-bottom: 20px;
         &.fold {
-        height: 342px;
+          height: 342px;
+
+          .in-title {
+            display: flex;
+            justify-content: space-between;
+          }
+
           .icon-fold {
             display: inline-block;
             font-size: 14px;
-            margin-left: 360px;
             transition: all 0.3s linear 0s;
             cursor: pointer;
           }
         }
         &.hidden {
-        height: 34px;
-         .icon-fold {
-           transform: rotate(180deg);
-         }
+          height: 34px;
+          .icon-fold {
+            transform: rotate(180deg);
+          }
         }
         .el-form-item {
           margin-bottom: 0px;
@@ -868,7 +931,7 @@
           padding: 14px 20px;
           font-weight: bold;
           font-size: 14px;
-          color: #333333;
+          color: #4f4f4f;
         }
         .ip-input-container {
           max-width: none !important;
@@ -893,21 +956,12 @@
         margin-top: 0;
         display: flex;
         justify-content: space-between;
-        margin-bottom: 20px;
-        .left {
-          background-color: rgba(240, 240, 240, 1);
-          height: 40px;
-          line-height: 40px;
-          width: 48%;
-          border-radius: 10px;
+        margin-bottom: 4px;
+        .cancel {
+          width: 218px;
         }
-        .right {
-          background-color: rgba(61, 104, 225, 1);
-          height: 40px;
-          line-height: 40px;
-          width: 48%;
-          color: #fff;
-          border-radius: 10px;
+        .ok {
+          width: 218px;
         }
       }
       .wifi-name {
@@ -920,15 +974,9 @@
         line-height: 48px;
       }
       .ad {
-        margin-top: 10px;
         height: 32px;
-        /* margin: 4px 0px 4px 5px; */
-        /* border-radius: 5px; */
-        line-height: 31px;
-        /* width: 27px; */
         text-align: center;
         font-size: 17px;
-        /* font-weight: bold; */
         margin-left: 10px;
         cursor: pointer;
       }
@@ -943,13 +991,13 @@
         align-items: center;
         box-sizing: border-box;
         padding: 0 20px;
-        margin-bottom: 10px;
+        margin-bottom: 4px;
         border-radius: 8px;
         .name {
           font-size: 15px;
           font-weight: bold;
           font-size: 14px;
-          color: #333333;
+          color: #4f4f4f;
         }
         .right {
           display: flex;
@@ -960,6 +1008,11 @@
           .el-switch.is-checked .el-switch__core::after {
             left: 100%;
             margin-left: -12px;
+          }
+
+          .el-switch.is-checked .el-switch__core {
+            background-color: var(--colorCard) !important;
+            border-color: var(--colorCard) !important;
           }
 
           .el-switch__core:after {
@@ -978,7 +1031,7 @@
             margin-right: 15px;
           }
           .good {
-            color: #4e94ff;
+            color: var(--colorCard);
             font-size: 16px;
           }
           .bad {
@@ -997,4 +1050,19 @@
     }
   }
 }
+.noticeBox p {
+  text-align: center;
+}
+
+.confirmBox {
+  text-align: center;
+
+  p {
+    text-align: center;
+  }
+
+  .el-message-box__status.el-icon-warning {
+    margin-left: 75px;
+  }
+}
 </style>

--
Gitblit v1.8.0