|
|
@@ -24,38 +24,38 @@
|
|
|
<view class="device-detail-item">
|
|
|
<text class="device-detail-label">联网模块</text>
|
|
|
<view class="device-detail-btn-container">
|
|
|
- <view class="device-detail-btn">升级</view>
|
|
|
- <view class="device-detail-btn">重启</view>
|
|
|
- <view class="device-detail-btn">MQTT配置</view>
|
|
|
+ <view class="device-detail-btn" @click="setDeviceContorl('dtu_update')">升级</view>
|
|
|
+ <view class="device-detail-btn" @click="setDeviceContorl('dtu_reboot')">重启</view>
|
|
|
+ <!-- <view class="device-detail-btn" @click="showMqttConfig">MQTT配置</view> -->
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="device-detail-item">
|
|
|
<text class="device-detail-label">板子设置</text>
|
|
|
<view class="device-detail-btn-container">
|
|
|
- <view class="device-detail-btn">查看原始IMEI</view>
|
|
|
- <view class="device-detail-btn">更改IMEI</view>
|
|
|
+ <!-- <view class="device-detail-btn">查看原始IMEI</view> -->
|
|
|
+ <view class="device-detail-btn" @click="showMqttConfig('imei')">更改IMEI</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="device-detail-item">
|
|
|
<text class="device-detail-label">强制操作</text>
|
|
|
<view class="device-detail-btn-container">
|
|
|
- <view class="device-detail-btn force-btn">拍照</view>
|
|
|
- <view class="device-detail-btn force-btn">升级</view>
|
|
|
- <view class="device-detail-btn force-btn">重启</view>
|
|
|
- <view class="device-detail-btn force-btn">震动关闭</view>
|
|
|
- <view class="device-detail-btn force-btn">震动开启</view>
|
|
|
+ <view class="device-detail-btn force-btn" @click="setDeviceContorl('takephoto')">拍照</view>
|
|
|
+ <view class="device-detail-btn force-btn" @click="setDeviceContorl('update')">升级</view>
|
|
|
+ <view class="device-detail-btn force-btn" @click="setDeviceContorl('reboot')">重启</view>
|
|
|
+ <view class="device-detail-btn force-btn" @click="setDeviceContorl('open_shake')">震动开启</view>
|
|
|
+ <view class="device-detail-btn force-btn" @click="setDeviceContorl('close_shake')">震动关闭</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="device-detail-content" style="padding-bottom: 50rpx" v-if="activeTab === 'viewImage'">
|
|
|
<view class="device-detail-viewImage">
|
|
|
- <text class="device-detail-label">联网模块</text>
|
|
|
- <u-switch v-model="checked" size="40" active-color="#0BBC58"></u-switch>
|
|
|
+ <text class="device-detail-label">设备开关:</text>
|
|
|
+ <u-switch v-model="equipContrlForm.ds" size="40" active-color="#0BBC58" active-value="1" inactive-value="0"></u-switch>
|
|
|
</view>
|
|
|
<view class="device-detail-viewImage">
|
|
|
<text class="device-detail-label">定时模式</text>
|
|
|
</view>
|
|
|
- <u-radio-group v-model="value" @change="radioGroupChange" active-color="#0BBC58">
|
|
|
+ <u-radio-group v-model="equipContrlForm.ts" @change="radioGroupChange" active-color="#0BBC58">
|
|
|
<u-radio
|
|
|
:name="0"
|
|
|
>光控
|
|
|
@@ -68,32 +68,43 @@
|
|
|
<view class="device-detail-viewImage">
|
|
|
<text class="device-detail-label">落虫时间(min)</text>
|
|
|
</view>
|
|
|
- <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
+ <u-slider v-model="equipContrlForm.collt" style="width:100%" max="20" active-color="#0BBC58"></u-slider>
|
|
|
<view class="device-detail-viewImage">
|
|
|
<text class="device-detail-label">加热时间(min)</text>
|
|
|
</view>
|
|
|
- <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
+ <u-slider v-model="equipContrlForm.htim" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
<view class="device-detail-viewImage">
|
|
|
<text class="device-detail-label">加热温度(℃)</text>
|
|
|
</view>
|
|
|
- <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
+ <u-slider v-model="equipContrlForm.hst" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
<view class="device-detail-viewImage">
|
|
|
<text class="device-detail-label">高温保护阀值(℃)</text>
|
|
|
</view>
|
|
|
- <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
+ <u-slider v-model="equipContrlForm.tph" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
<view class="device-detail-viewImage">
|
|
|
<text class="device-detail-label">低温保护阀值(℃)</text>
|
|
|
</view>
|
|
|
- <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
+ <u-slider v-model="equipContrlForm.tpl" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
|
|
|
<view class="device-detail-viewImage">
|
|
|
<text class="device-detail-label">数据上传间隔(min)</text>
|
|
|
</view>
|
|
|
- <u-slider v-model="value" style="width:100%;" max="100" active-color="#0BBC58"></u-slider>
|
|
|
+ <u-slider v-model="equipContrlForm.datt" style="width:100%;" max="100" active-color="#0BBC58"></u-slider>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="device-detail-btn-footer">
|
|
|
- <view class="device-detail-btn">保存</view>
|
|
|
+ <view class="device-detail-btn-footer" v-if="activeTab === 'viewImage'">
|
|
|
+ <view class="device-detail-btn" @click="saveSettings">保存</view>
|
|
|
</view>
|
|
|
+ <u-popup v-model="show" mode="bottom">
|
|
|
+ <view class="device-detail-content" style="height: 50vh">
|
|
|
+ <view class="device-detail-item">
|
|
|
+ <text class="device-detail-label">请输入imei</text>
|
|
|
+ <u-input v-model="equipContrlForm.imei" placeholder="请输入imei"></u-input>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="device-detail-btn-footer">
|
|
|
+ <view class="device-detail-btn" @click="setDeviceContorl('imei')">保存</view>
|
|
|
+ </view>
|
|
|
+ </u-popup>
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
@@ -103,15 +114,21 @@ export default {
|
|
|
return {
|
|
|
value: 10,
|
|
|
imageList: [],
|
|
|
- deviceInfo: {},
|
|
|
+ equipContrlForm: {},
|
|
|
time: '',
|
|
|
activeTab: 'pestAnalysis',
|
|
|
title: '设置控制',
|
|
|
deviceType: '',
|
|
|
location: '',
|
|
|
+ d_id: '',
|
|
|
+ show: false,
|
|
|
checked: false
|
|
|
}
|
|
|
},
|
|
|
+ onLoad(options){
|
|
|
+ this.d_id = options.d_id
|
|
|
+ this.getControlDeviceConfigInfo()
|
|
|
+ },
|
|
|
methods: {
|
|
|
handleBack() {
|
|
|
uni.navigateBack({
|
|
|
@@ -120,7 +137,95 @@ export default {
|
|
|
},
|
|
|
handleTabClick(tab) {
|
|
|
this.activeTab = tab;
|
|
|
- }
|
|
|
+ },
|
|
|
+ showMqttConfig(){
|
|
|
+ this.show = true;
|
|
|
+ },
|
|
|
+ closeMqttConfig(){
|
|
|
+ this.show = false;
|
|
|
+ },
|
|
|
+ async setDeviceContorl(type){
|
|
|
+ const data = {
|
|
|
+ device_type_id: 3,
|
|
|
+ d_id: this.d_id,
|
|
|
+ cmd: type,
|
|
|
+ }
|
|
|
+ if(type === 'imei'){
|
|
|
+ data.imei = this.equipContrlForm.imei
|
|
|
+ }else{
|
|
|
+ delete data.imei
|
|
|
+ }
|
|
|
+ this.$myRequest({
|
|
|
+ url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
|
|
|
+ method: 'POST',
|
|
|
+ data
|
|
|
+ }).then(res => {
|
|
|
+ this.closeMqttConfig()
|
|
|
+ if (res) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '设备控制修改成功!',
|
|
|
+ icon: 'success',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '设备控制修改失败',
|
|
|
+ icon: 'error',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ saveSettings(){
|
|
|
+ let newForm = Object.assign({}, this.equipContrlForm) // 深拷贝
|
|
|
+ newForm.st = newForm.st + ''
|
|
|
+ newForm.et = newForm.et + ''
|
|
|
+ newForm.st && newForm.st.slice(0, 2).charAt(0) != '0'
|
|
|
+ ? newForm.st.slice(0, 2)
|
|
|
+ : newForm.st.slice(1, 2)
|
|
|
+ newForm.et =
|
|
|
+ newForm.et && newForm.et.slice(0, 2).charAt(0) != '0'
|
|
|
+ ? newForm.et.slice(0, 2)
|
|
|
+ : newForm.et.slice(1, 2)
|
|
|
+
|
|
|
+ for (let k in newForm) {
|
|
|
+ if (typeof newForm[k] === 'number') {
|
|
|
+ newForm[k] = newForm[k] + ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newForm.st = newForm.st.replace(':00', '')
|
|
|
+ this.$myRequest({
|
|
|
+ url: '/api/api_gateway?method=forecast.send_control.device_control',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ device_type_id: 3,
|
|
|
+ d_id: this.d_id,
|
|
|
+ config: JSON.stringify(newForm)
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res) {
|
|
|
+ // 设备控制修改成功
|
|
|
+ uni.showToast({
|
|
|
+ title: '设备控制修改成功!',
|
|
|
+ icon: 'success',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '设备控制修改失败',
|
|
|
+ icon: 'error',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async getControlDeviceConfigInfo(){
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ url: '/api/api_gateway?method=forecast.send_control.device_control_info',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ d_id: this.d_id,
|
|
|
+ cmd:'paramconf'
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.equipContrlForm = res
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|