marketing.vue
8.49 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<template>
<div class="marking-container" v-if="flag">
<div class="marking-container-content m-b-16">
<div class="font-16 color-3 fw5 m-b-12 line-24">发送内容</div>
<template v-if="marketingDetails.attachmentList && marketingDetails.attachmentList.length > 0">
<div v-for="(item, index) in marketingDetails.attachmentList" :key="index">
<template v-if="item.attType == 1">
<div class="font-14 color-3 m-b-12" v-html="item.attContent"></div>
</template>
<template v-else-if="item.attType == 2">
<div class="marking-image m-b-12">
<img :src="item.attContent" />
</div>
</template>
<template v-else-if="item.attType == 7">
<div class="preview-activity">
<img class="applet-logo" src="@/assets/images/solicit/icon-applet.png" alt />
<span style="color: #999; line-height:18px">小程序</span>
<div class="activity-name">{{ activityContent[item.attContent.marketingType] }}</div>
<img v-if="item.attContent.marketingType == 1 || item.attContent.marketingType == 2" class="activity-logo" src="@/assets/images/solicit/activity-logo.png" alt />
<img v-if="item.attContent.marketingType == 3 || item.attContent.marketingType == 4" class="activity-logo" src="@/assets/images/solicit/activity-equity.png" alt />
<img v-if="item.attContent.marketingType == 5" class="activity-logo" src="@/assets/images/solicit/activity-spike.png" alt />
<div class="activity-footer">
<img src="@/assets/images/solicit/applet-footer.png" alt />
<span>小程序</span>
</div>
</div>
</template>
</div>
<!-- <div class="font-14 color-3">尊敬的客户,您好!我店本月推出自费喷漆特惠活动,折扣后单面喷漆低至200元,点击下方链接享受优惠:</div> -->
</template>
<template v-else>
<empty class="marking-empty" description="门店尚未针对该人群设置营销物料"></empty>
</template>
</div>
<div class="marking-container-customer flex-between">
<div class="font-16 color-3 fw5">发送客户</div>
<div class="color-2f font-14 flex" @click="goTo('solicit.customer')">
共{{ marketingDetails.customerInfoList ? marketingDetails.customerInfoList.length : 0 }}人
<div class="sprite-icon icon-arrow m-l-8"></div>
</div>
</div>
<div class="footer">
<div
:class="{
'marking-button': true,
disabled: !marketingDetails.attachmentList || !marketingDetails.customerInfoList || (marketingDetails.customerInfoList && marketingDetails.customerInfoList.length == 0)
}"
@click="sendHandle"
>
一键发送
</div>
</div>
</div>
</template>
<script>
const activityContent = {
2: '送您一张商城优惠券',
3: '送您一张专属权益服务卡',
4: '专属权益服务套餐',
5: '您有一个秒杀活动可参加'
}
import { solicitApi } from '@/api'
import { Toast, Notify } from 'vant'
import { mapState, mapMutations } from 'vuex'
import emoji from '@/utils/emo'
export default {
data() {
return {
flag:false,
activityContent,
isEmpty: true,
marketingDetails: {
customerInfoList: [],
attachmentList: []
}
}
},
created() {
this.groupId = this.getQuery().groupId
this.getocmarketingList()
},
computed: {
...mapState({
activityId: state => state.solicit.activityId,
staffId: state => state.solicit.staffId
})
},
methods: {
...mapMutations({
SET_COUSTOMER_LIST: 'solicit/SET_COUSTOMER_LIST'
}),
//一键营销内容回显
getocmarketingList() {
let params = {
id: this.activityId,
staffId: this.staffId,
groupId: this.groupId
}
this.showLoading()
solicitApi.getocmarketingList(params).then(({ code, data, message }) => {
this.hideLoading()
if (code == '0') {
this.marketingDetails = data
if (data.attachmentList) {
const attachmentList = this.marketingDetails.attachmentList.map(item => {
if (item.attType == 1) {
this.getEmoImg()
} else if (item.attType == 7) {
item.attContent = JSON.parse(item.attContent)
}
return item
})
this.$set(this.marketingDetails, 'attachmentList', attachmentList)
this.$set(this.marketingDetails, 'customerInfoList', data.customerInfoList)
}
this.SET_COUSTOMER_LIST({ customerInfoList: data.customerInfoList })
} else {
Notify(message)
}
this.flag = true
})
},
// 一键营销
sendHandle() {
if (!this.marketingDetails.attachmentList.length) {
return
}
if (this.marketingDetails.massFlag) {
Toast('您已进行企微营销,请查看营销统计')
return
}
if (this.marketingDetails.customerInfoList.length > 0) {
let params = {
groupId: this.groupId,
id: this.activityId,
businessUuid: this.marketingDetails.businessUuid,
configId: this.marketingDetails.configId,
staffId: this.staffId
}
solicitApi.createdOcmarketing(params).then(res => {
if (res) {
Toast('营销活动已创建,请及时在「企业微信-群发助手」中确认发送')
setTimeout(() => {
this.$router.go(-1)
}, 1000)
} else {
Notify('营销活动创建失败')
}
})
}
},
goTo(name) {
this.$router.push({ name })
},
// 表情包转化图片
getEmoImg() {
const attContent = this.marketingDetails.attachmentList[0].attContent
const htm = attContent.replace(/\[[\u4E00-\u9FA56]{1,4}]/gi, function (res) {
let word = res.replace(/\[|\]/gi, '')
const list = emoji.flat(Infinity)
let index = parseInt(list.indexOf(word)) + 1
if (index < 10) {
index = '00' + index
} else if (index >= 10 && index < 100) {
index = '0' + index
}
return `<img class="emo_img" src="https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png">`
})
this.marketingDetails.attachmentList[0].attContent = htm
this.$set(this.marketingDetails.attachmentList, 0, {
attType: 1,
attContent: htm
})
}
}
}
</script>
<style lang="scss" scoped>
.marking-container {
padding: 16px;
&-content {
background: #fff;
padding: 16px;
box-shadow: 0px 3px 10px 0px rgba(223, 228, 234, 0.81);
border-radius: 4px;
.marking-image {
width: 152px;
height: auto;
// margin: 12px 32px 16px 32px;
img {
width: 100%;
height: 100%;
}
}
.marking-empty {
padding: 39px 0 24px 0 !important;
/deep/ .van-empty__description {
padding: 0;
}
}
}
&-customer {
height: 56px;
background: #ffffff;
box-shadow: 0px 3px 10px 0px rgba(223, 228, 234, 0.81);
border-radius: 4px;
padding: 0 16px;
margin-bottom: 50px;
}
.footer {
width: 343px;
height: 58px;
background: #f7f7f7;
z-index: 100;
position: fixed;
bottom: 0;
}
.marking-button {
width: 343px;
height: 42px;
background: #3975c6;
border-radius: 21px;
font-size: 14px;
font-weight: 500;
color: #ffffff;
line-height: 42px;
text-align: center;
margin-bottom: 16px;
}
.disabled {
background: #d5d8db !important;
}
.preview-activity {
width: 232px;
// height: 184px;
background-color: #fff;
border-radius: 4px;
border: 1px solid #e8e8ea;
padding: 12px 12px 0;
font-size: 11px;
box-sizing: border-box;
.applet-logo {
width: 18px;
height: 18px;
margin-right: 4px;
}
.activity-logo {
width: 208px;
height: 166px;
margin-bottom: 8px;
}
.activity-name {
font-size: 12px;
color: #333;
margin: 7px 0 4px;
width: 160px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.activity-footer {
display: flex;
align-items: center;
padding: 3px 0;
img {
width: 10px;
height: 10px;
margin-right: 3px;
}
margin-top: 4px;
border-top: 1px solid #dfe4ea;
}
}
}
</style>