Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0b0758fa
authored
Mar 11, 2021
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
h5配置修改
1 parent
4ba1ec81
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
193 additions
and
129 deletions
linkwe-mobile/src/App.vue
linkwe-mobile/src/api/common.js
linkwe-mobile/src/store/index.js
linkwe-mobile/src/utils/index.js
linkwe-mobile/src/views/chat/index.vue
linkwe-mobile/src/views/portrait/index.vue
linkwe-mobile/src/App.vue
View file @
0b0758f
<
script
>
import
{
getUserInfo
}
from
'@/api/common'
import
{
getAgentTicket
,
getAppTicket
}
from
'@/api/common'
import
{
param2Obj
}
from
'@/utils/index'
export
default
{
name
:
'App'
,
data
()
{
return
{
ap
pId
:
''
,
agentId
:
'
1000005
'
,
cor
pId
:
''
,
agentId
:
''
,
}
},
created
()
{},
async
created
()
{
// http://106.13.201.219/?code=xxx&state=linkwechat#/route
// console.log('routerbeforeCreate', this.$route);
// this.$dialog({ message: 'url' + JSON.stringify(window.location) })
let
query
=
param2Obj
(
window
.
location
.
search
)
let
code
=
query
.
code
this
.
corpId
=
query
.
corpId
this
.
agentId
=
query
.
agentId
if
(
!
code
)
{
this
.
$toast
(
'未获得授权'
)
return
}
let
{
data
}
=
await
getUserInfo
(
code
,
query
.
agentId
)
this
.
$store
.
state
.
userId
=
data
.
userId
// this.$toast('userId:' + this.$store.state.userId)
},
watch
:
{
// 通过config接口注入权限验证配置
// 所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用(同一个url仅需调用一次,对于变化url的SPA(single-page application)的web app可在每次url变化时进行调用)
//
$route() {
//
this.wxConfig()
//
},
$route
()
{
this
.
wxConfig
()
},
},
methods
:
{
wxConfig
()
{
getAgentTicket
(
window
.
location
.
href
.
split
(
'#'
)[
0
]).
then
(({
data
})
=>
{
let
{
timestamp
,
nonceStr
,
signature
}
=
data
wx
.
agentConfig
({
debug
:
true
,
corpid
:
this
.
appId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
this
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
,
// 必填,生成签名的时间戳
nonceStr
,
// 必填,生成签名的随机串
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList
:
[
'sendChatMessage'
,
'getContext'
],
//必填
success
:
(
res
)
=>
{
// 回调
// this.$toast('agentId成功:')
},
fail
:
(
res
)
=>
{
this
.
$toast
(
'agentId失败:'
+
JSON
.
stringify
(
res
))
if
(
res
.
errMsg
.
indexOf
(
'function not exist'
)
>
-
1
)
{
alert
(
'版本过低请升级'
)
}
},
})
})
getAgentTicket
(
window
.
location
.
href
.
split
(
'#'
)[
0
],
this
.
agentId
).
then
(
({
data
})
=>
{
let
{
timestamp
,
nonceStr
,
signature
}
=
data
wx
.
agentConfig
({
debug
:
true
,
corpid
:
this
.
corpId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
this
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
,
// 必填,生成签名的时间戳
nonceStr
,
// 必填,生成签名的随机串
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList
:
[
'sendChatMessage'
,
'getContext'
,
'getCurExternalContact'
,
],
//必填
success
:
(
res
)
=>
{
// 回调
// this.$toast('agentId成功:')
},
fail
:
(
res
)
=>
{
this
.
$toast
(
'agentId失败:'
+
JSON
.
stringify
(
res
))
if
(
res
.
errMsg
.
indexOf
(
'function not exist'
)
>
-
1
)
{
alert
(
'版本过低请升级'
)
}
},
})
}
)
},
// 丢弃
// _wxConfig() {
...
...
@@ -49,7 +72,7 @@ export default {
// wx.config({
// beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
//
appId: this.ap
pId, // 必填,企业微信的corpID
//
corpId: this.cor
pId, // 必填,企业微信的corpID
// timestamp, // 必填,生成签名的时间戳
// nonceStr, // 必填,生成签名的随机串
// signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
...
...
@@ -60,7 +83,7 @@ export default {
// getAgentTicket(window.location.href).then(({ data }) => {
// let { timestamp, nonceStr, signature } = data
// wx.agentConfig({
// corpid: this.
ap
pId, // 必填,企业微信的corpid,必须与当前登录的企业一致
// corpid: this.
cor
pId, // 必填,企业微信的corpid,必须与当前登录的企业一致
// agentid: this.agentId, // 必填,企业微信的应用id (e.g. 1000247)
// timestamp, // 必填,生成签名的时间戳
// nonceStr, // 必填,生成签名的随机串
...
...
linkwe-mobile/src/api/common.js
View file @
0b0758f
...
...
@@ -6,12 +6,12 @@ const service = config.services.wecom
* 获取应用的jsapi_ticket
* @param {*} url 页面url
*/
export
function
getAgentTicket
(
url
)
{
export
function
getAgentTicket
(
url
,
agentId
)
{
return
request
({
url
:
service
+
'/ticket/getAgentTicket'
,
params
:
{
url
,
agentId
:
'1000005'
,
agentId
,
},
})
}
...
...
@@ -33,12 +33,12 @@ export function getAppTicket(url) {
* 获取登录用户id
* @param {*} url 页面url
*/
export
function
getUserInfo
(
code
)
{
export
function
getUserInfo
(
code
,
agentId
)
{
return
request
({
url
:
service
+
'/user/getUserInfo'
,
params
:
{
code
,
agentId
:
'1000005'
,
agentId
,
},
})
}
linkwe-mobile/src/store/index.js
View file @
0b0758f
import
Vue
from
"vue"
;
import
Vuex
from
"vuex"
;
import
Vue
from
'vue'
import
Vuex
from
'vuex'
Vue
.
use
(
Vuex
)
;
Vue
.
use
(
Vuex
)
export
default
new
Vuex
.
Store
({
state
:
{},
state
:
{
userId
:
''
,
},
mutations
:
{},
actions
:
{},
modules
:
{}
})
;
modules
:
{}
,
})
linkwe-mobile/src/utils/index.js
0 → 100644
View file @
0b0758f
/**
* 请求路径参数转为对象
* @param {*} url
*/
export
function
param2Obj
(
url
)
{
const
search
=
decodeURIComponent
(
url
)
.
split
(
'?'
)[
1
]
.
split
(
'#'
)[
0
]
if
(
!
search
)
{
return
{}
}
return
JSON
.
parse
(
'{"'
+
search
.
replace
(
/"/g
,
'\\"'
)
.
replace
(
/&/g
,
'","'
)
.
replace
(
/=/g
,
'":"'
)
+
'"}'
)
}
linkwe-mobile/src/views/chat/index.vue
View file @
0b0758f
<
script
>
import
{
getUserInfo
}
from
'@/api/common'
import
{
getTypeList
}
from
'@/api/chat'
import
List
from
'./List'
export
default
{
...
...
@@ -13,51 +12,18 @@ export default {
loading
:
false
,
finished
:
false
,
show
:
false
,
userId
:
''
,
// userId: this.$store.state.userId
,
}
},
watch
:
{},
computed
:
{},
beforeCreate
()
{
// http://106.13.201.219/?auth_code=xxx#/authWehatCallback
// console.log('routerbeforeCreate', this.$route);
// let auth_code = location.search
// .slice(1)
// .split('&')[0]
// .split('=')[1]
// if (!auth_code) {
// this.$toast('未获得授权')
// return
// }
// getUserInfo(auth_code)
// .then(({ data }) => {
// this.userId = data.userId
// this.$toast('userId:' + this.userId)
// })
// .catch((err) => {
// this.$toast('err:' + err)
// })
computed
:
{
userId
()
{
return
this
.
$store
.
state
.
userId
},
},
beforeCreate
()
{},
created
()
{
let
auth_code
=
location
.
search
.
slice
(
1
)
.
split
(
'&'
)[
0
]
.
split
(
'='
)[
1
]
if
(
!
auth_code
)
{
this
.
$toast
(
'未获得授权'
)
return
}
getUserInfo
(
auth_code
)
.
then
(({
data
})
=>
{
this
.
userId
=
data
.
userId
// this.$toast('userId:' + this.userId)
})
.
catch
((
err
)
=>
{
Dialog
.
confirm
({
title
:
'标题'
,
message
:
err
,
})
})
// this.$toast('userId:' + this.$store.state.userId)
this
.
getList
()
},
mounted
()
{},
...
...
linkwe-mobile/src/views/portrait/index.vue
View file @
0b0758f
...
...
@@ -333,7 +333,7 @@
</
template
>
<
script
>
import
{
getCustomerInfo
}
from
'@/api/portrait'
import
{
getCustomerInfo
}
from
'@/api/portrait'
export
default
{
data
()
{
return
{
...
...
@@ -341,71 +341,136 @@ export default {
show
:
false
,
// 客户待办的弹出框开始
usershow
:
false
,
conagency
:
""
,
// 待办内容
conagency
:
''
,
// 待办内容
// 待办日期
dateagency
:
""
,
dateagency
:
''
,
dateshow
:
false
,
minDate
:
new
Date
(
2021
,
0
,
1
),
maxDate
:
new
Date
(
2021
,
12
,
31
),
// 待办时间
timeagency
:
""
,
timeagency
:
''
,
starttimeshow
:
false
,
endtimeshow
:
false
,
currentTime
:
"12:00"
,
startTime
:
""
,
endTime
:
""
,
currentTime
:
'12:00'
,
startTime
:
''
,
endTime
:
''
,
// 客户待办的弹出框结束
actions
:
[{
name
:
"选项一"
},
{
name
:
"选项二"
},
{
name
:
"选项三"
}],
actions
:
[{
name
:
'选项一'
},
{
name
:
'选项二'
},
{
name
:
'选项三'
}],
// 步骤条
active
:
-
1
,
// 客户轨迹
// 待办动态
todonewsshow
:
false
,
// 接口开始
externalUserid
:
""
,
// 客户Id
userid
:
""
,
// 员工Id
};
externalUserid
:
''
,
// 客户Id
userId
:
''
,
// 员工Id
}
},
watch
:
{
'$store.state.userId'
(
val
)
{
this
.
userId
=
val
this
.
getDetail
()
},
},
methods
:
{
getDetail
()
{
this
.
$toast
.
loading
({
message
:
'正在加载...'
,
duration
:
0
,
forbidClick
:
true
,
})
let
entry
=
undefined
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'
,
{},
function
(
resContact
)
{
if
(
resContact
.
err_msg
==
'getCurExternalContact:ok'
)
{
this
.
externalUserid
=
resContact
.
userId
//返回当前外部联系人userId
// 获取客户详细信息
getCustomerInfo
({
externalUserid
:
this
.
externalUserid
,
userid
:
this
.
userId
,
})
.
then
(({
data
})
=>
{
_this
.
$toast
.
clear
()
console
.
log
(
data
)
_this
.
$dialog
({
message
:
'获取客户失败:'
+
JSON
.
stringify
(
data
),
})
})
.
catch
((
err
)
=>
{
_this
.
$toast
.
clear
()
console
.
log
(
err
)
_this
.
$dialog
({
message
:
'获取客户失败:'
+
JSON
.
stringify
(
err
),
})
})
}
else
{
_this
.
$toast
.
clear
()
//错误处理
_this
.
$dialog
({
message
:
'获取客户id失败:'
+
JSON
.
stringify
(
resContact
),
})
}
})
}
else
{
_this
.
$toast
.
clear
()
//错误处理
_this
.
$dialog
({
message
:
'进入失败:'
+
JSON
.
stringify
(
res
)
})
}
})
},
// 添加代办
// 表单提交
onSubmit
()
{},
// 待办日期
formatDate
(
dateagency
)
{
return
`
${
dateagency
.
getFullYear
()}
-
${
dateagency
.
getMonth
()
+
1
}
-
${
dateagency
.
getDate
()}
`
;
1
}
-
${
dateagency
.
getDate
()}
`
},
onConfirm
(
dateagency
)
{
this
.
dateshow
=
false
;
this
.
dateagency
=
this
.
formatDate
(
dateagency
)
;
this
.
dateshow
=
false
this
.
dateagency
=
this
.
formatDate
(
dateagency
)
},
// 待办时间
timecancel
()
{
this
.
starttimeshow
=
false
;
this
.
starttimeshow
=
false
},
starttimeconfirm
(
value
)
{
this
.
startTime
=
value
;
this
.
starttimeshow
=
false
;
this
.
endtimeshow
=
true
;
this
.
startTime
=
value
this
.
starttimeshow
=
false
this
.
endtimeshow
=
true
},
endtimeconfirm
(
value
)
{
this
.
endTime
=
value
;
this
.
endtimeshow
=
false
;
let
time
=
""
;
this
.
endTime
=
value
this
.
endtimeshow
=
false
let
time
=
''
if
(
this
.
startTime
>
this
.
endTime
)
{
time
=
this
.
startTime
;
this
.
startTime
=
this
.
endTime
;
this
.
endTime
=
time
;
time
=
this
.
startTime
this
.
startTime
=
this
.
endTime
this
.
endTime
=
time
}
// console.log(this.startTime, this.endTime);
this
.
endtimeshow
=
false
;
this
.
timeagency
=
this
.
formatTime
()
;
this
.
endtimeshow
=
false
this
.
timeagency
=
this
.
formatTime
()
},
formatTime
()
{
return
`
${
this
.
startTime
}
-
${
this
.
endTime
}
`
;
return
`
${
this
.
startTime
}
-
${
this
.
endTime
}
`
},
// 待办动态
// 点击删除按钮
...
...
@@ -413,44 +478,32 @@ export default {
goRoute
()
{
this
.
$router
.
push
({
path
:
"/detail"
,
path
:
'/detail'
,
query
:
{
// type
},
})
;
})
},
detailGoRoute
()
{
this
.
$router
.
push
({
path
:
"/community"
,
path
:
'/community'
,
query
:
{
// type
},
})
;
})
},
// 第一层标签
userLabel
()
{
console
.
log
(
123
)
;
console
.
log
(
123
)
},
// 第二层标签
changeLabel
()
{
console
.
log
(
456
)
;
console
.
log
(
456
)
},
saveInfo
()
{},
},
created
()
{
// 获取客户详细信息
getCustomerInfo
({
externalUserid
:
this
.
externalUserid
,
userid
:
this
.
userid
,
})
.
then
(({
data
})
=>
{
console
.
log
(
data
);
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
});
},
};
created
()
{},
}
</
script
>
<
style
lang=
"less"
scoped
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment