提交 9f7cf985 作者: 翁进城

修正地面站链路

上级 730345e1
......@@ -14,7 +14,7 @@ export default {
},
orders, //所有指令
callbackList: [], //ws消息callback队列
userInfo: "", //用户名
userInfo: {}, //用户信息
},
mutations: {
setWs(state, data) {
......@@ -98,9 +98,7 @@ export default {
type: 100,
systemCode: "mmc",
state: 1,
username: state.userInfo.username,
token: state.userInfo.token,
appId: state.userInfo.appId,
...userInfo,
};
ws.send(JSON.stringify(wsData));
resolve();
......
......@@ -2,10 +2,20 @@ export default `
<template>
<div>
<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-input v-model="deviceHardId"></el-input>
</el-form-item>
<el-form-item label="操作">
<el-button @click="connect">连接地面站ws</el-button>
<el-button @click="subscribe">订阅</el-button>
<el-button @click="unsubscribe">取消订阅</el-button>
<el-button @click="publish()">通过原始type发送指令</el-button>
......@@ -13,90 +23,127 @@ export default `
<el-button @click="addCallback">添加事件回调</el-button>
<el-button @click="removeCallback">移除事件回调</el-button>
</el-form-item>
<el-form-item label="支持的指令">
{{ orders }}
</el-form-item>
<el-form-item label="支持的指令">{{ orders }}</el-form-item>
</el-form>
<div>
{{ text }}
</div>
<div>
{{ callbackText }}
</div>
<div>{{ text }}</div>
<div>{{ callbackText }}</div>
</div>
</template>
<script>
export default {
name: 'GroundStation',
data(){
name: "GroundStation",
data() {
return {
deviceHardId: '',
account: "juchut",
password: "dG1qMDQwNyNuZXcuMQ==",
deviceHardId: "",
userInfo: {
username: 'admin',
token: 'cbe85bcd114cfb00a8547c86cac5460ad7942a1ab531094cd53e55a1e67617d9',
appId: 87878
username: "",
// token: "5e93559e5d00ed4dda7d75f9502ea9d83b8c15cb54672b4262dc85d0669ee53d",
appId: "40003",
// 'task-id': 1448
},
callbackText: ''
}
callbackText: "",
};
},
computed: {
text(){
text() {
return this.$store.state.MMCGroundStation.dataSet;
},
orders(){
orders() {
return this.$store.state.MMCGroundStation.orders;
},
},
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('地面站连接成功');
},
async created() {},
methods: {
subscribe(){
this.$store.dispatch('MMCGroundStation/subscribe', this.deviceHardId)
async login() {
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(){
this.$store.dispatch('MMCGroundStation/unsubscribe', this.deviceHardId)
unsubscribe() {
this.$store.dispatch("MMCGroundStation/unsubscribe", this.deviceHardId);
},
publish(){
this.$store.dispatch('MMCGroundStation/publish', {
publish() {
this.$store.dispatch("MMCGroundStation/publish", {
type: 200,
cmdFunction: 9001,
data: {
cmdControlType: 900,
},
deviceHardId: this.deviceHardId
})
deviceHardId: this.deviceHardId,
});
},
order( { order } ){
this.$store.dispatch('MMCGroundStation/order', {
order({ order }) {
this.$store.dispatch("MMCGroundStation/order", {
order,
data: {
cmdControlType: 900,
},
deviceHardId: this.deviceHardId
})
},
deviceHardId: this.deviceHardId,
});
},
callback(data) {
console.log("callback data", data);
this.callbackText += "收到事件,调试窗口查看 ";
},
callback(data){
console.log('callback data', data)
this.callbackText += '收到事件,调试窗口查看 ';
addCallback() {
this.$store.dispatch("MMCGroundStation/addCallback", this.callback);
},
addCallback(){
this.$store.dispatch('MMCGroundStation/addCallback', this.callback)
removeCallback() {
this.callbackText = "";
this.$store.dispatch("MMCGroundStation/removeCallback", this.callback);
},
removeCallback(){
this.callbackText = '';
this.$store.dispatch('MMCGroundStation/removeCallback', this.callback)
}
}
}
},
};
</script>
`;
\ No newline at end of file
<template>
<div>
<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-input v-model="deviceHardId"></el-input>
</el-form-item>
<el-form-item label="操作">
<el-button @click="connect">连接地面站ws</el-button>
<el-button @click="subscribe">订阅</el-button>
<el-button @click="unsubscribe">取消订阅</el-button>
<el-button @click="publish()">通过原始type发送指令</el-button>
......@@ -12,89 +22,126 @@
<el-button @click="addCallback">添加事件回调</el-button>
<el-button @click="removeCallback">移除事件回调</el-button>
</el-form-item>
<el-form-item label="支持的指令">
{{ orders }}
</el-form-item>
<el-form-item label="支持的指令">{{ orders }}</el-form-item>
</el-form>
<div>
{{ text }}
</div>
<div>
{{ callbackText }}
</div>
<div>{{ text }}</div>
<div>{{ callbackText }}</div>
</div>
</template>
<script>
export default {
name: 'GroundStation',
data(){
name: "GroundStation",
data() {
return {
deviceHardId: '',
account: "juchut",
password: "dG1qMDQwNyNuZXcuMQ==",
deviceHardId: "",
userInfo: {
username: 'admin',
token: 'cbe85bcd114cfb00a8547c86cac5460ad7942a1ab531094cd53e55a1e67617d9',
appId: 87878
username: "",
// token: "5e93559e5d00ed4dda7d75f9502ea9d83b8c15cb54672b4262dc85d0669ee53d",
appId: "40003",
// 'task-id': 1448
},
callbackText: ''
}
callbackText: "",
};
},
computed: {
text(){
text() {
return this.$store.state.MMCGroundStation.dataSet;
},
orders(){
orders() {
return this.$store.state.MMCGroundStation.orders;
},
},
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('地面站连接成功');
},
async created() {},
methods: {
subscribe(){
this.$store.dispatch('MMCGroundStation/subscribe', this.deviceHardId)
async login() {
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(){
this.$store.dispatch('MMCGroundStation/unsubscribe', this.deviceHardId)
unsubscribe() {
this.$store.dispatch("MMCGroundStation/unsubscribe", this.deviceHardId);
},
publish(){
this.$store.dispatch('MMCGroundStation/publish', {
publish() {
this.$store.dispatch("MMCGroundStation/publish", {
type: 200,
cmdFunction: 9001,
data: {
cmdControlType: 900,
},
deviceHardId: this.deviceHardId
})
deviceHardId: this.deviceHardId,
});
},
order( { order } ){
this.$store.dispatch('MMCGroundStation/order', {
order({ order }) {
this.$store.dispatch("MMCGroundStation/order", {
order,
data: {
cmdControlType: 900,
},
deviceHardId: this.deviceHardId
})
},
deviceHardId: this.deviceHardId,
});
},
callback(data) {
console.log("callback data", data);
this.callbackText += "收到事件,调试窗口查看 ";
},
callback(data){
console.log('callback data', data)
this.callbackText += '收到事件,调试窗口查看 ';
addCallback() {
this.$store.dispatch("MMCGroundStation/addCallback", this.callback);
},
addCallback(){
this.$store.dispatch('MMCGroundStation/addCallback', this.callback)
removeCallback() {
this.callbackText = "";
this.$store.dispatch("MMCGroundStation/removeCallback", this.callback);
},
removeCallback(){
this.callbackText = '';
this.$store.dispatch('MMCGroundStation/removeCallback', this.callback)
}
}
}
},
};
</script>
\ No newline at end of file
......@@ -17,6 +17,16 @@ module.exports = defineConfig({
"Cross-Origin-Embedder-Policy": "require-corp",
},
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论