mp-command-issuance.vue
2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
<view class="mp-u-modal">
<u-modal :mask-close-able="true" :show="showModal" closeOnClickOverlay :showConfirmButton="false"
@close="$emit('hideModal')" @touchmove.stop.prevent="disabledScroll" z-index="99999">
<view class="w-100 modal-content">
<view class="header-title">命令下发</view>
<view class="u-flex">
<text class="type-text">下发类型:</text>
<u-radio-group v-model="commandType" placement="row">
<u-radio activeColor="#3388FF" label="单向" name="OneWay"></u-radio>
<view style="margin: 0 20rpx;"></view>
<u-radio activeColor="#3388FF" label="双向" name="TwoWay"></u-radio>
</u-radio-group>
</view>
<view class="content-body">
<div class="u-flex u-row-between">
<u--textarea :placeholder="`请输入下发内容${isShowTCP?'(字符串格式)':'(json格式)'}`"
v-model="inputCommandVal" />
<u-icon v-if="!isShowTCP" @click="handleCopy(copyTextValue)" name="question-circle"
color="#2979ff" size="28" class="ml-10">
</u-icon>
</div>
</view>
<view class="button-group">
<view>
<u-button :customStyle="{ color: '#333' }" color="#e3e3e5" shape="circle" text="取消"
@click="cancelCommand"></u-button>
</view>
<view>
<u-button color="#3388ff" shape="circle" text="确认" @click="confirmCommand"></u-button>
</view>
</view>
</view>
</u-modal>
</view>
</template>
<script>
import {
useShowModal
} from '@/plugins/utils.js'
export default {
props: {
showModal: Boolean,
isShowTCP: Boolean
},
data() {
return {
current: 0,
commandType: 'OneWay',
inputCommandVal: '',
copyTextValue: {
"method": "methodThingskit",
"params": {
"pin": 7,
"value": 1
}
}
}
},
methods: {
cancelCommand() {
this.$emit('cancelCommand')
},
confirmCommand() {
this.$emit('confirmCommand', this.commandType, this.inputCommandVal)
},
handleCopy(value) {
useShowModal(JSON.stringify(value), '命令下发', '复制内容').then(res => {
uni.setClipboardData({
data: JSON.stringify(value),
success: () => {
uni.showToast({
title: '复制成功'
})
}
});
})
},
reset() {
this.commandType = 'OneWay'
this.inputCommandVal = ''
}
}
}
</script>
<style lang="scss" scoped>
.modal-content {
width: 720rpx;
padding: 0 30rpx;
background-color: white;
.header-title {
text-align: center;
font-weight: 700;
margin-bottom: 40rpx;
}
.type-text {
color: #333;
font-size: 14px;
font-weight: 700;
margin-right: 30rpx;
}
.content-body {
margin-top: 28rpx;
width: 100%;
}
.button-group {
display: flex;
margin-top: 40rpx;
justify-content: space-between;
view {
width: 300rpx;
}
}
}
</style>