DESKTOP-SVI9JE1\muzen 1 vuosi sitten
vanhempi
commit
d79dedc26b

+ 9 - 0
src/api/store/devices.js

@@ -52,4 +52,13 @@ export function remove(data) {
     method: 'delete',
     method: 'delete',
     data
     data
   })
   })
+}
+
+// wifi配网
+export function wifi(data) {
+  return request({
+    url: `/store/device/sendWifiInfo`,
+    method: 'post',
+    data
+  })
 }
 }

+ 15 - 0
src/router/index.js

@@ -158,6 +158,7 @@ export const dynamicRoutes = [
       },
       },
     ],
     ],
   },
   },
+  // 内容设定
   {
   {
     path: "/content",
     path: "/content",
     component: Layout,
     component: Layout,
@@ -170,6 +171,7 @@ export const dynamicRoutes = [
       meta: { title: '设定详情', activeMenu: "/content/setting"}
       meta: { title: '设定详情', activeMenu: "/content/setting"}
     }]
     }]
   },
   },
+  // 场景预设
   {
   {
     path: "/content",
     path: "/content",
     component: Layout,
     component: Layout,
@@ -181,6 +183,19 @@ export const dynamicRoutes = [
       name: "sceneDetail",
       name: "sceneDetail",
       meta: { title: '预设详情', activeMenu: "/content/scene" }
       meta: { title: '预设详情', activeMenu: "/content/scene" }
     }]
     }]
+  },
+  // 门店设备
+  {
+    path: '/store',
+    component: Layout,
+    hidden: true,
+    permissions: ["store:devices:list"],
+    children: [{
+      path: "devices/detail",
+      component: () => import("@/views/store/devices/detail"),
+      name: "deviceDetail",
+      meta: { title: 'WIFI配网', activeMenu: "/store/devices"}
+    }]
   }
   }
 ];
 ];
 
 

+ 70 - 0
src/views/store/devices/detail.vue

@@ -0,0 +1,70 @@
+<template>
+  <div class='app-container'>
+    <el-row>
+      <el-col :xs="24" :sm="10" :md="8" :lg="8" :xl="6">
+        <el-form label-width="100px" :model="data.form" ref="form" :rules="data.rules">
+          <el-form-item label="wifi名称:" prop="wifiName">
+            <el-input v-model="data.form.wifiName" placeholder="请输入wifi名称" />
+          </el-form-item>
+          <el-form-item label="wifi密码:" prop="wifiPwd">
+            <el-input v-model="data.form.wifiPwd" placeholder="请输入wifi密码" />
+          </el-form-item>
+          <el-form-item label="设备ID:" prop="deviceMac">
+            <el-input v-model="data.form.deviceMac" placeholder="请输入设备ID" />
+          </el-form-item>
+          <el-form-item label="设备型号:" prop="clientType">
+            <el-input v-model="data.form.clientType" placeholder="请输入设备型号" />
+          </el-form-item>
+        </el-form>
+        <div :class="[$route.query.deviceMac ? '' : 'form-btn']">
+          <el-button :style="{ width: $route.query.deviceMac ? '100%' : '' }" type="primary" @click="getSubmit">确定</el-button>
+        </div>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup>
+import { wifi } from '@/api/store/devices'
+
+const { proxy } = getCurrentInstance()
+
+const data = reactive({
+  // 表单
+  form: {},
+  // 
+  rules: {
+    wifiName: [{
+      required: true, message: '请输入wifi名称', trigger: 'bulr'
+    }],
+    wifiPwd: [{
+      required: true, message: '请输入wifi密码', trigger: 'bulr'
+    }],
+    deviceMac: [{
+      required: true, message: '请输入设备ID', trigger: 'bulr'
+    }],
+    clientType: [{
+      required: true, message: '请输入设备型号', trigger: 'bulr'
+    }]
+  }
+})
+
+const getDetail = () => {
+  data.form = proxy.$route.query
+}
+getDetail()
+
+const getSubmit = () => {
+  proxy.$refs.form.validate((vaild) => {
+    if (vaild) {
+      wifi(data.form).then(res => {
+        if (res.code === 0) {
+          proxy.$modal.msgSuccess('配网成功!')
+        }
+      })
+    } else {
+      return false
+    }
+  })
+}
+</script>

+ 7 - 0
src/views/store/devices/index.vue

@@ -23,6 +23,7 @@
         <el-button type="primary" icon="Search" @click="getSearch">搜索</el-button>
         <el-button type="primary" icon="Search" @click="getSearch">搜索</el-button>
         <el-button icon="Refresh" @click="getRefresh">重置</el-button>
         <el-button icon="Refresh" @click="getRefresh">重置</el-button>
         <el-button type="primary" plain icon="Plus" @click="getDialog()">关联设备</el-button>
         <el-button type="primary" plain icon="Plus" @click="getDialog()">关联设备</el-button>
+        <el-button icon="Link" @click="getRouter">WIFI配网</el-button>
       </el-form-item>
       </el-form-item>
       <el-form-item style="float: right">
       <el-form-item style="float: right">
         <el-button icon="Expand" @click="grid = false" />
         <el-button icon="Expand" @click="grid = false" />
@@ -273,6 +274,12 @@ const getDelete = (row) => {
   })
   })
 }
 }
 
 
+// wifi配网
+const getRouter = () => {
+  proxy.$router.push({
+    path: `/store/devices/detail`
+  })
+}
 
 
 // 监听
 // 监听
 watch(() => data.dialogForm.tenantId, (val) => {
 watch(() => data.dialogForm.tenantId, (val) => {