Commit 2aedd429 by xinla

客户画像调试

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