提交 9f7cf985 作者: 翁进城

修正地面站链路

上级 730345e1
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
}, },
orders, //所有指令 orders, //所有指令
callbackList: [], //ws消息callback队列 callbackList: [], //ws消息callback队列
userInfo: "", //用户名 userInfo: {}, //用户信息
}, },
mutations: { mutations: {
setWs(state, data) { setWs(state, data) {
...@@ -98,9 +98,7 @@ export default { ...@@ -98,9 +98,7 @@ export default {
type: 100, type: 100,
systemCode: "mmc", systemCode: "mmc",
state: 1, state: 1,
username: state.userInfo.username, ...userInfo,
token: state.userInfo.token,
appId: state.userInfo.appId,
}; };
ws.send(JSON.stringify(wsData)); ws.send(JSON.stringify(wsData));
resolve(); resolve();
......
...@@ -2,10 +2,20 @@ export default ` ...@@ -2,10 +2,20 @@ export default `
<template> <template>
<div> <div>
<el-form> <el-form>
<el-form-item label="账号">
<el-input v-model="account"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="password"></el-input>
</el-form-item>
<el-button @click="login">登录</el-button>
<el-form-item label="个人信息">{{ userInfo }}</el-form-item>
<el-form-item label="无人机id"> <el-form-item label="无人机id">
<el-input v-model="deviceHardId"></el-input> <el-input v-model="deviceHardId"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="操作"> <el-form-item label="操作">
<el-button @click="connect">连接地面站ws</el-button>
<el-button @click="subscribe">订阅</el-button> <el-button @click="subscribe">订阅</el-button>
<el-button @click="unsubscribe">取消订阅</el-button> <el-button @click="unsubscribe">取消订阅</el-button>
<el-button @click="publish()">通过原始type发送指令</el-button> <el-button @click="publish()">通过原始type发送指令</el-button>
...@@ -13,90 +23,127 @@ export default ` ...@@ -13,90 +23,127 @@ export default `
<el-button @click="addCallback">添加事件回调</el-button> <el-button @click="addCallback">添加事件回调</el-button>
<el-button @click="removeCallback">移除事件回调</el-button> <el-button @click="removeCallback">移除事件回调</el-button>
</el-form-item> </el-form-item>
<el-form-item label="支持的指令"> <el-form-item label="支持的指令">{{ orders }}</el-form-item>
{{ orders }}
</el-form-item>
</el-form> </el-form>
<div> <div>{{ text }}</div>
{{ text }} <div>{{ callbackText }}</div>
</div>
<div>
{{ callbackText }}
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'GroundStation', name: "GroundStation",
data(){ data() {
return { return {
deviceHardId: '', account: "juchut",
password: "dG1qMDQwNyNuZXcuMQ==",
deviceHardId: "",
userInfo: { userInfo: {
username: 'admin', username: "",
token: 'cbe85bcd114cfb00a8547c86cac5460ad7942a1ab531094cd53e55a1e67617d9', // token: "5e93559e5d00ed4dda7d75f9502ea9d83b8c15cb54672b4262dc85d0669ee53d",
appId: 87878 appId: "40003",
// 'task-id': 1448
}, },
callbackText: '' callbackText: "",
} };
}, },
computed: { computed: {
text(){ text() {
return this.$store.state.MMCGroundStation.dataSet; return this.$store.state.MMCGroundStation.dataSet;
}, },
orders(){ orders() {
return this.$store.state.MMCGroundStation.orders; return this.$store.state.MMCGroundStation.orders;
}, },
}, },
async created(){ async created() {},
try{
await this.$store.dispatch('MMCGroundStation/init', {
url: 'ws://116.62.122.225:30103',
userInfo: this.userInfo
})
}catch(e){
console.log('地面站连接失败', e)
}
console.log('地面站连接成功');
},
methods: { methods: {
subscribe(){ async login() {
this.$store.dispatch('MMCGroundStation/subscribe', this.deviceHardId) let formData = new FormData();
formData.append("userAccount", this.account);
formData.append("password", this.password);
let res1 = await fetch("/crm/account/login", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username: this.account,
password: this.password,
}),
});
let data1 = await res1.json();
if (data1.code == 200) {
this.userInfo.username = data1.data.username;
}
let res2 = await fetch("/crm/account/loginInfo", {
method: "post",
headers: {
token: data1.data.token,
"Content-Type": "application/json",
},
body: JSON.stringify({
loginInfo: {
appId: "40004",
token: data1.data.token,
},
}),
});
let data2 = await res2.json();
if (data2.code == 200) {
this.userInfo.token = data2.data.token + data2.data.flyingSessionId;
}
},
async connect() {
try {
await this.$store.dispatch("MMCGroundStation/init", {
url: "ws://121.43.58.140:30105",
userInfo: this.userInfo,
});
} catch (e) {
console.log("地面站连接失败", e);
}
console.log("地面站连接成功");
},
subscribe() {
this.$store.dispatch("MMCGroundStation/subscribe", this.deviceHardId);
}, },
unsubscribe(){ unsubscribe() {
this.$store.dispatch('MMCGroundStation/unsubscribe', this.deviceHardId) this.$store.dispatch("MMCGroundStation/unsubscribe", this.deviceHardId);
}, },
publish(){ publish() {
this.$store.dispatch('MMCGroundStation/publish', { this.$store.dispatch("MMCGroundStation/publish", {
type: 200, type: 200,
cmdFunction: 9001, cmdFunction: 9001,
data: { data: {
cmdControlType: 900, cmdControlType: 900,
}, },
deviceHardId: this.deviceHardId deviceHardId: this.deviceHardId,
}) });
}, },
order( { order } ){ order({ order }) {
this.$store.dispatch('MMCGroundStation/order', { this.$store.dispatch("MMCGroundStation/order", {
order, order,
data: { data: {
cmdControlType: 900, cmdControlType: 900,
}, },
deviceHardId: this.deviceHardId deviceHardId: this.deviceHardId,
}) });
},
callback(data) {
console.log("callback data", data);
this.callbackText += "收到事件,调试窗口查看 ";
}, },
callback(data){ addCallback() {
console.log('callback data', data) this.$store.dispatch("MMCGroundStation/addCallback", this.callback);
this.callbackText += '收到事件,调试窗口查看 ';
}, },
addCallback(){ removeCallback() {
this.$store.dispatch('MMCGroundStation/addCallback', this.callback) this.callbackText = "";
this.$store.dispatch("MMCGroundStation/removeCallback", this.callback);
}, },
removeCallback(){ },
this.callbackText = ''; };
this.$store.dispatch('MMCGroundStation/removeCallback', this.callback)
}
}
}
</script> </script>
`; `;
\ No newline at end of file
<template> <template>
<div> <div>
<el-form> <el-form>
<el-form-item label="账号">
<el-input v-model="account"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="password"></el-input>
</el-form-item>
<el-button @click="login">登录</el-button>
<el-form-item label="个人信息">{{ userInfo }}</el-form-item>
<el-form-item label="无人机id"> <el-form-item label="无人机id">
<el-input v-model="deviceHardId"></el-input> <el-input v-model="deviceHardId"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="操作"> <el-form-item label="操作">
<el-button @click="connect">连接地面站ws</el-button>
<el-button @click="subscribe">订阅</el-button> <el-button @click="subscribe">订阅</el-button>
<el-button @click="unsubscribe">取消订阅</el-button> <el-button @click="unsubscribe">取消订阅</el-button>
<el-button @click="publish()">通过原始type发送指令</el-button> <el-button @click="publish()">通过原始type发送指令</el-button>
...@@ -12,89 +22,126 @@ ...@@ -12,89 +22,126 @@
<el-button @click="addCallback">添加事件回调</el-button> <el-button @click="addCallback">添加事件回调</el-button>
<el-button @click="removeCallback">移除事件回调</el-button> <el-button @click="removeCallback">移除事件回调</el-button>
</el-form-item> </el-form-item>
<el-form-item label="支持的指令"> <el-form-item label="支持的指令">{{ orders }}</el-form-item>
{{ orders }}
</el-form-item>
</el-form> </el-form>
<div> <div>{{ text }}</div>
{{ text }} <div>{{ callbackText }}</div>
</div>
<div>
{{ callbackText }}
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'GroundStation', name: "GroundStation",
data(){ data() {
return { return {
deviceHardId: '', account: "juchut",
password: "dG1qMDQwNyNuZXcuMQ==",
deviceHardId: "",
userInfo: { userInfo: {
username: 'admin', username: "",
token: 'cbe85bcd114cfb00a8547c86cac5460ad7942a1ab531094cd53e55a1e67617d9', // token: "5e93559e5d00ed4dda7d75f9502ea9d83b8c15cb54672b4262dc85d0669ee53d",
appId: 87878 appId: "40003",
// 'task-id': 1448
}, },
callbackText: '' callbackText: "",
} };
}, },
computed: { computed: {
text(){ text() {
return this.$store.state.MMCGroundStation.dataSet; return this.$store.state.MMCGroundStation.dataSet;
}, },
orders(){ orders() {
return this.$store.state.MMCGroundStation.orders; return this.$store.state.MMCGroundStation.orders;
}, },
}, },
async created(){ async created() {},
try{
await this.$store.dispatch('MMCGroundStation/init', {
url: 'ws://116.62.122.225:30103',
userInfo: this.userInfo
})
}catch(e){
console.log('地面站连接失败', e)
}
console.log('地面站连接成功');
},
methods: { methods: {
subscribe(){ async login() {
this.$store.dispatch('MMCGroundStation/subscribe', this.deviceHardId) let formData = new FormData();
formData.append("userAccount", this.account);
formData.append("password", this.password);
let res1 = await fetch("/crm/account/login", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username: this.account,
password: this.password,
}),
});
let data1 = await res1.json();
if (data1.code == 200) {
this.userInfo.username = data1.data.username;
}
let res2 = await fetch("/crm/account/loginInfo", {
method: "post",
headers: {
token: data1.data.token,
"Content-Type": "application/json",
},
body: JSON.stringify({
loginInfo: {
appId: "40004",
token: data1.data.token,
},
}),
});
let data2 = await res2.json();
if (data2.code == 200) {
this.userInfo.token = data2.data.token + data2.data.flyingSessionId;
}
},
async connect() {
try {
await this.$store.dispatch("MMCGroundStation/init", {
url: "ws://121.43.58.140:30105",
userInfo: this.userInfo,
});
} catch (e) {
console.log("地面站连接失败", e);
}
console.log("地面站连接成功");
},
subscribe() {
this.$store.dispatch("MMCGroundStation/subscribe", this.deviceHardId);
}, },
unsubscribe(){ unsubscribe() {
this.$store.dispatch('MMCGroundStation/unsubscribe', this.deviceHardId) this.$store.dispatch("MMCGroundStation/unsubscribe", this.deviceHardId);
}, },
publish(){ publish() {
this.$store.dispatch('MMCGroundStation/publish', { this.$store.dispatch("MMCGroundStation/publish", {
type: 200, type: 200,
cmdFunction: 9001, cmdFunction: 9001,
data: { data: {
cmdControlType: 900, cmdControlType: 900,
}, },
deviceHardId: this.deviceHardId deviceHardId: this.deviceHardId,
}) });
}, },
order( { order } ){ order({ order }) {
this.$store.dispatch('MMCGroundStation/order', { this.$store.dispatch("MMCGroundStation/order", {
order, order,
data: { data: {
cmdControlType: 900, cmdControlType: 900,
}, },
deviceHardId: this.deviceHardId deviceHardId: this.deviceHardId,
}) });
},
callback(data) {
console.log("callback data", data);
this.callbackText += "收到事件,调试窗口查看 ";
}, },
callback(data){ addCallback() {
console.log('callback data', data) this.$store.dispatch("MMCGroundStation/addCallback", this.callback);
this.callbackText += '收到事件,调试窗口查看 ';
}, },
addCallback(){ removeCallback() {
this.$store.dispatch('MMCGroundStation/addCallback', this.callback) this.callbackText = "";
this.$store.dispatch("MMCGroundStation/removeCallback", this.callback);
}, },
removeCallback(){ },
this.callbackText = ''; };
this.$store.dispatch('MMCGroundStation/removeCallback', this.callback)
}
}
}
</script> </script>
\ No newline at end of file
...@@ -17,6 +17,16 @@ module.exports = defineConfig({ ...@@ -17,6 +17,16 @@ module.exports = defineConfig({
"Cross-Origin-Embedder-Policy": "require-corp", "Cross-Origin-Embedder-Policy": "require-corp",
}, },
proxy: { proxy: {
"/crm": {
target: "http://infra.mmcuav.cn/",
// target: "http://47.106.147.192/", //测试
// target: "http://120.79.102.66",
// target: "http://120.77.219.153:80", //v3正式
// target: "http://39.108.188.237:10009", //推广平台
ws: false,
changeOrigin: true,
pathRewrite: {},
},
}, },
}, },
}); });
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论