|
|
@@ -161,8 +161,20 @@
|
|
|
{{timeFormat(item.executeTime, 'yyyy-MM-dd')}}
|
|
|
</div>
|
|
|
<div class="sop_item">
|
|
|
- <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送<span
|
|
|
- style="color: #999;">{{item.isSend ? '(已发送)' : ''}}</span></div>
|
|
|
+ <div>
|
|
|
+ <span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>
|
|
|
+ 发送<span style="color: #999;">{{item.isSend ? '(已发送)' : ''}}</span>
|
|
|
+ </div>
|
|
|
+ <div class="sop_body" v-if="item.contentText">
|
|
|
+ <div>
|
|
|
+ <div class="sop_c">
|
|
|
+ <span>{{ item.contentText }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="sop_foot">
|
|
|
+ <div class="sop_btn" @click="sendContentText(item.id, item.contentText)">发送</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="sop_body" v-if="item.ctOthers.length > 0">
|
|
|
<div v-for="(c, cIndex) in item.ctOthers" :key="cIndex">
|
|
|
<div class="sop_c" v-if="c.matterType === 0">
|
|
|
@@ -181,7 +193,7 @@
|
|
|
<span>{{ c.fileName }}</span>
|
|
|
</div>
|
|
|
<div class="sop_foot">
|
|
|
- <div class="sop_btn" @click="handleSend(item.id, c)">发送</div>
|
|
|
+ <div class="sop_btn" @click="handleCtOthersSend(item.id, c)">发送</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -220,6 +232,9 @@
|
|
|
<div v-if="m.contentType === 4" class="sop_c">
|
|
|
<span>外部链接:{{ m.title }}</span>
|
|
|
</div>
|
|
|
+ <div class="sop_foot">
|
|
|
+ <div class="sop_btn" @click="handleMattersSend(item.id, m)">发送</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -245,8 +260,20 @@
|
|
|
{{timeFormat(item.executeTime, 'yyyy-MM-dd')}}
|
|
|
</div>
|
|
|
<div class="sop_item">
|
|
|
- <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送(<span
|
|
|
- style="color: #999;">{{item.isSend ? '已发送' : ''}}</span>)</div>
|
|
|
+ <div>
|
|
|
+ <span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>
|
|
|
+ 发送<span style="color: #999;">{{item.isSend ? '已发送' : ''}}</span>
|
|
|
+ </div>
|
|
|
+ <div class="sop_body" v-if="item.contentText">
|
|
|
+ <div>
|
|
|
+ <div class="sop_c">
|
|
|
+ <span>{{ item.contentText }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="sop_foot">
|
|
|
+ <div class="sop_btn" @click="sendContentText(item.id, item.contentText)">发送</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="sop_body" v-if="item.ctOthers.length > 0">
|
|
|
<div v-for="(c, cIndex) in item.ctOthers" :key="cIndex">
|
|
|
<div class="sop_c" v-if="c.matterType === 0">
|
|
|
@@ -265,7 +292,7 @@
|
|
|
<span>{{ c.fileName }}</span>
|
|
|
</div>
|
|
|
<div class="sop_foot">
|
|
|
- <div class="sop_btn" @click="handleSend(item.id, c)">发送</div>
|
|
|
+ <div class="sop_btn" @click="handleCtOthersSend(item.id, c)">发送</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -304,6 +331,9 @@
|
|
|
<div v-if="m.contentType === 4" class="sop_c">
|
|
|
<span>外部链接:{{ m.title }}</span>
|
|
|
</div>
|
|
|
+ <div class="sop_foot">
|
|
|
+ <div class="sop_btn" @click="handleMattersSend(item.id, m)">发送</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -347,8 +377,8 @@
|
|
|
// 授权
|
|
|
this.getAuth()
|
|
|
}
|
|
|
- // this.memberId = "woU17nDAAAnoSca19vZVKiNEKdc9tyYQ"
|
|
|
- // this.externalUserId = "wmU17nDAAAGT2PF6G8PUHdSx2DY1ljpg"
|
|
|
+ // this.memberId = "woU17nDAAAd2m75dFfnjeg_x_egmMkIQ"
|
|
|
+ // this.externalUserId = "wmU17nDAAARtlDBF2x_WFHAM5i360zAg"
|
|
|
// this.executeSopList()
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -439,7 +469,9 @@
|
|
|
},
|
|
|
//获取执行中的sop计划
|
|
|
executeSopList (status) {
|
|
|
- this.externalUserId = ''
|
|
|
+ if (!this.externalUserId) {
|
|
|
+ return
|
|
|
+ }
|
|
|
fetch(this.httpUrl + `/scrm/v1/wxcp-sop/p/executeSopList?externalUserId=${this.externalUserId}&memberId=${this.memberId}&bId=${this.bId}&status=${status || 0}`)
|
|
|
.then(res => {
|
|
|
return res.json()
|
|
|
@@ -489,7 +521,237 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- handleSend (historyId, c) {
|
|
|
+ // 发送话术(contentText)
|
|
|
+ sendContentText(historyId, contentText) {
|
|
|
+ this.historyId = historyId
|
|
|
+ fetch(this.httpUrl + '/scrm/v1/wxcp-corp/p/getAgentConfig', {
|
|
|
+ method: 'post',
|
|
|
+ body: JSON.stringify({
|
|
|
+ bid: this.bId,
|
|
|
+ url: window.location.href,
|
|
|
+ }),
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ return res.json()
|
|
|
+ }).then(result => {
|
|
|
+ let { data, code, msg } = result
|
|
|
+ if (code === 1) {
|
|
|
+ let that = this
|
|
|
+ wx.agentConfig({
|
|
|
+ corpid: data.corpid,
|
|
|
+ agentid: data.agentId,
|
|
|
+ timestamp: data.timestamp, // 必填,生成签名的时间戳
|
|
|
+ nonceStr: data.nonceStr, // 必填,生成签名的随机串
|
|
|
+ signature: data.agentSignature, // 必填,签名,见附录1
|
|
|
+ jsApiList: ['sendChatMessage'], // 必填,需要使用的JS接口列表
|
|
|
+ success: function (res) {
|
|
|
+ // 发送话术(contentText)
|
|
|
+ wx.invoke('sendChatMessage', {
|
|
|
+ msgtype: "text", //消息类型,必填
|
|
|
+ enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
|
|
|
+ text: {
|
|
|
+ content: contentText, //文本内容
|
|
|
+ },
|
|
|
+ }, function (res) {
|
|
|
+ if (res.err_msg == 'sendChatMessage:ok') {
|
|
|
+ that.updateSop()
|
|
|
+ //发送成功
|
|
|
+ that.$message({
|
|
|
+ message: '发送成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function (res) {
|
|
|
+ if (res.errMsg.indexOf('function not exist') > -1) {
|
|
|
+ alert('版本过低请升级');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete: function (res) {
|
|
|
+ // 回调
|
|
|
+ console.log('complete', res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: msg,
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取Matters mediaId
|
|
|
+ handleMattersSend(historyId, m) {
|
|
|
+ this.historyId = historyId
|
|
|
+ if (m.contentType === 1 || m.contentType === 3 || m.contentType === 15 || m.contentType === 19 || m.contentType === 31) {
|
|
|
+ fetch(this.httpUrl + `/scrm/v1/wxcp-sop/p/getMedia?planContentId=${m.id}`)
|
|
|
+ .then(res => {
|
|
|
+ return res.json()
|
|
|
+ }).then(result => {
|
|
|
+ let { data, code, msg } = result
|
|
|
+ if (code === 1) {
|
|
|
+ this.sendMattersData(m, data.mediaId)
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: msg,
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.sendMattersData(m)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 发送素材库素材(ctOthers)
|
|
|
+ sendMattersData(m, mediaId) {
|
|
|
+ fetch(this.httpUrl + '/scrm/v1/wxcp-corp/p/getAgentConfig', {
|
|
|
+ method: 'post',
|
|
|
+ body: JSON.stringify({
|
|
|
+ bid: this.bId,
|
|
|
+ url: window.location.href,
|
|
|
+ }),
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ return res.json()
|
|
|
+ }).then(result => {
|
|
|
+ let { data, code, msg } = result
|
|
|
+ if (code === 1) {
|
|
|
+ let that = this
|
|
|
+ wx.agentConfig({
|
|
|
+ corpid: data.corpid,
|
|
|
+ agentid: data.agentId,
|
|
|
+ timestamp: data.timestamp, // 必填,生成签名的时间戳
|
|
|
+ nonceStr: data.nonceStr, // 必填,生成签名的随机串
|
|
|
+ signature: data.agentSignature, // 必填,签名,见附录1
|
|
|
+ jsApiList: ['sendChatMessage'], // 必填,需要使用的JS接口列表
|
|
|
+ success: function (res) {
|
|
|
+ // 发送素材库数据
|
|
|
+ // 文章,表单,外部链接,视频,图集
|
|
|
+ if (m.contentType === 0 || m.contentType === 2 || m.contentType === 4 || m.contentType === 16 || m.contentType === 17) {
|
|
|
+ wx.invoke('sendChatMessage', {
|
|
|
+ msgtype: "news", //消息类型,必填
|
|
|
+ enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
|
|
|
+ news: {
|
|
|
+ link: m.sendUrl, //H5消息页面url 必填
|
|
|
+ title: m.title || m.name || '', //H5消息标题.
|
|
|
+ desc: m.abs || '', //H5消息摘要
|
|
|
+ imgUrl: m.cover || '', //H5消息封面图片URL
|
|
|
+ },
|
|
|
+ }, function (res) {
|
|
|
+ if (res.err_msg == 'sendChatMessage:ok') {
|
|
|
+ that.updateSop()
|
|
|
+ //发送成功
|
|
|
+ that.$message({
|
|
|
+ message: '发送成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 图片
|
|
|
+ } else if (m.contentType === 1 || m.contentType === 31) {
|
|
|
+ wx.invoke('sendChatMessage', {
|
|
|
+ msgtype: "image", //消息类型,必填
|
|
|
+ enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
|
|
|
+ image:
|
|
|
+ {
|
|
|
+ mediaid: mediaId, //视频的素材id
|
|
|
+ },
|
|
|
+ }, function (res) {
|
|
|
+ if (res.err_msg == 'sendChatMessage:ok') {
|
|
|
+ that.updateSop()
|
|
|
+ //发送成功
|
|
|
+ that.$message({
|
|
|
+ message: '发送成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 文件
|
|
|
+ } else if (m.contentType === 3) {
|
|
|
+ wx.invoke('sendChatMessage', {
|
|
|
+ msgtype: "file", //消息类型,必填
|
|
|
+ enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
|
|
|
+ file:
|
|
|
+ {
|
|
|
+ mediaid: mediaId, //视频的素材id
|
|
|
+ },
|
|
|
+ }, function (res) {
|
|
|
+ if (res.err_msg == 'sendChatMessage:ok') {
|
|
|
+ that.updateSop()
|
|
|
+ //发送成功
|
|
|
+ that.$message({
|
|
|
+ message: '发送成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 原生视频格式
|
|
|
+ } else if (m.contentType === 15) {
|
|
|
+ wx.invoke('sendChatMessage', {
|
|
|
+ msgtype: "video", //消息类型,必填
|
|
|
+ enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
|
|
|
+ video:
|
|
|
+ {
|
|
|
+ mediaid: mediaId, //视频的素材id
|
|
|
+ },
|
|
|
+ }, function (res) {
|
|
|
+ if (res.err_msg == 'sendChatMessage:ok') {
|
|
|
+ that.updateSop()
|
|
|
+ //发送成功
|
|
|
+ that.$message({
|
|
|
+ message: '发送成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 小程序
|
|
|
+ } else if (m.contentType === 33) {
|
|
|
+ wx.invoke('sendChatMessage', {
|
|
|
+ msgtype: "miniprogram", //消息类型,必填
|
|
|
+ enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
|
|
|
+ miniprogram: {
|
|
|
+ appid: m.wxId, //H5消息页面url 必填
|
|
|
+ title: m.title || m.name || '', //H5消息标题.
|
|
|
+ imgUrl: m.headImg || '', //H5消息封面图片URL
|
|
|
+ page: m.enterPoint || '', //H5消息摘要
|
|
|
+ },
|
|
|
+ }, function (res) {
|
|
|
+ if (res.err_msg == 'sendChatMessage:ok') {
|
|
|
+ that.updateSop()
|
|
|
+ //发送成功
|
|
|
+ that.$message({
|
|
|
+ message: '发送成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function (res) {
|
|
|
+ if (res.errMsg.indexOf('function not exist') > -1) {
|
|
|
+ alert('版本过低请升级');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete: function (res) {
|
|
|
+ // 回调
|
|
|
+ console.log('complete', res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: msg,
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取CtOthers mediaId
|
|
|
+ handleCtOthersSend (historyId, c) {
|
|
|
this.historyId = historyId
|
|
|
if (c.matterType === 1 || c.matterType === 2 || c.matterType === 4) {
|
|
|
fetch(this.httpUrl + `/scrm/v1/wxcp-sop/p/getMedia?planContentId=${c.id}`)
|
|
|
@@ -498,7 +760,7 @@
|
|
|
}).then(result => {
|
|
|
let { data, code, msg } = result
|
|
|
if (code === 1) {
|
|
|
- this.sendData(c, data.mediaId)
|
|
|
+ this.sendCtOthersData(c, data.mediaId)
|
|
|
} else {
|
|
|
this.$message({
|
|
|
message: msg,
|
|
|
@@ -507,10 +769,11 @@
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- this.sendData(c)
|
|
|
+ this.sendCtOthersData(c)
|
|
|
}
|
|
|
},
|
|
|
- sendData (c, mediaId) {
|
|
|
+ // 发送自定义素材(ctOthers)
|
|
|
+ sendCtOthersData (c, mediaId) {
|
|
|
fetch(this.httpUrl + '/scrm/v1/wxcp-corp/p/getAgentConfig', {
|
|
|
method: 'post',
|
|
|
body: JSON.stringify({
|
|
|
@@ -534,7 +797,7 @@
|
|
|
signature: data.agentSignature, // 必填,签名,见附录1
|
|
|
jsApiList: ['sendChatMessage'], // 必填,需要使用的JS接口列表
|
|
|
success: function(res) {
|
|
|
- // 回调
|
|
|
+ // 发送自定义数据
|
|
|
if (c.matterType === 0) {
|
|
|
wx.invoke('sendChatMessage', {
|
|
|
msgtype: "text", //消息类型,必填
|