Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
8e33b134
Commit
8e33b134
authored
Jul 19, 2021
by
zhangleyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:处理open-data组件
parent
b2c30729
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
148 additions
and
4 deletions
+148
-4
src/common/js/wechatApi.js
+124
-0
src/components/WWOpenDataCom.jsx
+11
-0
src/index.html
+3
-1
src/modules/college-manage/EmployeeManage.tsx
+4
-1
src/modules/root/App.tsx
+6
-2
No files found.
src/common/js/wechatApi.js
0 → 100644
View file @
8e33b134
/*
* @Author: wufan
* @Date: 2021-05-11 10:21:37
* @LastEditors: Please set LastEditors
* @LastEditTime: 2021-07-19 15:24:27
* @Description: 企业微信api
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import
User
from
'@/common/js/user'
;
import
Service
from
'@/common/js/service'
;
export
default
class
WechatApi
{
static
async
initConfig
(
params
=
{
isAgentConfig
:
false
,
url
:
''
})
{
return
Service
.
Hades
(
'anon/hades/getWxCorpJSAPISignature'
,
{
storeId
:
User
.
getStoreId
(),
url
:
params
.
url
,
}).
then
((
result
)
=>
{
const
res
=
result
.
result
;
this
.
config
({
beta
:
true
,
// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
debug
:
false
,
// 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId
:
res
.
appId
,
// 必填,企业微信的corpID
timestamp
:
res
.
timestamp
,
// 必填,生成签名的时间戳
nonceStr
:
res
.
nonceStr
,
// 必填,生成签名的随机串
signature
:
res
.
signature
,
// 必填,签名,见 附录-JS-SDK使用权限签名算法
jsApiList
:
[
'chooseImage'
,
'shareToExternalContact'
,
'selectExternalContact'
,
'selectEnterpriseContact'
],
}).
then
(()
=>
{
console
.
log
(
'微信config设置完毕'
)
if
(
params
.
isAgentConfig
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
Service
.
Hades
(
'anon/hades/getWxWorkJSAPISignature'
,
{
storeId
:
User
.
getStoreId
(),
url
:
params
.
url
,
}).
then
((
result2
)
=>
{
const
res2
=
result2
.
result
;
this
.
agentConfig
({
corpid
:
res2
.
corpid
,
// 必填,企业微信的corpid,必须与当前登录的企业一致
agentid
:
res2
.
agentid
,
// 必填,企业微信的应用id (e.g. 1000247)
timestamp
:
res2
.
timestamp
,
// 必填,生成签名的时间戳
nonceStr
:
res2
.
nonceStr
,
// 必填,生成签名的随机串
signature
:
res2
.
signature
,
// 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList
:
[
'selectExternalContact'
,
'getCurExternalContact'
,
'getContext'
,
'shareToExternalContact'
,
'sendChatMessage'
,
'shareToExternalChat'
],
success
:
(
res
)
=>
{
console
.
log
(
res
,
'res-agentconfig'
);
console
.
info
(
'window.WWOpenData'
,
window
.
WWOpenData
);
resolve
(
res
);
},
fail
:
(
err
)
=>
{
console
.
log
(
1213545344545
)
console
.
log
(
err
,
'err-agentconfig'
);
reject
(
err
);
},
});
});
});
}
})
});
}
static
async
config
(
config
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
info
(
'wx.config'
,
config
);
wx
.
config
(
config
);
wx
.
ready
(
resolve
);
wx
.
error
(
reject
);
}).
then
(
()
=>
{
console
.
info
(
'wx.ready'
);
},
(
error
)
=>
{
console
.
error
(
'wx.error'
,
error
);
throw
error
;
}
);
}
static
async
agentConfig
(
config
)
{
return
new
Promise
((
success
,
fail
)
=>
{
console
.
info
(
'wx.agentConfig'
,
config
);
wx
.
agentConfig
({
...
config
,
success
,
fail
});
}).
then
(
(
res
)
=>
{
console
.
info
(
'wx.agentConfig success'
,
res
);
return
res
;
},
(
error
)
=>
{
console
.
error
(
'wx.agentConfig fail'
,
error
);
throw
error
;
}
);
}
static
getCurExternalContact
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
ready
(()
=>
{
wx
.
invoke
(
'getCurExternalContact'
,
{},
function
(
res
)
{
if
(
res
.
err_msg
==
'getCurExternalContact:ok'
)
{
resolve
(
res
.
userId
);
//返回当前外部联系人userId
}
else
{
reject
(
res
.
err_msg
);
//错误处理
}
});
});
});
}
static
getContext
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
ready
(()
=>
{
wx
.
invoke
(
'getContext'
,
{},
function
(
res
)
{
if
(
res
.
err_msg
==
'getContext:ok'
)
{
resolve
(
res
.
entry
);
//返回进入H5页面的入口类型,目前有normal、contact_profile、single_chat_tools、group_chat_tools、chat_attachment
}
else
{
reject
(
res
.
err_msg
);
//错误处理
}
});
});
});
}
}
src/components/WWOpenDataCom.jsx
0 → 100644
View file @
8e33b134
import
React
,
{
useRef
,
useLayoutEffect
}
from
'react'
export
default
function
WWOpenDataCom
({
type
,
openid
})
{
const
ref
=
useRef
(
null
)
useLayoutEffect
(()
=>
{
console
.
log
(
WWOpenData
)
WWOpenData
&&
WWOpenData
.
bind
(
ref
.
current
)
})
return
<
ww
-
open
-
data
ref=
{
ref
}
type=
{
type
}
openid=
{
openid
}
/>
}
\ No newline at end of file
src/index.html
View file @
8e33b134
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: 吴文洁
* @Author: 吴文洁
* @Date: 2020-08-24 12:20:57
* @Date: 2020-08-24 12:20:57
* @LastEditors: Please set LastEditors
* @LastEditors: Please set LastEditors
* @LastEditTime: 2021-07-
08 19:38:52
* @LastEditTime: 2021-07-
19 15:48:51
* @Description:
* @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有
* @Copyright: 杭州杰竞科技有限公司 版权所有
-->
-->
...
@@ -47,6 +47,8 @@
...
@@ -47,6 +47,8 @@
<script
type=
"text/javascript"
src=
"https://image.xiaomaiketang.com/xm/PhotoClip.js"
></script>
<script
type=
"text/javascript"
src=
"https://image.xiaomaiketang.com/xm/PhotoClip.js"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"//g.alicdn.com/sd/ncpc/nc.js?t=2015052012"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"//g.alicdn.com/sd/ncpc/nc.js?t=2015052012"
></script>
<script
type=
"text/javascript"
src=
"https://xiaomai-js.oss-cn-hangzhou.aliyuncs.com/loghub-xm-0.0.1-beta.js"
></script>
<script
type=
"text/javascript"
src=
"https://xiaomai-js.oss-cn-hangzhou.aliyuncs.com/loghub-xm-0.0.1-beta.js"
></script>
<script
type=
"text/javascript"
src=
"//res.wx.qq.com/open/js/jweixin-1.2.0.js"
></script>
<script
type=
"text/javascript"
src=
"//open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"
></script>
</head>
</head>
<body>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
...
...
src/modules/college-manage/EmployeeManage.tsx
View file @
8e33b134
...
@@ -16,6 +16,7 @@ import StoreService from "@/domains/store-domain/storeService";
...
@@ -16,6 +16,7 @@ import StoreService from "@/domains/store-domain/storeService";
import
EmployeeAddOrEditModal
from
"../store-manage/EmployeeAddOrEditModal"
;
import
EmployeeAddOrEditModal
from
"../store-manage/EmployeeAddOrEditModal"
;
import
User
from
"@/common/js/user"
;
import
User
from
"@/common/js/user"
;
import
LimitTip
from
"./LimitTip"
;
import
LimitTip
from
"./LimitTip"
;
import
WWOpenDataCom
from
'@/components/WWOpenDataCom'
;
import
"./EmployeeManage.less"
;
import
"./EmployeeManage.less"
;
import
ChooseMembersModal
from
"./modal/ChooseMembersModal"
;
import
ChooseMembersModal
from
"./modal/ChooseMembersModal"
;
...
@@ -152,7 +153,9 @@ function EmployeeManage() {
...
@@ -152,7 +153,9 @@ function EmployeeManage() {
/>
/>
)
}
)
}
<
span
className=
"title"
>
{
val
}
</
span
>
<
span
className=
"title"
>
<
WWOpenDataCom
type=
"userName"
openid=
{
val
}
/>
</
span
>
</
div
>
</
div
>
);
);
},
},
...
...
src/modules/root/App.tsx
View file @
8e33b134
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: 吴文洁
* @Author: 吴文洁
* @Date: 2019-07-10 10:30:49
* @Date: 2019-07-10 10:30:49
* @LastEditors: Please set LastEditors
* @LastEditors: Please set LastEditors
* @LastEditTime: 2021-0
6-22 17:47:02
* @LastEditTime: 2021-0
7-19 16:21:07
* @Description:
* @Description:
*/
*/
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
;
...
@@ -19,6 +19,7 @@ import { VersionContext, VersionInfo, XMContext } from '@/store/context';
...
@@ -19,6 +19,7 @@ import { VersionContext, VersionInfo, XMContext } from '@/store/context';
import
{
setStoreGroupPermission
,
setStorePermission
,
setStoreGroupList
,
setStoreList
}
from
'@/store/actions/index'
;
import
{
setStoreGroupPermission
,
setStorePermission
,
setStoreGroupList
,
setStoreList
}
from
'@/store/actions/index'
;
import
Service
from
"@/common/js/service"
;
import
Service
from
"@/common/js/service"
;
import
Bus
from
'@/core/tbus'
;
import
Bus
from
'@/core/tbus'
;
import
WechatApi
from
'@/common/js/wechatApi'
;
import
{
func
}
from
'prop-types'
;
import
{
func
}
from
'prop-types'
;
const
{
Footer
,
Sider
,
Content
}
=
Layout
;
const
{
Footer
,
Sider
,
Content
}
=
Layout
;
...
@@ -36,6 +37,7 @@ const App: React.FC = (props: any) => {
...
@@ -36,6 +37,7 @@ const App: React.FC = (props: any) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
initWechatConfig
();
getStoreAndUserInfo
();
getStoreAndUserInfo
();
getVersion
();
getVersion
();
if
(
window
.
location
.
hash
===
"#/"
)
{
if
(
window
.
location
.
hash
===
"#/"
)
{
...
@@ -44,7 +46,9 @@ const App: React.FC = (props: any) => {
...
@@ -44,7 +46,9 @@ const App: React.FC = (props: any) => {
})
})
}
}
},
[])
},
[])
async
function
initWechatConfig
()
{
WechatApi
.
initConfig
({
isAgentConfig
:
true
,
url
:
window
.
location
.
href
.
split
(
'#'
)[
0
]
})
}
useEffect
(()
=>
{
useEffect
(()
=>
{
getStorePermission
();
getStorePermission
();
},
[
window
.
location
.
hash
])
},
[
window
.
location
.
hash
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment