|
@@ -5,7 +5,7 @@
|
5
|
5
|
<Input placeholder="字数不超过4个汉字或8个字母" size="large" v-model="menuTitle" clearable @input="toolClass.CutStr(menuTitle, 8, '字数不超过4个汉字或8个字母')" name="name" style="width: 300px"/>
|
6
|
6
|
<span class="error">{{toolClass.CutStr(menuTitle, 8, '字数不超过4个汉字或8个字母')}}</span>
|
7
|
7
|
</div>
|
8
|
|
- <div class="form-item">
|
|
8
|
+ <div class="form-item" v-if="hasContent">
|
9
|
9
|
<label for="name">菜单内容</label>
|
10
|
10
|
<RadioGroup v-model="type" >
|
11
|
11
|
<Radio label="发送消息"></Radio>
|
|
@@ -44,10 +44,28 @@
|
44
|
44
|
</Modal>
|
45
|
45
|
</div>
|
46
|
46
|
<div v-show="active === '图片'">
|
47
|
|
- 2
|
|
47
|
+ <div>
|
|
48
|
+ <Button type="info" @click="chooseImg">从素材库中选取</Button>
|
|
49
|
+ <Button type="success" @click="uploadImg">从本地上传图片</Button>
|
|
50
|
+ <Modal width='800' v-model="showMaterial" @on-ok="checkImg" @on-cancel="closeImg">
|
|
51
|
+ <material v-if="showMaterial" :type='materialType' :model='model' @emit='setImg'></material>
|
|
52
|
+ </Modal>
|
|
53
|
+ <div class="img-view">
|
|
54
|
+ <img v-if="img.url" :src="img.url">
|
|
55
|
+ </div>
|
|
56
|
+ </div>
|
48
|
57
|
</div>
|
49
|
58
|
<div v-show="active === '图文'">
|
50
|
|
- 3
|
|
59
|
+ <div>
|
|
60
|
+ <Button type="info" @click="chooseView">从素材库中选取</Button>
|
|
61
|
+ <Modal width='800' v-model="showMaterialView" @on-ok="checkView" @on-cancel="closeView">
|
|
62
|
+ <material v-if="showMaterialView" :type='materialType' :model='model' @emit='setView'></material>
|
|
63
|
+ </Modal>
|
|
64
|
+ <div class="img-view">
|
|
65
|
+ <img v-if="view.url" :src="view.url">
|
|
66
|
+ <p v-if="view.text">{{view.text}}</p>
|
|
67
|
+ </div>
|
|
68
|
+ </div>
|
51
|
69
|
</div>
|
52
|
70
|
</div>
|
53
|
71
|
<div v-if="type === '跳转网页'" class="type-content">
|
|
@@ -59,7 +77,7 @@
|
59
|
77
|
</div>
|
60
|
78
|
<div class="btn-group">
|
61
|
79
|
<Button type="primary" @click="emit">确认</Button>
|
62
|
|
- <Button @click="delMenu">删除当前菜单</Button>
|
|
80
|
+ <Button v-if="hasDelete" @click="delMenu">删除当前菜单</Button>
|
63
|
81
|
</div>
|
64
|
82
|
</div>
|
65
|
83
|
</template>
|
|
@@ -67,8 +85,9 @@
|
67
|
85
|
<script>
|
68
|
86
|
|
69
|
87
|
import Emotion from '@/components/Emotion/index'
|
|
88
|
+import material from '@/components/material'
|
70
|
89
|
export default {
|
71
|
|
- props: ['menuConfig'],
|
|
90
|
+ props: ['data', 'menuConfig', 'hasContent', 'hasDelete'],
|
72
|
91
|
data () {
|
73
|
92
|
return {
|
74
|
93
|
active: '文字',
|
|
@@ -80,13 +99,50 @@ export default {
|
80
|
99
|
menuTitle: '',
|
81
|
100
|
text: '',
|
82
|
101
|
linkText: '',
|
83
|
|
- linkHref: ''
|
|
102
|
+ linkHref: '',
|
|
103
|
+ showMaterial: false,
|
|
104
|
+ showMaterialView: false,
|
|
105
|
+ model: 'get',
|
|
106
|
+ materialType: 'img',
|
|
107
|
+ imghc: {},
|
|
108
|
+ viewhc: {},
|
|
109
|
+ img: {
|
|
110
|
+ media_id: '',
|
|
111
|
+ url: ''
|
|
112
|
+ },
|
|
113
|
+ view: {
|
|
114
|
+ media_id: '',
|
|
115
|
+ url: '',
|
|
116
|
+ text: ''
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+ },
|
|
120
|
+ created () {
|
|
121
|
+ if (!this.hasContent) {
|
|
122
|
+ this.type = null
|
|
123
|
+ }
|
|
124
|
+ if (this.data) {
|
|
125
|
+ if (this.menuConfig) {
|
|
126
|
+ this.menuTitle = this.data.name
|
|
127
|
+ }
|
|
128
|
+ if (this.data.type === 'text') {
|
|
129
|
+ this.active = '文字'
|
|
130
|
+ this.text = this.data.value
|
|
131
|
+ } else if (this.data.type === 'media_id') {
|
|
132
|
+ this.active = '图片'
|
|
133
|
+ this.img.media_id = this.data.media_id
|
|
134
|
+ this.img.url = this.data.url
|
|
135
|
+ } else if (this.data.type === 'view_limited') {
|
|
136
|
+ this.active = '图文'
|
|
137
|
+ this.view.media_id = this.data.media_id
|
|
138
|
+ this.view.url = this.data.url
|
|
139
|
+ } else if (this.data.type === 'view') {
|
|
140
|
+ this.type = '跳转网页'
|
|
141
|
+ this.linkHref = this.data.url
|
|
142
|
+ }
|
84
|
143
|
}
|
85
|
144
|
},
|
86
|
145
|
methods: {
|
87
|
|
- check () {
|
88
|
|
- console.log(this.error)
|
89
|
|
- },
|
90
|
146
|
checkLink () {
|
91
|
147
|
if (!this.linkText) {
|
92
|
148
|
this.$Message.warning('链接名称必填')
|
|
@@ -121,13 +177,48 @@ export default {
|
121
|
177
|
let index = list.indexOf(word)
|
122
|
178
|
return `<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/${index}.gif" align="middle">`
|
123
|
179
|
},
|
|
180
|
+ setImg (img) {
|
|
181
|
+ this.imghc = img
|
|
182
|
+ },
|
|
183
|
+ checkImg () {
|
|
184
|
+ this.img = this.imghc
|
|
185
|
+ this.closeImg()
|
|
186
|
+ },
|
|
187
|
+ closeImg () {
|
|
188
|
+ this.imghc = {}
|
|
189
|
+ this.showMaterial = false
|
|
190
|
+ },
|
|
191
|
+ chooseImg () {
|
|
192
|
+ this.model = 'get'
|
|
193
|
+ this.materialType = 'img'
|
|
194
|
+ this.showMaterial = true
|
|
195
|
+ },
|
|
196
|
+ uploadImg () {
|
|
197
|
+
|
|
198
|
+ },
|
|
199
|
+ setView (view) {
|
|
200
|
+ this.viewhc = view
|
|
201
|
+ },
|
|
202
|
+ checkView () {
|
|
203
|
+ this.view = this.viewhc
|
|
204
|
+ this.closeView()
|
|
205
|
+ },
|
|
206
|
+ chooseView () {
|
|
207
|
+ this.model = 'get'
|
|
208
|
+ this.materialType = 'view'
|
|
209
|
+ this.showMaterialView = true
|
|
210
|
+ },
|
|
211
|
+ closeView () {
|
|
212
|
+ this.viewhc = {}
|
|
213
|
+ this.showMaterialView = false
|
|
214
|
+ },
|
124
|
215
|
emit () {
|
125
|
216
|
let emitData = {}
|
126
|
217
|
if (this.menuConfig) {
|
127
|
218
|
if (!this.menuTitle) {
|
128
|
219
|
this.$Message.warning('菜单名称必填')
|
129
|
220
|
return false
|
130
|
|
- } else if (this.toolClass.CutStr(this.menuTitle, 8, '字数不超过4个汉字或8个字母') ) {
|
|
221
|
+ } else if (this.toolClass.CutStr(this.menuTitle, 8, '字数不超过4个汉字或8个字母')) {
|
131
|
222
|
this.$Message.warning('菜单名称超过4个汉字或8个字母')
|
132
|
223
|
return false
|
133
|
224
|
}
|
|
@@ -135,12 +226,26 @@ export default {
|
135
|
226
|
}
|
136
|
227
|
if (this.type === '发送消息') {
|
137
|
228
|
if (this.active === '文字') {
|
138
|
|
- if (!this.text){
|
|
229
|
+ if (!this.text) {
|
139
|
230
|
this.$Message.warning('消息文字必填')
|
140
|
231
|
return false
|
141
|
232
|
}
|
142
|
233
|
emitData.type = 'text'
|
143
|
234
|
emitData.value = this.text
|
|
235
|
+ } else if (this.active === '图片') {
|
|
236
|
+ if (!this.img.media_id) {
|
|
237
|
+ this.$Message.warning('请选择素材')
|
|
238
|
+ return false
|
|
239
|
+ }
|
|
240
|
+ emitData.type = 'media_id'
|
|
241
|
+ emitData.media_id = this.img.media_id
|
|
242
|
+ } else if (this.active === '图文') {
|
|
243
|
+ if (!this.view.media_id) {
|
|
244
|
+ this.$Message.warning('请选择素材')
|
|
245
|
+ return false
|
|
246
|
+ }
|
|
247
|
+ emitData.type = 'view_limited'
|
|
248
|
+ emitData.media_id = this.view.media_id
|
144
|
249
|
}
|
145
|
250
|
} else if (this.type === '跳转网页') {
|
146
|
251
|
if (this.errors.first('link')) {
|
|
@@ -151,13 +256,15 @@ export default {
|
151
|
256
|
emitData.type = 'view'
|
152
|
257
|
emitData.url = this.linkHref
|
153
|
258
|
}
|
|
259
|
+ this.$emit('emit', emitData)
|
154
|
260
|
},
|
155
|
261
|
delMenu () {
|
156
|
262
|
|
157
|
|
- }
|
|
263
|
+ },
|
158
|
264
|
},
|
159
|
265
|
components: {
|
160
|
|
- Emotion
|
|
266
|
+ Emotion,
|
|
267
|
+ material
|
161
|
268
|
}
|
162
|
269
|
}
|
163
|
270
|
</script>
|
|
@@ -165,6 +272,7 @@ export default {
|
165
|
272
|
<style lang="scss" scoped>
|
166
|
273
|
.box {
|
167
|
274
|
padding: 50px;
|
|
275
|
+ text-align: center;
|
168
|
276
|
.form-item {
|
169
|
277
|
display: flex;
|
170
|
278
|
justify-content: flex-start;
|
|
@@ -188,7 +296,7 @@ export default {
|
188
|
296
|
align-items: center;
|
189
|
297
|
}
|
190
|
298
|
button {
|
191
|
|
- margin-right: 40px;
|
|
299
|
+ margin: 0 20px;
|
192
|
300
|
}
|
193
|
301
|
.expression {
|
194
|
302
|
position: absolute;
|
|
@@ -201,5 +309,22 @@ export default {
|
201
|
309
|
border-radius: 5px;
|
202
|
310
|
text-align: center;
|
203
|
311
|
}
|
|
312
|
+ .img-view {
|
|
313
|
+ width: 200px;
|
|
314
|
+ height: 200px;
|
|
315
|
+ margin: 20px auto 0;
|
|
316
|
+ img {
|
|
317
|
+ width: 100%;
|
|
318
|
+ height: 100%;
|
|
319
|
+ object-fit: cover;
|
|
320
|
+ }
|
|
321
|
+ p {
|
|
322
|
+ padding-top: 8px;
|
|
323
|
+ width: 100%;
|
|
324
|
+ overflow: hidden;
|
|
325
|
+ text-overflow: ellipsis;
|
|
326
|
+ white-space: nowrap;
|
|
327
|
+ }
|
|
328
|
+ }
|
204
|
329
|
}
|
205
|
330
|
</style>
|