Merge branch 'paris_france_app' of http://1.95.131.171:3000/zzkj/smart_storage_app into paris_france_app
# Conflicts: # common/locales/homePage/ar.js # common/locales/homePage/de.js # common/locales/homePage/en.js
This commit is contained in:
3698
common/form.js
3698
common/form.js
File diff suppressed because it is too large
Load Diff
@ -176,7 +176,9 @@ const install = (Vue, vm) => {
|
|||||||
getStationListByStatus: (params = {}) =>
|
getStationListByStatus: (params = {}) =>
|
||||||
vm.$u.post(config.adminPath + "/business/station/findListByStationStatus ", params),
|
vm.$u.post(config.adminPath + "/business/station/findListByStationStatus ", params),
|
||||||
getStationPostionData: (params = {}) =>
|
getStationPostionData: (params = {}) =>
|
||||||
vm.$u.post(config.adminPath + "/business/dynamicConfig/pointListData", params)
|
vm.$u.post(config.adminPath + "/business/dynamicConfig/pointListData", params),
|
||||||
|
getStationPostionSn: (params = {}) =>
|
||||||
|
vm.$u.post(config.adminPath + "/business/point/getSN", params)
|
||||||
},
|
},
|
||||||
|
|
||||||
//设备
|
//设备
|
||||||
|
|||||||
@ -271,6 +271,7 @@ export default {
|
|||||||
cancel: 'الغاء',
|
cancel: 'الغاء',
|
||||||
messageDetail: 'تفاصيل الرسالة',
|
messageDetail: 'تفاصيل الرسالة',
|
||||||
operateSuccess: 'نجح العملية',
|
operateSuccess: 'نجح العملية',
|
||||||
|
operateFail: 'فشل العملية',
|
||||||
messageReaded: 'تمت قراءة هذه الرسالة، لا داعي لتكرار الإجراء'
|
messageReaded: 'تمت قراءة هذه الرسالة، لا داعي لتكرار الإجراء'
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
@ -469,7 +470,7 @@ export default {
|
|||||||
second: 'ثانية'
|
second: 'ثانية'
|
||||||
},
|
},
|
||||||
policy: {
|
policy: {
|
||||||
planCurve: 'منحنى الجدول الزمني',
|
planCurve: 'منحنى الجدول الزمني',
|
||||||
planCurveTem: 'قالب الجدول',
|
planCurveTem: 'قالب الجدول',
|
||||||
IssueDevice: 'الجهاز المستهدف',
|
IssueDevice: 'الجهاز المستهدف',
|
||||||
operateOrNot: 'قيد التشغيل',
|
operateOrNot: 'قيد التشغيل',
|
||||||
@ -519,6 +520,7 @@ export default {
|
|||||||
selectPlanCurveTem: 'اختر قالب الجدول',
|
selectPlanCurveTem: 'اختر قالب الجدول',
|
||||||
deliverErrorTip: 'تجاوز طاقة الشحن والتفريغ الطاقة المقدرة، يرجى التحقق من إعدادات منحنى الجدول الزمني!',
|
deliverErrorTip: 'تجاوز طاقة الشحن والتفريغ الطاقة المقدرة، يرجى التحقق من إعدادات منحنى الجدول الزمني!',
|
||||||
deliverTip: 'سواء تأكيد إصدار الأمر?'
|
deliverTip: 'سواء تأكيد إصدار الأمر?'
|
||||||
|
policyTitle: 'إصدار الاستراتيجية'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -272,6 +272,7 @@ export default {
|
|||||||
cancel: 'Abbrechen',
|
cancel: 'Abbrechen',
|
||||||
messageDetail: 'Nachrichtendetails',
|
messageDetail: 'Nachrichtendetails',
|
||||||
operateSuccess: 'Aktion erfolgreich',
|
operateSuccess: 'Aktion erfolgreich',
|
||||||
|
operateFail: 'Aktion fehlgeschlagen',
|
||||||
messageReaded: 'Diese Nachricht wurde bereits gelesen, keine Wiederholung der Aktion erforderlich'
|
messageReaded: 'Diese Nachricht wurde bereits gelesen, keine Wiederholung der Aktion erforderlich'
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
@ -556,5 +557,6 @@ export default {
|
|||||||
selectPlanCurveTem: 'Planvorlage wählen',
|
selectPlanCurveTem: 'Planvorlage wählen',
|
||||||
deliverErrorTip: 'Lade-/Entladeleistung größer als Nennleistung, bitte überprüfen Sie die Plan-Kurven-Einstellungen!',
|
deliverErrorTip: 'Lade-/Entladeleistung größer als Nennleistung, bitte überprüfen Sie die Plan-Kurven-Einstellungen!',
|
||||||
deliverTip: 'Befehlssendung wirklich bestätigen?'
|
deliverTip: 'Befehlssendung wirklich bestätigen?'
|
||||||
|
policyTitle: 'Strategieübertragung'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -257,6 +257,7 @@ export default {
|
|||||||
sureRead: 'Confirm as read',
|
sureRead: 'Confirm as read',
|
||||||
cancel: 'Cancel',
|
cancel: 'Cancel',
|
||||||
operateSuccess: 'Operation successful',
|
operateSuccess: 'Operation successful',
|
||||||
|
operateFail: 'Operation failed',
|
||||||
messageReaded: 'This message has been read. No need to repeat the'
|
messageReaded: 'This message has been read. No need to repeat the'
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
@ -523,5 +524,6 @@ export default {
|
|||||||
selectPlanCurveTem: 'Select schedule template',
|
selectPlanCurveTem: 'Select schedule template',
|
||||||
deliverErrorTip: 'Charging/discharging power exceeds rated power. Please confirm the planned curve.',
|
deliverErrorTip: 'Charging/discharging power exceeds rated power. Please confirm the planned curve.',
|
||||||
deliverTip: 'Confirm command issuance?'
|
deliverTip: 'Confirm command issuance?'
|
||||||
|
policyTitle: 'Strategy Issuance'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,6 +257,7 @@ export default {
|
|||||||
sureRead: 'Confirmar como leído',
|
sureRead: 'Confirmar como leído',
|
||||||
cancel: 'Cancelar',
|
cancel: 'Cancelar',
|
||||||
operateSuccess: 'Operación realizada con éxito',
|
operateSuccess: 'Operación realizada con éxito',
|
||||||
|
operateFail: 'Operación fallida',
|
||||||
messageReaded: 'Este mensaje ya fue leído; no es necesario repetir la operación'
|
messageReaded: 'Este mensaje ya fue leído; no es necesario repetir la operación'
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
@ -479,6 +480,7 @@ export default {
|
|||||||
confirmTime: 'Hora de confirmación'
|
confirmTime: 'Hora de confirmación'
|
||||||
},
|
},
|
||||||
policy: {
|
policy: {
|
||||||
|
policyTitle: 'Estrategia de envío',
|
||||||
planCurve: 'Curva planificada',
|
planCurve: 'Curva planificada',
|
||||||
planCurveTem: 'Plantilla programa',
|
planCurveTem: 'Plantilla programa',
|
||||||
IssueDevice: 'Equipo destino',
|
IssueDevice: 'Equipo destino',
|
||||||
|
|||||||
@ -257,6 +257,7 @@ export default {
|
|||||||
sureRead: 'Confirmer la lecture',
|
sureRead: 'Confirmer la lecture',
|
||||||
cancel: 'Annuler',
|
cancel: 'Annuler',
|
||||||
operateSuccess: 'Opération réussie',
|
operateSuccess: 'Opération réussie',
|
||||||
|
operateFail: 'Opération échouée',
|
||||||
messageReaded: "La lecture du message a été effectuée. Aucune répétition n'est nécessaire !"
|
messageReaded: "La lecture du message a été effectuée. Aucune répétition n'est nécessaire !"
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
@ -479,6 +480,7 @@ export default {
|
|||||||
confirmTime: 'Heure de confirmation'
|
confirmTime: 'Heure de confirmation'
|
||||||
},
|
},
|
||||||
policy: {
|
policy: {
|
||||||
|
policyTitle: 'Stratégie de distribution',
|
||||||
planCurve: 'Courbe programmée',
|
planCurve: 'Courbe programmée',
|
||||||
planCurveTem: 'Modèle de planning',
|
planCurveTem: 'Modèle de planning',
|
||||||
IssueDevice: "Équipement cible",
|
IssueDevice: "Équipement cible",
|
||||||
|
|||||||
@ -271,6 +271,7 @@ export default {
|
|||||||
cancel: 'Anuluj',
|
cancel: 'Anuluj',
|
||||||
messageDetail: 'Szczegóły wiadomości',
|
messageDetail: 'Szczegóły wiadomości',
|
||||||
operateSuccess: 'Operacja zakończona sukcesem',
|
operateSuccess: 'Operacja zakończona sukcesem',
|
||||||
|
operateFail: 'Operacja nie powiodła się',
|
||||||
messageReaded: 'Wiadomość została odczytana, nie ma potrzeby powtarzania akcji.'
|
messageReaded: 'Wiadomość została odczytana, nie ma potrzeby powtarzania akcji.'
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
@ -505,6 +506,7 @@ export default {
|
|||||||
confirmTime: 'Czas potwierdzenia'
|
confirmTime: 'Czas potwierdzenia'
|
||||||
},
|
},
|
||||||
policy: {
|
policy: {
|
||||||
|
policyTitle: 'Strategia dystrybucji',
|
||||||
planCurve: 'Krzywa planowania',
|
planCurve: 'Krzywa planowania',
|
||||||
planCurveTem: 'Szablon harmonogramu',
|
planCurveTem: 'Szablon harmonogramu',
|
||||||
IssueDevice: 'Urządzenie docelowe',
|
IssueDevice: 'Urządzenie docelowe',
|
||||||
|
|||||||
@ -264,8 +264,9 @@ export default {
|
|||||||
sureRead: '确认已读',
|
sureRead: '确认已读',
|
||||||
cancel: '取消',
|
cancel: '取消',
|
||||||
messageDetail: '消息详情',
|
messageDetail: '消息详情',
|
||||||
operateSuccess: '操作成功',
|
operateSuccess: '操作成功',
|
||||||
messageReaded: '该消息已读,无需重复操作'
|
operateFail: '操作失败',
|
||||||
|
messageReaded: '该消息已读,无需重复操作'
|
||||||
},
|
},
|
||||||
device: {
|
device: {
|
||||||
inputNameQuery: '输入名称搜索',
|
inputNameQuery: '输入名称搜索',
|
||||||
@ -549,5 +550,6 @@ export default {
|
|||||||
selectPlanCurveTem: '请选择计划曲线模板',
|
selectPlanCurveTem: '请选择计划曲线模板',
|
||||||
deliverErrorTip: '充放电功率大于额定功率,请确认计划曲线设置!',
|
deliverErrorTip: '充放电功率大于额定功率,请确认计划曲线设置!',
|
||||||
deliverTip: '是否确定下发命令?',
|
deliverTip: '是否确定下发命令?',
|
||||||
|
policyTitle: '策略下发',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
4
main.js
4
main.js
@ -6,7 +6,7 @@ Vue.config.productionTip = false
|
|||||||
|
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
// 引入全局 uView 框架
|
// 引入全局 uView 框架
|
||||||
import uView from 'uview-ui'
|
import uView from './uview-ui'
|
||||||
Vue.use(uView)
|
Vue.use(uView)
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ let vuexStore = require('@/store/$u.mixin.js')
|
|||||||
Vue.mixin(vuexStore)
|
Vue.mixin(vuexStore)
|
||||||
|
|
||||||
// 引入 uView 对小程序分享的 mixin 封装
|
// 引入 uView 对小程序分享的 mixin 封装
|
||||||
let mpShare = require('uview-ui/libs/mixin/mpShare.js')
|
let mpShare = require('./uview-ui/libs/mixin/mpShare.js')
|
||||||
Vue.mixin(mpShare)
|
Vue.mixin(mpShare)
|
||||||
|
|
||||||
// Vue i18n 国际化
|
// Vue i18n 国际化
|
||||||
|
|||||||
@ -97,6 +97,7 @@
|
|||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -1,245 +1,348 @@
|
|||||||
<template>
|
<template>
|
||||||
<view style="height: 100vh">
|
<view style="height: 100vh">
|
||||||
<view class="">
|
<view class="">
|
||||||
<u-navbar title="策略下发" :is-back="true" :background="background" :border-bottom="false"
|
<u-navbar
|
||||||
:custom-back="toback">
|
:title="$t('homePage.policy.policyTitle')"
|
||||||
</u-navbar>
|
:is-back="true"
|
||||||
</view>
|
title-color="#FFF"
|
||||||
<view class="policeForm">
|
:background="background"
|
||||||
<view class="" v-for="(item, index) in smallArr" :key="index">
|
:border-bottom="false"
|
||||||
<view class="" v-if="item.type == 'Input'">
|
:custom-back="toback"
|
||||||
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
|
>
|
||||||
<u-input :min="item.min" :max="item.max" v-model.number="item.value" type="number"
|
</u-navbar>
|
||||||
:placeholder="item[`place_${lang}`]" @input="handleInput(item, $event)" />
|
</view>
|
||||||
</u-form-item>
|
<view class="policeForm">
|
||||||
</view>
|
<u-form ref="form" labelPosition="top">
|
||||||
<view class="" v-if="item.type == 'Switch'">
|
<view class="" v-for="(item, index) in smallArr" :key="index">
|
||||||
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
|
<view class="" v-if="item.type == 'Input'">
|
||||||
<u-switch :size="40" v-model="item.value"></u-switch>
|
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
|
||||||
</u-form-item>
|
<u-input
|
||||||
</view>
|
:key="'input_' + item.prop + '_' + item.inputKey"
|
||||||
<view class="" v-if="item.type == 'Select'" @click="selectShow(item, index)">
|
:min="item.min"
|
||||||
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
|
:max="item.max"
|
||||||
<view class="" v-show="false">
|
:value="item.value"
|
||||||
<u-input v-model="item.value" disabled @click="selectShow(item, index)" />
|
type="number"
|
||||||
</view>
|
:placeholder="item[`place_${lang}`]"
|
||||||
<view class="">
|
@input="handleInput(item, $event)"
|
||||||
{{ item.selectLabel || $t("homePage.alarm.placeSelect") }}
|
/>
|
||||||
</view>
|
</u-form-item>
|
||||||
<u-select :key="item.prop" @confirm="confirm($event, item)" v-model="item.isShow"
|
</view>
|
||||||
:list="getSelectList(item)"></u-select>
|
<view class="" v-if="item.type == 'Switch'">
|
||||||
</u-form-item>
|
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
|
||||||
</view>
|
<u-switch :size="40" v-model="item.value"></u-switch>
|
||||||
</view>
|
</u-form-item>
|
||||||
|
</view>
|
||||||
|
<view class="" v-if="item.type == 'Select'">
|
||||||
|
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
|
||||||
|
<view class="" v-show="false">
|
||||||
|
<u-input
|
||||||
|
v-model="item.value"
|
||||||
|
disabled
|
||||||
|
@click="selectShow(item, index)"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="select-value" @click.stop="selectShow(item, index)">
|
||||||
|
{{ item.selectLabel || $t("homePage.alarm.placeSelect") }}
|
||||||
|
</view>
|
||||||
|
<u-select
|
||||||
|
:key="item.prop"
|
||||||
|
@confirm="confirm($event, item)"
|
||||||
|
v-model="item.isShow"
|
||||||
|
:list="getSelectList(item)"
|
||||||
|
></u-select>
|
||||||
|
</u-form-item>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-form>
|
||||||
|
|
||||||
<button @click="submitDevice" type="success" size="mini" style="
|
<button
|
||||||
|
@click="submitDevice"
|
||||||
|
type="success"
|
||||||
|
size="mini"
|
||||||
|
style="
|
||||||
background-color: #009458;
|
background-color: #009458;
|
||||||
padding: 10rpx 0;
|
padding: 10rpx 0;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
margin-top: 40rpx;
|
margin-top: 40rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
">
|
"
|
||||||
{{ $t("homePage.mine.submit") }}
|
>
|
||||||
</button>
|
{{ $t("homePage.mine.submit") }}
|
||||||
</view>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
<u-toast ref="uToast" />
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { formList } from "@/common/form.js";
|
||||||
formList
|
import { Langlist } from "@/common/lang";
|
||||||
} from "@/common/form.js";
|
import mqtt from "@/uni_modules/leliven-mqtt/index.js";
|
||||||
import {
|
import pako from "pako";
|
||||||
Langlist
|
export default {
|
||||||
} from "@/common/lang";
|
data() {
|
||||||
import mqtt from "@/uni_modules/leliven-mqtt/index.js";
|
return {
|
||||||
export default {
|
formList: formList,
|
||||||
|
background: {
|
||||||
|
backgroundColor: "#0EA17E",
|
||||||
|
},
|
||||||
|
|
||||||
data() {
|
mqttClient: null,
|
||||||
return {
|
backData: {},
|
||||||
formList: formList,
|
smallArr: [],
|
||||||
background: {
|
user: {
|
||||||
backgroundColor: "#0EA17E",
|
username: "admin", // 设置用户名
|
||||||
},
|
password: "zzkj@688737", // 设置密码
|
||||||
lang: 'en',
|
},
|
||||||
mqttClient: null,
|
};
|
||||||
backData: {},
|
},
|
||||||
smallArr: [],
|
|
||||||
user: {
|
|
||||||
username: 'admin', // 设置用户名
|
|
||||||
password: 'zzkj@688737' // 设置密码
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
computed: {
|
||||||
},
|
lang() {
|
||||||
computed: {
|
return (
|
||||||
language() {
|
Langlist.find((v) => v.value == this.$store.state.vuex_language).prop ||
|
||||||
return this.$store.state.vuex_language
|
"en"
|
||||||
},
|
);
|
||||||
currentStation() {
|
},
|
||||||
console.log(this.vuex_currentStation)
|
currentStation() {
|
||||||
return this.vuex_currentStation;
|
return this.vuex_currentStation;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
onLoad() {
|
||||||
|
this.getSn();
|
||||||
|
},
|
||||||
|
|
||||||
onShow() {
|
methods: {
|
||||||
this.initmqttClient()
|
getSn() {
|
||||||
},
|
this.$u.api.station
|
||||||
|
.getStationPostionSn({
|
||||||
|
stationId: this.currentStation.id,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
this.sn = res.data[0]?.sn;
|
||||||
|
this.initmqttClient();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
initmqttClient() {
|
||||||
|
console.log(this.lang);
|
||||||
|
console.log(this.currentStation);
|
||||||
|
// 初始化客户端连接地址
|
||||||
|
// #ifdef H5
|
||||||
|
let mqttClient = mqtt.connect("ws://1.95.170.86:8083/mqtt", {
|
||||||
|
...this.user,
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
// #ifdef MP-WEIXIN||APP-PLUS
|
||||||
|
let mqttClient = mqtt.connect("wx://1.95.170.86:8083/mqtt", {
|
||||||
|
...this.user,
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
this.mqttClient = mqttClient;
|
||||||
|
// 连接MQ服务
|
||||||
|
mqttClient
|
||||||
|
.on("connect", (res) => {
|
||||||
|
console.log("连接成功");
|
||||||
|
// 订阅主题
|
||||||
|
mqttClient.subscribe(`1/ems/${this.sn}/control/response`, (err) => {
|
||||||
|
console.log(`1/app/${this.sn}/control/request`);
|
||||||
|
if (!err) {
|
||||||
|
// 订阅成功
|
||||||
|
mqttClient.publish(
|
||||||
|
`1/app/${this.sn}/control/request`,
|
||||||
|
JSON.stringify({
|
||||||
|
fun: "GET",
|
||||||
|
type: "WJ_Get_NewControlSystem",
|
||||||
|
content: 0,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.on("reconnect", function () {
|
||||||
|
console.log("重新连接");
|
||||||
|
})
|
||||||
|
.on("error", function () {
|
||||||
|
console.log("连接失败");
|
||||||
|
})
|
||||||
|
.on("end", function () {
|
||||||
|
console.log("连接End");
|
||||||
|
})
|
||||||
|
.on("message", (topic, message) => {
|
||||||
|
console.log(this.decodeGzipBase64(message.toString()), "111");
|
||||||
|
let data = this.decodeGzipBase64(message.toString());
|
||||||
|
if (data.content && data.content.params) {
|
||||||
|
this.control(data.content);
|
||||||
|
} else if (data.content == 1) {
|
||||||
|
this.$refs.uToast.show({
|
||||||
|
title: this.$t("homePage.mine.operateSuccess"),
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: this.$t("homePage.mine.operateFail"),
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
decodeGzipBase64(base64Str) {
|
||||||
initmqttClient() {
|
// 1. base64 → Uint8Array
|
||||||
// 初始化客户端连接地址
|
const binaryStr = atob(base64Str);
|
||||||
// #ifdef H5
|
const len = binaryStr.length;
|
||||||
let mqttClient = mqtt.connect('ws://13.39.200.14:8083/mqtt', {
|
const bytes = new Uint8Array(len);
|
||||||
...this.user
|
|
||||||
})
|
|
||||||
// #endif
|
|
||||||
// #ifdef MP-WEIXIN||APP-PLUS
|
|
||||||
let mqttClient = mqtt.connect('wx://13.39.200.14:8083/mqtt', {
|
|
||||||
...this.user
|
|
||||||
})
|
|
||||||
// #endif
|
|
||||||
console.log(mqttClient,'888')
|
|
||||||
this.mqttClient = mqttClient
|
|
||||||
// 连接MQ服务
|
|
||||||
mqttClient.on('connect', function(res) {
|
|
||||||
console.log('连接成功')
|
|
||||||
console.log(res)
|
|
||||||
|
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
bytes[i] = binaryStr.charCodeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
// 订阅主题
|
// 2. gunzip 解压
|
||||||
mqttClient.subscribe('presence', function(err) {
|
const decompressed = pako.ungzip(bytes, {
|
||||||
if (!err) {
|
to: "string",
|
||||||
// 订阅成功
|
});
|
||||||
mqttClient.publish('presence', 'hello mqtt')
|
// 3. 转 JSON(如果是 JSON)
|
||||||
}
|
return JSON.parse(decompressed);
|
||||||
})
|
},
|
||||||
}).on('reconnect', function() {
|
getSelectList(item) {
|
||||||
console.log('重新连接')
|
if (item.selectArr && item.selectArr.length > 0) {
|
||||||
}).on('error', function() {
|
return item.selectArr.map((option) => ({
|
||||||
console.log('连接失败')
|
value: option.value.toString(),
|
||||||
}).on('end', function() {
|
label: option[`label_${this.lang}`] || option.label,
|
||||||
console.log('连接End')
|
}));
|
||||||
}).on('message', function(topic, message) {
|
}
|
||||||
// 收到MQ消息
|
return [];
|
||||||
console.log(message.toString())
|
},
|
||||||
})
|
control(NewControlSystemShow_data) {
|
||||||
},
|
console.log(NewControlSystemShow_data, "123");
|
||||||
|
this.formList.forEach((item) => {
|
||||||
|
if (
|
||||||
|
item.type == "Switch" &&
|
||||||
|
NewControlSystemShow_data?.smallScreen?.includes(item.prop)
|
||||||
|
) {
|
||||||
|
this.$set(
|
||||||
|
item,
|
||||||
|
"value",
|
||||||
|
NewControlSystemShow_data?.params[item.prop] ? true : false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
item.type == "Input" &&
|
||||||
|
NewControlSystemShow_data?.smallScreen?.includes(item.prop)
|
||||||
|
) {
|
||||||
|
this.$set(
|
||||||
|
item,
|
||||||
|
"value",
|
||||||
|
NewControlSystemShow_data?.params[item.prop] ?? item.default,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
item.type == "Select" &&
|
||||||
|
NewControlSystemShow_data?.smallScreen?.includes(item.prop)
|
||||||
|
) {
|
||||||
|
const newValue =
|
||||||
|
NewControlSystemShow_data?.params[item.prop] ?? item.default;
|
||||||
|
this.$set(item, "value", newValue);
|
||||||
|
item.selectLabel = item.selectArr.find((v) => v.value == newValue)?.[
|
||||||
|
`label_${this.lang}`
|
||||||
|
];
|
||||||
|
}
|
||||||
|
this.$set(item, "isShow", false);
|
||||||
|
});
|
||||||
|
this.backData = NewControlSystemShow_data;
|
||||||
|
this.smallArr = this.formList.filter((v) =>
|
||||||
|
NewControlSystemShow_data?.smallScreen.includes(v.prop),
|
||||||
|
);
|
||||||
|
console.log(this.smallArr, "234");
|
||||||
|
},
|
||||||
|
confirm(val, item) {
|
||||||
|
if (val && val.length > 0) {
|
||||||
|
this.$set(item, "value", val[0].value);
|
||||||
|
this.$set(item, "selectLabel", val[0].label);
|
||||||
|
}
|
||||||
|
this.$set(item, "isShow", false);
|
||||||
|
},
|
||||||
|
handleInput(item, value) {
|
||||||
|
try {
|
||||||
|
// u-input 组件 @input 事件直接传递 value 值,不是 event 对象
|
||||||
|
let iptval = String(value || "").replace(/[^0-9.]/g, "");
|
||||||
|
const parts = iptval.split(".");
|
||||||
|
if (parts.length > 2) {
|
||||||
|
iptval = parts[0] + "." + parts.slice(1).join("");
|
||||||
|
}
|
||||||
|
if (!iptval || iptval === ".") {
|
||||||
|
item.value = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let numVal = Number(iptval);
|
||||||
|
numVal = isNaN(numVal) ? 0 : numVal;
|
||||||
|
|
||||||
|
// 检查是否需要强制更新(值被限制)
|
||||||
|
let needForceUpdate = false;
|
||||||
|
if (item.min !== undefined && item.min !== null && numVal < item.min) {
|
||||||
|
numVal = item.min;
|
||||||
|
needForceUpdate = true;
|
||||||
|
}
|
||||||
|
if (item.max !== undefined && item.max !== null && numVal > item.max) {
|
||||||
|
numVal = item.max;
|
||||||
|
needForceUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.value = numVal;
|
||||||
|
|
||||||
|
// 如果值被限制,强制重新渲染输入框
|
||||||
|
if (needForceUpdate) {
|
||||||
|
this.$set(item, "inputKey", (item.inputKey || 0) + 1);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("handleInput方法错误:", error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
decodeGzipBase64(base64Str) {
|
toback() {
|
||||||
// 1. base64 → Uint8Array
|
uni.navigateBack();
|
||||||
const binaryStr = atob(base64Str);
|
},
|
||||||
const len = binaryStr.length;
|
selectShow(val, index) {
|
||||||
const bytes = new Uint8Array(len);
|
console.log(123);
|
||||||
|
this.$set(val, "isShow", true);
|
||||||
|
},
|
||||||
|
submitDevice() {
|
||||||
|
let smallParam = this.smallArr.reduce((pre, cur) => {
|
||||||
|
pre[cur.prop] = cur.type == "Switch" ? (cur.value ? 1 : 0) : cur.value;
|
||||||
|
pre[cur.prop] = Number(pre[cur.prop]);
|
||||||
|
return pre;
|
||||||
|
}, {});
|
||||||
|
|
||||||
for (let i = 0; i < len; i++) {
|
this.mqttClient.publish(
|
||||||
bytes[i] = binaryStr.charCodeAt(i);
|
`1/app/${this.sn}/control/request`,
|
||||||
}
|
JSON.stringify({
|
||||||
|
fun: "SET",
|
||||||
// 2. gunzip 解压
|
type: "WJ_Set_NewControlSystem",
|
||||||
const decompressed = pako.ungzip(bytes, {
|
content: {
|
||||||
to: "string"
|
...this.backData,
|
||||||
});
|
params: {
|
||||||
// 3. 转 JSON(如果是 JSON)
|
...this.backData.params,
|
||||||
return JSON.parse(decompressed);
|
...smallParam,
|
||||||
},
|
},
|
||||||
getSelectList(item) {
|
},
|
||||||
if (item.selectArr && item.selectArr.length > 0) {
|
}),
|
||||||
return item.selectArr.map(option => ({
|
);
|
||||||
value: option.value.toString(),
|
},
|
||||||
label: option[`label_${this.lang}`] || option.label
|
},
|
||||||
}))
|
};
|
||||||
}
|
|
||||||
return []
|
|
||||||
},
|
|
||||||
control(NewControlSystemShow_data) {
|
|
||||||
this.formList.forEach(item => {
|
|
||||||
if (item.type == "Switch") {
|
|
||||||
item.value = NewControlSystemShow_data?.params[item.prop] ? true : false
|
|
||||||
} else {
|
|
||||||
item.value = NewControlSystemShow_data?.params[item.prop] || item.default
|
|
||||||
}
|
|
||||||
if (item.type == 'Select') {
|
|
||||||
item.selectLabel = item.selectArr.find(v => v.value == item.value)?.[`label_${this.lang}`]
|
|
||||||
}
|
|
||||||
item.isShow = false
|
|
||||||
})
|
|
||||||
this.backData = NewControlSystemShow_data
|
|
||||||
this.smallArr = this.formList.filter(v => NewControlSystemShow_data?.smallScreen.includes(v.prop))
|
|
||||||
},
|
|
||||||
confirm(val, item) {
|
|
||||||
if (val && val.length > 0) {
|
|
||||||
item.value = val[0].value
|
|
||||||
item.selectLabel = val[0].label
|
|
||||||
}
|
|
||||||
item.isShow = false
|
|
||||||
},
|
|
||||||
handleInput(item, event) {
|
|
||||||
try {
|
|
||||||
let inputValue = event.detail.value;
|
|
||||||
let iptval = String(inputValue).replace(/[^0-9.]/g, '');
|
|
||||||
const parts = iptval.split('.');
|
|
||||||
if (parts.length > 2) {
|
|
||||||
iptval = parts[0] + '.' + parts.slice(1).join('');
|
|
||||||
}
|
|
||||||
if (!iptval || iptval === '.') {
|
|
||||||
item.value = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let numVal = Number(iptval);
|
|
||||||
if (item.min !== undefined && item.min !== null) {
|
|
||||||
numVal = Math.max(numVal, item.min);
|
|
||||||
}
|
|
||||||
if (item.max !== undefined && item.max !== null) {
|
|
||||||
numVal = Math.min(numVal, item.max);
|
|
||||||
}
|
|
||||||
numVal = isNaN(numVal) ? 0 : numVal;
|
|
||||||
item.value = numVal;
|
|
||||||
} catch (error) {
|
|
||||||
console.log('handleInput方法错误:', error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
toback() {
|
|
||||||
uni.navigateBack()
|
|
||||||
},
|
|
||||||
selectShow(val, index) {
|
|
||||||
val.isShow = true
|
|
||||||
},
|
|
||||||
submitDevice() {
|
|
||||||
let smallParam = this.smallArr.reduce((pre, cur) => {
|
|
||||||
pre[cur.prop] = cur.type == "Switch" ? cur.value ? 1 : 0 : cur.value
|
|
||||||
pre[cur.prop] = Number(pre[cur.prop])
|
|
||||||
return pre
|
|
||||||
}, {})
|
|
||||||
console.log(this.mqttClient)
|
|
||||||
this.mqttClient.publish('presence', JSON.stringify({
|
|
||||||
fun: 'SET',
|
|
||||||
type: 'WJ_Set_NewControlSystem',
|
|
||||||
content: {
|
|
||||||
...this.backData,
|
|
||||||
params: {
|
|
||||||
...this.backData.params,
|
|
||||||
...smallParam
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.policeForm {
|
.policeForm {
|
||||||
margin: 22rpx;
|
margin: 22rpx;
|
||||||
padding: 22rpx;
|
padding: 22rpx;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
box-shadow: 0px 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
box-shadow: 0px 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.select-value {
|
||||||
|
padding: 16rpx 0;
|
||||||
|
color: #333;
|
||||||
|
min-height: 60rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -84,6 +84,8 @@
|
|||||||
|
|
||||||
{{ $t('homePage.home.emsControl') }}
|
{{ $t('homePage.home.emsControl') }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
@ -165,6 +167,7 @@
|
|||||||
return this.vuex_language
|
return this.vuex_language
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
currentStation: {
|
currentStation: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
@ -282,12 +285,18 @@
|
|||||||
this.userId = this.vuex_user.userId
|
this.userId = this.vuex_user.userId
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
toDeviceControl() {
|
toDeviceControl() {
|
||||||
console.log(123)
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pages/home-page/policy-Config/index'
|
url:'/pages/home-page/policy-Config/index'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
toStrategy(){
|
||||||
|
uni.navigateTo({
|
||||||
|
url:'/pages/home-page/strategy/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
confirmTime(val) {
|
confirmTime(val) {
|
||||||
this.formInfo.effectiveTime = val.hour + ':' + val.minute
|
this.formInfo.effectiveTime = val.hour + ':' + val.minute
|
||||||
this.formInfo.planRefreshH = val.hour
|
this.formInfo.planRefreshH = val.hour
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import config from '@/common/config.js';
|
import config from '@/common/config.js';
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
@ -6,20 +5,22 @@ Vue.use(Vuex)
|
|||||||
|
|
||||||
let lifeData = {};
|
let lifeData = {};
|
||||||
|
|
||||||
try{
|
try {
|
||||||
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
|
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
|
||||||
lifeData = uni.getStorageSync('lifeData');
|
lifeData = uni.getStorageSync('lifeData');
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
|
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
|
||||||
let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_remember', 'vuex_locale','vuex_isAgent','vuex_language','vuex_stationValue'];
|
let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_remember', 'vuex_locale', 'vuex_isAgent', 'vuex_language',
|
||||||
|
'vuex_stationValue'
|
||||||
|
];
|
||||||
|
|
||||||
// 保存变量到本地存储中
|
// 保存变量到本地存储中
|
||||||
const saveLifeData = function(key, value){
|
const saveLifeData = function(key, value) {
|
||||||
// 判断变量名是否在需要存储的数组中
|
// 判断变量名是否在需要存储的数组中
|
||||||
if(saveStateKeys.indexOf(key) != -1) {
|
if (saveStateKeys.indexOf(key) != -1) {
|
||||||
// 获取本地存储的lifeData对象,将变量添加到对象中
|
// 获取本地存储的lifeData对象,将变量添加到对象中
|
||||||
let tmp = uni.getStorageSync('lifeData');
|
let tmp = uni.getStorageSync('lifeData');
|
||||||
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
|
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
|
||||||
@ -49,47 +50,46 @@ const store = new Vuex.Store({
|
|||||||
vuex_isAgent: lifeData.vuex_isAgent ? lifeData.vuex_isAgent : '',
|
vuex_isAgent: lifeData.vuex_isAgent ? lifeData.vuex_isAgent : '',
|
||||||
vuex_iv: lifeData.vuex_iv ? lifeData.vuex_iv : '',
|
vuex_iv: lifeData.vuex_iv ? lifeData.vuex_iv : '',
|
||||||
vuex_psdkey: lifeData.vuex_psdkey ? lifeData.vuex_psdkey : '',
|
vuex_psdkey: lifeData.vuex_psdkey ? lifeData.vuex_psdkey : '',
|
||||||
vuex_StationShow:lifeData.vuex_StationShow ? lifeData.vuex_StationShow : [0,0,0],
|
vuex_StationShow: lifeData.vuex_StationShow ? lifeData.vuex_StationShow : [0, 0, 0],
|
||||||
tabbar_current: 0,
|
tabbar_current: 0,
|
||||||
vuex_stationValue:lifeData.vuex_stationValue ? lifeData.vuex_stationValue : '',
|
vuex_stationValue: lifeData.vuex_stationValue ? lifeData.vuex_stationValue : '',
|
||||||
vuex_inverterFlag:lifeData.vuex_inverterFlag ? lifeData.vuex_inverterFlag : 0,
|
vuex_inverterFlag: lifeData.vuex_inverterFlag ? lifeData.vuex_inverterFlag : 0,
|
||||||
tabbarList: [
|
tabbarList: [{
|
||||||
{
|
"icon": "warning",
|
||||||
"icon": "warning",
|
"text": "告警",
|
||||||
"text": "告警",
|
'name': 'Alarm'
|
||||||
'name': 'Alarm'
|
},
|
||||||
},
|
// {
|
||||||
// {
|
// "icon": "order",
|
||||||
// "icon": "order",
|
// "text": "设备",
|
||||||
// "text": "设备",
|
// 'name': 'Device'
|
||||||
// 'name': 'Device'
|
|
||||||
|
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
"icon": "moments",
|
"icon": "moments",
|
||||||
"text": "数据",
|
"text": "数据",
|
||||||
'name': 'Data'
|
'name': 'Data'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"icon": "attach",
|
"icon": "attach",
|
||||||
"text": "收益",
|
"text": "收益",
|
||||||
'name': 'Earnings'
|
'name': 'Earnings'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"icon": "attach",
|
"icon": "attach",
|
||||||
"text": "策略",
|
"text": "策略",
|
||||||
'name': 'Policy'
|
'name': 'Policy'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"icon": "account",
|
"icon": "account",
|
||||||
"text": "我的",
|
"text": "我的",
|
||||||
'name': 'My'
|
'name': 'My'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
vuex_language:"en_US",
|
vuex_language: "en_US",
|
||||||
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
|
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
|
||||||
vuex_config: config,
|
vuex_config: config,
|
||||||
vuex_currentComponent:'Data'
|
vuex_currentComponent: 'Data'
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
$uStore(state, payload) {
|
$uStore(state, payload) {
|
||||||
@ -97,9 +97,9 @@ const store = new Vuex.Store({
|
|||||||
let nameArr = payload.name.split('.');
|
let nameArr = payload.name.split('.');
|
||||||
let saveKey = '';
|
let saveKey = '';
|
||||||
let len = nameArr.length;
|
let len = nameArr.length;
|
||||||
if(len >= 2) {
|
if (len >= 2) {
|
||||||
let obj = state[nameArr[0]];
|
let obj = state[nameArr[0]];
|
||||||
for(let i = 1; i < len - 1; i ++) {
|
for (let i = 1; i < len - 1; i++) {
|
||||||
obj = obj[nameArr[i]];
|
obj = obj[nameArr[i]];
|
||||||
}
|
}
|
||||||
obj[nameArr[len - 1]] = payload.value;
|
obj[nameArr[len - 1]] = payload.value;
|
||||||
|
|||||||
Reference in New Issue
Block a user