Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sport-train
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tangjiale
sport-train
Commits
0ddeb16d
Commit
0ddeb16d
authored
Jun 08, 2022
by
tangjiale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
废弃mixins和behaviors,原生小程序受限无法动态配置
parent
1b60b956
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
169 additions
and
213 deletions
+169
-213
app.js
app.js
+2
-5
project.config.json
project.config.json
+2
-2
ai-fwc-sport.js
subPages/sport/ai-fwc-sport/ai-fwc-sport.js
+1
-1
ai-fwc-mixins.js
subPages/sport/ai-mixins/ai-fwc-mixins.js
+9
-6
ai-gtjz-mixins.js
subPages/sport/ai-mixins/ai-gtjz-mixins.js
+6
-4
ai-gtt-mixins.js
subPages/sport/ai-mixins/ai-gtt-mixins.js
+10
-9
ai-kht-mixins.js
subPages/sport/ai-mixins/ai-kht-mixins.js
+10
-6
ai-sd-mixins.js
subPages/sport/ai-mixins/ai-sd-mixins.js
+10
-6
ai-tjz-mixins.js
subPages/sport/ai-mixins/ai-tjz-mixins.js
+9
-6
ai-ts-mixins.js
subPages/sport/ai-mixins/ai-ts-mixins.js
+74
-74
ai-ydp-mixins.js
subPages/sport/ai-mixins/ai-ydp-mixins.js
+7
-5
ai-ydtt-mixins.js
subPages/sport/ai-mixins/ai-ydtt-mixins.js
+8
-6
ai-ywqz-mixins.js
subPages/sport/ai-mixins/ai-ywqz-mixins.js
+10
-8
ai-sport.js
subPages/sport/ai-sport/ai-sport.js
+10
-3
ai-sport.wxml
subPages/sport/ai-sport/ai-sport.wxml
+1
-1
detail.js
subPages/sport/detail/detail.js
+0
-0
wx-mixins.js
wx-mixins.js
+0
-71
No files found.
app.js
View file @
0ddeb16d
...
...
@@ -3,14 +3,11 @@
* @eMail: 932055106@qq.com
* @Date: 2022-01-13 17:47:44
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 15:08:24
* @LastEditTime: 2022-06-0
8 10:39:10
*/
// wx.setStorageSync('host', 'https://sdb.youchengzhang.cn/'); //正式环境
wx
.
setStorageSync
(
'host'
,
'https://test.xiaobentiyu.cn'
);
//测试环境
//引入混合模式
require
(
'./wx-mixins.js'
)
//ai姿势识别
const
fetchWechat
=
require
(
'fetch-wechat'
)
const
tf
=
require
(
'@tensorflow/tfjs-core'
)
...
...
@@ -22,7 +19,7 @@ App({
onLaunch
:
function
()
{
this
.
autoUpdate
();
wx
.
setStorageSync
(
'appId'
,
'wx
d56eb1b3b99e5cf0
'
);
wx
.
setStorageSync
(
'appId'
,
'wx
7d7fbc0e6746baf5
'
);
plugins
.
configPlugin
({
// polyfill fetch function
...
...
project.config.json
View file @
0ddeb16d
...
...
@@ -44,8 +44,8 @@
},
"compileType"
:
"miniprogram"
,
"libVersion"
:
"2.17.0"
,
"appid"
:
"wx
d56eb1b3b99e5cf0
"
,
"projectname"
:
"
wx-tfs-demo
"
,
"appid"
:
"wx
7d7fbc0e6746baf5
"
,
"projectname"
:
"
奔腾宝贝
"
,
"simulatorType"
:
"wechat"
,
"simulatorPluginLibVersion"
:
{},
"editorSetting"
:
{
...
...
subPages/sport/ai-fwc-sport/ai-fwc-sport.js
View file @
0ddeb16d
...
...
@@ -58,7 +58,7 @@ Page({
that
.
data
.
innerAudioContext
.
obeyMuteSwitch
=
false
;
that
.
data
.
innerAudioContext2
.
obeyMuteSwitch
=
false
;
that
.
loadMoveNet
();
//
that.loadMoveNet();
})
...
...
subPages/sport/ai-mixins/ai-fwc-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:42:40
* @LastEditTime: 2022-06-0
8 11:01:27
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -16,13 +16,14 @@ var angle_boby = 0;
var
angle_hand_l
=
0
;
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/push-ups-bg.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -128,11 +129,11 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
// url: '../../../packageA/pushUp/share/share?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
// })
}
else
{
that
.
setData
({
...
...
@@ -160,4 +161,6 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
subPages/sport/ai-mixins/ai-gtjz-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:21:18
* @LastEditTime: 2022-06-0
8 11:01:55
*/
// 拐踢毽子计算配置
...
...
@@ -19,13 +19,14 @@ var correct = 0;
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -171,7 +172,7 @@ module.exports = {
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
console
.
log
(
'仰卧起坐结果'
,
res
)
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
wx
.
redirectTo
({
...
...
@@ -203,4 +204,5 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
subPages/sport/ai-mixins/ai-gtt-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:50:37
* @LastEditTime: 2022-06-0
8 11:03:40
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -13,17 +13,17 @@ var correct = 0;//识别成功次数
var
dir
=
0
;
// 0躺下 1坐起
var
dirr
=
1
;
// 0躺下 1坐起
var
angle_boby
=
0
;
var
angle_l
=
0
;
var
angle_r
=
0
;
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/squat-bg.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -44,8 +44,6 @@ module.exports = {
}
}
angle_boby
=
that
.
angle
(
keypoimts
[
12
],
keypoimts
[
6
],
keypoimts
[
16
]);
//计算深蹲关键点
angle_l
=
that
.
angle
(
keypoimts
[
14
],
keypoimts
[
12
],
keypoimts
[
16
]);
angle_r
=
that
.
angle
(
keypoimts
[
13
],
keypoimts
[
11
],
keypoimts
[
15
]);
...
...
@@ -160,11 +158,11 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
// url:'../../../packageA/highLegLifts/share/share?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
// })
}
else
{
that
.
setData
({
...
...
@@ -192,4 +190,6 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
\ No newline at end of file
subPages/sport/ai-mixins/ai-kht-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:20:56
* @LastEditTime: 2022-06-0
8 11:13:58
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -16,14 +16,16 @@ var angle_foot = 0;
var
angle_hand
=
0
;
var
correct
=
0
;
//识别成功次数
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/jumping-jacks.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
console
.
log
(
'什么鬼啊------------'
)
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
app
.
globalData
.
movenet
.
estimatePoses
(
object
).
then
(
function
(
res
)
{
...
...
@@ -127,11 +129,11 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
// url: '../../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
// })
}
else
{
that
.
setData
({
...
...
@@ -159,4 +161,6 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
subPages/sport/ai-mixins/ai-sd-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:34:33
* @LastEditTime: 2022-06-0
8 11:03:58
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -15,13 +15,14 @@ var dir = 0;// 0躺下 1坐起
var
angle_boby
=
0
;
var
angle_tui
=
0
;
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/squat-bg.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -127,11 +128,11 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
// url: '../../../packageA/deepSquat/share/sahre?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
// })
}
else
{
that
.
setData
({
...
...
@@ -159,4 +160,6 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
\ No newline at end of file
subPages/sport/ai-mixins/ai-tjz-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:27:39
* @LastEditTime: 2022-06-0
8 11:04:17
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -17,13 +17,14 @@ var angle_l = 0;
var
angle_r
=
0
;
var
angle_boby
=
0
;
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/jumping-jacks.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -160,11 +161,11 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
// url:'../../../packageA/shuttlecock/share/share?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
// })
}
else
{
that
.
setData
({
...
...
@@ -192,4 +193,6 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
subPages/sport/ai-mixins/ai-ts-mixins.js
View file @
0ddeb16d
...
...
@@ -3,15 +3,11 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:21:15
* @LastEditTime: 2022-06-0
8 11:04:30
*/
var
API
=
require
(
"../../../utils/request"
);
// 拐踢毽子计算配置
// AI混淆
var
count
=
0
;
var
correct
=
0
;
var
dir
=
0
;
// 0躺下 1坐起
var
count
=
0
;
//个数
var
angle_foot
=
0
;
...
...
@@ -20,17 +16,23 @@ var correct = 0;//识别成功次数
var
lastAngle
=
0
;
//上一次的角度
var
pointList
=
[];
//基准点列表
var
point
=
0
;
//基准点
var
skipType
=
1
;
//当前跳绳模式 0两者都行 1 双脚 2 单双脚交替
var
equal
=
0
;
//个数相等的次数
module
.
exports
=
{
var
prey
=
0
;
var
hanld
=
0
;
var
hanld_a
=
0
;
var
p
=
0
;
module
.
exports
=
Behavior
({
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/jumping-jacks.png'
,
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
app
.
globalData
.
movenet
.
estimatePoses
(
object
).
then
(
function
(
res
)
{
...
...
@@ -55,6 +57,12 @@ module.exports = {
angle_foot
=
that
.
angle
(
keypoimts
[
11
],
keypoimts
[
15
],
keypoimts
[
16
]);
var
nowPoint
=
(
keypoimts
[
11
].
y
+
keypoimts
[
2
].
y
)
/
2
;
//每个的基准点
angle_knee
=
that
.
angle
(
keypoimts
[
13
],
keypoimts
[
11
],
keypoimts
[
15
]);
var
pointfoot
=
keypoimts
[
16
];
hanld
=
that
.
angle
(
keypoimts
[
8
],
keypoimts
[
6
],
keypoimts
[
10
]);
hanld_a
=
that
.
angle
(
keypoimts
[
7
],
keypoimts
[
5
],
keypoimts
[
9
]);
p
=
pointfoot
.
y
;
if
(
that
.
data
.
aiState
==
1
){
if
(
angle_foot
-
lastAngle
<
10
){
correct
++
;
...
...
@@ -80,92 +88,72 @@ module.exports = {
//通过角度判断个数
//console.log('当前基准点',nowPoint,'平均基准点',point,'当前个数',that.data.aiCount)
if
(
that
.
data
.
aiState
==
3
){
console
.
log
(
'当前个数'
,
Math
.
floor
(
count
),
that
.
data
.
aiCount
,
skipType
,
that
.
data
.
showTime
)
if
(
Math
.
floor
(
count
)
==
that
.
data
.
aiCount
){
equal
++
;
}
else
{
equal
=
0
;
}
//console.log('相等次数',equal)
if
(
equal
==
15
){
skipType
=
skipType
==
1
?
2
:
1
;
equal
=
0
;
console
.
log
(
'一秒没数据,切换模式'
,
skipType
)
// if(that.data.aiCount > 0){
// console.log('自动加1')
// count = count + 1;
// }
}
//当前为双脚模式
if
(
skipType
==
1
){
if
(
nowPoint
-
15
>
point
){
if
(
dir
==
0
){
if
(
that
.
data
.
skipType
==
2
){
console
.
log
(
'当前角度'
,
hanld
+
'脚坐标'
+
p
+
'prey'
+
prey
)
if
(
prey
==
0
){
prey
=
p
}
else
{
if
(
p
>
prey
+
2
&&
hanld
>=
120
){
if
(
dir
==
1
){
count
=
count
+
0.5
;
dir
=
1
;
equal
=
0
;
dir
=
0
;
if
(
count
>
that
.
data
.
sportTime
*
5
+
20
){
count
=
that
.
data
.
sportTime
*
5
+
20
}
that
.
setData
({
aiCount
:
Math
.
floor
(
count
)
})
}
}
//站直
if
(
nowPoint
<
point
){
if
(
dir
==
1
){
if
(
p
<
prey
-
2
&&
hanld
>=
120
&&
(
hanld
<=
170
||
hanld_a
<=
170
)){
if
(
dir
==
0
){
count
=
count
+
0.5
;
dir
=
0
;
skipType
=
1
;
equal
=
0
;
console
.
log
(
'双脚模式'
,
nowPoint
+
'---'
+
point
)
dir
=
1
;
if
(
count
>
that
.
data
.
sportTime
*
5
+
20
){
count
=
that
.
data
.
sportTime
*
5
+
20
}
that
.
setData
({
aiCount
:
Math
.
floor
(
count
)
})
console
.
log
(
'双脚+1'
)
}
}
prey
=
p
;
}
}
console
.
log
(
'当前膝盖角度'
,
angle_knee
)
//
console.log('当前膝盖角度',angle_knee)
//当前为单双脚模式
if
(
skipType
==
2
){
if
(
angle_knee
>=
177
){
if
(
dir
==
0
){
if
(
that
.
data
.
aiCount
>
0
&&
that
.
data
.
aiCount
<
270
){
count
=
count
+
1.9
;
if
(
that
.
data
.
skipType
==
1
){
console
.
log
(
'当前角度'
,
hanld
+
'脚坐标'
+
p
+
'prey'
+
prey
)
if
(
prey
==
0
){
prey
=
p
}
else
{
count
=
count
+
0.5
;
if
(
p
>
prey
+
2
&&
hanld
>=
120
){
if
(
dir
==
1
){
count
=
count
+
1
;
dir
=
0
;
if
(
count
>
that
.
data
.
sportTime
*
5
+
20
){
count
=
that
.
data
.
sportTime
*
5
+
20
}
dir
=
1
;
equal
=
0
;
that
.
setData
({
levelfontsize
:
'font-size:40px;color:#FFFF00;line-height:44px;'
,
aiCount
:
Math
.
floor
(
count
)
},()
=>
{
setTimeout
(()
=>
{
that
.
setData
({
levelfontsize
:
'font-size:34px;color:#FFFFFF;line-height:48px;'
,
})
},
200
)
})
}
}
if
(
angle_knee
<=
165
){
if
(
dir
==
1
){
count
=
count
+
0.9
;
dir
=
0
;
skipType
=
2
;
equal
=
0
;
if
(
p
<
prey
-
2
&&
hanld
>=
120
&&
(
hanld
<=
170
||
hanld_a
<=
170
)){
if
(
dir
==
0
){
count
=
count
+
1
;
dir
=
1
;
if
(
count
>
that
.
data
.
sportTime
*
5
+
20
){
count
=
that
.
data
.
sportTime
*
5
+
20
}
that
.
setData
({
levelfontsize
:
'font-size:40px;color:#FFFF00;line-height:44px;'
,
aiCount
:
Math
.
floor
(
count
)
},()
=>
{
setTimeout
(()
=>
{
that
.
setData
({
levelfontsize
:
'font-size:34px;color:#FFFFFF;line-height:48px;'
,
})
},
200
)
})
console
.
log
(
'单双脚+1'
)
}
}
prey
=
p
;
}
}
}
}).
catch
(
function
(
err
)
{
...
...
@@ -193,15 +181,26 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
//
wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
//
})
wx
.
redirectTo
({
// url: '../../../packageA/aiSkip/share/share?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
})
}
else
{
that
.
setData
({
aiState
:
4
wx
.
showModal
({
title
:
'提示'
,
content
:
res
.
message
,
showCancel
:
false
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
//这里是点击了确定以后
wx
.
navigateBack
({
//返回
delta
:
1
})
}
else
{
//这里是点击了取消以后
console
.
log
(
'用户点击取消'
)
}
}
})
}
})
...
...
@@ -225,4 +224,5 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
subPages/sport/ai-mixins/ai-ydp-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 17:09:07
* @LastEditTime: 2022-06-0
8 11:04:44
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -18,13 +18,14 @@ var angle_l = 0;
var
angle_r
=
0
;
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/squat-bg.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -161,7 +162,7 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
...
...
@@ -193,4 +194,5 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
subPages/sport/ai-mixins/ai-ydtt-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 16:57:57
* @LastEditTime: 2022-06-0
8 11:04:59
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -17,13 +17,14 @@ var angle_boby = 0;
var
angle_l
=
0
;
var
angle_r
=
0
;
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/squat-bg.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -160,11 +161,11 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
// url:'../../../packageA/hipKicked/share/share?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
// })
}
else
{
that
.
setData
({
...
...
@@ -192,4 +193,5 @@ module.exports = {
var
angleA
=
Math
.
round
(
Math
.
acos
(
cosA
)
*
180
/
Math
.
PI
);
return
angleA
;
},
}
}
})
subPages/sport/ai-mixins/ai-ywqz-mixins.js
View file @
0ddeb16d
...
...
@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 09:53:47
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-0
7 17:21:47
* @LastEditTime: 2022-06-0
8 11:05:18
*/
var
API
=
require
(
"../../../utils/request"
);
...
...
@@ -13,13 +13,14 @@ var correct = 0;//识别成功次数
var
dir
=
0
;
// 0躺下 1坐起
module
.
exports
=
{
module
.
exports
=
Behavior
(
{
onLoad
:
function
(
option
){
},
data
:
{
showImageUrl
:
'https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/bg-sit.png'
},
methods
:{
actionSend
(
object
,
app
){
// 识别点
var
that
=
this
;
//console.log('app.globalData.movenet',app.globalData.movenet)
...
...
@@ -51,7 +52,7 @@ module.exports = {
//上传成绩
save
(){
var
that
=
this
;
if
(
that
.
data
.
aiCount
==
0
){
if
(
that
.
data
.
aiCount
==
0
||
that
.
data
.
aiCount
>
10
0
){
that
.
setData
({
aiState
:
4
})
...
...
@@ -67,11 +68,11 @@ module.exports = {
}
console
.
log
(
'当前的参数'
,
postData
)
API
.
requestAll
(
'/project/addReord'
,
postData
,
(
res
)
=>
{
clearTimeout
(
this
.
data
.
loading
);
clearTimeout
(
that
.
data
.
waitTimer
);
var
uid
=
res
.
data
.
id
;
if
(
res
.
code
==
200
){
// wx.redirectTo({
// url: '../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1'
,
// url: '../../../packageA/sitUp/share/share?share=0' + '&id=' + uid + '&showMedal=1&sportTime='+that.formatSeconds(that.data.sportTime)
,
// })
}
else
{
that
.
setData
({
...
...
@@ -150,5 +151,6 @@ module.exports = {
}
}
}
},
}
},
}
})
subPages/sport/ai-sport/ai-sport.js
View file @
0ddeb16d
var
app
=
getApp
()
var
poseDetection
=
require
(
'@tensorflow-models/pose-detection'
);
//引入混合模式
var
flagTimer
=
null
;
var
time
=
0
;
var
iosNum
=
0
;
//ios不能重复播放同一地址音频,后加一位数,加时间戳不行
const
aiSportType
=
app
.
_aiSportType
||
'1'
var
ts
=
require
(
'../ai-mixins/ai-
gtjz
-mixins.js'
)
//跳绳
var
ts
=
require
(
'../ai-mixins/ai-
ts
-mixins.js'
)
//跳绳
var
ywqz
=
require
(
'../ai-mixins/ai-ywqz-mixins.js'
)
//仰卧起坐
var
tjz
=
require
(
'../ai-mixins/ai-tjz-mixins.js'
)
//踢毽子
var
kht
=
require
(
'../ai-mixins/ai-kht-mixins.js'
)
//开合跳
...
...
@@ -28,8 +30,12 @@ const sportObj = {
16
:
ydtt
,
//原地踢腿
17
:
ydp
,
//原地跑
}
console
.
log
(
'aiSportType'
,
aiSportType
)
Page
({
mixins
:
[
sportObj
[
aiSportType
]],
// mixins: [sportObj[aiSportType]],
behaviors
:
[
sportObj
[
aiSportType
]],
name
:
'ai-sport'
,
data
:
{
fps
:
20
,
//控制频率
...
...
@@ -58,6 +64,7 @@ Page({
levelfontsize
:
''
,
sportTime
:
60
,
//运动时长
skipType
:
1
,
//当前跳绳模式 0两者都行 1 双脚 2 单双脚交替
},
onLoad
:
function
(
options
)
{
...
...
@@ -68,7 +75,7 @@ Page({
//运动时长(秒)
if
(
options
.
sportTime
){
// 30/60/120/180
this
.
setData
({
sportTime
:
options
.
sportTime
})
this
.
setData
({
sportTime
:
options
.
sportTime
,
skipType
:
options
.
type
})
}
// 音频/语音交互相关
...
...
subPages/sport/ai-sport/ai-sport.wxml
View file @
0ddeb16d
...
...
@@ -2,7 +2,7 @@
<canvas type="2d" id="myCanvas" class="canvas"></canvas>
</camera>
<view wx:if="{{aiState == 1 || aiState == 6}}">
<image class="help-img"
src="https://cdn.xiaobentiyu.cn/sport_minapp_img/sitUp/jumping-jacks.png
"></image>
<image class="help-img"
wx:if="{{showImageUrl}}" src="{{showImageUrl}}
"></image>
<view class="help">
<view class="title">互动小提示</view>
<view class="content">手机竖屏固定放置,调整屏幕角度,训练者全身及双脚出现至屏幕内,识别更精准。</view>
...
...
subPages/sport/detail/detail.js
View file @
0ddeb16d
wx-mixins.js
deleted
100644 → 0
View file @
1b60b956
/*
* @Author: tangjiale
* @eMail: 932055106@qq.com
* @Date: 2022-05-11 17:06:34
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-07 15:16:02
*/
//代码转自:https://blog.csdn.net/yezi__6/article/details/118362069
//微信小程序中优先级为 Page > Mixins,所以需要劫持并改写 Page 函数,最后再重新把它释放出来
function
mixinPage
()
{
// 保存原生的 Page 函数
const
originPage
=
Page
Page
=
(
options
)
=>
{
const
mixins
=
options
.
mixins
// mixins 必须为数组
if
(
Array
.
isArray
(
mixins
))
{
delete
options
.
mixins
// mixins 注入并执行相应逻辑
options
=
mergePage
(
mixins
,
options
)
}
originPage
(
options
)
}
}
const
ORIGIN_PROPERTIES_PAGE
=
[
'data'
]
const
ORIGIN_METHODS
=
[
'onLoad'
,
'onReady'
,
'onShow'
,
'onHide'
,
'onUnload'
,
'onPullDownRefresh'
,
'onReachBottom'
,
'onShareAppMessage'
,
'onPageScroll'
,
'onResize'
,
'onTabItemTap'
]
function
mergePage
(
mixins
,
options
)
{
mixins
.
forEach
((
mixin
)
=>
{
if
(
typeof
mixin
==
'object'
)
{
// 遍历 mixin 里面的所有属性
for
(
let
key
in
mixin
)
{
// for (let [key, value] of Object.entries(mixin)) {
if
(
ORIGIN_PROPERTIES_PAGE
.
includes
(
key
))
{
// 内置对象属性混入
options
[
key
]
=
{
...
mixin
[
key
],
...
options
[
key
]
}
}
else
if
(
ORIGIN_METHODS
.
includes
(
key
))
{
// 内置方法属性混入,优先执行混入的部分
const
originFunc
=
options
[
key
]
options
[
key
]
=
function
(...
args
)
{
mixin
[
key
].
call
(
this
,
...
args
)
return
originFunc
&&
originFunc
.
call
(
this
,
...
args
)
}
}
else
{
// 自定义方法混入
options
=
{
...
mixin
,
...
options
}
}
}
}
})
return
options
}
mixinPage
()
\ No newline at end of file
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