ynkszx-applet-study-player 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.
- package/README.md +275 -0
- package/package.json +19 -0
- package/src/api/auth.js +102 -0
- package/src/api/player.js +27 -0
- package/src/api/upload.js +28 -0
- package/src/components/jjb-auth/code-comp/code-comp.js +83 -0
- package/src/components/jjb-auth/code-comp/code-comp.json +8 -0
- package/src/components/jjb-auth/code-comp/code-comp.wxml +33 -0
- package/src/components/jjb-auth/code-comp/code-comp.wxss +19 -0
- package/src/components/jjb-auth/face-comp/face-comp.js +125 -0
- package/src/components/jjb-auth/face-comp/face-comp.json +4 -0
- package/src/components/jjb-auth/face-comp/face-comp.wxml +39 -0
- package/src/components/jjb-auth/face-comp/face-comp.wxss +39 -0
- package/src/components/jjb-auth/face-conf/face-conf.js +36 -0
- package/src/components/jjb-auth/face-conf/face-conf.json +4 -0
- package/src/components/jjb-auth/face-conf/face-conf.wxml +17 -0
- package/src/components/jjb-auth/face-conf/face-conf.wxss +26 -0
- package/src/components/jjb-auth/jjb-auth.js +200 -0
- package/src/components/jjb-auth/jjb-auth.json +11 -0
- package/src/components/jjb-auth/jjb-auth.wxml +44 -0
- package/src/components/jjb-auth/living-comp/living-comp.js +221 -0
- package/src/components/jjb-auth/living-comp/living-comp.json +4 -0
- package/src/components/jjb-auth/living-comp/living-comp.wxml +44 -0
- package/src/components/jjb-auth/living-comp/living-comp.wxss +48 -0
- package/src/components/jjb-auth/msg-comp/msg-comp.js +27 -0
- package/src/components/jjb-auth/msg-comp/msg-comp.json +8 -0
- package/src/components/jjb-auth/msg-comp/msg-comp.wxml +16 -0
- package/src/components/jjb-auth/msg-comp/msg-comp.wxss +17 -0
- package/src/components/jjb-auth/qa-auth.wxss +9 -0
- package/src/components/jjb-auth/tip-comp/tip-comp.js +38 -0
- package/src/components/jjb-auth/tip-comp/tip-comp.json +4 -0
- package/src/components/jjb-auth/tip-comp/tip-comp.wxml +20 -0
- package/src/components/jjb-auth/tip-comp/tip-comp.wxss +25 -0
- package/src/components/jjb-player/jjb-player.js +73 -0
- package/src/components/jjb-player/jjb-player.json +7 -0
- package/src/components/jjb-player/jjb-player.wxml +19 -0
- package/src/components/jjb-player/jjb-player.wxss +1 -0
- package/src/components/jjb-player/video-comp/time.wxs +11 -0
- package/src/components/jjb-player/video-comp/video-comp.js +250 -0
- package/src/components/jjb-player/video-comp/video-comp.json +4 -0
- package/src/components/jjb-player/video-comp/video-comp.wxml +52 -0
- package/src/components/jjb-player/video-comp/video-comp.wxss +35 -0
- package/src/components/jjb-verify/verify-idcard/verify-idcard.js +47 -0
- package/src/components/jjb-verify/verify-idcard/verify-idcard.json +4 -0
- package/src/components/jjb-verify/verify-idcard/verify-idcard.wxml +3 -0
- package/src/components/jjb-verify/verify-idcard/verify-idcard.wxss +2 -0
- package/src/components/jjb-verify/verify-move/verify-move.js +44 -0
- package/src/components/jjb-verify/verify-move/verify-move.json +4 -0
- package/src/components/jjb-verify/verify-move/verify-move.wxml +3 -0
- package/src/components/jjb-verify/verify-move/verify-move.wxss +9 -0
- package/src/components/jjb-verify/verify-number/verify-number.js +60 -0
- package/src/components/jjb-verify/verify-number/verify-number.json +4 -0
- package/src/components/jjb-verify/verify-number/verify-number.wxml +9 -0
- package/src/components/jjb-verify/verify-number/verify-number.wxss +2 -0
- package/src/lib/crypto.js +55 -0
- package/src/style/common.wxss +113 -0
- package/src/utils/crypto.js +43 -0
- package/src/utils/http/config/index.js +7 -0
- package/src/utils/http/index.js +173 -0
- package/src/utils/oss/config/index.js +5 -0
- package/src/utils/oss/index.js +6 -0
- package/src/utils/storage.js +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# 微信小程序学时监管 SDK 说明文档
|
|
2
|
+
|
|
3
|
+
## 描述
|
|
4
|
+
|
|
5
|
+
`@cqsjjb/yn-applet-study-player`用于微信小程序点播课的实时学时监管
|
|
6
|
+
|
|
7
|
+
## 使用场景
|
|
8
|
+
|
|
9
|
+
1、课程视频学习时使用,集成了 Video 播放器、学时监管、随机验证等;
|
|
10
|
+
2、只需引入组件,传入对应参数,即可开始学习,不需要再自己写视频学习逻辑。
|
|
11
|
+
|
|
12
|
+
## 支持验证方式
|
|
13
|
+
|
|
14
|
+
1、FACE 拍照人脸验证;
|
|
15
|
+
2、LIVINGBODY 活体验证;
|
|
16
|
+
3、SLIDER 滑块拖动验证;
|
|
17
|
+
4、NUMBER 数字验证;
|
|
18
|
+
5、IDCARD 学员身份证号后四位验证。
|
|
19
|
+
|
|
20
|
+
## 使用教程
|
|
21
|
+
|
|
22
|
+
### 微信小程序原生使用:
|
|
23
|
+
|
|
24
|
+
1. 安装插件
|
|
25
|
+
```bash
|
|
26
|
+
npm install @cqsjjb/yn-applet-study-player
|
|
27
|
+
```
|
|
28
|
+
2. 构建 npm
|
|
29
|
+
```bash
|
|
30
|
+
在微信开发者工具中,选择“工具”->“构建npm”
|
|
31
|
+
```
|
|
32
|
+
3. 引入组件
|
|
33
|
+
在需要使用的页面的 json 文件中引入组件
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"usingComponents": {
|
|
37
|
+
"jjb-player": "@cqsjjb/yn-applet-study-player/components/jjb-player/jjb-player"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
4. 使用组件
|
|
42
|
+
在需要使用的页面的 wxml 文件中引入组件
|
|
43
|
+
```xml
|
|
44
|
+
<jjb-player></jjb-player>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 在 uni-app 中使用
|
|
48
|
+
|
|
49
|
+
1. 安装插件
|
|
50
|
+
```bash
|
|
51
|
+
npm install @cqsjjb/yn-applet-study-player
|
|
52
|
+
```
|
|
53
|
+
2. 构建脚本
|
|
54
|
+
|
|
55
|
+
由于`uni-app`并不支持直接引入微信小程序原生组件,需要使用脚本把 npm 安装的包复制到特定目录。
|
|
56
|
+
|
|
57
|
+
在项目根目录新建`scripts/pkg-copy.js`文件,内容如下:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
// scripts/pkg-copy.js
|
|
61
|
+
// 本脚本用于将原生 npm 组件复制到 wxcomponents 文件夹
|
|
62
|
+
const fs = require("fs-extra");
|
|
63
|
+
const path = require("path");
|
|
64
|
+
|
|
65
|
+
// 需要复制的包
|
|
66
|
+
const pkgList = [
|
|
67
|
+
{
|
|
68
|
+
from: "@cqsjjb/yn-applet-study-player/src",
|
|
69
|
+
to: "yn-applet-study-player",
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const npmPath = path.join(__dirname, "../node_modules");
|
|
74
|
+
const distPath = path.join(__dirname, "../src/wxcomponents");
|
|
75
|
+
|
|
76
|
+
function copyPkg(pkg) {
|
|
77
|
+
const from = `${npmPath}/${pkg.from}`;
|
|
78
|
+
const to = `${distPath}/${pkg.to}`;
|
|
79
|
+
fs.copySync(from, to);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 复制所有包
|
|
83
|
+
pkgList.forEach(copyPkg);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
在`package.json`新增脚本:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"scripts": {
|
|
91
|
+
"postinstall": "node scripts/pkg-copy"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
执行`npm install`会把包复制到`src/wxcomponents`目录下
|
|
97
|
+
|
|
98
|
+
3. 引入组件
|
|
99
|
+
在配置微信小程序的 page 的 json 文件中引入组件(一般是在`pages.json`中):
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"path": "xxxxx",
|
|
103
|
+
"style": {
|
|
104
|
+
"usingComponents": {
|
|
105
|
+
"jjb-player": "/wxcomponents/yn-applet-study-player/components/jjb-player/jjb-player"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
4. 使用组件
|
|
111
|
+
在需要使用的页面的 vue 文件中使用组件
|
|
112
|
+
```xml
|
|
113
|
+
<jjb-player></jjb-player>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 参数说明
|
|
117
|
+
|
|
118
|
+
### baseUrl
|
|
119
|
+
|
|
120
|
+
类型:`string`
|
|
121
|
+
说明:自定义接口请求地址(末尾不带斜杠`/`),例:`https://xxx.com`,末尾不能带`/`。请求地址须在微信小程序后台配置`Request白名单`、`Upload白名单`。
|
|
122
|
+
|
|
123
|
+
### videoSty
|
|
124
|
+
|
|
125
|
+
类型:`string`,选填
|
|
126
|
+
说明:播放器样式,默认`width: 100%; height: 420rpx`
|
|
127
|
+
|
|
128
|
+
### options
|
|
129
|
+
|
|
130
|
+
类型:`object`,必填
|
|
131
|
+
说明:学习所需参数,见下方
|
|
132
|
+
|
|
133
|
+
### appId
|
|
134
|
+
|
|
135
|
+
类型:`string`,必填
|
|
136
|
+
说明:接口鉴权 appId,对接的时候会给。
|
|
137
|
+
|
|
138
|
+
#### options 参数说明:
|
|
139
|
+
|
|
140
|
+
| 字段 | 类型 | 描述 | 是否必传 |
|
|
141
|
+
| ------------- | ---------------- | ------------------------------------- | -------- |
|
|
142
|
+
| url | String | 视频地址,如`.mp4`、`.m3u8` | |
|
|
143
|
+
| appKey | String | 学时监管的 appkey,授权使用,对接提供 | 是 |
|
|
144
|
+
| courseCode | String \| Number | 课程 id | 是 |
|
|
145
|
+
| courseName | String | 课程名称 | 是 |
|
|
146
|
+
| duration | Number | 当前视频时长 | 是 |
|
|
147
|
+
| durationAll | Number | 该岗位的需修学时 | 是 |
|
|
148
|
+
| sectionCode | String \| Number | 课程小节 id | 是 |
|
|
149
|
+
| sectionName | String | 课程小节名称 | 是 |
|
|
150
|
+
| trainPostCode | String \| Number | 培训岗位 code | 是 |
|
|
151
|
+
| trainPostName | String | 培训岗位名称 | 是 |
|
|
152
|
+
| trainTypeEnum | String | 培训类型(值只能是下面两个) | 是 |
|
|
153
|
+
| | 'SEND_JXJY' | 继续教育 | |
|
|
154
|
+
| | 'SEND_GQPX' | 岗前培训 | |
|
|
155
|
+
| idCard | String | 学员身份证 | 是 |
|
|
156
|
+
| studentName | String | 学员姓名 | 是 |
|
|
157
|
+
| studyId | Number \| String | 学员 id | 是 |
|
|
158
|
+
| poster | String | 视频封面 | 否 |
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### 事件
|
|
163
|
+
|
|
164
|
+
#### bind:error
|
|
165
|
+
|
|
166
|
+
类型:`function`
|
|
167
|
+
说明:视频播放 video 抛错时会显示错误提示弹窗,点击重试触发该事件,此时可重新获取视频数据,或自定义业务逻辑
|
|
168
|
+
|
|
169
|
+
#### bind:end
|
|
170
|
+
|
|
171
|
+
类型:`function`
|
|
172
|
+
说明:当前视频播放结束后触发
|
|
173
|
+
|
|
174
|
+
## 使用说明
|
|
175
|
+
|
|
176
|
+
请参照**使用教程**正确引入组件,以下仅为代码示例,根据实际场景传入正确的参数
|
|
177
|
+
|
|
178
|
+
### 原生开发
|
|
179
|
+
|
|
180
|
+
在js 中初始化插件,并处理好组件需要的参数
|
|
181
|
+
|
|
182
|
+
```js
|
|
183
|
+
Page({
|
|
184
|
+
data: {
|
|
185
|
+
baseUrl: 'xxxx',
|
|
186
|
+
appId: 'xxxx',
|
|
187
|
+
videoSty: "width: 100%; height: 420rpx", // video样式
|
|
188
|
+
options: {
|
|
189
|
+
appKey: "xxxxxxxxxxxxxxxxx", // APPKEY
|
|
190
|
+
courseCode: "xxxxxxx", // 课程CODE/课程版本id
|
|
191
|
+
courseName: "xxxxxxx", // 课程名称
|
|
192
|
+
duration: "1623", // 当前视频时长(秒)
|
|
193
|
+
durationAll: "27", // 总视频时长(小时)
|
|
194
|
+
sectionCode: "xxxxxxx", // 课程小节CODE
|
|
195
|
+
sectionName: "xxxxxxx", // 课程小节名称
|
|
196
|
+
trainPostCode: "xxxxxxx", // 培训岗位code
|
|
197
|
+
trainPostName: "xxxxxxx", // 培训岗位名称
|
|
198
|
+
idCard: "xxxxxxxxxxxxxxxxxx", // 身份证号码
|
|
199
|
+
studentName: "xxx", // 学员名称
|
|
200
|
+
trainTypeEnum: "SEND_GQPX", // 继续教育:SEND_JXJY,岗前培训:SEND_GQPX
|
|
201
|
+
studyId: "xxxxxxx", // 继续教育任务ID或岗前培训计划ID
|
|
202
|
+
url: "https://xxx.com/xxx/xxx.mp4", // 视频地址
|
|
203
|
+
poster: "https://xx.com/xxx/xxx.png", // 视频封面
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
methods: {
|
|
207
|
+
/**
|
|
208
|
+
* @todo 播放出错处理
|
|
209
|
+
* @description 视频播放video抛错时会显示错误提示弹窗,点击重试触发该事件,此时可重新获取视频数据,或自定义业务逻辑
|
|
210
|
+
*/
|
|
211
|
+
onError() {},
|
|
212
|
+
/**
|
|
213
|
+
* @todo 视频播放结束
|
|
214
|
+
* @description 视频播放结束触发
|
|
215
|
+
*/
|
|
216
|
+
onEnd() {},
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
4、study.wxml 中使用 jjb-player(在 json 文件中定义的组件名称)组件,传入所需参数
|
|
222
|
+
|
|
223
|
+
```wxml
|
|
224
|
+
<jjb-player baseUrl="{{baseUrl}}" appId="{{appId}}" options="{{options}}" bind:error="onError" bind:end="onEnd"></jjb-player>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### UNIAPP 开发
|
|
228
|
+
|
|
229
|
+
基本与原生一致
|
|
230
|
+
|
|
231
|
+
3、在页面中使用 jjb-player(在 json 文件中定义的组件名称)组件,传入所需参数
|
|
232
|
+
|
|
233
|
+
```vue
|
|
234
|
+
<template>
|
|
235
|
+
<jjb-player
|
|
236
|
+
:baseUrl="baseUrl"
|
|
237
|
+
:appId="appId"
|
|
238
|
+
:options="options"
|
|
239
|
+
@error="onError"
|
|
240
|
+
@end="onEnd"
|
|
241
|
+
></jjb-player>
|
|
242
|
+
</template>
|
|
243
|
+
<script setup>
|
|
244
|
+
const baseUrl = "xxxxx";
|
|
245
|
+
const appId = "xxxxx";
|
|
246
|
+
const options = ref({
|
|
247
|
+
appKey: "xxxxxxxxxxxxxxxxx", // APPKEY
|
|
248
|
+
courseCode: "xxxxxxx", // 课程CODE/课程版本id
|
|
249
|
+
courseName: "xxxxxxx", // 课程名称
|
|
250
|
+
duration: "1623", // 当前视频时长(秒)
|
|
251
|
+
durationAll: "27", // 总视频时长(小时)
|
|
252
|
+
sectionCode: "xxxxxxx", // 课程小节CODE
|
|
253
|
+
sectionName: "xxxxxxx", // 课程小节名称
|
|
254
|
+
trainPostCode: "xxxxxxx", // 培训岗位code
|
|
255
|
+
trainPostName: "xxxxxxx", // 培训岗位名称
|
|
256
|
+
idCard: "xxxxxxxxxxxxxxxxxx", // 身份证号码
|
|
257
|
+
studentName: "xxx", // 学员名称
|
|
258
|
+
trainTypeEnum: "SEND_GQPX", // 继续教育:SEND_JXJY,岗前培训:SEND_GQPX
|
|
259
|
+
studyId: "xxxxxxx", // 继续教育任务ID或岗前培训计划ID
|
|
260
|
+
url: "https://xxx.com/xxx/xxx.mp4", // 视频地址
|
|
261
|
+
poster: "https://xx.com/xxx/xxx.png", // 视频封面
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @todo 播放出错处理
|
|
266
|
+
* @description 视频播放video抛错时会显示错误提示弹窗,点击重试触发该事件,此时可重新获取视频数据,或自定义业务逻辑
|
|
267
|
+
*/
|
|
268
|
+
const onError = () => {};
|
|
269
|
+
/**
|
|
270
|
+
* @todo 视频播放结束
|
|
271
|
+
* @description 视频播放结束触发
|
|
272
|
+
*/
|
|
273
|
+
const onEnd = () => {};
|
|
274
|
+
</script>
|
|
275
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ynkszx-applet-study-player",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "学时监管小程序SDK",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "src/components/jjb-player/jjb-player",
|
|
7
|
+
"miniprogram": "src",
|
|
8
|
+
"author": "",
|
|
9
|
+
"files": [
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
+
"build": "node ./scripts/build.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/api/auth.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const { http } = require("../utils/http/index");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取数字验证码
|
|
5
|
+
* @param data
|
|
6
|
+
*/
|
|
7
|
+
const getCaptcha = (data) => {
|
|
8
|
+
return http.request({
|
|
9
|
+
url: "/sdk/handle/captcha",
|
|
10
|
+
method: "POST",
|
|
11
|
+
data,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 初始化验证
|
|
17
|
+
* @param data
|
|
18
|
+
*/
|
|
19
|
+
const handleInit = (data) => {
|
|
20
|
+
return http.request({
|
|
21
|
+
url: "/sdk/handle/init",
|
|
22
|
+
method: "POST",
|
|
23
|
+
data: { ...data, terminalCode: "MINI_APPS" },
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 重新获取验证方式
|
|
28
|
+
* @param data
|
|
29
|
+
*/
|
|
30
|
+
const handleRefresh = (data) => {
|
|
31
|
+
return http.request({
|
|
32
|
+
url: "/sdk/handle/afresh",
|
|
33
|
+
method: "POST",
|
|
34
|
+
data,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 校验验证码
|
|
39
|
+
* @param data
|
|
40
|
+
* @param {number} data.validateId 验证ID
|
|
41
|
+
* @param {string} data.ruleValue 验证值,滑块传TRUE
|
|
42
|
+
* @param {string} data.countHours 当前进度
|
|
43
|
+
*/
|
|
44
|
+
const checkCaptcha = (data) => {
|
|
45
|
+
return http.request({
|
|
46
|
+
url: "/sdk/handle/check",
|
|
47
|
+
method: "POST",
|
|
48
|
+
data,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 小程序(人脸)验证
|
|
53
|
+
* @param {number} data.validateId 学习记录id,认证id
|
|
54
|
+
* @param {string} data.urls 人脸oss地址
|
|
55
|
+
* @returns data.verifySuccess 验证是否成功 0否1是
|
|
56
|
+
*/
|
|
57
|
+
const checkFace = (data) => {
|
|
58
|
+
return http.request(
|
|
59
|
+
{
|
|
60
|
+
url: "/sdk/handle/qr/check",
|
|
61
|
+
method: "POST",
|
|
62
|
+
header: {
|
|
63
|
+
"Group-App-Id": "THOS-MIN-8010315302225062013052",
|
|
64
|
+
},
|
|
65
|
+
data,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
crypto: false,
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 小程序(活体)验证
|
|
75
|
+
* @param {number} data.validateId 学习记录id,认证id
|
|
76
|
+
* @param {string} data.videoUrl oss地址
|
|
77
|
+
* @returns data.verifySuccess 验证是否成功 0否1是
|
|
78
|
+
*/
|
|
79
|
+
const checkLiving = (data) => {
|
|
80
|
+
return http.request(
|
|
81
|
+
{
|
|
82
|
+
url: "/sdk/handle/qr/living",
|
|
83
|
+
method: "POST",
|
|
84
|
+
data,
|
|
85
|
+
header: {
|
|
86
|
+
"Group-App-Id": "THOS-MIN-8010315302225062013052",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
crypto: false,
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
module.exports = {
|
|
96
|
+
handleInit,
|
|
97
|
+
handleRefresh,
|
|
98
|
+
getCaptcha,
|
|
99
|
+
checkCaptcha,
|
|
100
|
+
checkFace,
|
|
101
|
+
checkLiving,
|
|
102
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { http } = require('../utils/http/index')
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 播放视频
|
|
6
|
+
* @param data
|
|
7
|
+
* @param {0 | 1 | 2 | 3} type 0: 开始 1: 暂停 2: 结束 3: 保存实时进度
|
|
8
|
+
*/
|
|
9
|
+
const handlePlayer = (data, type) => {
|
|
10
|
+
const url = [
|
|
11
|
+
'/sdk/handle/start',
|
|
12
|
+
'/sdk/handle/suspend',
|
|
13
|
+
'/sdk/handle/end',
|
|
14
|
+
'/sdk/handle/studyCourse',
|
|
15
|
+
]
|
|
16
|
+
return http.request({
|
|
17
|
+
url: url[type],
|
|
18
|
+
method: 'POST',
|
|
19
|
+
data,
|
|
20
|
+
}, {
|
|
21
|
+
loading: type !== 3
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
handlePlayer,
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { http } = require("../utils/http/index");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 轮询查询人脸或者活体是否验证成功
|
|
5
|
+
* @param {string} filePath
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export const upload = (filePath) => {
|
|
9
|
+
return http.upload(
|
|
10
|
+
{
|
|
11
|
+
url: "/union/file/pubUpload",
|
|
12
|
+
method: "POST",
|
|
13
|
+
name: "file",
|
|
14
|
+
filePath,
|
|
15
|
+
header: {
|
|
16
|
+
"App-Id": "19000002",
|
|
17
|
+
"Group-App-Id": "THOS-MIN-8010315302225062013052",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
crypto: false,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
upload,
|
|
28
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// plugin/components/jjb-auth/code/code-comp.js
|
|
2
|
+
import { checkCaptcha } from '../../../api/auth'
|
|
3
|
+
import { oss } from '../../../utils/oss/index'
|
|
4
|
+
|
|
5
|
+
Component({
|
|
6
|
+
/**
|
|
7
|
+
* 组件的属性列表
|
|
8
|
+
*/
|
|
9
|
+
properties: {
|
|
10
|
+
seconds: {
|
|
11
|
+
type: Number,
|
|
12
|
+
value: 0
|
|
13
|
+
},
|
|
14
|
+
validateId: {
|
|
15
|
+
type: String,
|
|
16
|
+
value: '',
|
|
17
|
+
observer() {
|
|
18
|
+
this.setData({ isFlag: false, result: {} })
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
countHours: {
|
|
22
|
+
type: Number,
|
|
23
|
+
value: '',
|
|
24
|
+
},
|
|
25
|
+
ruleType: {
|
|
26
|
+
type: String,
|
|
27
|
+
value: ''
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 组件的初始数据
|
|
33
|
+
*/
|
|
34
|
+
data: {
|
|
35
|
+
ico: {
|
|
36
|
+
error: oss('cw', 'sdk/face'),
|
|
37
|
+
warn: oss('cs', 'sdk/face'),
|
|
38
|
+
safe: oss('safe', 'sdk/face'),
|
|
39
|
+
},
|
|
40
|
+
isFlag: false,
|
|
41
|
+
result: {},
|
|
42
|
+
conf: {
|
|
43
|
+
NUMBER: {
|
|
44
|
+
title: '请输入数字验证码',
|
|
45
|
+
msg: '数字验证'
|
|
46
|
+
},
|
|
47
|
+
COMPUTE: {
|
|
48
|
+
title: '请输入计算结果',
|
|
49
|
+
msg: '计算,并将正确的计算结果填入空格内'
|
|
50
|
+
},
|
|
51
|
+
SLIDER: {
|
|
52
|
+
title: '请拖动滑块',
|
|
53
|
+
msg: '滑动验证'
|
|
54
|
+
},
|
|
55
|
+
IDCARD: {
|
|
56
|
+
title: '请输入身份证号码',
|
|
57
|
+
msg: '身份证验证'
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 组件的方法列表
|
|
64
|
+
*/
|
|
65
|
+
methods: {
|
|
66
|
+
async onCheck({ detail }) {
|
|
67
|
+
try {
|
|
68
|
+
const { validateId, countHours } = this.data
|
|
69
|
+
const result = await checkCaptcha({ ruleValue: detail, validateId, countHours })
|
|
70
|
+
result.verifySuccess = result.verifySuccess === 1 ? 1 : 0
|
|
71
|
+
this.triggerEvent('check', result)
|
|
72
|
+
this.setData({ isFlag: false, result })
|
|
73
|
+
} catch (e) {
|
|
74
|
+
this.triggerEvent('check', { verifySuccess: 0 })
|
|
75
|
+
this.setData({ isFlag: true })
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
onRefresh() {
|
|
79
|
+
const { result } = this.data
|
|
80
|
+
this.triggerEvent('refresh', result)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!--plugin/components/jjb-auth/code/code-comp.wxml-->
|
|
2
|
+
<view class="jjb-modal">
|
|
3
|
+
<view class="jjb-modal-content">
|
|
4
|
+
<image class="jjb-ico" src="{{ico.safe}}" />
|
|
5
|
+
<!-- 验证状态 -->
|
|
6
|
+
<view wx:if="{{result.verifySuccess === 0 || isFlag}}">
|
|
7
|
+
<view class="jjb-flex jjb-text-red jjb-text-size-lg jjb-text-weight-b" style="margin: 20rpx 0px 60rpx">
|
|
8
|
+
<image src="{{ico.error}}" style="width: 36rpx; height: 36rpx;margin-right: 20rpx" />
|
|
9
|
+
<view>验证失败</view>
|
|
10
|
+
</view>
|
|
11
|
+
<button class="jjb-btn" bindtap="onRefresh">重新验证</button>
|
|
12
|
+
</view>
|
|
13
|
+
<view wx:elif="{{seconds <= 0}}">
|
|
14
|
+
<view class="jjb-flex jjb-text-orange jjb-text-size-lg jjb-text-weight-b" style="margin: 20rpx 0px 60rpx">
|
|
15
|
+
<image src="{{ico.warn}}" style="width: 36rpx; height: 36rpx;margin-right: 20rpx" />
|
|
16
|
+
<view>验证超时</view>
|
|
17
|
+
</view>
|
|
18
|
+
<button class="jjb-btn" bindtap="onRefresh">重新验证</button>
|
|
19
|
+
</view>
|
|
20
|
+
<!-- 验证 -->
|
|
21
|
+
<block wx:else>
|
|
22
|
+
<view class="jjb-text-size-lg jjb-text-weight-b jjb-text-align-center">
|
|
23
|
+
{{conf[ruleType].title}}
|
|
24
|
+
</view>
|
|
25
|
+
<view class="jjb-text-align-center jjb-tip jjb-text-darken-2 jjb-text-size-n">
|
|
26
|
+
请在<text class="jjb-text-red">{{seconds || '0'}}</text>秒内完成{{conf[ruleType].msg}},验证通过后可继续观看
|
|
27
|
+
</view>
|
|
28
|
+
<verify-number wx:if="{{ruleType === 'NUMBER'}}" validateId="{{validateId}}" bind:confirm="onCheck" />
|
|
29
|
+
<verify-move wx:elif="{{ruleType === 'SLIDER'}}" validateId="{{validateId}}" bind:confirm="onCheck" />
|
|
30
|
+
<verify-idcard wx:elif="{{ruleType === 'IDCARD'}}" validateId="{{validateId}}" bind:confirm="onCheck" />
|
|
31
|
+
</block>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* plugin/components/jjb-auth/code/code-comp.wxss */
|
|
2
|
+
@import "../../../style/common.wxss";
|
|
3
|
+
|
|
4
|
+
.jjb-tip {
|
|
5
|
+
margin: 28rpx 0px 48rpx;
|
|
6
|
+
line-height: 44rpx;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.jjb-ico {
|
|
10
|
+
width: 80rpx;
|
|
11
|
+
height: 80rpx;
|
|
12
|
+
position: absolute;
|
|
13
|
+
right: 12rpx;
|
|
14
|
+
top: 12rpx;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.jjb-modal-content {
|
|
18
|
+
background-image: linear-gradient(to bottom, #E6EEFF, #FFFFFF);
|
|
19
|
+
}
|