yuantianjiao 6 anos atrás
pai
commit
2ba6f819cf

+ 30
- 0
src/components/Emotion/Emotion.vue Ver arquivo

@@ -0,0 +1,30 @@
1
+<template>
2
+  <div class="ly-emotion" >
3
+    <slot></slot>
4
+  </div>
5
+</template>
6
+
7
+<script>
8
+export default {
9
+  name: 'ly-emotion',
10
+  mounted () {
11
+    const name = this.$el.innerHTML
12
+    const list = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴', '睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过', '酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢', '饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂', '疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见', '擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠', '鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀', '西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰', '凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀', '足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强', '弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你', 'NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈', '磕头', '回头', '跳绳', '挥手', '激动', '街舞', '献吻', '左太极', '右太极']
13
+    let index = list.indexOf(name)
14
+    let imgHTML = `<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/${index}.gif">`
15
+    this.$nextTick(() => {
16
+      this.$el.innerHTML = imgHTML
17
+    })
18
+  },
19
+}
20
+</script>
21
+<style scoped>
22
+.ly-emotion {
23
+  display: inline-block
24
+}
25
+.ly-static-emotion {
26
+  width: 24px;
27
+  height: 24px;
28
+  display: inline-block;
29
+}
30
+</style>

+ 73
- 0
src/components/Emotion/index.vue Ver arquivo

@@ -0,0 +1,73 @@
1
+<template>
2
+  <div>
3
+    <div class="emotion-box" :style="{height: height + 'px' }" >
4
+      <div class="emotion-box-line" v-for="(line, i) in list" :key="i" >
5
+        <emotion class="emotion-item" v-for="(item, i) in line" :key="i" @click.native="clickHandler(item)" >{{item}}</emotion>
6
+      </div>
7
+    </div>
8
+  </div>
9
+</template>
10
+
11
+<script>
12
+import Emotion from './Emotion'
13
+export default {
14
+  props: {
15
+    height: {
16
+      type: Number,
17
+      default: 200,
18
+    }
19
+  },
20
+  data () {
21
+    return {
22
+      list: [
23
+        ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴'],
24
+        ['睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过'],
25
+        ['酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢'],
26
+        ['饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂'],
27
+        ['疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见'],
28
+        ['擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠'],
29
+        ['鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀'],
30
+        ['西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰',],
31
+        ['凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀'],
32
+        ['足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强'],
33
+        ['弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你'],
34
+        ['NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈'],
35
+        ['磕头', '回头', '跳绳', '挥手', '激动', '街舞', '左太极', '右太极'],
36
+      ]
37
+    }
38
+  },
39
+  methods: {
40
+    clickHandler (i) {
41
+      let emotion = `#${i};`
42
+      this.$emit('emotion', emotion)
43
+    }
44
+  },
45
+  components: {
46
+    Emotion
47
+  }
48
+}
49
+</script>
50
+<style scoped>
51
+.emotion-box {
52
+  margin: 0 auto;
53
+  width: 100%;
54
+  box-sizing: border-box;
55
+  padding: 5px;
56
+  box-shadow: 0 0 5px 2px #eee;
57
+  overflow: hidden;
58
+  overflow-y: auto;
59
+  background-color: #fff;
60
+  border-radius: 5px;
61
+}
62
+.emotion-box::-webkit-scrollbar {
63
+  display: none;
64
+}
65
+.emotion-box-line {
66
+  display: flex;
67
+}
68
+.emotion-item {
69
+  flex: 1;
70
+  text-align: center;
71
+  cursor: pointer;
72
+}
73
+</style>

+ 101
- 11
src/components/menuForm.vue Ver arquivo

@@ -13,14 +13,42 @@
13 13
       </RadioGroup>
14 14
       <span class="error">{{errors.first('name')}}</span>
15 15
     </div>
16
-    <div v-if="type === '发送消息'">
17
-      <RadioGroup v-model="active" type="button" size="large">
16
+    <div v-if="type === '发送消息'" class="type-content">
17
+      <RadioGroup v-model="active" type="button" size="large" style="padding-bottom:20px">
18 18
         <Radio label="文字"></Radio>
19 19
         <Radio label="图片"></Radio>
20 20
         <Radio label="图文"></Radio>
21 21
       </RadioGroup>
22 22
       <div v-show="active === '文字'">
23
-        1
23
+        <Input type="textarea" v-model="text" :rows="4" placeholder="输入消息文字" />
24
+        <div style="padding-top:20px;">
25
+          <Button @click="showExpression = !showExpression">
26
+            <Icon type="ios-sad-outline" size='20'/>
27
+          </Button>
28
+          <Button @click="showLink = !showLink">
29
+            <Icon type="ios-link-outline" size='20'/>
30
+          </Button>
31
+        </div>
32
+        <div class="expression" v-show="showExpression">
33
+          <emotion @emotion="handleEmotion" :height="200"></emotion>
34
+        </div>
35
+        <div class="link" v-show="showLink">
36
+          <div class="form-item">
37
+            <label for="name">链接文字</label>
38
+            <Input placeholder="链接文字" size="large" v-model="linkText" clearable name="text" style="width: 300px"/>
39
+          </div>
40
+          <div class="form-item">
41
+            <label for="name">链接&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
42
+            <Input placeholder="链接" v-validate="'url:require_protocol'" size="large" v-model="linkHref" clearable name="link" style="width: 300px"/>
43
+            <span class="error" v-show="errors.first('link')">请输入正确的url</span>
44
+          </div>
45
+          <Button type="primary" @click="checkLink()">
46
+            确定
47
+          </Button>
48
+          <Button @click="showLink = false">
49
+            取消
50
+          </Button>
51
+        </div>
24 52
       </div>
25 53
       <div v-show="active === '图片'">
26 54
         2
@@ -29,11 +57,23 @@
29 57
         3
30 58
       </div>
31 59
     </div>
32
-    <div v-if="type === '跳转网页'">
33
-
60
+    <div v-if="type === '跳转网页'" class="type-content">
61
+      <div class="link">
62
+        <div class="form-item">
63
+          <label for="name">链接&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
64
+          <Input placeholder="链接" v-validate="'url:require_protocol'" size="large" v-model="linkHref" clearable name="link" style="width: 300px"/>
65
+          <span class="error" v-show="errors.first('link')">请输入正确的url</span>
66
+        </div>
67
+        <Button type="primary" @click="checkLink()">
68
+          确定
69
+        </Button>
70
+        <Button @click="showLink = false">
71
+          取消
72
+        </Button>
73
+      </div>
34 74
     </div>
35 75
     <div class="btn-group">
36
-      <Button type="primary" style="color:#fff;" @click="1">确认</Button>
76
+      <Button type="primary" @click="1">确认</Button>
37 77
       <Button @click="2">删除当前菜单</Button>
38 78
     </div>
39 79
     
@@ -41,19 +81,50 @@
41 81
 </template>
42 82
 
43 83
 <script>
84
+
85
+import Emotion from '@/components/Emotion/index'
44 86
 export default {
45 87
   props: [''],
46 88
   data () {
47 89
     return {
48 90
       active: '文字',
49
-      type: '发送消息'
91
+      type: '发送消息',
92
+      content: '',
93
+      comment: '',
94
+      showExpression: false,
95
+      showLink: false,
96
+      text: '',
97
+      linkText: '',
98
+      linkHref: ''
50 99
     }
51 100
   },
52 101
   methods: {
53 102
     check () {
54 103
       console.log(this.error)
104
+    },
105
+    checkLink () {
106
+      let text = `<a href='${this.linkHref}'>${this.linkText}</a>`
107
+      this.text += text
108
+      this.linkText = ''
109
+      this.linkHref = ''
110
+      this.showLink = false
111
+    },
112
+    handleEmotion (i) {
113
+      this.content = i
114
+      this.text += this.content
115
+      this.showExpression = false
116
+    },
117
+    // 将匹配结果替换表情图片
118
+    emotion (res) {
119
+      let word = res.replace(/#|;/gi, '')
120
+      const list = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴', '睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过', '酷', '冷汗', '抓狂', '吐', '偷笑', '可爱', '白眼', '傲慢', '饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂', '疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见', '擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠', '鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀', '西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰', '凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀', '足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强', '弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你', 'NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈', '磕头', '回头', '跳绳', '挥手', '激动', '街舞', '献吻', '左太极', '右太极']
121
+      let index = list.indexOf(word)
122
+      return `<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/${index}.gif" align="middle">`
55 123
     }
56 124
   },
125
+  components: {
126
+    Emotion
127
+  }
57 128
 }
58 129
 </script>
59 130
 
@@ -73,13 +144,32 @@ export default {
73 144
       padding-left: 20px;
74 145
     }
75 146
   }
76
-  .btn-group{
147
+  .type-content {
148
+    position: relative;
149
+    height: 475px;
150
+  }
151
+  .btn-group {
77 152
     display: flex;
78 153
     justify-content: center;
79 154
     align-items: center;
80
-    Button{
81
-      margin-right: 40px;
82
-    }
155
+  }
156
+  button {
157
+    margin-right: 40px;
158
+  }
159
+  .expression {
160
+    position: absolute;
161
+    bottom: 50px;
162
+    left: 0px;
163
+    width: 400px;
164
+  }
165
+  .link {
166
+    position: absolute;
167
+    bottom: 45px;
168
+    left: 450px;
169
+    box-shadow: 0 0 5px 2px #eee;
170
+    padding: 20px;
171
+    border-radius: 5px;
172
+    text-align: center;
83 173
   }
84 174
 }
85 175
 </style>