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 4457b445
authored
Nov 08, 2021
by
liwk
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit
1 parent
e7de3d1e
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
224 additions
and
44 deletions
public/index.html
src/api/index.js
src/api/wxConfig.js
src/components/Tab.vue
src/main.js
src/store/modules/app.js
src/utils/index.js
src/utils/util.js
src/views/coupon/index.vue
src/views/merchant/index.vue
vue.config.js
public/index.html
View file @
4457b44
...
...
@@ -18,7 +18,7 @@
to continue.
</strong>
</noscript>
<div
id=
"app"
></div>
<
script
src=
"//res.wx.qq.com/open/js/jweixin-1.2.0.js"
></script
>
<
!-- <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> --
>
<script
src=
"https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"
></script>
<!-- 使用CDN加速的JS文件,配置在vue.config.js下 -->
<
% for (var i in htmlWebpackPlugin.options.cdn
&&
htmlWebpackPlugin.options.cdn.js) { %>
...
...
@@ -27,4 +27,4 @@
<!-- built files will be auto injected -->
</body>
</html>
</html>
\ No newline at end of file
src/api/index.js
View file @
4457b44
...
...
@@ -7,10 +7,10 @@
* @LastEditTime: 2021-06-17 18:23:27
*/
import
ssoApi
from
'./ssoApi'
import
wx
C
onfig
from
'./wxConfig'
import
wx
_c
onfig
from
'./wxConfig'
import
shopmallApi
from
'./shopmallApi'
export
{
ssoApi
,
wx
C
onfig
,
wx
_c
onfig
,
shopmallApi
}
\ No newline at end of file
src/api/wxConfig.js
View file @
4457b44
...
...
@@ -2,37 +2,43 @@ import util from '@/utils/util'
import
{
Notify
}
from
'vant'
class
WxConfig
{
constructor
(
jsApiList
)
{
jsApiList
.
map
(
e
=>
{
if
(
e
==
'chooseImage'
)
jsApiList
.
push
(
'getLocalImgData'
)
})
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'#'
)
const
corpId
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
const
{
corpId
}
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
/** 获取企微应用AgentConfig */
let
data
=
{
corpId
,
method
:
'scrm.api.work.wechat.get.agent.config'
,
url
:
redirectUrl
,
appCode
:
'DJQW
ZS
'
appCode
:
'DJQW
GJ
'
}
window
.
$HTTP
({
url
:
'/rop-scrm-wechat/router'
,
data
}).
then
(
res
=>
{
console
.
log
(
res
)
if
(
res
)
{
this
.
setConfig
({
...
res
.
data
,
jsApiList
}).
then
(
obj
=>
{
if
(
obj
)
{
console
.
log
(
obj
)
wx
.
agentConfig
({
corpid
:
obj
.
corpId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
obj
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
:
obj
.
timestamp
,
// 必填,生成签名的时间戳
nonceStr
:
obj
.
nonceStr
,
// 必填,生成签名的随机串
signature
:
obj
.
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法,
jsApiList
,
success
(
res
)
{
console
.
log
(
res
)
},
fail
(
err
)
{
console
.
log
(
err
)
}
})
}
else
{
Notify
(
'网络异常'
)
}
})
}
setConfig
(
params
)
{
let
obj
=
{}
Object
.
keys
(
params
).
map
(
key
=>
{
if
(
params
[
key
])
obj
[
key
]
=
params
[
key
]
})
wx
.
agentConfig
(
obj
)
}
getContext
(
callBack
)
{
/**
* entry String 场景值
...
...
@@ -140,6 +146,136 @@ class WxConfig {
})
})
}
/**打开会话 */
openEnterpriseChat
({
externalUserIds
=
[],
groupName
=
''
,
userIds
=
[],
chatId
=
''
})
{
return
new
Promise
((
resolve
)
=>
{
userIds
=
userIds
.
join
(
';'
)
externalUserIds
=
externalUserIds
.
join
(
';'
)
wx
.
openEnterpriseChat
({
// 注意:userIds和externalUserIds至少选填一个。内部群最多2000人;外部群最多500人;如果有微信联系人,最多40人
userIds
,
//参与会话的企业成员列表,格式为userid1;userid2;...,用分号隔开。
externalUserIds
,
// 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
groupName
,
// 会话名称。单聊时该参数传入空字符串""即可。
chatId
,
// 若要打开已有会话,需指定此参数。如果是新建会话,chatId必须为空串
success
(
res
)
{
resolve
(
res
)
},
fail
(
res
)
{
if
(
res
.
errMsg
.
indexOf
(
'function not exist'
)
>
-
1
)
{
Notify
(
'版本过低请升级'
)
}
}
})
})
}
/**企业微信扫一扫 */
scanQRCode
(
needResult
)
{
return
new
Promise
((
resolve
)
=>
{
wx
.
scanQRCode
({
desc
:
'scanQRCode desc'
,
needResult
,
// 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
scanType
:
[
"qrCode"
,
"barCode"
],
// 可以指定扫二维码还是条形码(一维码),默认二者都有
success
(
res
)
{
resolve
(
res
)
},
error
:
function
(
res
)
{
if
(
res
.
errMsg
.
indexOf
(
'function_not_exist'
)
>
0
)
{
alert
(
'版本过低请升级'
)
}
}
})
})
}
/**获取本地图片接口 */
getLocalImgData
()
{
return
new
Promise
((
resolve
)
=>
{
wx
.
getLocalImgData
({
localId
:
''
,
// 图片的localID
success
(
res
)
{
resolve
(
res
)
//localData是图片的base64数据,可以用img标签显示
}
})
})
}
/**拍照或从手机相册中选图接口 */
chooseImage
(
count
=
1
)
{
return
new
Promise
((
resolve
)
=>
{
wx
.
chooseImage
({
count
,
// 默认1
sizeType
:
[
'original'
,
'compressed'
],
// 可以指定是原图还是压缩图,默认二者都有
sourceType
:
[
'album'
,
'camera'
],
// 可以指定来源是相册还是相机,默认二者都有
success
(
res
)
{
let
{
localIds
}
=
res
let
imgs
=
[]
localIds
.
map
((
e
,
index
)
=>
{
wx
.
getLocalImgData
({
localId
:
e
,
success
(
img
)
{
imgs
.
push
(
img
)
if
(
index
==
localIds
.
length
-
1
)
resolve
(
imgs
)
}
})
})
}
})
})
}
/**预览图片接口 */
previewImage
(
obj
)
{
/**current 当前显示图片的http链接
* urls 需要预览的图片http链接列表
*/
wx
.
previewImage
(
obj
)
}
/**上传图片接口 */
uploadImage
(
localId
)
{
return
new
Promise
((
resolve
)
=>
{
wx
.
uploadImage
({
localId
,
// 需要上传的图片的本地ID,由chooseImage接口获得
isShowProgressTips
:
1
,
// 默认为1,显示进度提示
success
(
res
)
{
resolve
(
res
)
// 返回图片的服务器端ID
/**备注:上传图片有效期3天,可用素材管理接口下载图片到自己的服务器,此处获得的 serverId 即 media_id。 */
}
})
})
}
/**使用企业微信内置地图查看位置接口 */
openLocation
(
obj
)
{
/**
latitude: 0, // 纬度,浮点数,范围为90 ~ -90
longitude: 0, // 经度,浮点数,范围为180 ~ -180。
name: '', // 位置名
address: '', // 地址详情说明
scale, // 地图缩放级别,整形值,范围从1~28。默认为16
*/
wx
.
openLocation
(
obj
)
}
/**获取地理位置接口 */
getLocation
(
type
=
'wgs84'
)
{
return
new
Promise
((
resolve
)
=>
{
wx
.
getLocation
({
type
,
// 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success
(
res
)
{
resolve
(
res
)
}
})
})
}
}
export
default
WxConfig
\ No newline at end of file
src/components/Tab.vue
View file @
4457b44
...
...
@@ -27,11 +27,15 @@ export default {
return
[]
}
},
sticky
:
Boolean
sticky
:
Boolean
,
index
:
{
type
:
Number
,
default
:
0
}
},
data
()
{
return
{
tabIndex
:
0
tabIndex
:
this
.
index
}
},
mounted
()
{
...
...
src/main.js
View file @
4457b44
...
...
@@ -21,7 +21,6 @@ import { bus, tools, store as local } from './utils'
import
'./utils/util'
import
'components'
import
{
components
}
from
'@/plugins/vant'
import
{
Http
}
from
'glsx-common'
components
.
forEach
(
component
=>
Vue
.
use
(
component
))
Vue
.
prototype
.
api
=
api
Vue
.
prototype
.
bus
=
bus
...
...
@@ -40,16 +39,14 @@ Vue.prototype.to = function(name, params) {
Vue
.
config
.
productionTip
=
false
import
VConsole
from
'vconsole'
const
vConsole
=
new
VConsole
()
//
const vConsole = new VConsole()
const
isMock
=
true
fetchConfig
(
!
isMock
).
then
(
res
=>
{
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue
.
use
(
cfg
)
window
.
$baseUrl
=
res
.
request
.
baseURL
window
.
$HTTP
=
new
Http
({...
res
,
alert
:
components
.
Notify
})
console
.
log
(
window
.
$HTTP
)
window
.
$fetchConfig
=
res
/**登录过期 重新登录 */
window
.
reLogin
=
()
=>
{
console
.
log
(
123
)
...
...
src/store/modules/app.js
View file @
4457b44
...
...
@@ -7,8 +7,9 @@
* @LastEditTime: 2021-07-06 12:02:21
*/
import
{
ssoApi
}
from
'@/api'
import
{
store
}
from
'utils'
import
util
from
'@/utils/util'
import
{
store
,
util
}
from
'utils'
import
{
Http
}
from
'glsx-common'
import
{
Notify
}
from
'vant'
const
state
=
{
pageMeta
:
''
,
keepAlives
:
[],
...
...
@@ -57,17 +58,20 @@ const actions = {
removeKeep
({
commit
},
names
)
{
commit
(
'REMOVE_KEEP'
,
names
)
},
login
()
{
login
(
{
dispatch
}
)
{
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'?'
)
const
code
=
getParams
(
'code'
)
if
(
code
)
{
const
corpId
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
const
{
corpId
}
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
ssoApi
.
login
({
code
,
corpId
}).
then
(({
code
,
data
,
message
})
=>
{
let
url
=
`
${
window
.
$baseUrl
}
/dj-scrm-wx-work-main/#/`
let
route
=
state
.
lastPath
==
'home'
?
''
:
state
.
lastPath
console
.
log
(
data
,
code
)
// const { baseURL } = window.$fetchConfig.request
const
[
baseURL
]
=
redirectUrl
.
split
(
'/dj-scrm-wx-work-main/'
)
let
url
=
`
${
baseURL
}
/dj-scrm-wx-work-main/#/`
let
route
=
state
.
lastPath
==
'home'
?
''
:
state
.
lastPath
||
''
state
.
showWindow
=
true
if
(
code
==
'0'
)
{
if
(
data
.
loginList
.
length
)
{
...
...
@@ -75,11 +79,30 @@ const actions = {
util
.
setLocalStorage
(
'dj_scrm_loginToken'
,
data
.
loginToken
)
util
.
setLocalStorage
(
'dj_scrm_accountList'
,
data
.
loginList
)
let
redirect_uri
=
encodeURI
(
`
${
redirectUrl
}${
route
}
`
)
window
.
location
.
replace
(
`
${
url
}
common/accountList?redirect_uri=
${
redirect_uri
}
`
)
//先注释 window.location.replace(`${url}common/accountList?redirect_uri=${redirect_uri}`)
//以下是 本地调试多账号默认第一个
let
[
userInfo
]
=
data
.
loginList
let
{
merchantId
,
accountName
}
=
userInfo
let
loginAccount
=
accountName
ssoApi
.
selectAccount
({
loginAccount
,
merchantId
,
loginToken
:
data
.
loginToken
,
loginSource
:
'WW'
,
loginType
:
3
}).
then
(
res
=>
{
util
.
removeLocalStorage
(
'dj_scrm_loginToken'
)
util
.
removeLocalStorage
(
'dj_scrm_accountList'
)
util
.
setLocalStorage
(
'dj_scrm_userInfo'
,
res
.
data
)
util
.
setSessionId
(
res
.
data
.
sessionId
)
dispatch
(
'registerHttp'
,
res
.
data
.
sessionId
)
window
.
location
.
replace
(
`
${
redirectUrl
}${
route
}
`
)
})
}
else
{
let
[
userInfo
]
=
data
.
loginList
util
.
setLocalStorage
(
'dj_scrm_userInfo'
,
userInfo
)
util
.
setLocalStorage
(
'dj_scrm_session_id'
,
userInfo
.
sessionId
)
util
.
setSessionId
(
userInfo
.
sessionId
)
registerHttp
(
userInfo
.
sessionId
)
// 只有一个账号 history.back()
console
.
log
(
`
${
redirectUrl
}${
route
}
`
)
window
.
location
.
replace
(
`
${
redirectUrl
}${
route
}
`
)
...
...
@@ -96,28 +119,35 @@ const actions = {
})
}
else
{
util
.
showLoading
()
let
corpId
=
getParams
(
'corpId'
)
//从链接获取
if
(
!
corpId
)
corpId
=
'ww7ee69c648ae1b7e6'
util
.
setLocalStorage
(
'dj_scrm_corpId'
,
corpId
)
let
appid
=
getParams
(
'corpId'
)
//从链接获取
let
dj_scrm
=
util
.
getLocalStorage
(
'dj_scrm_corpId'
)
if
(
!
appid
)
appid
=
dj_scrm
&&
dj_scrm
.
corpId
||
'ww7ee69c648ae1b7e6'
//
util
.
setLocalStorage
(
'dj_scrm_corpId'
,
{
corpId
:
appid
})
// 'ww657a2d4ae89a4424'
const
wxUrl
=
'https://open.weixin.qq.com/connect/oauth2/authorize'
window
.
location
.
replace
(
`
${
wxUrl
}
?appid=
${
corpId
}
&redirect_uri=
${
encodeURIComponent
(
redirectUrl
)}
&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
)
window
.
location
.
href
=
`
${
wxUrl
}
?appid=
${
appid
}
&redirect_uri=
${
encodeURIComponent
(
redirectUrl
)}
&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
}
},
navigation
({
dispatch
})
{
util
.
showLoading
()
const
sessionId
=
getParams
(
'sessionId'
)
const
storage_sessionId
=
util
.
get
LocalStorage
(
'dj_scrm_session_id'
)
const
storage_sessionId
=
util
.
get
SessionId
(
)
if
(
sessionId
||
storage_sessionId
)
{
state
.
showWindow
=
true
util
.
setLocalStorage
(
'dj_scrm_session_id'
,
sessionId
||
storage_sessionId
)
util
.
setSessionId
(
sessionId
||
storage_sessionId
)
registerHttp
(
sessionId
||
storage_sessionId
)
}
else
{
registerHttp
()
dispatch
(
'login'
)
return
}
state
.
showWindow
=
true
}
}
const
registerHttp
=
(
sessionId
=
''
)
=>
{
window
.
$HTTP
=
new
Http
({...
window
.
$fetchConfig
,
alert
:
Notify
,
headers
:
{
token
:
sessionId
}
})
}
const
getParams
=
name
=>
{
let
[
url
,
paramsList
]
=
window
.
location
.
href
.
split
(
'?'
)
if
(
!
paramsList
)
return
name
?
null
:
{}
...
...
src/utils/index.js
View file @
4457b44
...
...
@@ -7,8 +7,9 @@
* @LastEditTime: 2021-06-20 12:49:11
*/
import
bus
from
'./eventBus'
import
util
from
'./util'
import
*
as
tool
from
'./tools'
const
{
debounce
,
throttle
,
...
tools
}
=
tool
import
*
as
constants
from
'./constants'
import
store
from
'./store'
export
{
bus
,
tools
,
debounce
,
throttle
,
constants
,
store
}
\ No newline at end of file
export
{
bus
,
tools
,
debounce
,
throttle
,
constants
,
store
,
util
}
\ No newline at end of file
src/utils/util.js
View file @
4457b44
...
...
@@ -79,6 +79,12 @@ const touchstart = e => {
const
touchend
=
e
=>
{
e
.
target
.
classList
.
remove
(
'btn-on-leave'
)
}
const
setSessionId
=
val
=>
{
window
.
localStorage
.
setItem
(
'dj_scrm_session_id'
,
val
)
}
const
getSessionId
=
()
=>
{
return
window
.
localStorage
.
getItem
(
'dj_scrm_session_id'
)
}
const
setLocalStorage
=
(
key
,
item
)
=>
{
window
.
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
item
))
}
...
...
@@ -164,6 +170,8 @@ const utils = {
makePhoneCall
,
isFullSucreen
,
watchPageBack
,
setSessionId
,
getSessionId
,
showLoading
,
hideLoading
,
refreshPage
,
...
...
src/views/coupon/index.vue
View file @
4457b44
...
...
@@ -51,7 +51,8 @@
</template>
<
script
type=
'text/ecmascript-6'
>
let
test
=
false
import
{
wx_config
}
from
'@/api'
const
WX
=
new
wx_config
([
'shareToExternalContact'
])
export
default
{
name
:
''
,
data
()
{
...
...
@@ -80,10 +81,12 @@ export default {
methods
:
{
jump
()
{
window
.
$back
=
true
this
.
jumpChildrenPage
(
'list'
)
},
change
(
index
)
{
this
.
tabIndex
=
index
WX
.
shareToExternalContact
().
then
(
res
=>
{
console
.
log
(
res
)
})
},
onSelect
({
type
})
{
console
.
log
(
type
)
...
...
src/views/merchant/index.vue
View file @
4457b44
...
...
@@ -5,6 +5,7 @@
:data=
"['会员套餐','门店商品']"
@
change=
"change"
sticky
:index=
"tabIndex"
></tab>
<scroll-view
:class=
"['list-box']"
>
<div
:class=
"[`type-$
{tabIndex}`]">
...
...
vue.config.js
View file @
4457b44
...
...
@@ -51,7 +51,7 @@ const spritesmithFunction = data => {
}
module
.
exports
=
{
publicPath
:
IS_PROD
?
'./'
:
'/dj-scrm-wx-work-main/
attachment-activity/'
,
// 署应用包时的基本 URL。 vue-router hash 模式
使用
publicPath
:
IS_PROD
?
'./'
:
'/dj-scrm-wx-work-main/
'
,
// 本地调试时需登录时
使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-attachment-activity/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: '/dj-scrm-wx-work-attachment-activity/', // 署应用包时的基本 URL。 vue-router history模式使用
...
...
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