|
|
|
@ -13,9 +13,29 @@
|
|
|
|
|
<f7-app :params="$root.f7params">
|
|
|
|
|
<f7-view main>
|
|
|
|
|
<f7-page>
|
|
|
|
|
<f7-navbar title="首页">
|
|
|
|
|
<a href="config.html" slot="nav-right" class="link external"><i class="icon f7-icons if-not-md">menu</i></a>
|
|
|
|
|
<f7-navbar title="产品">
|
|
|
|
|
<f7-nav-right>
|
|
|
|
|
<f7-link class="searchbar-enable" data-searchbar=".searchbar" icon-ios="f7:search"></f7-link>
|
|
|
|
|
</f7-nav-right>
|
|
|
|
|
<f7-searchbar class="searchbar-demo"
|
|
|
|
|
expandable
|
|
|
|
|
search-container=".search-list"
|
|
|
|
|
search-in=".item-title"></f7-searchbar>
|
|
|
|
|
</f7-navbar>
|
|
|
|
|
<f7-list class="searchbar-not-found">
|
|
|
|
|
<f7-list-item title="没有匹配的结果"></f7-list-item>
|
|
|
|
|
</f7-list>
|
|
|
|
|
<f7-list class="search-list searchbar-found">
|
|
|
|
|
<li style="width:33.3%;display:inline-block;" v-if="model" v-for="n in model">
|
|
|
|
|
<a :href="'node.html?number='+n.Number" class="card external" style="display:block;text-align:center;">
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
<span class="item-title">{{n.Name}}</span>
|
|
|
|
|
<span class="right"><span class="badge color-green">{{n.DeviceCount}}</span></span>
|
|
|
|
|
</div>
|
|
|
|
|
<img style="margin:0 auto;" :src="server+'/IoTCenter'+n.Image" />
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</f7-list>
|
|
|
|
|
<f7-toolbar tabbar labels position="bottom">
|
|
|
|
|
<a href="index.html" class="tab-link external tab-link-active">
|
|
|
|
|
<i class="icon icon f7-icons">house</i>
|
|
|
|
@ -34,6 +54,7 @@
|
|
|
|
|
</f7-view>
|
|
|
|
|
</f7-app>
|
|
|
|
|
</div>
|
|
|
|
|
<script type="text/javascript" src="lib/signalr/signalr.min.js"></script>
|
|
|
|
|
<script type="text/javascript" src="lib/axios/axios.min.js"></script>
|
|
|
|
|
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
|
|
|
|
|
<script type="text/javascript" src="lib/jquery.validation/jquery.validate.min.js"></script>
|
|
|
|
@ -41,6 +62,39 @@
|
|
|
|
|
<script type="text/javascript" src="lib/vue/vue.min.js"></script>
|
|
|
|
|
<script type="text/javascript" src="lib/framework7/js/framework7.bundle.min.js"></script>
|
|
|
|
|
<script type="text/javascript" src="lib/framework7/js/framework7-vue.bundle.min.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
var debug = true;
|
|
|
|
|
var wsUrl = localStorage.getItem('server') + '/IoTCenter/hub?group=page';
|
|
|
|
|
var connectionId;
|
|
|
|
|
const connection = new signalR.HubConnectionBuilder()
|
|
|
|
|
.withUrl(wsUrl)
|
|
|
|
|
.build();
|
|
|
|
|
function connect() {
|
|
|
|
|
if (debug) { console.log('start connect to server:' + Date()); }
|
|
|
|
|
connection.start().then(function () {
|
|
|
|
|
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
console.error(err.toString());
|
|
|
|
|
setTimeout(connect, 15 * 1000);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
connection.on('Connected', function (id) {
|
|
|
|
|
connectionId = id;
|
|
|
|
|
console.log(connectionId);
|
|
|
|
|
});
|
|
|
|
|
connection.onclose(function (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
setTimeout(connect, 15 * 1000);
|
|
|
|
|
});
|
|
|
|
|
connection.on("ServerToClient", function (method, json, from) {
|
|
|
|
|
console.log(method + ':' + json);
|
|
|
|
|
if (method == 'ProductEntityInserted' ||
|
|
|
|
|
method == 'DeviceEntityInserted' ||
|
|
|
|
|
method == 'DeviceEntityDeleted') {
|
|
|
|
|
vm.load();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
Framework7.use(Framework7Vue);
|
|
|
|
|
var app;
|
|
|
|
@ -55,7 +109,8 @@
|
|
|
|
|
theme: 'ios',
|
|
|
|
|
},
|
|
|
|
|
server: localStorage.getItem('server'),
|
|
|
|
|
token: localStorage.getItem('token')
|
|
|
|
|
token: localStorage.getItem('token'),
|
|
|
|
|
model: null
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
@ -68,25 +123,19 @@
|
|
|
|
|
this.$f7ready((f7) => {
|
|
|
|
|
app = this.$f7;
|
|
|
|
|
});
|
|
|
|
|
connect();
|
|
|
|
|
this.load();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
submit: function (e) {
|
|
|
|
|
if (!$(e.target).valid()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var url = e.target.action;
|
|
|
|
|
var data = $(e.target).serialize();
|
|
|
|
|
load: function () {
|
|
|
|
|
var url = this.server + '/IoTCenter/App/GetProducts';
|
|
|
|
|
var data = new FormData();
|
|
|
|
|
data.append('token', this.token);
|
|
|
|
|
axios.post(url, data)
|
|
|
|
|
.then(function (response) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
var data = response.data;
|
|
|
|
|
if (data.Code === 0) {
|
|
|
|
|
localStorage.setItem("token", data.Token);
|
|
|
|
|
window.location.href = "index.html";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
app.dialog.alert(data.Message, '警告', function () { });
|
|
|
|
|
}
|
|
|
|
|
vm.model = data;
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
app.dialog.alert(error, '警告', function () { })
|
|
|
|
|