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.
Files changed (62) hide show
  1. package/README.md +275 -0
  2. package/package.json +19 -0
  3. package/src/api/auth.js +102 -0
  4. package/src/api/player.js +27 -0
  5. package/src/api/upload.js +28 -0
  6. package/src/components/jjb-auth/code-comp/code-comp.js +83 -0
  7. package/src/components/jjb-auth/code-comp/code-comp.json +8 -0
  8. package/src/components/jjb-auth/code-comp/code-comp.wxml +33 -0
  9. package/src/components/jjb-auth/code-comp/code-comp.wxss +19 -0
  10. package/src/components/jjb-auth/face-comp/face-comp.js +125 -0
  11. package/src/components/jjb-auth/face-comp/face-comp.json +4 -0
  12. package/src/components/jjb-auth/face-comp/face-comp.wxml +39 -0
  13. package/src/components/jjb-auth/face-comp/face-comp.wxss +39 -0
  14. package/src/components/jjb-auth/face-conf/face-conf.js +36 -0
  15. package/src/components/jjb-auth/face-conf/face-conf.json +4 -0
  16. package/src/components/jjb-auth/face-conf/face-conf.wxml +17 -0
  17. package/src/components/jjb-auth/face-conf/face-conf.wxss +26 -0
  18. package/src/components/jjb-auth/jjb-auth.js +200 -0
  19. package/src/components/jjb-auth/jjb-auth.json +11 -0
  20. package/src/components/jjb-auth/jjb-auth.wxml +44 -0
  21. package/src/components/jjb-auth/living-comp/living-comp.js +221 -0
  22. package/src/components/jjb-auth/living-comp/living-comp.json +4 -0
  23. package/src/components/jjb-auth/living-comp/living-comp.wxml +44 -0
  24. package/src/components/jjb-auth/living-comp/living-comp.wxss +48 -0
  25. package/src/components/jjb-auth/msg-comp/msg-comp.js +27 -0
  26. package/src/components/jjb-auth/msg-comp/msg-comp.json +8 -0
  27. package/src/components/jjb-auth/msg-comp/msg-comp.wxml +16 -0
  28. package/src/components/jjb-auth/msg-comp/msg-comp.wxss +17 -0
  29. package/src/components/jjb-auth/qa-auth.wxss +9 -0
  30. package/src/components/jjb-auth/tip-comp/tip-comp.js +38 -0
  31. package/src/components/jjb-auth/tip-comp/tip-comp.json +4 -0
  32. package/src/components/jjb-auth/tip-comp/tip-comp.wxml +20 -0
  33. package/src/components/jjb-auth/tip-comp/tip-comp.wxss +25 -0
  34. package/src/components/jjb-player/jjb-player.js +73 -0
  35. package/src/components/jjb-player/jjb-player.json +7 -0
  36. package/src/components/jjb-player/jjb-player.wxml +19 -0
  37. package/src/components/jjb-player/jjb-player.wxss +1 -0
  38. package/src/components/jjb-player/video-comp/time.wxs +11 -0
  39. package/src/components/jjb-player/video-comp/video-comp.js +250 -0
  40. package/src/components/jjb-player/video-comp/video-comp.json +4 -0
  41. package/src/components/jjb-player/video-comp/video-comp.wxml +52 -0
  42. package/src/components/jjb-player/video-comp/video-comp.wxss +35 -0
  43. package/src/components/jjb-verify/verify-idcard/verify-idcard.js +47 -0
  44. package/src/components/jjb-verify/verify-idcard/verify-idcard.json +4 -0
  45. package/src/components/jjb-verify/verify-idcard/verify-idcard.wxml +3 -0
  46. package/src/components/jjb-verify/verify-idcard/verify-idcard.wxss +2 -0
  47. package/src/components/jjb-verify/verify-move/verify-move.js +44 -0
  48. package/src/components/jjb-verify/verify-move/verify-move.json +4 -0
  49. package/src/components/jjb-verify/verify-move/verify-move.wxml +3 -0
  50. package/src/components/jjb-verify/verify-move/verify-move.wxss +9 -0
  51. package/src/components/jjb-verify/verify-number/verify-number.js +60 -0
  52. package/src/components/jjb-verify/verify-number/verify-number.json +4 -0
  53. package/src/components/jjb-verify/verify-number/verify-number.wxml +9 -0
  54. package/src/components/jjb-verify/verify-number/verify-number.wxss +2 -0
  55. package/src/lib/crypto.js +55 -0
  56. package/src/style/common.wxss +113 -0
  57. package/src/utils/crypto.js +43 -0
  58. package/src/utils/http/config/index.js +7 -0
  59. package/src/utils/http/index.js +173 -0
  60. package/src/utils/oss/config/index.js +5 -0
  61. package/src/utils/oss/index.js +6 -0
  62. package/src/utils/storage.js +22 -0
@@ -0,0 +1,125 @@
1
+ // plugin/components/jjb-auth/face/face-comp.js
2
+ import { upload } from "../../../api/upload";
3
+ import { checkFace } from "../../../api/auth";
4
+ import { oss } from "../../../utils/oss/index";
5
+
6
+ const defaultD = {
7
+ loading: false,
8
+ error: false,
9
+ status: 0,
10
+ result: {},
11
+ };
12
+
13
+ Component({
14
+ /**
15
+ * 组件的属性列表
16
+ */
17
+ properties: {
18
+ seconds: {
19
+ type: Number,
20
+ value: null,
21
+ observer(value) {
22
+ const { status } = this.data;
23
+ if (value === 0 && status === 0) this.setData({ status: 2 });
24
+ },
25
+ },
26
+ validateId: {
27
+ type: String,
28
+ value: "",
29
+ observer() {
30
+ this.setData({ ...defaultD });
31
+ },
32
+ },
33
+ },
34
+ /**
35
+ * 组件的初始数据
36
+ */
37
+ data: {
38
+ conf: [
39
+ { text: "验证中", color: "primary" },
40
+ { text: "验证成功", ico: oss("cg", "sdk/face"), color: "green" },
41
+ { text: "验证超时", ico: oss("cs", "sdk/face"), color: "orange" },
42
+ { text: "验证失败", ico: oss("cw", "sdk/face"), color: "red" },
43
+ ],
44
+ tips: [
45
+ { text: "光线充足", ico: oss("gxcz", "sdk/face") },
46
+ { text: "正对手机", ico: oss("zdsj", "sdk/face") },
47
+ { text: "脸无遮挡", ico: oss("lwzd", "sdk/face") },
48
+ ],
49
+ ...defaultD,
50
+ },
51
+
52
+ ready() {
53
+ this.ctx = wx.createCameraContext("jjb-camera", this);
54
+ },
55
+
56
+ /**
57
+ * 组件的方法列表
58
+ */
59
+ methods: {
60
+ handlePhoto() {
61
+ this.setData({ loading: true });
62
+ this.ctx.takePhoto({
63
+ success: ({ tempImagePath }) => this.onUpload(tempImagePath),
64
+ fail: () => {
65
+ wx.showToast({ title: "拍照失败,请重试", icon: "none" });
66
+ this.setData({ loading: false });
67
+ },
68
+ });
69
+ },
70
+ async onUpload(url) {
71
+ try {
72
+ const data = await upload(url);
73
+ this.onCheck(data.url);
74
+ } catch (e) {
75
+ this.setData({ loading: false });
76
+ }
77
+ },
78
+ async onCheck(url) {
79
+ const { validateId } = this.data;
80
+ try {
81
+ const data = await checkFace({ validateId, urls: [url] });
82
+ const result = { verifySuccess: data.verifySuccess === 1 ? 1 : 0 };
83
+ this.setData({
84
+ status: data.verifySuccess === 1 ? 1 : 3,
85
+ result,
86
+ });
87
+ this.triggerEvent("check", result);
88
+ } catch (e) {
89
+ this.triggerEvent("check", { verifySuccess: 0 });
90
+ this.setData({ loading: false, status: 3 });
91
+ }
92
+ },
93
+ onRefresh() {
94
+ const { result } = this.data;
95
+ this.triggerEvent("refresh", result);
96
+ },
97
+ onError() {
98
+ this.setData({ error: 0 });
99
+ wx.showModal({
100
+ title: "温馨提示",
101
+ content: "您拒绝了摄像头权限",
102
+ showCancel: true,
103
+ confirmText: "去授权",
104
+ success: ({ confirm }) => {
105
+ if (confirm) {
106
+ wx.openSetting({
107
+ success: (res) => {
108
+ if (res.authSetting["scope.camera"]) {
109
+ this.setData({ error: true }, () => {
110
+ this.setData({ error: false });
111
+ });
112
+ } else {
113
+ this.onError();
114
+ }
115
+ },
116
+ fail: (err) => {
117
+ // 出错
118
+ },
119
+ });
120
+ }
121
+ },
122
+ });
123
+ },
124
+ },
125
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,39 @@
1
+ <!--plugin/components/jjb-auth/face/face-comp.wxml-->
2
+ <scroll-view scroll-y style="height: 100vh">
3
+ <view class="jjb-face-page jjb-flex-col">
4
+ <view class="jjb-title jjb-text-size-2xl jjb-text-weight-b">拿起手机,拍照</view>
5
+ <view style="height: 888rpx">
6
+ <view class="jjb-camera-box jjb-flex-col">
7
+ <camera
8
+ wx:if="{{!error}}"
9
+ id="jjb-camera"
10
+ class="jjb-camera"
11
+ mode="normal"
12
+ device-position="front"
13
+ flash="auto"
14
+ resolution="medium"
15
+ binderror="onError"
16
+ />
17
+ </view>
18
+ <view class="jjb-text-{{conf[status].color}} jjb-text-size-2xl">
19
+ <image wx:if="{{conf[status].ico}}" src="{{conf[status].ico}}" style="width: 44rpx;height: 44rpx; margin-right: 16rpx" />
20
+ <view>{{conf[status].text}}</view>
21
+ </view>
22
+ <view wx:if="{{status === 0}}" class="jjb-tip jjb-text-size-m jjb-text-grey">
23
+ 请在<text class="jjb-text-red">{{seconds}}</text>秒内完成验证,验证通过后可继续观看
24
+ </view>
25
+ <view wx:elif="{{status === 1}}" class="jjb-tip jjb-text-size-m jjb-text-grey">
26
+ 马上关闭验证,开始学习
27
+ </view>
28
+ <button wx:if="{{error === 0}}" class="jjb-btn" bindtap="onError">获取摄像头权限</button>
29
+ <button wx:elif="{{status === 0}}" class="jjb-btn" disabled="{{loading}}" loading="{{loading}}" bindtap="handlePhoto">拍照</button>
30
+ <button wx:elif="{{status > 1}}" class="jjb-btn" bindtap="onRefresh">重新验证</button>
31
+ </view>
32
+ <view class="jjb-tips jjb-flex-center-between jjb-text-size-m jjb-text-grey">
33
+ <view wx:for="{{tips}}" wx:key="text">
34
+ <image src="{{item.ico}}" style="width: 52rpx;height: 52rpx" />
35
+ <view style="margin-top: 18rpx">{{ item.text }}</view>
36
+ </view>
37
+ </view>
38
+ </view>
39
+ </scroll-view>
@@ -0,0 +1,39 @@
1
+ /* plugin/components/jjb-auth/face/face-comp.wxss */
2
+ @import "../../../style/common.wxss";
3
+
4
+ .jjb-face-page {
5
+ background-color: #fff;
6
+ width: 100vw;
7
+ min-height: 100vh;
8
+ text-align: center;
9
+ flex-direction: column;
10
+ }
11
+
12
+ .jjb-camera-box {
13
+ width: 428rpx;
14
+ height: 428rpx;
15
+ margin: 80rpx auto;
16
+ flex-direction: column;
17
+ }
18
+
19
+ .jjb-camera {
20
+ width: 400rpx;
21
+ height: 400rpx;
22
+ border-radius: 200rpx;
23
+ }
24
+
25
+ .jjb-tip {
26
+ margin-top: 24rpx;
27
+ }
28
+
29
+ .jjb-btn {
30
+ width: 590rpx;
31
+ margin-top: 80rpx;
32
+ }
33
+
34
+ .jjb-tips {
35
+ width: 506rpx;
36
+ padding-top: 84rpx;
37
+ margin: 28rpx auto 0px;
38
+ border-top: 1px solid #eee;
39
+ }
@@ -0,0 +1,36 @@
1
+ // plugin/components/jjb-auth/msg-comp/msg-comp.js
2
+ import { oss } from '../../../utils/oss/index'
3
+ Component({
4
+ /**
5
+ * 组件的属性列表
6
+ */
7
+ properties: {
8
+ studentName: {
9
+ type: String,
10
+ value: ''
11
+ },
12
+ ruleType: {
13
+ type: String,
14
+ value: ''
15
+ },
16
+ },
17
+
18
+ /**
19
+ * 组件的初始数据
20
+ */
21
+ data: {
22
+ ico: {
23
+ face: oss('face', 'sdk/face'),
24
+ safe: oss('safe', 'sdk/face')
25
+ }
26
+ },
27
+
28
+ /**
29
+ * 组件的方法列表
30
+ */
31
+ methods: {
32
+ onConfirm() {
33
+ this.triggerEvent('confirm')
34
+ }
35
+ }
36
+ })
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,17 @@
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
+ <view class="jjb-text-size-lg jjb-text-weight-b jjb-text-align-center">
6
+ 人脸识别验证
7
+ </view>
8
+ <view class="jjb-text-align-center jjb-tip jjb-text-darken-2 jjb-text-size-n">
9
+ 为保证是您本人进行课程学习,请按要求完成人脸识别验证
10
+ </view>
11
+ <image class="jjb-tip-img" src="{{ico.face}}" />
12
+ <button class="jjb-btn" bindtap="onConfirm">开始验证</button>
13
+ <view class="jjb-text-grey jjb-text-align-center jjb-text-size-m" style="padding: 40rpx 0px 0px">
14
+ 请确保是<text class="jjb-text-primary">{{studentName}}</text>本人进行操作
15
+ </view>
16
+ </view>
17
+ </view>
@@ -0,0 +1,26 @@
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-tip-img {
18
+ width: 420rpx;
19
+ height: 420rpx;
20
+ margin: 40rpx auto 60rpx;
21
+ display: block;
22
+ }
23
+
24
+ .jjb-modal-content {
25
+ background-image: linear-gradient(to bottom, #E6EEFF, #FFFFFF);
26
+ }
@@ -0,0 +1,200 @@
1
+ // plugin/components/jjb-auth/jjb-auth.js
2
+ import { handleInit, handleRefresh } from "../../api/auth";
3
+ import { storage } from "../../utils/storage";
4
+ /**
5
+ * 验证
6
+ * @param {object} auth
7
+ * @param {string} auth.ruleType 验证规则类型 ("FACE", "人脸"),("LIVINGBODY", "活体"),("SLIDER", "滑块"),("IDCARD", "身份证"),("NUMBER", "数字")
8
+ * @param {number} auth.initVerify 是否需要首验证 0否1是
9
+ * @param {number} auth.effectiveTm 验证有效时间(秒)
10
+ * @param {0 | 1} auth.initVerifySuccess 首验证是否成功 0否1是
11
+ * @param {string} auth.validateId 验证id
12
+ */
13
+
14
+ Component({
15
+ behaviors: ["wx://component-export"],
16
+ export() {
17
+ return {
18
+ auth: this.setAuth.bind(this),
19
+ };
20
+ },
21
+ /**
22
+ * 组件的属性列表
23
+ */
24
+ properties: {
25
+ options: {
26
+ type: Object,
27
+ value: {},
28
+ },
29
+ err: {
30
+ type: Object,
31
+ value: {},
32
+ observer(error) {
33
+ error.msg && this.setData({ show: true, error });
34
+ },
35
+ },
36
+ },
37
+ observers: {
38
+ options: function (value) {
39
+ if (!value || !Object.keys(value).length) return;
40
+ this.initAuth();
41
+ },
42
+ },
43
+ /**
44
+ * 组件的初始数据
45
+ */
46
+ data: {
47
+ show: !storage.get(0),
48
+ isAuthTip: storage.get(0),
49
+ seconds: 60,
50
+ faceConfirm: false,
51
+ auth: {},
52
+ error: {
53
+ msg: "",
54
+ tag: null, // 视频播放出错为1
55
+ },
56
+ },
57
+
58
+ ready() {
59
+ this.setData({
60
+ show: !storage.get(0),
61
+ isAuthTip: storage.get(0),
62
+ });
63
+ },
64
+
65
+ /**
66
+ * 组件的方法列表
67
+ */
68
+ methods: {
69
+ /**
70
+ * 初始化验证
71
+ * @returns
72
+ */
73
+ async initAuth() {
74
+ this.clearTimer();
75
+ const { options, isAuthTip } = this.data;
76
+ if (!isAuthTip) return;
77
+ if (!options) {
78
+ wx.showToast({
79
+ title: "option数据配置错误",
80
+ icon: "none",
81
+ });
82
+ }
83
+ try {
84
+ const auth = await handleInit(options);
85
+ this.setData(
86
+ {
87
+ show: auth.initVerify === 1 && auth.initVerifySuccess !== 1,
88
+ auth,
89
+ faceConfirm: false,
90
+ seconds: auth.effectiveTm,
91
+ error: {},
92
+ },
93
+ () => {
94
+ // 人脸/活体点击开始验证才倒计时
95
+ this.data.show
96
+ ? !["FACE", "LIVINGBODY"].includes(auth.ruleType) &&
97
+ this.countdown()
98
+ : this.onComplete();
99
+ }
100
+ );
101
+ } catch (msg) {
102
+ this.setData({ error: { msg } });
103
+ }
104
+ },
105
+ /**
106
+ * 重置验证数据
107
+ */
108
+ async refreshAuth(e) {
109
+ this.clearTimer();
110
+ const { validateId } = (e && e.detail) || {};
111
+ validateId ? this.setAuth(e.detail) : this.getNAuth();
112
+ },
113
+ /**
114
+ * 重新获取验证方式
115
+ */
116
+ async getNAuth() {
117
+ const { validateId } = this.data.auth;
118
+ if (!validateId) return;
119
+ try {
120
+ const data = await handleRefresh({ validateId });
121
+ this.setAuth(data);
122
+ } catch (error) {}
123
+ },
124
+ setAuth(data) {
125
+ const { auth } = this.data;
126
+ this.setData(
127
+ {
128
+ show: true,
129
+ auth: { ...auth, ...data },
130
+ seconds: data.effectiveTm,
131
+ },
132
+ () => {
133
+ this.countdown();
134
+ }
135
+ );
136
+ },
137
+ /**
138
+ * 倒计时
139
+ */
140
+ countdown() {
141
+ this.clearTimer();
142
+ this.timer = setTimeout(() => {
143
+ const { seconds } = this.data;
144
+ if (seconds > 0) {
145
+ this.setData(
146
+ {
147
+ seconds: seconds - 1,
148
+ },
149
+ () => {
150
+ this.countdown();
151
+ }
152
+ );
153
+ } else {
154
+ this.clearTimer();
155
+ }
156
+ }, 1e3);
157
+ },
158
+ /**
159
+ * 清除倒计时定时器
160
+ */
161
+ clearTimer() {
162
+ if (this.timer) clearTimeout(this.timer);
163
+ this.timer = null;
164
+ },
165
+ /**
166
+ * 本次验证结束
167
+ */
168
+ onCheck({ detail }) {
169
+ this.clearTimer();
170
+ detail.verifySuccess === 1 && this.onComplete();
171
+ },
172
+ /**
173
+ * 完成本次验证
174
+ */
175
+ onComplete() {
176
+ const { auth } = this.data;
177
+ this.setData({ show: false });
178
+ this.triggerEvent("complete", auth);
179
+ },
180
+ onBack() {
181
+ const { show } = this.data;
182
+ show && wx.navigateBack();
183
+ },
184
+ onFaceTip() {
185
+ this.countdown();
186
+ this.setData({ faceConfirm: true });
187
+ },
188
+ onTips({ detail }) {
189
+ this.setData({ isAuthTip: true }, () => this.initAuth());
190
+ detail && storage.set(0, true);
191
+ },
192
+ onError() {
193
+ const { tag } = this.data.error;
194
+ if (tag === 1) {
195
+ this.triggerEvent("error");
196
+ this.setData({ error: {}, show: false });
197
+ } else this.initAuth();
198
+ },
199
+ },
200
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "code-comp": "./code-comp/code-comp",
5
+ "face-comp": "./face-comp/face-comp",
6
+ "living-comp": "./living-comp/living-comp",
7
+ "face-conf": "./face-conf/face-conf",
8
+ "msg-comp": "./msg-comp/msg-comp",
9
+ "tip-comp": "./tip-comp/tip-comp"
10
+ }
11
+ }
@@ -0,0 +1,44 @@
1
+ <!--plugin/components/jjb-auth/jjb-auth.wxml-->
2
+ <page-container
3
+ show="{{show}}"
4
+ z-index="{{9999}}"
5
+ bind:afterleave="onBack"
6
+ >
7
+ <tip-comp wx:if="{{!isAuthTip}}" bind:confirm="onTips" />
8
+ <msg-comp wx:elif="{{error.msg}}" msg="{{error.msg}}" bind:confirm="onError" />
9
+ <block wx:elif="{{auth.ruleType}}">
10
+ <face-conf
11
+ wx:if="{{(auth.ruleType === 'FACE' || auth.ruleType === 'LIVINGBODY') && !faceConfirm}}"
12
+ studentName="{{options.studentName}}"
13
+ ruleType="{{auth.ruleType}}"
14
+ bind:confirm="onFaceTip"
15
+ />
16
+ <face-comp
17
+ wx:elif="{{auth.ruleType === 'FACE'}}"
18
+ ruleType="{{auth.ruleType}}"
19
+ validateId="{{auth.validateId}}"
20
+ countHours="{{auth.progress}}"
21
+ seconds="{{seconds}}"
22
+ bind:check="onCheck"
23
+ bind:refresh="refreshAuth"
24
+ />
25
+ <living-comp
26
+ wx:elif="{{auth.ruleType === 'LIVINGBODY'}}"
27
+ ruleType="{{auth.ruleType}}"
28
+ validateId="{{auth.validateId}}"
29
+ countHours="{{auth.progress}}"
30
+ seconds="{{seconds}}"
31
+ bind:check="onCheck"
32
+ bind:refresh="refreshAuth"
33
+ />
34
+ <code-comp
35
+ wx:else
36
+ ruleType="{{auth.ruleType}}"
37
+ validateId="{{auth.validateId}}"
38
+ countHours="{{auth.progress}}"
39
+ seconds="{{seconds}}"
40
+ bind:check="onCheck"
41
+ bind:refresh="refreshAuth"
42
+ />
43
+ </block>
44
+ </page-container>