Commit 726d0b8a65d32b7122896c1a1f28d42606f31206

Authored by xp.Huang
2 parents cf016cd9 cfd49115

Merge branch 'ft_local_dev' into 'main'

pref:优化命令详情

See merge request huang/thingskit-app!90
@@ -71,7 +71,11 @@ export default { @@ -71,7 +71,11 @@ export default {
71 return formatToDate(date, 'YYYY-MM-DD HH:mm:ss'); 71 return formatToDate(date, 'YYYY-MM-DD HH:mm:ss');
72 }, 72 },
73 formatValue(value) { 73 formatValue(value) {
74 - return JSON.stringify(value); 74 + const val = JSON.stringify(value);
  75 + return val
  76 + .replace(/\\"/g, '"')
  77 + .replace(/]"/g, ']')
  78 + .replace(/"\[/g, '[');
75 } 79 }
76 }, 80 },
77 onLoad(options) { 81 onLoad(options) {
@@ -62,7 +62,7 @@ @@ -62,7 +62,7 @@
62 <u-radio activeColor="#3388FF" label="双向" name="TwoWay"></u-radio> 62 <u-radio activeColor="#3388FF" label="双向" name="TwoWay"></u-radio>
63 </u-radio-group> 63 </u-radio-group>
64 </view> 64 </view>
65 - <view style="margin-top: 28rpx;width: 100%;"><u--textarea placeholder="请输入下发内容" v-model="commandValue" /></view> 65 + <view style="margin-top: 28rpx;width: 100%;"><u--textarea placeholder="请输入下发内容(json格式)" v-model="inputCommandVal" /></view>
66 66
67 <view class="button-group"> 67 <view class="button-group">
68 <view><u-button :customStyle="{ color: '#333' }" color="#e3e3e5" shape="circle" text="取消" @click="cancelCommand"></u-button></view> 68 <view><u-button :customStyle="{ color: '#333' }" color="#e3e3e5" shape="circle" text="取消" @click="cancelCommand"></u-button></view>
@@ -87,13 +87,8 @@ export default { @@ -87,13 +87,8 @@ export default {
87 return { 87 return {
88 showModel: false, 88 showModel: false,
89 commandType: 'OneWay', 89 commandType: 'OneWay',
90 - commandValue: JSON.stringify({  
91 - method: 'methodThingskit',  
92 - params: {  
93 - method: 'methodThingskit',  
94 - params: { pin: 7, value: 1 }  
95 - }  
96 - }) 90 + commandValue: {},
  91 + inputCommandVal: ''
97 }; 92 };
98 }, 93 },
99 computed: { 94 computed: {
@@ -130,6 +125,7 @@ export default { @@ -130,6 +125,7 @@ export default {
130 }, 125 },
131 showModal() { 126 showModal() {
132 this.showModel = true; 127 this.showModel = true;
  128 + this.inputCommandVal = '';
133 }, 129 },
134 disabledScroll() { 130 disabledScroll() {
135 return; 131 return;
@@ -139,12 +135,16 @@ export default { @@ -139,12 +135,16 @@ export default {
139 }, 135 },
140 async confirmCommand() { 136 async confirmCommand() {
141 try { 137 try {
142 - const commandValue = JSON.parse(this.commandValue);  
143 - commandValue.persistent = true;  
144 - commandValue.additionalInfo = { 138 + const commandJsonValue = JSON.parse(this.inputCommandVal);
  139 + this.commandValue.persistent = true;
  140 + this.commandValue.additionalInfo = {
145 cmdType: 'API' 141 cmdType: 'API'
146 }; 142 };
147 - await issueCommand(this.commandType, this.deviceDetail.tbDeviceId, commandValue); 143 + this.commandValue.method = 'methodThingskit';
  144 + this.commandValue.params = {
  145 + params: commandJsonValue
  146 + };
  147 + await issueCommand(this.commandType, this.deviceDetail.tbDeviceId, this.commandValue);
148 this.hiddenModal(); 148 this.hiddenModal();
149 uni.$u.toast('下发成功~'); 149 uni.$u.toast('下发成功~');
150 } catch (e) { 150 } catch (e) {