Commit 46afb285d9a2406b7d2b0c2040513744762c5a90

Authored by fengwotao
1 parent 51cfeea8

feat:优化命令下发新增一个快捷复制

@@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
8 <u-icon v-if="deviceDetail.deviceInfo.longitude !== ''" @click="handleClick" name="map-fill"> 8 <u-icon v-if="deviceDetail.deviceInfo.longitude !== ''" @click="handleClick" name="map-fill">
9 </u-icon> 9 </u-icon>
10 </view> 10 </view>
11 - <view class="text-clip" style="margin-left: 20rpx;width:370rpx">{{ deviceDetail.alias? deviceDetail.alias: deviceDetail.name }}</view> 11 + <view class="text-clip" style="margin-left: 20rpx;width:370rpx">
  12 + {{ deviceDetail.alias? deviceDetail.alias: deviceDetail.name }}
  13 + </view>
12 <view style="margin-left: 20rpx; font-size: 14px;" 14 <view style="margin-left: 20rpx; font-size: 14px;"
13 :style="{ color: deviceDetail.deviceState === 'INACTIVE' ? '#666' : deviceDetail.deviceState === 'ONLINE' ? '#377DFF' : '#DE4437' }"> 15 :style="{ color: deviceDetail.deviceState === 'INACTIVE' ? '#666' : deviceDetail.deviceState === 'ONLINE' ? '#377DFF' : '#DE4437' }">
14 {{ deviceDetail.deviceState === 'INACTIVE' ? '待激活' : deviceDetail.deviceState === 'ONLINE' ? '在线' : '离线' }} 16 {{ deviceDetail.deviceState === 'INACTIVE' ? '待激活' : deviceDetail.deviceState === 'ONLINE' ? '在线' : '离线' }}
@@ -123,7 +125,12 @@ @@ -123,7 +125,12 @@
123 </u-radio-group> 125 </u-radio-group>
124 </view> 126 </view>
125 <view style="margin-top: 28rpx;width: 100%;"> 127 <view style="margin-top: 28rpx;width: 100%;">
126 - <u--textarea placeholder="请输入下发内容(json格式)" v-model="inputCommandVal" /> 128 + <div class="u-flex u-row-between">
  129 + <u--textarea placeholder="请输入下发内容(json格式)" v-model="inputCommandVal" />
  130 + <u-icon @click="handleCopy(copyTextValue)" name="question-circle" color="#2979ff" size="28"
  131 + class="ml-10">
  132 + </u-icon>
  133 + </div>
127 </view> 134 </view>
128 135
129 <view class="button-group"> 136 <view class="button-group">
@@ -157,6 +164,13 @@ @@ -157,6 +164,13 @@
157 }, 164 },
158 data() { 165 data() {
159 return { 166 return {
  167 + copyTextValue: {
  168 + "method": "methodThingskit",
  169 + "params": {
  170 + "pin": 7,
  171 + "value": 1
  172 + }
  173 + },
160 showNodal: false, 174 showNodal: false,
161 items: [{ 175 items: [{
162 value: 'OneWay', 176 value: 'OneWay',
@@ -202,6 +216,22 @@ @@ -202,6 +216,22 @@
202 this.modalName = null 216 this.modalName = null
203 }, 217 },
204 methods: { 218 methods: {
  219 + handleCopy(value) {
  220 + uni.showModal({
  221 + content: JSON.stringify(value), //模板中提示的内容
  222 + confirmText: '复制内容',
  223 + success: () => { //点击复制内容的后调函数
  224 + uni.setClipboardData({
  225 + data: JSON.stringify(value), //要被复制的内容
  226 + success: () => { //复制成功的回调函数
  227 + uni.showToast({ //提示
  228 + title: '复制成功'
  229 + })
  230 + }
  231 + });
  232 + }
  233 + });
  234 + },
205 radioChange: function(evt) { 235 radioChange: function(evt) {
206 for (let i = 0; i < this.items.length; i++) { 236 for (let i = 0; i < this.items.length; i++) {
207 if (this.items[i].value === evt.detail.value) { 237 if (this.items[i].value === evt.detail.value) {
@@ -247,9 +277,7 @@ @@ -247,9 +277,7 @@
247 cmdType: 'API' 277 cmdType: 'API'
248 }; 278 };
249 this.commandValue.method = 'methodThingskit'; 279 this.commandValue.method = 'methodThingskit';
250 - this.commandValue.params = {  
251 - params: commandJsonValue  
252 - }; 280 + this.commandValue.params = commandJsonValue
253 await issueCommand(this.commandType, this.deviceDetail.tbDeviceId, this.commandValue); 281 await issueCommand(this.commandType, this.deviceDetail.tbDeviceId, this.commandValue);
254 this.hiddenModal(); 282 this.hiddenModal();
255 uni.$u.toast('下发成功~'); 283 uni.$u.toast('下发成功~');