提交 d97282f3 作者: 毛细亚

修改日志记录任务

上级 26ef2fa3
...@@ -14,6 +14,7 @@ const state = { ...@@ -14,6 +14,7 @@ const state = {
bindGameUserList: [], // 用户绑定的游戏角色 bindGameUserList: [], // 用户绑定的游戏角色
changeSelectWindow: false, // 切换客服窗口的时候 下发通知 changeSelectWindow: false, // 切换客服窗口的时候 下发通知
gameUserInfo:{}, gameUserInfo:{},
send_game_log: null, // 转游发送渠道新增日志发送信息
chatUserInfo: {}, // 当前选中的用户的详情 chatUserInfo: {}, // 当前选中的用户的详情
} }
...@@ -35,6 +36,9 @@ const mutations = { ...@@ -35,6 +36,9 @@ const mutations = {
}, },
set_gameUserInfo(state, data) { set_gameUserInfo(state, data) {
state.gameUserInfo = data state.gameUserInfo = data
},
set_send_game_log(state, data) {
state.send_game_log = data
} }
} }
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
*/ */
import store from '@/store' import store from '@/store'
import Clipboard from 'clipboard' import Clipboard from 'clipboard'
import { getMediaId } from '@/api/works'
import { Message } from 'element-ui'
import * as ww from '@wecom/jssdk'
export function parseTime(time, cFormat) { export function parseTime(time, cFormat) {
if (arguments.length === 0 || !time) { if (arguments.length === 0 || !time) {
return null return null
...@@ -677,4 +681,72 @@ export const fallbackCopyTextToClipboard = function(text, successCallback, error ...@@ -677,4 +681,72 @@ export const fallbackCopyTextToClipboard = function(text, successCallback, error
} }
document.body.removeChild(textArea) document.body.removeChild(textArea)
}
// 企业微信发送聊天消息的通用方法
export async function sendChatMessage(content, type) {
let messageObj = {}
if (type === 'text') {
messageObj = {
msgtype: 'text',
text: {
content: content
},
success: (res) => {
console.log(res, '发送文本成功')
},
fail: (err) => {
console.log(err, '发送文本失败')
}
}
} else if (type === 'link') {
messageObj = {
msgtype: 'news',
news: content,
success: (res) => {
console.log(res, '发送 news 成功')
},
fail: (err) => {
console.log(err, '发送 news 失败')
}
}
} else if (type === 'image') {
// 发送图片作为链接消息
if (content) {
try {
const res = await getMediaId({ url: content })
if (res.status_code == 1) {
messageObj = {
msgtype: 'image',
image: {
mediaid: res.data.media_id
},
success: (res) => {
console.log(res, '发送 image 成功')
},
fail: (err) => {
console.log(err, '发送 image 失败')
}
}
}
} catch (error) {
console.error('获取媒体ID失败:', error)
Message.error('获取图片媒体ID失败')
return
}
} else {
Message.error('图片链接不存在,无法发送')
return
}
} else if (type === 'miniprogram') {
messageObj = {
msgtype: 'miniprogram',
miniprogram: content
}
}
console.log(messageObj, '发送消息对象')
ww.sendChatMessage(messageObj)
} }
\ No newline at end of file
...@@ -288,6 +288,19 @@ ...@@ -288,6 +288,19 @@
@close="SendTransAppGameClose" @close="SendTransAppGameClose"
@confirm="handleAppGameConfirm" @confirm="handleAppGameConfirm"
/> />
<!-- 选择发送渠道 -->
<selectChannel
v-if="showLayer"
:show.sync="showLayer"
:chat-user="chatUserInfo"
:channel-info-list="channelInfoList"
/>
<!-- 如果选择发送的渠道链接只有一个 直接发送 -->
<sendSelectChannel
:show.sync="showSendChannel"
:chat-user="chatUserInfo"
:channel-info-list="channelInfoList"
/>
</div> </div>
</template> </template>
<script> <script>
...@@ -305,20 +318,23 @@ ...@@ -305,20 +318,23 @@
getLandingPageConfig, getLandingPageConfig,
getMemberTransStatus getMemberTransStatus
} from '@/api/game' } from '@/api/game'
import { getRecentSendLog, markTransScene,getZqCserGroup,getZqCserWxBelong,getMediaId } from '@/api/works' import { getRecentSendLog, markTransScene,getZqCserGroup,getZqCserWxBelong,getMediaId,send_log_add } from '@/api/works'
import { companyviewConfig } from '@/api/user' import { companyviewConfig } from '@/api/user'
import { throttle, throttleStart } from '@/utils/index' import { throttle, throttleStart, sendChatMessage } from '@/utils/index'
import createChannel from './sendGame/createChannel' import createChannel from './sendGame/createChannel'
import sendPage from './sendGame/SendTransPage.vue' import sendPage from './sendGame/SendTransPage.vue'
import SendTransWxGame from './sendGame/SendTransWxGame.vue' import SendTransWxGame from './sendGame/SendTransWxGame.vue'
import SendTransAppGame from './sendGame/SendTransAppGame.vue' import SendTransAppGame from './sendGame/SendTransAppGame.vue'
import selectChannel from './sendGame/selectChannel.vue'
import sendSelectChannel from './sendGame/sendSelectChannel.vue'
export default { export default {
components: { components: {
createChannel, createChannel,
sendPage, sendPage,
SendTransWxGame, SendTransWxGame,
SendTransAppGame SendTransAppGame,
selectChannel,
sendSelectChannel
}, },
data() { data() {
return { return {
...@@ -350,6 +366,9 @@ ...@@ -350,6 +366,9 @@
selectedAppGameList: [], // 安卓或者 Ios 选择的游戏 selectedAppGameList: [], // 安卓或者 Ios 选择的游戏
sendGameInfoSave: {}, sendGameInfoSave: {},
imageInfo: {}, imageInfo: {},
showLayer: false,
showSendChannel: false,
channelInfoList:{},
transMemberStatus: true transMemberStatus: true
} }
}, },
...@@ -358,7 +377,7 @@ ...@@ -358,7 +377,7 @@
this.sendGameInfo() this.sendGameInfo()
}, },
computed: { computed: {
...mapState('game', ['accountSelect', 'bindGameUserList','chatUserInfo','gameUserInfo']), ...mapState('game', ['accountSelect', 'bindGameUserList','chatUserInfo','gameUserInfo','send_game_log']),
...mapState('user', ['userInfo','corp_id']) ...mapState('user', ['userInfo','corp_id'])
}, },
// props: [ 'chatUserInfo', 'chatUser'], // props: [ 'chatUserInfo', 'chatUser'],
...@@ -380,7 +399,7 @@ ...@@ -380,7 +399,7 @@
} }
}, },
methods: { methods: {
// ...mapMutations('game', ['set_send_game_log']), ...mapMutations('game', ['set_send_game_log']),
initDisable(){ initDisable(){
// 切换 w 账号的时候清空 conversionGameList 数据 // 切换 w 账号的时候清空 conversionGameList 数据
this.conversionGameList = [] this.conversionGameList = []
...@@ -391,6 +410,15 @@ ...@@ -391,6 +410,15 @@
this.disabled = true this.disabled = true
} }
}, },
channelInfo(info) {
this.channelInfoList = info
// 只有 1 个渠道的时候 直接发送不出现弹窗
if (info.channelList.length === 1) {
this.showSendChannel = true
} else {
this.showLayer = true
}
},
requestConfig() { requestConfig() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
companyviewConfig({corp_id:this.corp_id}).then((res) => { companyviewConfig({corp_id:this.corp_id}).then((res) => {
...@@ -932,6 +960,39 @@ ...@@ -932,6 +960,39 @@
return return
} }
}, },
/**
* 发送游戏日志
* @param {Object} item 游戏信息
* 1.send_log_add方法是发送游戏日志的接口
* 2.set_send_game_log 是储存在vuex中的需要发送的时候调用的 信息 也就是 send_log_add 中需要的信息
* 3.每次调用 sendGameLog 方法 或者 set_send_game_log方法 的时候都需要记录 send_game_log 的信息 然后 监听 send_game_log 变量的变化 然后调用 send_log_add 方法
* 4.你需要 查看 ./sendGame/*.vue 所有的 vue 文件 查看是否文件中有 sendGameLog 方法 如果有 你需要帮我自动完成日志的记录功能 需要的步骤如下
* 5.你需要 在 vuex 中 引入 send_game_log 变量 然后 监听 send_game_log 如果 新值存在 那么就调用 send_log_add
* 6.请你仔细查看 ./sendGame/*.vue 的所有 vue 文件 帮我 自动完成 send_log_add 的日志收集功能 如果需要特殊处理 的地方你需要仔细查看逻辑 并且 自动处理
* 7.你可以封装成一个 minix 或者你有更好的处理逻辑 来完成 发送游戏日志的收集工作
* 8.总结:每次调用 set_send_game_log 方法的时候 是在 vuex 中记录 需要发送的日志信息 你要监听 send_game_log 变量的变化 然后调用 send_log_add 方法 完成日志的收集工作 你需要帮我选一个最佳的方案来完成这个功能 尽量保证不出问题
*/
send_log_add(info) {
const data = {
game_id: this.send_game_log.game_id,
game_name: this.send_game_log.game_name,
game_type: this.send_game_log.game_type || '',
main_game_id: this.send_game_log.main_game_id || '',
weixin_blongs_id: this.send_game_log.weixin_blongs_id || '',
content: info.message,
type: this.send_game_log.type || 2,
frontend_message_id: info.frontend_message_id,
session_id: info.session_id,
userid: this.chatUser.userid,
external_userid: this.chatUser.external_userid
}
this.set_send_game_log(null)
send_log_add(data).then((res) => {
if (res.status_code === 1) {
console.log('日志记录成功')
}
})
},
sendGameLog(item) { sendGameLog(item) {
item && item.game_id && item.game_name ? this.set_send_game_log({ game_id: item.game_id, game_name: item.game_name, game_type: item.game_type || '', main_game_id: item.main_game_id, weixin_blongs_id: item.weixin_blongs_id, type: item.type || '' }) : '' item && item.game_id && item.game_name ? this.set_send_game_log({ game_id: item.game_id, game_name: item.game_name, game_type: item.game_type || '', main_game_id: item.main_game_id, weixin_blongs_id: item.weixin_blongs_id, type: item.type || '' }) : ''
}, },
...@@ -1158,62 +1219,14 @@ ...@@ -1158,62 +1219,14 @@
// this.set_sendSkillMessage(list) // this.set_sendSkillMessage(list)
this.sendChatMessage(`游戏地址:${data.landing_page_url} \n账号:${data.username} \n密码:${data.password}`,'text') this.sendChatMessage(`游戏地址:${data.landing_page_url} \n账号:${data.username} \n密码:${data.password}`,'text')
}, },
sendChatMessage(content,type){ async sendChatMessage(content, type) {
let message = {} // 调用公共的sendChatMessage方法
if(type == 'text'){ await sendChatMessage(content, type)
message = {
msgtype: 'text',
text: {
content: content
},
success: (res) => {
console.log(res, '发送文本成功')
},
fail: (err) => {
console.log(err, '发送文本失败')
}
}
}else if(type == 'link'){
message = {
msgtype: 'news',
news: content,
success: (res) => {
console.log(res, '发送 news 成功')
},
fail: (err) => {
console.log(err, '发送 news 失败')
}
}
}else if(type == 'image'){
message = {
msgtype: 'image',
image: {
mediaid: content
},
success: (res) => {
console.log(res, '发送 image 成功')
},
fail: (err) => {
console.log(err, '发送 image 失败')
}
}
}else if(type=='miniprogram'){
message = {
msgtype: 'miniprogram',
miniprogram: content,
}
}
console.log(message,'1231')
this.$ww.sendChatMessage(message)
}, },
async getMediaId(picurl){ async getMediaId(picurl){
// 发送图片作为链接消息 // 发送图片作为链接消息
if (picurl) { if (picurl) {
const res = await getMediaId({url:picurl}) this.sendChatMessage(picurl, 'image')
if(res.status_code == 1){
this.sendChatMessage(res.data.media_id,'image')
}
} else { } else {
// 如果没有图片URL,提示用户 // 如果没有图片URL,提示用户
this.$message.error('图片链接不存在,无法发送') this.$message.error('图片链接不存在,无法发送')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论