Commit 2aedd429 by xinla

客户画像调试

1 parent 9a74d171
...@@ -28,7 +28,7 @@ export default { ...@@ -28,7 +28,7 @@ export default {
let code = query.code let code = query.code
this.corpId = query.corpId this.corpId = query.corpId
this.agentId = query.agentId this.agentId = query.agentId
this.$toast('agentId:' + this.agentId) // this.$toast('agentId:' + this.agentId)
if (!code) { if (!code) {
this.$toast('未获得授权') this.$toast('未获得授权')
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
} }
let { data } = await getUserInfo(code, this.agentId) let { data } = await getUserInfo(code, this.agentId)
this.$store.state.userId = data.userId this.$store.state.userId = data.userId
this.$toast('userId:' + this.$store.state.userId) // this.$toast('userId:' + this.$store.state.userId)
}, },
watch: { watch: {
// 通过config接口注入权限验证配置 // 通过config接口注入权限验证配置
...@@ -51,42 +51,46 @@ export default { ...@@ -51,42 +51,46 @@ export default {
reload() { reload() {
this.isRouterAlive = false this.isRouterAlive = false
this.$nextTick(function() { this.$nextTick(function() {
// this.isRouterAlive = true this.isRouterAlive = true
}) })
}, },
wxConfig() { async wxConfig() {
getAgentTicket(window.location.href.split('#')[0], this.agentId).then( this.$store.state.agentConfigStatus = false
({ data }) => { try {
let { timestamp, nonceStr, signature } = data let { data } = await getAgentTicket(
wx.agentConfig({ window.location.href.split('#')[0],
beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题 this.agentId
debug: true, )
corpid: this.corpId, // 必填,企业微信的corpid,必须与当前登录的企业一致 let { timestamp, nonceStr, signature } = data
agentid: this.agentId, // 必填,企业微信的应用id (e.g. 1000247) wx.agentConfig({
timestamp, // 必填,生成签名的时间戳 beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
nonceStr, // 必填,生成签名的随机串 debug: true,
signature, // 必填,签名,见附录-JS-SDK使用权限签名算法 corpid: this.corpId, // 必填,企业微信的corpid,必须与当前登录的企业一致
jsApiList: [ agentid: this.agentId, // 必填,企业微信的应用id (e.g. 1000247)
'sendChatMessage', timestamp, // 必填,生成签名的时间戳
'getContext', nonceStr, // 必填,生成签名的随机串
'getCurExternalContact', signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
'openEnterpriseChat', jsApiList: [
'shareToExternalContact', 'sendChatMessage',
'shareToExternalChat', 'getContext',
], //必填 'getCurExternalContact',
success: (res) => { 'openEnterpriseChat',
// 回调 'shareToExternalContact',
// this.$toast('agentId成功:') 'shareToExternalChat',
}, ], //必填
fail: (res) => { success: (res) => {
this.$toast('agentId失败:' + JSON.stringify(res)) // 回调
if (res.errMsg.indexOf('function not exist') > -1) { this.$toast('agentId成功:')
alert('版本过低请升级') this.$store.state.agentConfigStatus = true
} },
}, fail: (res) => {
}) this.$toast('agentId失败:' + JSON.stringify(res))
} if (res.errMsg.indexOf('function not exist') > -1) {
) alert('版本过低请升级')
}
},
})
} catch (error) {}
}, },
// 丢弃 // 丢弃
// _wxConfig() { // _wxConfig() {
......
...@@ -6,6 +6,7 @@ Vue.use(Vuex) ...@@ -6,6 +6,7 @@ Vue.use(Vuex)
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
userId: '', userId: '',
agentConfigStatus: false,
}, },
mutations: {}, mutations: {},
actions: {}, actions: {},
......
...@@ -387,7 +387,7 @@ export default { ...@@ -387,7 +387,7 @@ export default {
// 接口开始 // 接口开始
// externalUserid: "wm2H-nDQAACG5x4XjsM1OoW8UVfpbn3A", // 客户Id // externalUserid: "wm2H-nDQAACG5x4XjsM1OoW8UVfpbn3A", // 客户Id
// externalUserid: "wmiGuBCgAAgeijfvvpJ62cBfwrB-c4kw", // externalUserid: "wmiGuBCgAAgeijfvvpJ62cBfwrB-c4kw",
externalUserid: 'FengJuZhuDeJieDao', externalUserid: '',
userid: this.$store.state.userId, // 员工Id userid: this.$store.state.userId, // 员工Id
form: { form: {
name: '', // 昵称 name: '', // 昵称
...@@ -431,6 +431,11 @@ export default { ...@@ -431,6 +431,11 @@ export default {
flage: true, flage: true,
} }
}, },
watch: {
'$store.state.agentConfigStatus'(val) {
val && this.init()
},
},
computed: { computed: {
// activeLabel : () => { // activeLabel : () => {
// this.addTag.forEach((value) => { // this.addTag.forEach((value) => {
...@@ -440,6 +445,51 @@ export default { ...@@ -440,6 +445,51 @@ export default {
// } // }
}, },
methods: { methods: {
init() {
let _this = this
wx.invoke('getContext', {}, function(res) {
if (res.err_msg == 'getContext:ok') {
let entry = res.entry //返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools
if (
![
'single_chat_tools',
'group_chat_tools',
'contact_profile',
].includes(entry)
) {
// _this.$toast.clear()
_this.$toast('入口错误:' + entry)
return
}
wx.invoke('getCurExternalContact', {}, (res) => {
if (res.err_msg == 'getCurExternalContact:ok') {
_this.externalUserid = res.userId //返回当前外部联系人userId
// 获取客户信息
_this.findAddaddEmployes()
_this.findAddGroupNum()
_this.getCustomerInfo()
_this.findTrajectory()
getAllTags()
.then(({ data }) => {
// console.log(data);
_this.alllabel = data
})
.catch((err) => {
console.log(err)
})
} else {
//错误处理
_this.$dialog({ message: '进入失败:' + JSON.stringify(res) })
}
_this.$toast.clear()
})
} else {
//错误处理
_this.$toast.clear()
_this.$dialog({ message: '进入失败:' + JSON.stringify(res) })
}
})
},
// 客户待办点击保存事件 // 客户待办点击保存事件
saveInfo2() {}, saveInfo2() {},
// 添加或编辑轨迹 // 添加或编辑轨迹
...@@ -691,44 +741,10 @@ export default { ...@@ -691,44 +741,10 @@ export default {
}, },
}, },
created() { created() {
let _this = this this.$toast.loading({
wx.invoke('getContext', {}, function(res) { message: 'loading...',
if (res.err_msg == 'getContext:ok') { duration: 0,
entry = res.entry //返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools forbidClick: true,
if (
![
'single_chat_tools',
'group_chat_tools',
'contact_profile',
].includes(entry)
) {
// _this.$toast.clear()
_this.$toast('入口错误:' + entry)
return
}
wx.invoke('getCurExternalContact', {}, (res) => {
if (res.err_msg == 'getCurExternalContact:ok') {
_this.externalUserid = res.userId //返回当前外部联系人userId
// 获取客户信息
_this.findAddaddEmployes(),
_this.findAddGroupNum(),
_this.getCustomerInfo(),
_this.findTrajectory(),
getAllTags()
.then(({ data }) => {
// console.log(data);
_this.alllabel = data
})
.catch((err) => {
console.log(err)
})
} else {
//错误处理
}
})
} else {
//错误处理
}
}) })
}, },
components: { components: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!