Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
scrm-wx-merchant-activity
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 d3967981
authored
Aug 01, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改地址交互、获取微信config增加重载
1 parent
ee60db15
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
55 deletions
src/api/wxConfig.js
src/assets/css/crowdfunding.scss
src/utils/util.js
src/views/crowdfunding/index.vue
src/api/wxConfig.js
View file @
d396798
import
util
from
'@/utils/util'
import
{
Notify
}
from
'vant'
let
requestCount
=
0
let
wwRequestCount
=
0
const
WxConfig
=
{
init
(
jsApiList
=
[])
{
const
isWxWork
=
window
.
$ISWXWORK
...
...
@@ -7,29 +9,43 @@ const WxConfig = {
jsApiList
.
map
(
e
=>
{
if
(
e
==
'chooseImage'
)
jsApiList
.
push
(
'getLocalImgData'
)
})
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'#'
)
if
(
isWxWork
)
{
const
STORAGE_PARAMS
=
util
.
getLocalStorage
(
'wx_scrm_link_params'
)
let
data
=
{
corpId
:
STORAGE_PARAMS
.
corpId
,
method
:
'scrm.api.work.wechat.get.agent.config'
,
url
:
redirectUrl
,
appCode
:
'DJQWGJ'
}
this
.
getWxConfig
(
jsApiList
).
then
(()
=>
{
console
.
log
(
'wxconfig'
)
wx
.
ready
(()
=>
{
window
.
$HTTP
({
url
:
'/rop-scrm-wechat/router'
,
data
}).
then
(
obj
=>
{
if
(
obj
)
{
return
this
.
getWWConfig
(
jsApiList
).
then
(()
=>
{
resolve
()
})
}
else
{
return
this
.
getWxConfig
(
jsApiList
).
then
(()
=>
{
resolve
()
})
}
})
},
getWWConfig
(
jsApiList
)
{
wwRequestCount
+=
1
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'#'
)
return
new
Promise
((
resolve
)
=>
{
const
STORAGE_PARAMS
=
util
.
getLocalStorage
(
'wx_scrm_link_params'
)
let
data
=
{
corpId
:
STORAGE_PARAMS
.
corpId
,
method
:
'scrm.api.work.wechat.get.agent.config'
,
url
:
redirectUrl
,
appCode
:
'DJQWGJ'
}
this
.
getWxConfig
(
jsApiList
).
then
(()
=>
{
wx
.
ready
(()
=>
{
window
.
$HTTP
({
url
:
'/rop-scrm-wechat/router'
,
data
,
returnAll
:
true
}).
then
(({
code
,
data
,
message
})
=>
{
if
(
code
==
'0'
)
{
if
(
data
)
{
wx
.
agentConfig
({
corpid
:
obj
.
corpId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
obj
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
:
obj
.
timestamp
,
// 必填,生成签名的时间戳
nonceStr
:
obj
.
nonceStr
,
// 必填,生成签名的随机串
signature
:
obj
.
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法,
corpid
:
data
.
corpId
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
data
.
agentId
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
:
data
.
timestamp
,
// 必填,生成签名的时间戳
nonceStr
:
data
.
nonceStr
,
// 必填,生成签名的随机串
signature
:
data
.
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法,
jsApiList
:
[
'getContext'
,
...
jsApiList
],
success
(
res
)
{
console
.
log
(
res
,
'ww_config'
)
...
...
@@ -37,47 +53,62 @@ const WxConfig = {
},
fail
(
err
)
{
console
.
log
(
err
,
'ww_config'
)
reject
(
err
)
Notify
(
JSONStringify
(
err
)
)
}
})
}
else
{
Notify
(
'网络异常'
)
if
(
wwRequestCount
<
3
)
this
.
getWWConfig
(
jsApiList
)
else
util
.
refreshPage
(
'获取WWCONFIG失败'
).
then
(()
=>
{
window
.
location
.
reload
()
})
}
})
}
else
{
if
(
wwRequestCount
<
3
)
this
.
getWWConfig
(
jsApiList
)
else
util
.
refreshPage
(
message
).
then
(()
=>
{
window
.
location
.
reload
()
})
}
})
})
}
else
{
return
this
.
getWxConfig
(
jsApiList
).
then
(()
=>
{
resolve
()
})
}
})
})
},
getWxConfig
(
jsApiList
)
{
requestCount
+=
1
let
[
redirectUrl
]
=
window
.
location
.
href
.
split
(
'#'
)
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
)
=>
{
window
.
$HTTP
({
url
:
'/rop-scrm-equity/router'
,
data
:
{
url
:
redirectUrl
,
appId
:
window
.
$fetchConfig
.
appid
,
method
:
'scrm.api.equity.common.wechat.jsconfig'
}
}).
then
(
data
=>
{
if
(
data
)
{
let
obj
=
{}
Object
.
keys
(
data
).
map
(
key
=>
{
if
(
data
[
key
])
obj
[
key
]
=
data
[
key
]
})
wx
.
config
({
...
obj
,
jsApiList
,
openTagList
:
[
'wx-open-launch-weapp'
]
})
resolve
()
},
returnAll
:
true
}).
then
(({
code
,
data
,
message
})
=>
{
if
(
code
==
'0'
)
{
if
(
data
)
{
let
obj
=
{}
Object
.
keys
(
data
).
map
(
key
=>
{
if
(
data
[
key
])
obj
[
key
]
=
data
[
key
]
})
wx
.
config
({
...
obj
,
jsApiList
,
openTagList
:
[
'wx-open-launch-weapp'
]
})
resolve
()
}
else
{
if
(
requestCount
<
3
)
this
.
getWxConfig
(
jsApiList
)
else
util
.
refreshPage
(
'获取WXCONFIG失败'
).
then
(()
=>
{
window
.
location
.
reload
()
})
}
}
else
{
reject
()
Notify
(
'网络异常'
)
if
(
requestCount
<
3
)
this
.
getWxConfig
(
jsApiList
)
else
util
.
refreshPage
(
message
).
then
(()
=>
{
window
.
location
.
reload
()
})
}
})
})
...
...
src/assets/css/crowdfunding.scss
View file @
d396798
...
...
@@ -198,6 +198,9 @@
.icon-address
{
margin
:
0
auto
;
}
.auth-text
{
font-size
:
8px
;
}
}
}
...
...
src/utils/util.js
View file @
d396798
...
...
@@ -173,7 +173,7 @@ const refreshPage = (message = '系统异常') => {
message
,
theme
:
'round-button'
,
confirmButtonText
:
'点击重试'
,
confirmButtonColor
:
'#
FF7336
'
confirmButtonColor
:
'#
f13c3d
'
})
}
const
toTop
=
()
=>
{
...
...
src/views/crowdfunding/index.vue
View file @
d396798
...
...
@@ -94,10 +94,16 @@
<div
class=
"address-btn"
:key=
"distanceKey"
@
click=
"
openLocation
"
@
click=
"
authLocation(detail)
"
>
<div
class=
"sprite-icon icon-address"
></div>
<template
v-if=
"detail.distance"
>
{{
detail
.
distance
}}
km
</
template
>
<
template
v-else
>
<div
class=
"auth-text"
>
获取门店距离
</div>
</
template
>
</div>
</template>
</div>
...
...
@@ -313,17 +319,21 @@ export default {
if
(
!
this
.
ISWXWORK
)
wxConfig
.
updateAppMessageShareData
(
this
.
shareInfo
)
else
wxConfig
.
onMenuShareAppMessage
(
this
.
shareInfo
)
if
(
data
.
activityAddressLat
&&
data
.
activityAddressLng
)
{
wxConfig
.
getLocation
().
then
(
res
=>
{
console
.
log
(
res
)
mapApi
.
calculateDistance
([
res
.
latitude
,
res
.
longitude
],
[
data
.
activityAddressLat
,
data
.
activityAddressLng
]).
then
(({
elements
:
[
address
]
}
)
=>
{
console
.
log
(
address
)
this
.
detail
.
distance
=
Number
((
address
.
distance
/
1000
)).
toFixed
(
2
)
this
.
distanceKey
=
Date
.
now
()
}
)
}
)
}
}
)
}
,
authLocation
(
data
)
{
if
(
data
.
distance
)
this
.
openLocation
()
else
wxConfig
.
getLocation
().
then
(
res
=>
{
console
.
log
(
res
)
mapApi
.
calculateDistance
([
res
.
latitude
,
res
.
longitude
],
[
data
.
activityAddressLat
,
data
.
activityAddressLng
]).
then
(({
elements
:
[
address
]
}
)
=>
{
console
.
log
(
address
)
this
.
detail
.
distance
=
Number
((
address
.
distance
/
1000
)).
toFixed
(
2
)
this
.
distanceKey
=
Date
.
now
()
}
)
}
)
}
,
imgError
(
index
)
{
this
.
detail
.
activityVideos
[
index
].
poster
=
''
}
,
...
...
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