mali-applet-ui 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <view class="ml-textarea">
3
+ <view v-if="readonly" class="content">{{ inpVal }}</view>
4
+ <view v-else>
5
+ <textarea class="textarea" v-model="inpVal" :rows="rows" :maxlength="maxLength" :placeholder="placeholder" @input="inputEvent" :style="{color:fontColor}"></textarea>
6
+ <view v-if="showWordLimit" class="word-count">
7
+ <VoiceInput v-if="showVoice" class="word-voice" v-model="inpVal" @input="inputEvent"></VoiceInput>
8
+ <view class="word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
9
+ </view>
10
+ </view>
11
+ </view>
12
+ </template>
13
+
14
+ <script>
15
+ import VoiceInput from './voice-input.vue'
16
+
17
+ export default {
18
+ name: 'ml-textarea',
19
+ components: {
20
+ VoiceInput
21
+ },
22
+ props: {
23
+ value: {
24
+ type: String,
25
+ default: ''
26
+ },
27
+ rows: {
28
+ type: Number,
29
+ default: 2
30
+ },
31
+ maxLength: {
32
+ type: Number,
33
+ default: 251
34
+ },
35
+ placeholder: {
36
+ type: String,
37
+ default: '请输入'
38
+ },
39
+ showWordLimit: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ readonly: {
44
+ type: Boolean,
45
+ default: false
46
+ },
47
+ showVoice: Boolean,
48
+ fontColor: String
49
+ },
50
+ data () {
51
+ return {
52
+ inpVal: ''
53
+ }
54
+ },
55
+ watch: {
56
+ value (val) {
57
+ this.inpVal = val
58
+ }
59
+ },
60
+ created () {
61
+ this.inpVal = this.value
62
+ },
63
+ methods: {
64
+ inputEvent () {
65
+ if (this.maxLength && this.inpVal && this.inpVal.length > this.maxLength) {
66
+ this.$emit('input', this.inpVal.slice(0, this.maxLength))
67
+ } else {
68
+ this.$emit('input', this.inpVal)
69
+ }
70
+ }
71
+ }
72
+ }
73
+ </script>
74
+
75
+ <style lang="scss">
76
+ .ml-textarea {
77
+ & > .content {
78
+ height: 280rpx;
79
+ width: 100%;
80
+ overflow: auto;
81
+ word-break: break-all;
82
+ }
83
+ .textarea {
84
+ color: rgba(39, 42, 48, 0.4500);
85
+ height: 280rpx;
86
+ width: 100%;
87
+ font-size:26rpx;
88
+ }
89
+ .word-count {
90
+ display: flex;
91
+ }
92
+ .word-numbers {
93
+ flex-grow: 1;
94
+ color: #999999;
95
+ font-size: 24rpx;
96
+ text-align: right;
97
+ padding-right: 20rpx;
98
+ }
99
+ }
100
+ </style>
@@ -0,0 +1,213 @@
1
+ <template>
2
+ <view>
3
+ <view class="voice-input" @click="openMarkDisplay">
4
+ <view class="voice-image">
5
+ <image class="img" src="/static/project/voice.png"></image>
6
+ </view>
7
+ <view class="voice-hint">语音输入</view>
8
+ </view>
9
+ <view class="voice-mark" @touchmove.stop.prevent v-if="showModal">
10
+ <textarea v-model="message" class="voice-area"></textarea>
11
+ <view class="flex justify-center align-center voice" :class="{ speaking: isSpeaking }" @touchstart="streamRecord" @touchend="streamRecordEnd">
12
+ <view class="voice-desc">按住说话</view>
13
+ <view v-show="isSpeaking" class="animation-Icon" :class="{ animation: showAnimation }"></view>
14
+ <image class="img" src="/static/icon-voice.png" @touchend="streamRecordEnd"></image>
15
+ </view>
16
+ <view class="bottom">
17
+ <view class="left" @click="closeMarkDisplay">取消</view>
18
+ <view @click="saveRecord" class="right">保存</view>
19
+ </view>
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ export default {
26
+ props: {
27
+ value: {
28
+ type: Boolean,
29
+ default: false
30
+ }
31
+ },
32
+ data() {
33
+ return {
34
+ isSpeaking: false,
35
+ showAnimation: false,
36
+ message: '',
37
+ showModal: false
38
+ }
39
+ },
40
+ methods: {
41
+ openMarkDisplay() {
42
+ this.showModal = true
43
+ if (!this.manager) {
44
+ this.plugin = requirePlugin('WechatSI')
45
+ this.manager = this.plugin.getRecordRecognitionManager()
46
+ }
47
+ },
48
+ closeMarkDisplay() {
49
+ this.showModal = false
50
+ },
51
+ streamRecord(e) {
52
+ e.preventDefault()
53
+ this.isSpeaking = true
54
+ this.manager.onStart = () => {
55
+ this.isSpeaking = true
56
+ this.$nextTick(function() {
57
+ this.showAnimation = true
58
+ })
59
+ }
60
+ this.manager.onStop = res => {
61
+ this.isSpeaking = false
62
+ const {
63
+ result
64
+ } = res
65
+ if (result.length === 0) {
66
+ return
67
+ }
68
+ this.message += result
69
+ }
70
+ this.manager.start({
71
+ lang: 'zh_CN'
72
+ })
73
+ },
74
+ streamRecordEnd() {
75
+ this.isSpeaking = false
76
+ this.showAnimation = false
77
+ this.manager.stop()
78
+ },
79
+ saveRecord() {
80
+ this.$emit('input', this.message)
81
+ this.closeMarkDisplay()
82
+ }
83
+ }
84
+ }
85
+ </script>
86
+
87
+ <style lang="scss">
88
+ .voice-input {
89
+ display: flex;
90
+ align-items: center;
91
+ .voice-image {
92
+ width: 46rpx;
93
+ height: 46rpx;
94
+
95
+ .img {
96
+ display: block;
97
+ width: 100%;
98
+ height: 100%;
99
+ }
100
+ }
101
+
102
+ .voice-hint {
103
+ color: #2497FF;
104
+ font-size: 26rpx;
105
+ }
106
+ }
107
+
108
+ .voice-mark {
109
+ position: fixed;
110
+ top: 0;
111
+ left: 0;
112
+ width: 100%;
113
+ height: 100%;
114
+ background-color: rgba(16, 35, 84, 0.83);
115
+ z-index: 99;
116
+
117
+ .voice-area {
118
+ width: 670rpx;
119
+ height: 380rpx;
120
+ padding: 25rpx;
121
+ border-radius: 23rpx;
122
+ background-color: #00BBF9;
123
+ color: #FFFFFF;
124
+ margin: 400rpx auto 0;
125
+ font-size: 28rpx;
126
+ }
127
+
128
+
129
+ .voice {
130
+ width: 200rpx;
131
+ height: 200rpx;
132
+ margin: 20rpx auto 60rpx auto;
133
+ position: relative;
134
+
135
+ .textColor {
136
+ color: #FFFFFF;
137
+ }
138
+
139
+ .img {
140
+ width: 100%;
141
+ height: 100%;
142
+ position: absolute;
143
+ display: block;
144
+ }
145
+
146
+ .speaking {
147
+ border-radius: 50%;
148
+ }
149
+
150
+ .voice-desc {
151
+ color: #fff;
152
+ position: absolute;
153
+ top: 186rpx;
154
+ z-index: 44;
155
+ }
156
+
157
+ .animation-Icon {
158
+ width: 100%;
159
+ height: 100%;
160
+
161
+ &.animation {
162
+ animation: voiceSpeaking linear 0.5s infinite forwards;
163
+ }
164
+ }
165
+
166
+ }
167
+
168
+ .bottom {
169
+ display: flex;
170
+ justify-content: space-between;
171
+ padding: 0 150rpx;
172
+
173
+ .left {
174
+ width: 180rpx;
175
+ height: 60rpx;
176
+ background-color: #FFFFFF;
177
+ text-align: center;
178
+ line-height: 60rpx;
179
+ border-radius: 30rpx;
180
+ color: #0AB3FE;
181
+ }
182
+
183
+ .right {
184
+ width: 180rpx;
185
+ height: 60rpx;
186
+ background: linear-gradient(270deg, #0AB4FF 0%, #017FF0 100%);
187
+ text-align: center;
188
+ line-height: 60rpx;
189
+ border-radius: 30rpx;
190
+ color: #FFFFFF;
191
+ }
192
+ }
193
+ }
194
+
195
+ @keyframes voiceSpeaking {
196
+ from {
197
+ background: radial-gradient(circle, #0076ee, #00bbf9);
198
+ transform: scale(1);
199
+ border-radius: 50%;
200
+ }
201
+
202
+ 50% {
203
+ transform: scale(1.1);
204
+ border-radius: 50%;
205
+ }
206
+
207
+ to {
208
+ background: radial-gradient(circle, #00bbf9, #0076ee);
209
+ transform: scale(1.2);
210
+ border-radius: 50%;
211
+ }
212
+ }
213
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",