Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-h5-ailipay
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 dc9c58ab
authored
Dec 23, 2021
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit
1 parent
faeed82e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
90 deletions
src/api/wxConfig.js
src/mixins/shareMixin.js
src/views/home.vue
src/api/wxConfig.js
View file @
dc9c58a
...
@@ -8,47 +8,49 @@ const WxConfig = {
...
@@ -8,47 +8,49 @@ const WxConfig = {
})
})
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'#'
)
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'#'
)
const
{
corpId
}
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
const
{
corpId
}
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
/** 获取企微应用AgentConfig */
/** 获取企微应用AgentConfig */
let
data
=
{
let
data
=
{
corpId
,
corpId
,
method
:
'scrm.api.work.wechat.get.agent.config'
,
method
:
'scrm.api.work.wechat.get.agent.config'
,
url
:
redirectUrl
,
url
:
redirectUrl
,
appCode
:
'DJQWGJ'
appCode
:
'DJQWGJ'
}
}
window
.
$HTTP
({
window
url
:
'/rop-scrm-wechat/router'
,
.
$HTTP
({
data
url
:
'/rop-scrm-wechat/router'
,
}).
then
(
obj
=>
{
data
if
(
obj
)
{
})
wx
.
agentConfig
({
.
then
(
obj
=>
{
corpid
:
obj
.
corpId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
if
(
obj
)
{
agentid
:
obj
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
wx
.
agentConfig
({
timestamp
:
obj
.
timestamp
,
// 必填,生成签名的时间戳
corpid
:
obj
.
corpId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
nonceStr
:
obj
.
nonceStr
,
// 必填,生成签名的随机串
agentid
:
obj
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
signature
:
obj
.
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法,
timestamp
:
obj
.
timestamp
,
// 必填,生成签名的时间戳
jsApiList
,
nonceStr
:
obj
.
nonceStr
,
// 必填,生成签名的随机串
success
(
res
)
{
signature
:
obj
.
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法,
console
.
log
(
res
,
'wx_config'
)
jsApiList
,
resolve
()
success
(
res
)
{
},
console
.
log
(
res
,
'wx_config'
)
fail
(
err
)
{
resolve
()
console
.
log
(
err
,
'wx_config'
)
},
reject
(
err
)
fail
(
err
)
{
}
console
.
log
(
err
,
'wx_config'
)
})
reject
(
err
)
}
else
{
}
Notify
(
'网络异常'
)
})
}
}
else
{
})
Notify
(
'网络异常'
)
}
})
})
})
},
},
getContext
(
callBack
)
{
getContext
()
{
/**
/**
* entry String 场景值
* entry String 场景值
* shareTicket String 仅当转发时设置了withShareTicket转发到会话的消息进入才返回该字段,详见私密消息
* shareTicket String 仅当转发时设置了withShareTicket转发到会话的消息进入才返回该字段,详见私密消息
**/
**/
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
invoke
(
'getContext'
,
{},
(
res
)
=>
{
wx
.
invoke
(
'getContext'
,
{},
res
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
let
{
err_msg
,
entry
,
shareTicket
}
=
res
let
{
err_msg
,
entry
,
shareTicket
}
=
res
/** entry 说明
/** entry 说明
...
@@ -61,12 +63,12 @@ const WxConfig = {
...
@@ -61,12 +63,12 @@ const WxConfig = {
if
(
err_msg
==
'getContext:ok'
)
{
if
(
err_msg
==
'getContext:ok'
)
{
//entry 返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools、chat_attachment
//entry 返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools、chat_attachment
//shareTicket可用于调用getShareInfo接口
//shareTicket可用于调用getShareInfo接口
callBack
(
resolve
,
{
resolve
(
{
entry
,
entry
,
shareTicket
shareTicket
})
})
}
else
{
}
else
{
callBack
(
reject
)
reject
(
)
}
}
})
})
})
})
...
@@ -87,22 +89,25 @@ const WxConfig = {
...
@@ -87,22 +89,25 @@ const WxConfig = {
/** 外部联系人选人接口 */
/** 外部联系人选人接口 */
selectExternalContact
()
{
selectExternalContact
()
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
invoke
(
'selectExternalContact'
,
{
wx
.
invoke
(
filterType
:
0
,
//0表示展示全部外部联系人列表,1表示仅展示未曾选择过的外部联系人。默认值为0;除了0与1,其他值非法。在企业微信2.4.22及以后版本支持该参数
'selectExternalContact'
,
},
res
=>
{
{
if
(
res
.
err_msg
==
"selectExternalContact:ok"
)
{
filterType
:
0
//0表示展示全部外部联系人列表,1表示仅展示未曾选择过的外部联系人。默认值为0;除了0与1,其他值非法。在企业微信2.4.22及以后版本支持该参数
resolve
(
res
)
},
res
=>
{
if
(
res
.
err_msg
==
'selectExternalContact:ok'
)
{
resolve
(
res
)
}
}
}
}
)
)
})
})
},
},
/**分享消息到当前会话 */
/**分享消息到当前会话 */
sendChatMessage
(
params
)
{
sendChatMessage
(
params
)
{
console
.
log
(
params
)
console
.
log
(
params
)
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
invoke
(
'sendChatMessage'
,
params
,
res
=>
{
wx
.
invoke
(
'sendChatMessage'
,
params
,
res
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
if
(
res
.
err_msg
==
'sendChatMessage:ok'
)
{
if
(
res
.
err_msg
==
'sendChatMessage:ok'
)
{
...
@@ -114,7 +119,7 @@ const WxConfig = {
...
@@ -114,7 +119,7 @@ const WxConfig = {
/**群发消息给客户 */
/**群发消息给客户 */
shareToExternalContact
(
params
)
{
shareToExternalContact
(
params
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
invoke
(
'shareToExternalContact'
,
params
,
res
=>
{
wx
.
invoke
(
'shareToExternalContact'
,
params
,
res
=>
{
if
(
res
.
err_msg
==
'shareToExternalContact:ok'
)
{
if
(
res
.
err_msg
==
'shareToExternalContact:ok'
)
{
resolve
()
resolve
()
...
@@ -125,7 +130,7 @@ const WxConfig = {
...
@@ -125,7 +130,7 @@ const WxConfig = {
/**群发消息到客户群 */
/**群发消息到客户群 */
shareToExternalChat
(
params
)
{
shareToExternalChat
(
params
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
invoke
(
'shareToExternalChat'
,
params
,
res
=>
{
wx
.
invoke
(
'shareToExternalChat'
,
params
,
res
=>
{
if
(
res
.
err_msg
==
'shareToExternalChat:ok'
)
{
if
(
res
.
err_msg
==
'shareToExternalChat:ok'
)
{
resolve
()
resolve
()
...
@@ -141,7 +146,7 @@ const WxConfig = {
...
@@ -141,7 +146,7 @@ const WxConfig = {
/**发表内容到客户朋友圈 */
/**发表内容到客户朋友圈 */
shareToExternalMoments
(
params
)
{
shareToExternalMoments
(
params
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
invoke
(
'shareToExternalMoments'
,
params
,
res
=>
{
wx
.
invoke
(
'shareToExternalMoments'
,
params
,
res
=>
{
if
(
res
.
err_msg
==
'shareToExternalMoments:ok'
)
{
if
(
res
.
err_msg
==
'shareToExternalMoments:ok'
)
{
resolve
()
resolve
()
...
@@ -151,13 +156,8 @@ const WxConfig = {
...
@@ -151,13 +156,8 @@ const WxConfig = {
},
},
/**打开会话 */
/**打开会话 */
openEnterpriseChat
({
openEnterpriseChat
({
externalUserIds
=
[],
groupName
=
''
,
userIds
=
[],
chatId
=
''
})
{
externalUserIds
=
[],
return
new
Promise
(
resolve
=>
{
groupName
=
''
,
userIds
=
[],
chatId
=
''
})
{
return
new
Promise
((
resolve
)
=>
{
userIds
=
userIds
.
join
(
';'
)
userIds
=
userIds
.
join
(
';'
)
externalUserIds
=
externalUserIds
.
join
(
';'
)
externalUserIds
=
externalUserIds
.
join
(
';'
)
wx
.
openEnterpriseChat
({
wx
.
openEnterpriseChat
({
...
@@ -180,15 +180,15 @@ const WxConfig = {
...
@@ -180,15 +180,15 @@ const WxConfig = {
/**企业微信扫一扫 */
/**企业微信扫一扫 */
scanQRCode
(
needResult
)
{
scanQRCode
(
needResult
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
scanQRCode
({
wx
.
scanQRCode
({
desc
:
'scanQRCode desc'
,
desc
:
'scanQRCode desc'
,
needResult
,
// 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
needResult
,
// 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
scanType
:
[
"qrCode"
,
"barCode"
],
// 可以指定扫二维码还是条形码(一维码),默认二者都有
scanType
:
[
'qrCode'
,
'barCode'
],
// 可以指定扫二维码还是条形码(一维码),默认二者都有
success
(
res
)
{
success
(
res
)
{
resolve
(
res
)
resolve
(
res
)
},
},
error
:
function
(
res
)
{
error
:
function
(
res
)
{
if
(
res
.
errMsg
.
indexOf
(
'function_not_exist'
)
>
0
)
{
if
(
res
.
errMsg
.
indexOf
(
'function_not_exist'
)
>
0
)
{
alert
(
'版本过低请升级'
)
alert
(
'版本过低请升级'
)
}
}
...
@@ -214,7 +214,7 @@ const WxConfig = {
...
@@ -214,7 +214,7 @@ const WxConfig = {
/**拍照或从手机相册中选图接口 */
/**拍照或从手机相册中选图接口 */
chooseImage
(
count
=
1
)
{
chooseImage
(
count
=
1
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
chooseImage
({
wx
.
chooseImage
({
count
,
// 默认1
count
,
// 默认1
sizeType
:
[
'original'
,
'compressed'
],
// 可以指定是原图还是压缩图,默认二者都有
sizeType
:
[
'original'
,
'compressed'
],
// 可以指定是原图还是压缩图,默认二者都有
...
@@ -239,20 +239,20 @@ const WxConfig = {
...
@@ -239,20 +239,20 @@ const WxConfig = {
/**预览图片接口 */
/**预览图片接口 */
previewImage
(
obj
)
{
previewImage
(
obj
)
{
/**current 当前显示图片的http链接
/**current 当前显示图片的http链接
* urls 需要预览的图片http链接列表
* urls 需要预览的图片http链接列表
*/
*/
wx
.
previewImage
(
obj
)
wx
.
previewImage
(
obj
)
},
},
/**上传图片接口 */
/**上传图片接口 */
uploadImage
(
localId
)
{
uploadImage
(
localId
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
uploadImage
({
wx
.
uploadImage
({
localId
,
// 需要上传的图片的本地ID,由chooseImage接口获得
localId
,
// 需要上传的图片的本地ID,由chooseImage接口获得
isShowProgressTips
:
1
,
// 默认为1,显示进度提示
isShowProgressTips
:
1
,
// 默认为1,显示进度提示
success
(
res
)
{
success
(
res
)
{
resolve
(
res
)
// 返回图片的服务器端ID
resolve
(
res
)
// 返回图片的服务器端ID
/**备注:上传图片有效期3天,可用素材管理接口下载图片到自己的服务器,此处获得的 serverId 即 media_id。 */
/**备注:上传图片有效期3天,可用素材管理接口下载图片到自己的服务器,此处获得的 serverId 即 media_id。 */
}
}
})
})
})
})
...
@@ -260,7 +260,7 @@ const WxConfig = {
...
@@ -260,7 +260,7 @@ const WxConfig = {
/**下载图片接口 */
/**下载图片接口 */
downloadImage
(
serverId
)
{
downloadImage
(
serverId
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
downloadImage
({
wx
.
downloadImage
({
serverId
,
// 需要下载的图片的服务器端ID,由uploadImage接口获得
serverId
,
// 需要下载的图片的服务器端ID,由uploadImage接口获得
isShowProgressTips
:
1
,
// 默认为1,显示进度提示
isShowProgressTips
:
1
,
// 默认为1,显示进度提示
...
@@ -269,7 +269,6 @@ const WxConfig = {
...
@@ -269,7 +269,6 @@ const WxConfig = {
}
}
})
})
})
})
},
},
/**使用企业微信内置地图查看位置接口 */
/**使用企业微信内置地图查看位置接口 */
...
@@ -286,7 +285,7 @@ const WxConfig = {
...
@@ -286,7 +285,7 @@ const WxConfig = {
/**获取地理位置接口 */
/**获取地理位置接口 */
getLocation
(
type
=
'wgs84'
)
{
getLocation
(
type
=
'wgs84'
)
{
return
new
Promise
(
(
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
getLocation
({
wx
.
getLocation
({
type
,
// 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
type
,
// 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success
(
res
)
{
success
(
res
)
{
...
@@ -302,16 +301,14 @@ const WxConfig = {
...
@@ -302,16 +301,14 @@ const WxConfig = {
// desc: '', // 分享描述
// desc: '', // 分享描述
// link: '', // 分享链接
// link: '', // 分享链接
// imgUrl: '' // 分享封面
// imgUrl: '' // 分享封面
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
invoke
(
"shareAppMessage"
,
obj
,
wx
.
invoke
(
'shareAppMessage'
,
obj
,
function
(
res
)
{
function
(
res
)
{
if
(
res
.
err_msg
==
'shareAppMessage:ok'
)
{
if
(
res
.
err_msg
==
"shareAppMessage:ok"
)
{
resolve
(
res
)
resolve
(
res
)
}
else
{
}
else
{
reject
(
res
)
reject
(
res
)
}
}
}
)
}
)
})
})
},
},
/**自定义转发到微信 */
/**自定义转发到微信 */
...
@@ -320,18 +317,16 @@ const WxConfig = {
...
@@ -320,18 +317,16 @@ const WxConfig = {
// desc: '', // 分享描述
// desc: '', // 分享描述
// link: '', // 分享链接
// link: '', // 分享链接
// imgUrl: '' // 分享封面
// imgUrl: '' // 分享封面
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
(
resolve
=>
{
wx
.
invoke
(
'shareWechatMessage'
,
obj
,
wx
.
invoke
(
'shareWechatMessage'
,
obj
,
function
(
res
)
{
function
(
res
)
{
if
(
res
.
err_msg
==
'shareWechatMessage:ok'
)
{
if
(
res
.
err_msg
==
'shareWechatMessage:ok'
)
{
resolve
(
res
)
resolve
(
res
)
}
else
{
}
else
{
reject
(
res
)
reject
(
res
)
}
}
}
)
}
)
})
})
}
}
}
}
export
default
WxConfig
\ No newline at end of file
\ No newline at end of file
export
default
WxConfig
src/mixins/shareMixin.js
View file @
dc9c58a
...
@@ -2,15 +2,19 @@ import { shopmallApi, activityApi, couponApi, liveApi, boutiquecouponApi, equity
...
@@ -2,15 +2,19 @@ import { shopmallApi, activityApi, couponApi, liveApi, boutiquecouponApi, equity
const
{
environment
}
=
window
.
$fetchConfig
const
{
environment
}
=
window
.
$fetchConfig
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{}
}
},
},
mounted
()
{
mounted
()
{
if
(
this
.
$route
.
meta
.
isTab
)
this
.
wxInit
()
if
(
this
.
$route
.
meta
.
isTab
)
this
.
wxInit
()
},
},
methods
:
{
methods
:
{
wxInit
()
{
wxInit
()
{
wxConfig
.
init
([
'shareAppMessage'
,
'sendChatMessage'
,
'getCurExternalContact'
])
let
_this
=
this
wxConfig
.
init
([
'shareAppMessage'
,
'sendChatMessage'
,
'getCurExternalContact'
,
'getContext'
]).
then
(()
=>
{
wxConfig
.
getContext
().
then
(({
entry
})
=>
{
_this
.
$parent
.
entry
=
entry
})
})
},
},
showShareModel
(
i
)
{
showShareModel
(
i
)
{
let
{
tabIndex
}
=
this
let
{
tabIndex
}
=
this
...
...
src/views/home.vue
View file @
dc9c58a
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<transition
name=
"fade"
>
<transition
name=
"fade"
>
<router-view
v-if=
"!$route.meta.keepAlive"
></router-view>
<router-view
v-if=
"!$route.meta.keepAlive"
></router-view>
</transition>
</transition>
<template
v-if=
"$route.meta.isTab"
>
<template
v-if=
"$route.meta.isTab
&& entry != 'normal'
"
>
<tab-bar
:data=
"tabList"
></tab-bar>
<tab-bar
:data=
"tabList"
></tab-bar>
</
template
>
</
template
>
</template>
</template>
...
@@ -18,8 +18,9 @@
...
@@ -18,8 +18,9 @@
</template>
</template>
<
script
>
<
script
>
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
entry
:
'chat_attachment'
,
tabList
:
[
tabList
:
[
{
{
title
:
'卡券'
,
title
:
'卡券'
,
...
@@ -39,30 +40,28 @@ export default {
...
@@ -39,30 +40,28 @@ export default {
active
:
require
(
'@/assets/images/tabbar/merchant_active.png'
),
active
:
require
(
'@/assets/images/tabbar/merchant_active.png'
),
inactive
:
require
(
'@/assets/images/tabbar/merchant.png'
)
inactive
:
require
(
'@/assets/images/tabbar/merchant.png'
)
}
}
]
,
]
}
}
},
},
watch
:
{
watch
:
{
watchFlag
:
{
watchFlag
:
{
immediate
:
true
,
immediate
:
true
,
handler
(
newval
)
{
handler
(
newval
)
{
this
.
showWindow
=
newval
this
.
showWindow
=
newval
this
.
hideLoading
()
this
.
hideLoading
()
}
}
}
}
},
},
computed
:
{
computed
:
{
watchFlag
()
{
watchFlag
()
{
return
this
.
$store
.
state
.
app
.
showWindow
return
this
.
$store
.
state
.
app
.
showWindow
}
}
},
},
mounted
()
{
mounted
()
{},
},
methods
:
{
methods
:
{}
}
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
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