gc_mobile 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/package.json +28 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 QiLiang Hu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # 绿云移动端类库
2
+
3
+
4
+ ## 简介
5
+
6
+ 支持免登各类客户端并获取用户中心信息
7
+
8
+ ## 安装
9
+
10
+ ```bash
11
+ npm install gc_mobile--save
12
+ ```
13
+
14
+ ## 使用
15
+
16
+ ```javascript
17
+ const res = await mobile({
18
+ appCode: "DZ-TEST", // 应用appCode名字
19
+ apiPrefix:"http://www.baidu.com" // api前缀 dev/prod/api路径,不传默认dev
20
+ });
21
+ console.log("res", res.userInfo); // 获取用户信息和ucToken
22
+ this.$store.commit("setUserInfo",res.userInfo) // 保存到vuex
23
+ ```
24
+
25
+ ## 钉钉免登测试流程
26
+
27
+ 1.启动uniapp或本地环境,假设为 http://192.168.1.43:8081,corpId为绿云科技corpId ( ding013ea2dcb2eb81a5f2c783f7214b6d69 )
28
+
29
+ http://192.168.1.43:8081/?corpId=ding013ea2dcb2eb81a5f2c783f7214b6d69
30
+
31
+ 2.登录钉钉后台,新建一个测试应用并将首页设置为 http://192.168.1.43:8081(本地或测试域名),保存并发布版本 ( 此步骤可联系管理员处理 )
32
+
33
+ 3.将手机和电脑连接到同一网络,并配置vue-cli或uniapp局域网可访问
34
+
35
+ 4.测试环境配置代理(测试环境不支持跨域),方式如下:
36
+
37
+ ```json
38
+
39
+ vue-cli或vite代理配置
40
+
41
+ proxy: {
42
+ "/api": {
43
+ "target": "https://test.ihotel.cn/gw/v1/platform-gcding/",
44
+ "changeOrigin": true
45
+ }
46
+ }
47
+ ```
48
+
49
+ ```json
50
+
51
+ uniapp的配置,打开manifest.json,切换到源码视图,加入代码
52
+
53
+ "h5" : {
54
+ "devServer" : {
55
+ "disableHostCheck" : true,
56
+ "proxy" : {
57
+ "/api" : {
58
+ "target" : "https://test.ihotel.cn/gw/v1/platform-gcding/",
59
+ "changeOrigin" : true
60
+ }
61
+ }
62
+ }
63
+ },
64
+
65
+ ```
66
+ 5.手机端查看测试
67
+
68
+
69
+ ## 参数说明
70
+
71
+ | 属性 | 说明 | 类型 | 默认值 |
72
+ | :-------: | :------------: | :----: | :----: |
73
+ | appCode | 必传,应用appCode名字 |string | / |
74
+ | apiPrefix | api前缀,dev/prod/自定义api路径,不传默认dev | string | dev |
75
+
76
+ ## 返回参数说明
77
+
78
+ | 属性 | 说明 | 类型 | 默认值 |
79
+ | :-------: | :------------: | :----: | :----: |
80
+ | config | 配置项信息 | Object | / |
81
+ | env | 当前环境信息 | Object | / |
82
+ | js | 当前库的返回值,钉钉环境返回钉钉js操作库 | Object | / |
83
+ | userInfo | 用户信息,ucToken为用户中心token | Object | / |
84
+
85
+ ## 返回参数示例:
86
+
87
+ ```json
88
+ {
89
+ "config": {
90
+ "appCode": "DZ-TEST"
91
+ },
92
+ "env": {
93
+ "code": "dd",
94
+ "name": "钉钉",
95
+ "value": true
96
+ },
97
+ "js": {
98
+ "dd": {
99
+ }
100
+ },
101
+ "userInfo": {
102
+ "avatarUrl": "",
103
+ "corpId": "ding013ea2dcb2eb81a5f2c783f7214b6d69",
104
+ "generalDing": false,
105
+ "id": 156,
106
+ "mobile": "+86-17826856221",
107
+ "nick": "",
108
+ "openId": "",
109
+ "resultDetailDtos": [
110
+ {
111
+ "appCode": "DZ-TEST",
112
+ "deptId": "",
113
+ "deptName": "",
114
+ "parentUnitCode": "GCBZG1",
115
+ "unitCode": "GCBZG1",
116
+ "unitName": "绿云标准版标准库集团",
117
+ "unitType": "GROUP",
118
+ "userCode": "",
119
+ "userName": ""
120
+ }
121
+ ],
122
+ "ucToken": "eyJhbGciOiJIUzUxMiJ9.eyJkZXZpY2VUeXBlIjoiQ09NUFVURVIiLCJtYWluQXBwQ29kZSI6IkRaLVRFU1QiLCJvcmdDb2RlIjoiR0NCWkcxIiwidWNTZXJ2ZXJVcmwiOiJodHRwOi8vMTkyLjE2OC4wLjg1OjIyMjIvdWMtd2ViLyIsImFwcENvZGUiOiJEWi1URVNUIiwidXNlclR5cGUiOiJOT1JNQUwiLCJsb2dpbkF0IjoxNzE3MjkzOTg2MDAwLCJwcmluY2lwYWxVc2VyQ29kZSI6IlpDWSIsImV4cCI6MzI1MDM2NTEyMDAsInVzZXJDb2RlIjoiWkNZIiwic3NvIjoiU1NPX1NFUlZFUiJ9.USTdSQ1sxqHsAor-LtUbxxeqirAVc2LQJ1qKD-SxBy9i8pW5eMpyz15gvKj_MXAkcV"
123
+ }
124
+ }
125
+
126
+ ```
127
+
128
+ ## 示例代码
129
+
130
+
131
+ ```bash
132
+ 示例代码文件夹说明
133
+
134
+ example/
135
+ └── dd // uniapp 钉钉示例
136
+ ```
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "gc_mobile",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "files": [
6
+ "dist",
7
+ "index.d.ts"
8
+ ],
9
+ "main": "./libs/main.umd.cjs",
10
+ "module": "./libs/main.js",
11
+ "types": "./index.d.ts",
12
+ "scripts": {
13
+ "dev": "vite",
14
+ "build:dev": "vite build --mode development",
15
+ "build": "vite build",
16
+ "cnpm": "cnpm sync gc_mobile"
17
+ },
18
+ "devDependencies": {
19
+ "vconsole": "^3.15.1",
20
+ "vite": "^5.2.10"
21
+ },
22
+ "dependencies": {
23
+ "axios": "^1.7.2",
24
+ "dingtalk-jsapi": "^3.0.33",
25
+ "lodash-es": "^4.17.21",
26
+ "qs": "^6.12.1"
27
+ }
28
+ }