Commit 01070a2a by tangjiale

更新代码

parent 756bca13
......@@ -3,10 +3,13 @@
* @eMail: 932055106@qq.com
* @Date: 2022-01-13 17:47:44
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-08 10:39:10
* @LastEditTime: 2022-06-08 19:59:38
*/
// wx.setStorageSync('host', 'https://sdb.youchengzhang.cn/'); //正式环境
wx.setStorageSync('host', 'https://test.xiaobentiyu.cn'); //测试环境
// wx.setStorageSync('host', 'https://test.xiaobentiyu.cn'); //测试环境
wx.setStorageSync('host', 'https://test.xiaobentiyu.cn/pxmobileapi'); //测试环境
//https://test.xiaobentiyu.cn/pxmobileapi
//https://test.xiaobentiyu.cn/pxmobileapi/doc.html#/home
//ai姿势识别
const fetchWechat = require('fetch-wechat')
......
......@@ -25,7 +25,14 @@
"ai-gtt-sport/ai-gtt-sport",
"ai-ydtt-sport/ai-ydtt-sport",
"ai-ydp-sport/ai-ydp-sport",
"share/share"
"share/share",
"ywqz-sport/ywqz-sport",
"checkSkip/checkSkip",
"skip-edit/skip-edit",
"musicList/musicList",
"ordinDaka/ordinDaka",
"sportTime/sportTime",
"myData/myData"
]
},
{
......@@ -72,6 +79,9 @@
"van-picker": "@vant/weapp/picker/index",
"van-dialog": "@vant/weapp/dialog/index"
},
"requiredBackgroundModes": [
"audio"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
......
......@@ -3,7 +3,7 @@
* @eMail: 932055106@qq.com
* @Date: 2022-06-06 16:45:35
* @LastEditors: tangjiale
* @LastEditTime: 2022-06-07 15:27:35
* @LastEditTime: 2022-06-08 17:22:18
*/
var API = require("../../utils/request");
Page({
......@@ -13,6 +13,22 @@ Page({
*/
data: {
skipType: 1, //1、定时跳,2、定数跳,3、自由跳
timeList: {
1: '00:30',
2: '1:00',
3: '2:00',
4: '3:00'
}, //定时跳map
numberList: {
1: '100次',
2: '200次',
3: '300次',
4: '500次',
5: '800次',
6: '1000次'
}, //定时跳map
selectContent: '', //当前模式
dataList:[]
},
......@@ -30,6 +46,103 @@ Page({
onReady: function () {
},
//切换模式
checkSkipType(e) {
var that = this;
var type = e.currentTarget.dataset.type;
this.setData({
skipType: type
}, () => {
if (type == 1) {
that.setData({
selectType: 2,
selectContent: that.data.timeList[2]
})
} else if (type == 2) {
that.setData({
selectType: 2,
selectContent: that.data.numberList[2]
})
} else {
that.setData({
selectContent: '无限制'
})
}
})
},
//往前选择模式
lastType() {
var that = this;
if (that.data.skipType == 1) {
that.data.selectType--;
if (that.data.selectType == 0) {
that.setData({
selectType: 4
}, () => {
that.setData({
selectContent: that.data.timeList[that.data.selectType]
})
})
} else {
that.setData({
selectContent: that.data.timeList[that.data.selectType]
})
}
}
if (that.data.skipType == 2) {
that.data.selectType--;
if (that.data.selectType == 0) {
that.setData({
selectType: 6
}, () => {
that.setData({
selectContent: that.data.numberList[that.data.selectType]
})
})
} else {
that.setData({
selectContent: that.data.numberList[that.data.selectType]
})
}
}
},
//往后选择模式
nextType() {
var that = this;
if (that.data.skipType == 1) {
that.data.selectType++;
if (that.data.selectType == 5) {
that.setData({
selectType: 1
}, () => {
that.setData({
selectContent: that.data.timeList[that.data.selectType]
})
})
} else {
that.setData({
selectContent: that.data.timeList[that.data.selectType]
})
}
}
if (that.data.skipType == 2) {
that.data.selectType++;
if (that.data.selectType == 7) {
that.setData({
selectType: 1
}, () => {
that.setData({
selectContent: that.data.numberList[that.data.selectType]
})
})
} else {
that.setData({
selectContent: that.data.numberList[that.data.selectType]
})
}
}
},
/**
* 生命周期函数--监听页面显示
......@@ -41,6 +154,11 @@ Page({
selected: 1
})
}
this.setData({
skipType: 1, //1、定时跳,2、定数跳,3、自由跳
selectType: 2,
selectContent: this.data.timeList[2]
})
//获取所有体育运动项目
this.getAllProgect()
},
......@@ -69,6 +187,16 @@ Page({
url: '/subPages/sport/detail/detail?id=' + project
})
},
//开始跳绳(选择跳绳模式)
checkSkip() {
var that = this;
var type = that.data.skipType;
var select = that.data.selectType;
console.log('当前选择', type, select)
wx.navigateTo({
url: '../../subPages/sport/checkSkip/checkSkip?type=' + type + '&select=' + select,
})
},
/**
* 生命周期函数--监听页面隐藏
......
<view class="list">
<view class="top-content {{skipType==1?'top-content-a':skipType==2?'top-content-b':skipType==3?'top-content-c':'top-content-a'}}">
<image class="time-skip" style="{{skipType==1 ? 'display:block' : ''}}" src="../../images/home/time_skip.png"></image>
<image class="time-skip" style="{{skipType==2 ? 'display:block' : ''}}" src="../../images/home/num_skip.png"></image>
<image class="time-skip" style="{{skipType==3 ? 'display:block' : ''}}" src="../../images/home/free_skip.png"></image>
<view class="skip-type">
<view class="skip-type-item border-l" data-type="1" bindtap="checkSkipType" style="{{skipType==1?'color:#ffffff;background:#FF811E':''}}"><text>计时跳</text></view>
<view class="skip-type-item border-z" data-type="2" bindtap="checkSkipType" style="{{skipType==2?'color:#ffffff;background:#FF811E':''}}"><text>计数跳</text></view>
<view class="skip-type-item border-r" data-type="3" bindtap="checkSkipType" style="{{skipType==3?'color:#ffffff;background:#FF811E':''}}"><text>自由跳</text></view>
</view>
<view class="start-skip-bg">
<view class="time-check">
<view class="last" wx:if="{{skipType != 3}}">
<image catchtap="lastType" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/icon_check_left.png"></image>
</view>
<view class="type">{{selectContent}}</view>
<view class="next" wx:if="{{skipType != 3}}">
<image catchtap="nextType" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/icon_check_right.png"></image>
</view>
</view>
<view class="start-skip" catchtap="checkSkip" id="start">开始跳绳</view>
</view>
</view>
<view class="li" bindtap="sport" data-item="{{item}}" wx:for="{{dataList}}" wx:key="index">
<image class="sport-img" src="{{item.bigImg}}"></image>
<!-- <image class="tc" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/bq-tcxm.png" wx:if="{{item.testProject == 1}}"></image> -->
......
......@@ -10,7 +10,7 @@
position: relative;
float: left;
width: 49%;
margin-right: 1%;
margin-left: 2%;
margin-bottom: 40rpx;
}
......@@ -18,7 +18,7 @@
position: relative;
float: left;
width: 49%;
margin-left: 1%;
margin-left: 0%;
margin-bottom: 40rpx;
}
......@@ -54,3 +54,165 @@
margin-right: 10rpx;
margin-top: 4rpx;
}
/* -------------------------------- */
.top-title image {
width: 112rpx;
height: 68rpx;
}
.top-content {
position: relative;
width: 690rpx;
height: 382rpx;
margin: 16rpx auto 30rpx auto;
}
.time-skip {
position: absolute;
width: 690rpx;
height: 382rpx;
display: none;
}
.top-content-a {
/* background: url('https://cdn.xiaobentiyu.cn/sport_minapp_img/home/time_skip.png'); */
background-size: 690rpx 382rpx;
}
.top-content-b {
/* background: url('https://cdn.xiaobentiyu.cn/sport_minapp_img/home/num_skip.png'); */
background-size: 690rpx 382rpx;
}
.top-content-c {
/* background: url('https://cdn.xiaobentiyu.cn/sport_minapp_img/home/free_skip.png'); */
background-size: 690rpx 382rpx;
}
.top-bg {
position: absolute;
width: 690rpx;
height: 382rpx;
z-index: -1;
}
.skip-type {
display: flex;
flex-direction: row;
align-items: center;
background: #FFE6CC;
height: 120rpx;
border-radius: 24rpx;
}
.border-l {
border-radius: 24rpx 46rpx 46rpx 24rpx;
}
.border-z {
border-radius: 46rpx 46rpx 46rpx 46rpx;
}
.border-r {
border-radius: 46rpx 24rpx 24rpx 46rpx;
}
.skip-type-item text {
line-height: 80rpx;
}
.start-skip-bg {
position: absolute;
width: 690rpx;
height: 302rpx;
border-radius: 24rpx;
bottom: 0rpx;
background: #FF811E;
}
.time-check {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
margin-top: 40rpx;
margin-bottom: 30rpx;
}
.time-check image {
width: 76rpx;
height: 96rpx;
}
.time-check .type {
/* font-family: 'Number'; */
flex: 2;
display: flex;
flex-direction: row;
justify-content: center;
font-size: 72rpx;
font-weight: bold;
color: rgba(255, 255, 255, 0.9);
}
.time-check .type text {
font-size: 56rpx;
}
.last {
/* flex: 1; */
float: left;
margin-left: 40rpx;
}
.next {
/* flex: 1; */
float: right;
margin-right: 40rpx;
}
.last:active {
width: 76rpx;
height: 96rpx;
margin-top: -8rpx;
border-radius: 16rpx;
background-color: rgba(255, 255, 255, 0.08);
}
.next:active {
width: 76rpx;
height: 96rpx;
margin-top: -8rpx;
border-radius: 16rpx;
background-color: rgba(255, 255, 255, 0.08);
}
.skip-type-item {
position: relative;
z-index: 1;
flex: 1;
/* height: 80rpx; */
text-align: center;
height: 120rpx;
font-size: 34rpx;
font-weight: bold;
color: #FF811E;
}
.start-skip {
position: absolute;
left: 40rpx;
bottom: 30rpx;
width: 610rpx;
height: 96rpx;
line-height: 96rpx;
text-align: center;
margin: 0 auto;
background: #FFFFFF;
border-radius: 48rpx;
font-size: 34rpx;
font-weight: bold;
color: #FF811E;
}
.start-skip:active {
background-color: rgba(255, 255, 255, 0.8);
}
\ No newline at end of file
......@@ -27,13 +27,6 @@
"scene": null
},
{
"name": "ai运动",
"pathName": "subPages/sport/ai-sport/ai-sport",
"query": "id=11",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "subPages/sport/ai-ywqz-sport/ai-ywqz-sport",
"query": "sportTime=60",
......@@ -44,8 +37,22 @@
"name": "ai运动分享",
"pathName": "subPages/sport/share/share",
"query": "id=10774553&share=0&showMedal=1&user=1&sportTime=00:02:00",
"scene": null,
"launchMode": "default"
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "subPages/sport/ywqz-sport/ywqz-sport",
"query": "sportType=1",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "subPages/sport/sportTime/sportTime",
"query": "type=1",
"launchMode": "default",
"scene": null
}
]
}
......
......@@ -68,6 +68,8 @@ Page({
},
onUnload(){
var that = this;
that.data.innerAudioContext.stop();
that.data.innerAudioContext2.stop();
that.data.innerAudioContext.destroy();
that.data.innerAudioContext2.destroy();
......
var mode = 0;//跳绳模式
Page({
/**
* 页面的初始数据
*/
data: {
type:'',//当前跳绳模式
select:'',//当前选择模式下的模块
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('接收到的参数',options)
this.setData({
type:options.type,
select:options.select
})
},
//ai跳绳
aiSport(){
wx.redirectTo({
url: '../ai-ts-sport/ai-ts-sport',
})
},
//普通跳绳
generalSport(){
var that = this;
if(that.data.type == 1){
wx.redirectTo({
url: '../ywqz-sport/ywqz-sport?sportType=1' + '&select=' + that.data.select,
})
}
if(that.data.type == 3){
wx.redirectTo({
url: '../ordinDaka/ordinDaka?sportType=1',
})
}
},
//智能跳绳
smartSport(){
var that = this;
if(that.data.type == 1){
console.log('计时跳')
if(that.data.select == 1){
mode = 0
}else if(that.data.select == 2){
mode = 2
}else if(that.data.select == 3){
mode = 3
}else if(that.data.select == 4){
mode = 4
}
wx.redirectTo({
// url: '../skip/skip/skip?mode=' + mode,
})
}else if(that.data.type == 2){
console.log('计数跳')
if(that.data.select == 1){
mode = 24
}else if(that.data.select == 2){
mode = 25
}else if(that.data.select == 3){
mode = 12
}else if(that.data.select == 4){
mode = 13
}else if(that.data.select == 5){
mode = 26
}else if(that.data.select == 6){
mode = 14
}
wx.redirectTo({
// url: '../skip/skip/skip?mode=' + mode,
})
}else if(that.data.type == 3){
console.log('自由模式')
wx.redirectTo({
// url: '../skip/skip/skip?mode=1',
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": ""
}
\ No newline at end of file
<!--packageA/checkSkip/checkSkip.wxml-->
<view class="check-skip-model">
<view class="check-skip-title">选择你的跳绳方式</view>
<view class="model-list">
<view class="model-item" bindtap="smartSport">
<image class="model-bg" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/ksts_bg_znts.png"></image>
<image class="model-img" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/ksts_icon_znts.png"></image>
<view class="model-content">
<view class="model-name model-zn">智能跳绳<image src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/bq_tj.png"></image>
</view>
<view class="model-msg">跳绳数据自动上传,智能计时计数更省心</view>
</view>
</view>
<view class="model-item" wx:if="{{type == 1 && select == 2}}" bindtap="aiSport">
<image class="model-bg" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/ksts_bg_aits.png"></image>
<image class="model-img" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/ksts_icon_aits.png"></image>
<view class="model-content">
<view class="model-name">AI跳绳</view>
<view class="model-msg">人工智能实时识别,但因环境或光线干扰数据会存在误差</view>
</view>
</view>
<view class="model-item" wx:if="{{type != 2 && select != 1}}" bindtap="generalSport">
<image class="model-bg" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/ksts_bg_ptts.png"></image>
<image class="model-img" src="https://cdn.xiaobentiyu.cn/sport_minapp_img/home/ksts_icon_ptts.png"></image>
<view class="model-content">
<view class="model-name">普通跳绳</view>
<view class="model-msg">仅提供计时功能,需要你手动录入</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
/* packageA/checkSkip/checkSkip.wxss */
.check-skip-title {
display: flex;
flex-direction: row;
justify-content: center;
width: 100%;
margin-top: 4rpx;
font-size: 44rpx;
line-height: 60rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: rgba(0, 0, 0, 0.9);
}
.model-list {
width: 690rpx;
margin: 30rpx;
}
.model-item {
display: flex;
flex-direction: row;
align-items: center;
position: relative;
width: 100%;
height: 240rpx;
margin-bottom: 20rpx;
background: #FAF8F6;
border-radius: 24rpx;
}
.model-item:active{
background-color: rgba(0, 0, 0, 0.05);
}
.model-bg {
position: absolute;
top: 40rpx;
right: 40rpx;
width: 160rpx;
height: 160rpx;
}
.model-img {
width: 96rpx;
height: 96rpx;
margin-left: 40rpx;
}
.model-content {
display: flex;
flex-direction: column;
margin-left: 30rpx;
}
.model-name {
font-size: 34rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: rgba(0, 0, 0, 0.9);
}
.model-zn {
display: flex;
flex-direction: row;
align-items: center;
}
.model-zn image {
width: 84rpx;
height: 36rpx;
margin-left: 10rpx;
}
.model-msg {
max-width: 432rpx;
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: rgba(0, 0, 0, 0.3);
}
\ No newline at end of file
......@@ -94,9 +94,13 @@ Page({
//返回首页
back(){
//跳转仰卧起坐普通模式页面
if(this.data.sportDetail.id == 2){
wx.navigateTo({
url: '/packageB/activity/daka/daka?sportType=2',
url: '../ywqz-sport/ywqz-sport?sportType=2',
})
}
},
changeSelect(e){
let {value} = e.detail
......
// pages/skip/musicList/musicList.js
var API = require("../../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
list:[],
currentCampus: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options);
var that = this;
that.setData({
currentCampus:options.id
})
that.getBgMusic();
},
palyVoice(url) {
wx.playBackgroundAudio({
dataUrl: url,
success(e) { console.log(e); },
fail(e) { console.log(e); },
complete() { }
})
},
//获取背景音乐列表
getBgMusic() {
var that = this;
API.getData('/config/getBgMusic', {}, function (res) {
console.log(res);
that.setData({
list:res.data
})
}, function () {
});
},
chooseCampus: function(options) {
var that = this
var id = options.currentTarget.dataset.id;
var music = options.currentTarget.dataset.music;
console.log(id);
console.log(music);
that.palyVoice(music);
//设置当前样式
that.setData({
currentCampus:id
})
API.requestAll('/config/setSkipConfig', {
skipBackMusic:id
}, function (res) {
console.log('设置背景音乐',res);
}, function () {
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
this.setData({
is_start:false
});
wx.stopBackgroundAudio();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
this.setData({
is_start:false
});
wx.stopBackgroundAudio();
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "选择音乐",
"navigationBarBackgroundColor": "#F5F5F5"
}
\ No newline at end of file
<view>
<view wx:for="{{list}}" wx:for-item="campus" bindtap="chooseCampus" class="item {{currentCampus==campus.id?'sel':''}}" data-id="{{campus.id}}" data-music="{{campus.musicUrl}}">
{{campus.musicName}}
<image class="icon" src="/images/sport/icon-sel.png"></image>
</view>
</view>
.item{
position: relative;
color: #353535;
width: 84%;
height: 100rpx;
line-height: 100rpx;
margin: 0 auto;
padding-left: 10%;
border-bottom: 1rpx solid #EEEEEE;
}
.item .icon{
display: none;
position: absolute;
width: 32rpx;
height: 32rpx;
left: 0rpx;
top: 36rpx;
}
.sel{
color: #FF9B4D;
}
.sel .icon{
display: block;
}
\ No newline at end of file
// packageB/user/myData/myData.js
var API = require("../../../utils/request.js");
var timeUtils = require("../../../utils/time.js");
var page = 1;
var size = 30;
Page({
/**
* 页面的初始数据
*/
data: {
projectId:1,
totalList:[],
startDay:null,
endDay:null,
sportRecordList:[],
sportMap:{1:'跳绳',2:'仰卧起坐',3:'踢毽子',4:'步数',5:'坐位体前屈',6:'50米跑',11:'开合跳',13:'深蹲',14:'俯卧撑',15:'高抬腿',16:'原地臀踢',17:'原地跑'}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that= this;
that.setData({
projectId:options.projectId,
startDay:options.startDay || null,
endDay:options.endDay || null,
},()=>{
that.getRecord(options.projectId)
wx.setNavigationBarTitle({
title: that.data.sportMap[options.projectId] + '记录'
})
})
},
//获取当前选中的运动记录
getRecord(id){
var that = this;
if(that.data.startDay){
var postDate = {
projectId:id,
page:page,
size:size,
startDate:that.data.startDay,
endDate:that.data.endDay
}
}else{
var postDate = {
projectId:id,
page:page,
size:size,
}
}
API.getData('/project/record', postDate, (res) => {
console.log('我是当前选中的数据',res);
that.setData({
totalList:that.data.totalList.concat(res.data),
},()=>{
console.log('翻页合并后的数据',that.data.totalList);
var arr = []; //存放新数组
for (var i = 0; i < that.data.totalList.length; i++) {
//读取每条数据的日期
var recordDate = that.data.totalList[i].recordDate;
//当日期相同,只要传这个
var valDetailList = {
"id": that.data.totalList[i].id,
"count": that.data.totalList[i].count,
"projectId": that.data.totalList[i].projectId,
"isDevData":that.data.totalList[i].isDevData,
"sportValue": that.data.totalList[i].sportValue,
"sportValueType": that.data.totalList[i].sportValueType,
"recordDate":that.data.totalList[i].recordDate,
"createTime":that.data.totalList[i].createTime.slice(10),
"classId":that.data.totalList[i].classId,
"sportTime":timeUtils.forTimes(that.data.totalList[i].sportTime),
"calorie":that.data.totalList[i].calorie,
"speed":that.data.totalList[i].speed,
"sportValueTypeName":that.data.totalList[i].sportValueTypeName,
"listIcon":that.data.totalList[i].listIcon
}
//当日期没有相同的,就新建一个Item
var valItem = {
"recordDate": '',
"detailList": []
}
valItem.recordDate = recordDate;
valItem.detailList.push(valDetailList);
//第0个不需要比较
if (i == 0) {
arr.push(valItem);
}
//第1个就要开始找新数组arr相同的日期
else{
var index = -1;
for(var k =0;k<arr.length;k++){
if(recordDate == arr[k].recordDate){
index = k;
break;
}
}
if(index === -1){
arr.push(valItem);
}else{
arr[k].detailList.push(valDetailList);
}
}
}
console.log('我是合并后的数组',arr);
that.setData({
sportRecordList:arr
})
})
}, function () {
wx.hideLoading()
});
},
//查看详情
checkInfo(e){
console.log(e.currentTarget.dataset.info)
var id = e.currentTarget.dataset.info.id;
var sportTime = e.currentTarget.dataset.info.sportTime;
var projectId = e.currentTarget.dataset.info.projectId;
var isdevdata = e.currentTarget.dataset.info.isdevdata;
if(projectId == 1){
wx.navigateTo({
url: '../share/share?id=' + id + "&showMedal=1&sportTime=" + sportTime
})
}else if(projectId == 2){
wx.navigateTo({
url:'../share/share?id=' + id + '&share=0&isDev=' + isdevdata + '&showMedal=0&user=1&sportTime=' + sportTime
})
}else if(projectId == 3){
wx.navigateTo({
url:'../share/share?id=' + id + '&share=0&isDev=' + isdevdata + '&showMedal=0&user=1&sportTime=' + sportTime
})
}else if(projectId == 11){
wx.navigateTo({
url:'../share/share?id=' + id + '&share=0&isDev=' + isdevdata + '&showMedal=0&user=1&sportTime=' + sportTime
})
}else if(projectId == 14){
wx.navigateTo({
url:'../share/share?id=' + id + '&share=0&showMedal=1&user=1&sportTime=' + sportTime
})
}else if(projectId == 13){
wx.navigateTo({
url:'../share/sahre?id=' + id + '&share=0&showMedal=1&user=1&sportTime=' + sportTime
})
}else if(projectId == 15){
wx.navigateTo({
url:'../share/share?id=' + id + '&share=0&showMedal=1&user=1&sportTime=' + sportTime
})
}else if(projectId == 16){
wx.navigateTo({
url:'../share/share?id=' + id + '&share=0&showMedal=1&user=1&sportTime=' + sportTime
})
}else if(projectId == 17){
wx.navigateTo({
url:'../share/share?id=' + id + '&share=0&showMedal=1&user=1&sportTime=' + sportTime
})
}else{
// wx.navigateTo({
// url:'../../../packageB/activity/secondsMark/secondsMark?id=' + id
// })
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
var that = this;
console.log('触发上拉操作');
page = page + 1;
console.log('当前的上拉页码数',page);
that.getRecord(that.data.projectId)
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "记录"
}
\ No newline at end of file
<view class="todayList">
<view class="nodata" wx:if="{{sportRecordList.length == 0}}">
<image src="https://ttxs01-10066525.file.myqcloud.com/sport/miniapp/mobile/skip/nodata.png"></image>
</view>
<view class="all" wx:else>全部</view>
<view wx:for="{{sportRecordList}}">
<view class="sport-time">{{item.recordDate}}</view>
<view class="li" hover-class="after-click-content" wx:for="{{item.detailList}}" wx:for-item="items" data-info="{{items}}" bindtap="checkInfo">
<image class="more-img" src="/images/home/next.png"></image>
<view class="todayTime">{{items.createTime}}</view>
<view class="li">
<view class="left">
<image src="{{items.listIcon}}"></image>
</view>
<view class="right">
<view class="num">
<view class="sportType" wx:if="{{items.projectId == 1}}">跳绳</view>
<text class="sportType" wx:if="{{items.projectId == 2}}">仰卧起坐</text>
<text class="sportType" wx:if="{{items.projectId == 3}}">踢毽子</text>
<text class="sportType" wx:if="{{items.projectId == 4}}">步数</text>
<text class="sportType" wx:if="{{items.projectId == 5}}">坐位体前屈</text>
<text class="sportType" wx:if="{{items.projectId == 6}}">50米跑</text>
<text class="sportType" wx:if="{{items.projectId == 11}}">开合跳</text>
<text class="sportType" wx:if="{{items.projectId == 13}}">深蹲</text>
<text class="sportType" wx:if="{{items.projectId == 14}}">俯卧撑</text>
<text class="sportType" wx:if="{{items.projectId == 15}}">高抬腿</text>
<text class="sportType" wx:if="{{items.projectId == 16}}">原地臀踢</text>
<text class="sportType" wx:if="{{items.projectId == 17}}">原地跑</text>
<text class="isSmart" catchtap="buy" wx:if="{{items.isDevData == 1 && items.projectId == 1}}">智能跳绳</text>
</view>
<view class="info" wx:if="{{items.projectId == 1 || items.projectId == 2 || items.projectId == 3 || items.projectId == 4 || items.projectId == 5 || items.projectId == 6 || items.projectId == 11 || items.projectId == 13 || items.projectId == 14 || items.projectId == 15 || items.projectId == 16 || items.projectId == 17}}">
<view class="time" wx:if="{{items.projectId == 1 || items.projectId == 2 || items.projectId == 3 || items.projectId == 4 || items.projectId == 5 || items.projectId == 11 || items.projectId == 13 || items.projectId == 14 || items.projectId == 15 || items.projectId == 16}}">{{items.sportValue}} <text>个</text></view>
<view class="time" wx:elif="{{items.projectId == 17}}">{{items.sportValue}}<text>米</text></view>
<view class="time" wx:elif="{{items.projectId == 6}}">{{items.sportTime}}<text>秒</text></view>
<view class="time" wx:else>{{items.count}}<text>次</text></view>
<view>
<view class="time">{{items.sportTime}}</view>
<image src="/images/skip/time_black.png"></image>
</view>
<view>
<view class="qk">{{items.calorie}}</view>
<image src="/images/skip/calorie_black.png"></image>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
page{
background: #f5f5f5;
}
.top-wrap{
background: #fff;
}
.day{display: flex;}
.day view{
width: 160rpx;
height: 100%;
margin-right: 23rpx;
display: inline-block;
margin-left: 10px;
background-color: blue;
text-align: center;
font-size: 24rpx;
color: #333;
height: 70rpx;
line-height: 70rpx;
}
.data{
position: relative;
height: 330rpx;
display: flex;
}
.data .line{
position: absolute;
width: 2rpx;
height: 100%;
background: #FFFFFF;
left: 50%;
top: 10rpx;
opacity: 0.1;
transform: scaleX(0.5);
}
.data .item{
width: 180rpx;
height: 100%;
margin-right: 23rpx;
display: inline-block;
margin-left: 10px;
}
.item_list .item-set{
color: #3FCB7D;
}
.item_list .item .val{
text-align: center;
color: #FFFFFF;
font-size: 26rpx;
position: absolute;
}
.chart{
height: 338rpx;
width: 60rpx;
margin:0 auto;
border-radius: 60rpx 60rpx 0 0;
position: relative;
}
.chart view{
height: 400rpx;
width: 60rpx;
background: linear-gradient(180deg, #239E71 0%, #183247 100%);
margin:0 auto;
border-radius: 60rpx 60rpx 0 0;
position: absolute;
bottom: 18rpx;
left: 0;
}
.chart-set{
background: #29CC84 !important;
}
.card {
position: relative;
background-color: #fff;
padding-bottom: 30rpx;
padding-top: 0rpx;
border-radius: 24rpx 24rpx 0rpx 0rpx;
margin-top: -48rpx;
}
.data-wrap{
display: flex;
margin-top: 40rpx;
padding-top: 30rpx;
}
.data-wrap .item{
flex: 1;
font-family: "Number";
text-align: center
}
.data-wrap .item-time{
margin-top: 60rpx;
}
.data-wrap .key{
font-size: 22rpx;
color: #B2B2B2;
margin-top: 10rpx;
}
.card .number{
font-family: "Number";
width: 100%;
text-align: center;
font-size: 104rpx;
margin-top: 40rpx;
margin-bottom: 60rpx;
padding-top: 40rpx;
}
.data-wrap .val text{
font-size: 18rpx;
font-weight: normal;
}
.data-wrap .val{
font-size: 48rpx;
}
.data-item{
background: #fff;
margin-top: 20rpx;
}
.data-item .top{
width: 654rpx;
height: 100rpx;
line-height: 100rpx;
margin:0 auto;
border-bottom: 1rpx solid #dbdbdb;
}
.data-item .top .val{
float: left;
font-size: 36rpx;
}
.data-item .top .val text{
font-size:16rpx ;
}
.data-item .top .mode{
float: left;
width:120rpx;
height:36rpx;
background:rgba(237,255,244,1);
border:1rpx solid rgba(63,195,121,1);
border-radius:18rpx;
color:rgba(63,195,121,1);
text-align: center;
line-height: 36rpx;
font-size: 20rpx;
margin:32rpx 30rpx 0 30rpx;
}
.data-item .time{
float: right;
font-size: 26rpx;
}
.data-item .bottom{
display: flex;
height: 100rpx;
width: 654rpx;
margin:0 auto;
}
.t-l{
text-align: left;
}
.t-r{
text-align: right;
}
.center{
min-width: 400rpx;
}
.data-item .bottom .li{
flex: 1;
text-align: center;
}
.data-item .bottom .li .key{
font-size: 22rpx;
color: #656565;
}
.data-item .bottom .li .val{
font-size: 26rpx;
margin-top: 10rpx;
}
.last{
float:left;
font-size: 28rpx;
text-align: center;
padding: 10rpx 20rpx;
border-radius: 10rpx;
color: #FFFFFF;
background: #3FCB7D;
margin: 20rpx;
}
.next{
float:right;
font-size: 28rpx;
text-align: center;
padding: 10rpx 20rpx;
border-radius: 10rpx;
color: #FFFFFF;
background: #3FCB7D;
margin: 20rpx;
}
.top{
overflow: hidden;
background: #FFFFFF;
}
.on{
background: #f5f5f5;
color: #000000;
}
.scroll_box{
width: 100%;
height: 410rpx;
/* padding: 20rpx; */
white-space: nowrap;
}
.scroll_box scroll-view{
background: #183247;
height: 420rpx;
width: auto;
}
.item_list{
position: relative;
top: 0;
text-align: center;
/* width: 130rpx; */
height: 100%;
/* margin-right: 23rpx; */
display: inline-block;
margin-left: 10px;
font-size: 26rpx;
}
.item_list .item{
font-size: 22rpx;
height: 80rpx;
line-height: 80rpx;
color: #b2b2b2;
}
.item_list .item-set{
color: #FFFFFF;
font-weight: bold;
}
::-webkit-scrollbar{
width: 0;
height: 0;
color: transparent;
}
.todayList{
overflow: hidden;
width: 100%;
background: #FFFFFF;
}
.todayList .li{
position: relative;
width: 100%;
/* height: 210rpx; */
display: flex;
}
.todayList .li .left{
text-align: center;
margin-left: 30rpx;
margin-right: 18rpx;
}
.todayList .li .left image{
width: 100rpx;
height: 100rpx;
margin-top: 30rpx;
}
.todayList .li .right{
flex: 1;
border-bottom: 2rpx solid #EEEEEE;
margin-right: 30rpx;
padding-bottom: 14rpx;
}
.todayList .li .alone{
margin-left: 30rpx;
}
.right .type{
height: 30rpx;
margin-top: 30rpx;
font-size: 22rpx;
color: #B2B2B2;
}
.right .num{
font-family: "Number";
color: #353535;
font-size: 48rpx;
margin-top: 20rpx;
margin-bottom: 20rpx;
overflow: hidden;
}
.right .unit{
font-size: 20rpx;
color: #B2B2B2;
margin-left: 6rpx;
}
.right .isSmart{
display: block;
font-size: 22rpx;
background: rgba(1, 162, 255, 0.12);
color: #01A2FF;
padding: 6rpx;
margin-left: 20rpx;
border-radius: 6rpx;
margin-top: -2rpx;
float: left;
}
.right .info{
overflow: hidden;
margin-top: 12rpx;
}
.alone .info{
overflow: hidden;
margin-top: 12rpx;
margin-bottom: 12rpx;
}
.right .info image{
width: 28rpx;
height: 28rpx;
float: left;
margin-top: 8rpx;
margin-left: 8rpx;
}
.right .info .time{
font-family: "Number";
font-size: 36rpx;
float: left;
}
.right .info .qk{
font-family: "Number";
font-size: 36rpx;
float: left;
margin-left: 20rpx;
}
.todayTime{
position: absolute;
right: 60rpx;
top: 40rpx;
font-size: 22rpx;
color: #B2B2B2;
}
.todayList .nodata{
width: 100%;
text-align: center;
}
.todayList .nodata image{
width: 440rpx;
height: 328rpx;
margin-top: 60rpx;
}
.sportTime{
padding-left: 30rpx;
color: #888888;
font-size: 28rpx;
height: 80rpx;
line-height: 80rpx;
}
.top{
background: #183247;
color: #748490;
width: 100%;
height: 76rpx;
line-height: 76rpx;
display: flex;
border-bottom: 1rpx solid #465B6C;
}
.top .type{
flex:1;
text-align: center;
font-size: 28rpx;
line-height: 88rpx;
color: #888888;
}
.top .active{
color: #FFFFFF;
font-weight: bold;
}
.top .type .name{
width: 100%;
text-align: center;
}
.select{
width: 30rpx;
height: 4rpx;
border-radius: 12rpx;
background: #FFFFFF;
margin: 0 auto;
margin-top: -14rpx;
}
.total{
overflow: hidden;
background: #183247;
height: 420rpx;
width: auto;
}
.totla-number{
font-family: "Number";
width: 100%;
color: #FFFFFF;
font-size: 100rpx;
text-align: center;
padding-top: 40rpx;
}
.totla-number .unit{
font-size: 22rpx;
color: #FFFFFF;
}
.viewToatl{
width: 100%;
height: 420rpx;
}
.total-type{
width: 84%;
display: flex;
margin: 0 auto;
margin-top: 50rpx;
}
.total-type .type-item{
flex: 1;
text-align: center;
color: #FFFFFF;
}
.type-item .num{
font-family: "Number";
font-size: 40rpx;
font-weight: bold;
}
.type-item .content{
font-size: 22rpx;
color: #FFFFFF;
margin-top: 8rpx;
}
.type-item .left{
text-align: left;
}
.type-item .contents{
text-align: content;
}
.type-item .right{
text-align: right;
}
.selTime{
position: absolute;
width: 90%;
margin: 0 auto;
font-size: 28rpx;
color: #888888;
left: 5%;
top: 20rpx;
}
.time text{
color: #B2B2B2;
margin-right: 40rpx;
font-size: 22rpx;
}
.sportType{
color: #353535;
font-size: 28rpx;
font-weight: bold;
float: left;
}
.more{
position: absolute;
font-size: 24rpx;
right: 50rpx;
bottom: 32rpx;
}
.more-img{
position: absolute;
width: 24rpx;
height: 24rpx;
top: 42rpx;
right: 30rpx;
}
.sport-time{
font-size: 28rpx;
color: rgba(0, 0, 0, 0.5);
width: 690rpx;
margin: 0 auto;
padding-top: 20rpx;
}
.all{
width: 690rpx;
margin: 0 auto;
font-size: 30rpx;
font-weight: bold;
margin-top: 40rpx;
color: rgba(0, 0, 0, 0.9);
}
\ No newline at end of file
var API = require("../../../utils/request.js");
var tool = require("../../../utils/util.js");
var handle = 0;
var sportType = 1;//1跳绳 2 仰卧起坐 3//踢键子
var sportData = 0;
var _this = this;
var updataId = 0;
var sportTime = 60;
var activityId = 0;
var submitFlag = true;
var timeHandle = 0; //定时器句柄
var startSkips = 0;//开始
Page({
data: {
array: ['倒计时1分钟', '倒计时2分钟', '倒计时3分钟'],
index:0,
num: 5,
play: false,
list: [],
flag: false, //数据统计
placeholder: '请输入跳绳个数',
startFlag: false,
delBtnWidth: 260,
startX: "",
inputVal: '',
countdown:60,
time:0,
showTime:'00:00',
is_start:true,
start:true,
end:false,
sourcesId:0, //当前活动id
startCountdown:0, //开始前倒计时
endCountdown:0, //结束前倒计时
skipJz:1, //背景音乐开关
music:'', //当前的背景音乐
isSz:true, //是否设置
},
onLoad: function (options) {
var that =this;
that.setData({
innerAudioContext: wx.createInnerAudioContext()
})
wx.setInnerAudioOption({
obeyMuteSwitch: false,
success: function (e) {
console.log(e)
console.log('play success')
},
fail: function (e) {
console.log(e)
console.log('play fail')
}
})
console.log('页面加载');
that.setData({
sourcesId:options.activityId
})
that.getBgMusic();
//that.getActivityDetail();
submitFlag = true;
console.log(options);
this.setType(options); //设置运动类型
activityId = options.activityId;
console.log('当前的活动id+++',that.data.sourcesId);
if(options.sportType === "1"){
that.setData({
isTs:true
})
}else{
that.setData({
isTs:false
})
}
wx.setNavigationBarTitle({
title: '跳绳'
})
that.setData({ startFlag: false });
// 背景音乐播放结束监听
wx.onBackgroundAudioStop(()=>{
console.log('背景音乐结束')
var that = this;
if(that.data.is_start){
setTimeout(function() {
that.palyVoice(that.data.music);
}, 200);
}
})
},
formatSeconds(value) {
let result = parseInt(value)
let h = Math.floor(result / 3600) < 10 ? Math.floor(result / 3600) : Math.floor(result / 3600);
let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
var time = m + ":" + s
return time;
},
// 获取当前的活动
// getActivityDetail() {
// var that = this;
// API.getData('/activity/getCur', {}, function (res) {
// console.log('当前活动的id',res);
// if (res.code == 200) {
// that.setData({
// sourcesId:res.data.id
// })
// }
// }, function () {
// });
// },
getNum(e) {
console.log(e.detail.value);
sportData = e.detail.value;
},
//开始
clickKs(){
this.amiata();
},
clickBc(){
var _this = this;
if(_this.data.time < 10){
wx.showToast({
title: '本次时间太短了,无法保存哦~',
icon: 'none',
duration: 1500//持续的时间
})
return false;
}
_this.setData({
is_start:false
});
if (sportType == 1) {
_this.palyVoice('https://ttxs01-10066525.cos.ap-shanghai.myqcloud.com/youplus/mp3/a_3.mp3');
}
_this.setData({ flag: true});
clearInterval(handle);
},
onReady: function () {
},
onShow: function () {
var that = this;
that.getBgMusic();
console.log(that.data.time);
//that.getActivityDetail();
if(that.data.flag == true && that.data.time > 0){
that.setData({
is_start:false
})
wx.stopBackgroundAudio();
}else if(that.data.flag == false && that.data.time > 0){
//this.palyVoice('http://cdn.xiaobentiyu.cn/video/syjzsp.m4v');
this.palyVoice(this.data.music);
}
wx.setKeepScreenOn({
keepScreenOn: true
})
},
onUnload: function () {
var that = this;
console.log("---onUnload-----");
clearTimeout(startSkips);//清楚定时任务
clearInterval(handle);
that.data.innerAudioContext.destroy();
setTimeout(function(){
that.setData({
is_start:false
})
wx.stopBackgroundAudio();
},200)
},
onHide: function () {
console.log("---onHide-----");
this.setData({
is_start:false
})
wx.stopBackgroundAudio();
//clearInterval(handle);
},
//播放本地音乐组件
palyLocal(url) {
var that = this;
this.data.innerAudioContext.autoplay = true;
this.data.innerAudioContext.src=url;
this.data.innerAudioContext.onPlay(() => {
console.log('开始播放')
})
this.data.innerAudioContext.onError((res) => {
console.log(res)
})
},
palyVoice(url) {
wx.playBackgroundAudio({
dataUrl: url,
success(e) { console.log(e); },
fail(e) { console.log(e); },
complete() { }
})
},
//设置运动类型
setType(options) {
console.log(options);
if (options.sportType == 1) {
sportType = options.sportType;
this.setData({ placeholder: '请输入跳绳个数' })
this.setData({ sportType: sportType });
}
},
// 初始动画
amiata() {
var _this = this;
_this.setData({
isSz:false,
start:false,
end:true,
startFlag: true,
is_start:false,
isTs:false
})
if(this.data.startCountdown == 1){
var num = this.data.num;
var num = 5;
_this.palyLocal('/images/ai/N5.mp3');
setTimeout(function () {
handle = setInterval(function () {
num = num - 1;
// console.log(num);
_this.setData({ num: num })
if(num ===4){
_this.palyLocal('/images/ai/N4.mp3');
_this.setData({
is_start:false
})
}else if(num ===3){
_this.palyLocal('/images/ai/N3.mp3');
_this.setData({
is_start:false
})
}else if(num ===2){
_this.palyLocal('/images/ai/N2.mp3');
_this.setData({
is_start:false
})
}else if(num ===1){
_this.palyLocal('/images/ai/N1.mp3');
_this.setData({
is_start:false
})
}else if (num === 0) {
if (sportType == 1) {
_this.setData({
isTs:true
})
} else{
_this.setData({
isTs:false
})
}
clearInterval(handle);
_this.setData({ num: '开始' });
_this.palyLocal('/images/ai/V_START.mp3')
startSkips = setTimeout(function () {
_this.setData({
startFlag: false,
is_start:true
});
_this.startTime();
}, 1200);
}
}, 1000)
}, 1000)
}else{
console.log('关闭开始前');
_this.setData({ num: '开始' });
_this.palyLocal('/images/ai/V_START.mp3')
setTimeout(function () {
_this.setData({
startFlag: false,
is_start:true
});
_this.startTime();
}, 1200);
}
},
// 提交运动记录
submits:tool.throttle(function(){
var that = this;
console.log('点击了保存');
wx.showLoading({
title: '保存中...',
mask:true
})
if (submitFlag) {
//submitFlag = false;
if (sportData) {
if (updataId) {
this.updataApi();
return null;
}
var subData = {
projectId: parseInt(sportType), //项目id 比如跳绳
sportValue: parseInt(sportData),//运动值
sourceType: 1, //1 活动,2课程
sourceId: that.data.sourcesId,//活动id
sportTime: that.data.time,//运动时长 单位为s
sportModel:23
}
if(!/^\d+$/.test(sportData)){
submitFlag = true;
sportData = 0;
this.setData({
inputVal: ''
})
wx.showToast({
title: '请输入正确的跳绳数',
icon: 'none',
duration: 1000
})
return false;
}
API.requestAll('/project/addReord', subData, (res) => {
submitFlag = true;
console.log("我是上传的数据",subData);
console.log(res);
if (res.code == 200) {
sportData = 0;
this.setData({ flag: false, play: false });
//this.getSportDataList();
var uid = res.data.id;
setTimeout(function(){
wx.hideLoading({
success: (res) => {
if(sportType == 1){
wx.redirectTo({
url: '../share/share?ordin=1&id=' + uid + '&showMedal=1&sportTime=' + that.data.showTime,
})
}else{
wx.switchTab({
url:'/pages/index/index'
//url:'../../skip/sportInfo/sportInfo?id=' + res.data.id,
})
}
},
})
},2000)
} else {
wx.hideLoading()
submitFlag = true;
sportData = 0;
this.setData({ inputVal: '' })
wx.showToast({ icon: 'none', title: res.message, duration: 2000 })
}
}, function () {
wx.hideLoading()
});
} else {
wx.hideLoading()
wx.showToast({ icon: 'none', title: '请记录运动数据', duration: 2000 })
}
}
},2000),
// 开始运动
startTime() {
this.setData({ time: '0' });
console.log(this.data.time)
var time = parseInt(this.data.time);
var _this = this;
_this.setData({ num: '', play: true });
startSkips = setTimeout(function(){
_this.palyVoice(_this.data.music);
},1000)
handle = setInterval(function () {
time = time + 1;
if (time < 10) {
_this.setData({ time: '0' + time })
} else {
_this.setData({ time: time })
}
var showTime = _this.formatSeconds(time);
_this.setData({ time: time,showTime:showTime});
console.log(time);
}, 1000)
},
//获取背景音乐列表
getBgMusic() {
var that = this;
wx.showLoading({
title: '加载中...',
})
API.getData('/config/getBgMusic', {}, function (res) {
var list = res.data;
API.getData('/config/getSkipConfig', {}, function (res) {
console.log('当前的音乐配置',res.data);
console.log('当前的音乐列表',list);
if(res.data == null){
that.setData({
startCountdown:1,
endCountdown:1,
skipJz:1,
music:list[0].musicUrl
})
}else{
if(res.data.skipJz == 1 && res.data.skipBackMusic != null){
for(var i = 0; i < list.length; i++){
if(list[i].id == res.data.skipBackMusic){
console.log(list[i].musicName);
that.setData({
music:list[i].musicUrl
})
}
}
}else if(res.data.skipJz == null && res.data.skipBackMusic != null){
for(var i = 0; i < list.length; i++){
if(list[i].id == res.data.skipBackMusic){
console.log(list[i].musicName);
that.setData({
music:list[i].musicUrl
})
}
}
}else if(res.data.skipJz == 1 && res.data.skipBackMusic == null){
that.setData({
music:list[0].musicUrl
})
}else if(res.data.skipJz == null && res.data.skipBackMusic == null){
that.setData({
music:list[0].musicUrl
})
}
else if(res.data.skipJz == 0){
console.log('当前背景音乐关闭');
that.setData({
music:''
})
}
if(res.data.startCountdown == 0){
that.setData({
startCountdown:0
})
}else{
that.setData({
startCountdown:1
})
}
if(res.data.endCountdown == 0){
that.setData({
endCountdown:0
})
}else{
that.setData({
endCountdown:1
})
}
if(res.data.skipJz == 0){
that.setData({
skipJz:0
})
}else{
that.setData({
skipJz:1
})
}
}
wx.hideLoading();
})
}, function () {
});
},
//设置
goEdit(){
wx.navigateTo({
url:'../skip-edit/skip-edit'
})
}
})
{
"usingComponents": {}
}
\ No newline at end of file
<view class="daka">
<view class="{{num==='开始'?'go mix':'go '}}" wx:if="{{num && startFlag}}">{{num}}</view>
<view wx:if="{{!startFlag}}" class="daka-wrap">
<view class="edit" bindtap="goEdit" wx:if="{{isSz && isTs}}">设置</view>
<view class="edit-no" wx:else>设置</view>
<view class="time">{{showTime}}</view>
<view class="btn" bindtap="clickKs" wx:if="{{start}}">
<image src="/images/skip/icon_ks.png"></image>
开始
</view>
<view class="btn" bindtap="clickBc" wx:if="{{end}}">
<image src="/images/skip/icon_bc.png"></image>
保存
</view>
<view class="mask" wx:if="{{flag}}"></view>
<view class="layer" wx:if="{{flag}}">
<view class="title">运动数据统计</view>
<view class="content">为确保运动数据更准确,请如实输入个数</view>
<view class="input-wrap">
<input placeholder="{{placeholder}}" type="number" bindinput="getNum" maxlength="4" value="{{inputVal}}"></input>
</view>
<view class="btn" hover-class="after-click-btn" bindtap="submits">确定</view>
</view>
</view>
</view>
\ No newline at end of file
.go {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: #FF9B4D;
line-height: 800rpx;
text-align: center;
font-size: 300rpx;
color: #fff;
}
.mix {
font-size: 200rpx;
}
page {
background: #FF9B4D;
}
.daka-wrap {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: #FFFFFF;
}
.time {
font-family: "Number";
font-size: 120rpx;
text-align: center;
margin-top: 300rpx;
color: #353535;
}
.btn-wrap {
height: 165rpx;
padding: 0 30rpx;
margin-top: 20px;
}
.btn-wrap .btn {
width: 170rpx;
height: 170rpx;
border: 3rpx solid #6f7179;
border-radius: 50%;
}
.btn-wrap .btn view {
width: 160rpx;
height: 160rpx;
margin: 5rpx auto;
background: #6f7179;
border-radius: 50%;
font-size: 32rpx;
}
.btn-right view {
background: #4f6d64 !important;
}
.btn-right {
border: 3rpx solid #4f6d64
}
.btn-left {
line-height: 160rpx;
text-align: center;
color: #fff;
}
.btn-right text {
display: block;
text-align: center;
position: relative;
top: 32rpx;
color: #45b876
}
.keep .btn {
margin: 0 auto;
}
.keep .btn view {
background: #6f7179 !important;
}
.keep .btn text {
color: #fff !important;
}
.list {
height: 300px;
position: fixed;
bottom: 0;
border-top: 1rpx solid #fff;
padding-top: 1rpx;
}
.list .item {
height: 133rpx;
line-height: 133rpx;
padding: 0 0rpx;
color: #fff;
border-bottom: 1rpx solid #fff;
position: relative;
padding-bottom: 1rpx;
}
.list .item .inner {
position: absolute;
top: 0;
}
.list .item .content {
width: 100%;
box-sizing: border-box;
padding: 0 30rpx;
z-index: 200;
background: #52535e
}
.list .item .del {
right: 0;
text-align: center;
width: 260rpx;
background: #ff0000;
}
.list .item .updata {
right: 130rpx;
text-align: center;
width: 130rpx;
background: #41cf7e;
}
.mask {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: #000;
opacity: 0.3;
z-index: 200;
}
.layer {
position: absolute;
width: 90%;
top: 400rpx;
left: 5%;
z-index: 300;
border-radius: 10rpx;
background: #fff;
}
.layer .title {
height: 90rpx;
line-height: 90rpx;
background: #FFFFFF;
color: #353535;
padding: 0 30rpx;
text-align: center;
border-radius: 10rpx 10rpx 0 0;
font-weight: bold;
}
.layer .content{
color: #888888;
font-size: 28rpx;
text-align: center;
}
.layer .input-wrap {
margin: 40rpx auto 40rpx auto;
height: 88rpx;
width: 90%;
border: 2rpx solid #F3F3F3;
border-radius: 50rpx;
}
.layer input {
width: 100%;
height: 88rpx;
color: #888888;
text-align: center;
}
.layer .btn {
width: 90%;
height: 88rpx;
line-height: 88rpx;
background: #FF9B4D;
margin: 10rpx auto 30rpx auto;
text-align: center;
color: #fff;
border-radius: 50rpx;
}
.count{
position: fixed;
z-index: 9;
width: 100%;
top: 50rpx;
}
.mode-sel{
font-size: 26rpx;
color: #353535;
margin:0 auto;
float: left;
position:absolute;
left:50%;
top:50%;
transform:translateX(-50%) translateY(-50%);
background: #F8F8F8;
border:2rpx solid #E8E8E8;
padding: 10rpx 28rpx 10rpx 38rpx;
border-radius:30rpx;
font-weight:bold;
}
.jt {
width: 32rpx;
height: 32rpx;
position: relative;
top: 6rpx;
}
.btn {
position: relative;
width: 178rpx;
height: 178rpx;
border-radius: 50%;
line-height: 220rpx;
background: #FF9B4D;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.06);
color: #fff;
text-align: center;
margin: 160rpx auto 0 auto;
}
.btn image{
position: absolute;
left: 68rpx;
top:32rpx;
width: 48rpx;
height: 48rpx;
}
.edit{
position: absolute;
right: 40rpx;
top: 26rpx;
height: 40rpx;
font-size: 28rpx;
color: #353535;
}
.edit-no{
position: absolute;
right: 40rpx;
top: 26rpx;
height: 40rpx;
font-size: 28rpx;
color: #888888;
}
.edit image{
width: 40rpx;
height: 40rpx;
}
\ No newline at end of file
// pages/skip/edit/edit.js
var API = require("../../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
beforeChecked:true,
afterChecked:true,
backgroundChecked:true,
backgroundCheckedCount:true,
music:'',
musicId:1
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
global.backgroundMusic = 0;
console.log('页面加载');
var that = this;
that.getSkipConfig();
that.getBgMusic();
},
//获取当前的设置
getSkipConfig() {
var that = this;
API.getData('/config/getSkipConfig', {}, function (res) {
console.log('当前的设置',res);
if(res.data == null){
return false;
}
if(res.data.startCountdown == 0){
that.setData({
beforeChecked:false
})
}else{
that.setData({
beforeChecked:true
})
}
if(res.data.endCountdown == 0){
that.setData({
afterChecked:false
})
}else{
that.setData({
afterChecked:true
})
}
if(res.data.skipJz == 0){
that.setData({
backgroundChecked:false
})
}else{
that.setData({
backgroundChecked:true
})
}
if(res.data.audioCountNum == 0){
that.setData({
backgroundCheckedCount:false
})
}else{
that.setData({
backgroundCheckedCount:true
})
}
}, function () {
});
},
//获取背景音乐列表
getBgMusic() {
var that = this;
wx.showLoading({
title: '加载中...',
})
API.getData('/config/getBgMusic', {}, function (res) {
var list = res.data;
API.getData('/config/getSkipConfig', {}, function (res) {
console.log('当前的音乐配置',res.data);
console.log('当前的音乐列表',list);
if(res.data == null){
that.setData({
startCountdown:1,
endCountdown:1,
skipJz:1,
music:list[0].musicName,
musicId:1
})
}else{
if(res.data.skipJz == 1 && res.data.skipBackMusic != null){
for(var i = 0; i < list.length; i++){
if(list[i].id == res.data.skipBackMusic){
console.log(list[i].musicName);
that.setData({
musicId:list[i].id,
music:list[i].musicName
})
}
}
}else if(res.data.skipJz == null && res.data.skipBackMusic != null){
for(var i = 0; i < list.length; i++){
if(list[i].id == res.data.skipBackMusic){
console.log(list[i].musicName);
that.setData({
musicId:list[i].id,
music:list[i].musicName
})
}
}
}else if(res.data.skipJz == 1 && res.data.skipBackMusic == null){
that.setData({
musicId:list[0].id,
music:list[0].musicName
})
}else if(res.data.skipJz == null && res.data.skipBackMusic == null){
that.setData({
musicId:list[0].id,
music:list[0].musicName
})
}else if(res.data.skipJz == 0 && res.data.skipBackMusic == null){
that.setData({
musicId:list[0].id,
music:list[0].musicName
})
}else if(res.data.skipJz == 0 && res.data.skipBackMusic != null){
for(var i = 0; i < list.length; i++){
if(list[i].id == res.data.skipBackMusic){
console.log(list[i].musicName);
that.setData({
musicId:list[i].id,
music:list[i].musicName
})
}
}
}
if(res.data.startCountdown == 0){
that.setData({
startCountdown:0
})
}else{
that.setData({
startCountdown:1
})
}
if(res.data.endCountdown == 0){
that.setData({
endCountdown:0
})
}else{
that.setData({
endCountdown:1
})
}
if(res.data.skipJz == 0){
that.setData({
skipJz:0
})
}else{
that.setData({
skipJz:1
})
}
}
wx.hideLoading();
})
}, function () {
});
},
//开始前
beforeChange: function(e) {
console.log('开始前-----', e.detail.value);
var num = 0;
if(e.detail.value == false){
num = 0
}else{
num = 1
}
API.requestAll('/config/setSkipConfig', {
startCountdown:num
}, function (res) {
console.log('设置背景音乐',res);
}, function () {
});
},
//开始后
afterChange: function(e) {
console.log('开始后-----', e.detail.value);
var num = 0;
if(e.detail.value == false){
num = 0
}else{
num = 1
}
API.requestAll('/config/setSkipConfig', {
endCountdown:num
}, function (res) {
console.log('设置背景音乐',res);
}, function () {
});
},
//背景音乐
backgroundChange: function(e){
var that = this;
console.log('背景音乐-----', e.detail.value);
that.setData({
backgroundChecked:e.detail.value
})
var num = 0;
if(e.detail.value == false){
num = 0
}else{
num = 1
}
API.requestAll('/config/setSkipConfig', {
skipJz:num
}, function (res) {
console.log('设置背景音乐',res);
}, function () {
});
},
//选择背景音乐
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
index: e.detail.value
})
var num = Number(e.detail.value) + 1;
console.log(num);
API.requestAll('/config/setSkipConfig', {
skipBackMusic:num
}, function (res) {
console.log('设置背景音乐',res);
}, function () {
});
},
//设置音乐
goSet(e){
console.log(e.currentTarget.dataset.id);
wx.navigateTo({
url: '../musicList/musicList?id=' + e.currentTarget.dataset.id,
})
},
//设置播报次数开关
backgroundCheckedCount(e){
console.log('播报次数开关',e.detail.value)
var num = 0;
if(e.detail.value == false){
num = 0
}else{
num = 1
}
API.requestAll('/config/setSkipConfig', {
audioCountNum:num
}, function (res) {
console.log('播报次数开关',res);
}, function () {
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var that = this;
that.getBgMusic();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarBackgroundColor": "#F5F5F5",
"navigationBarTitleText": "跳绳设置"
}
\ No newline at end of file
<view class="item">
<view class="li">
<view class="name">开始前倒计时</view>
<switch class="switch" checked="{{beforeChecked}}" bindchange="beforeChange"/>
</view>
<view class="li">
<view class="name">结束前倒计时<text>(仅支持计时跳)</text></view>
<switch class="switch" checked="{{afterChecked}}" bindchange="afterChange"/>
</view>
</view>
<view class="item">
<view class="li">
<view class="name">背景音乐</view>
<switch class="switch" checked="{{backgroundChecked}}" bindchange="backgroundChange"/>
</view>
<view class="li" wx:if="{{backgroundChecked == true}}" data-id="{{musicId}}" bindtap="goSet">
<view class="picker">
{{music}}
</view>
<image class="next" src="/images/sport/next.png"></image>
</view>
<view class="li" wx:else>
<view class="picker no-next">
{{music}}
</view>
<image class="next" src="/images/sport/no-next.png"></image>
</view>
</view>
<view class="item">
<view class="li">
<view class="name">播报次数开关</view>
<switch class="switch" checked="{{backgroundCheckedCount}}" bindchange="backgroundCheckedCount"/>
</view>
</view>
<view class="edit-content">
BPM(Beats Per Minute 每一分钟节拍数量)跳在音乐的拍子上,有助于协调身体,降低疲劳
</view>
\ No newline at end of file
page{
background: #F5F5F5;
}
.item{
width: 94%;
margin: 0 auto;
margin-top: 20rpx;
background: #FFFFFF;
border-radius: 24rpx;
}
.item .li{
position: relative;
width: 90%;
height: 100rpx;
margin: 0 auto;
border-bottom: 1rpx solid #EEEEEE;
}
.item .li .name{
font-size: 32rpx;
font-weight: bold;
color: #353535;
line-height: 100rpx;
}
.item .li text{
font-size: 26rpx;
font-weight: 400;
color: #B2B2B2;
line-height: 100rpx;
margin-left: 10rpx;
}
.item .li:last-child{
border-bottom: 0rpx;
}
.item .li .switch{
position: absolute;
right: 0rpx;
top: 30rpx;
zoom: 0.8;
}
.item .li .picker{
color: #353535;
font-size: 28rpx;
width: 100%;
height: 100rpx;
line-height: 100rpx;
}
.item .li .no-next{
color: #D8D8D8;
font-size: 28rpx;
width: 100%;
height: 100rpx;
line-height: 100rpx;
}
.next{
position: absolute;
width: 32rpx;
height: 32rpx;
right: 10rpx;
top:34rpx;
}
/*科室排班表 */
.table{
display: inline-flex;
flex-direction: column;
border: 1rpx solid rgba(218, 217, 217, 1);
border-bottom: 0;
}
.scrollClass {
display: flex;
width: 100%;
white-space: nowrap;
margin-top: 23px;
height: 100%;
background-color: white;
}
.table_header {
display: inline-flex;
}
.th {
display: flex;
flex-direction: column;
width: 200rpx;
height: 90rpx;
background: rgba(241, 252, 255, 1);
border-right: 1rpx solid rgba(218, 217, 217, 1);
border-bottom: 1rpx solid rgba(218, 217, 217, 1);
justify-content: center;
align-items: center;
overflow-x: auto;
}
.cell_label{
font-size: 26rpx;
color: rgba(74, 74, 74, 1);
}
.cell_date_label{
font-size: 20rpx;
color: rgba(74, 74, 74, 1);
}
.table_main {
display: inline-flex;
flex-direction: row;
}
.right-item{
display: flex;
flex-direction: row;
}
.td {
display: flex;
flex-direction: column;
width: 200rpx;
/* height: 90rpx; */
background: white;
justify-content: center;
align-items: center;
border: 1rpx solid rgba(218, 217, 217, 1);
border-top: 0;
border-left:0;
}
.table_Text_class {
display: flex;
justify-content: center;
align-items: center;
height: 60rpx;
font-size: 30rpx;
color: rgba(55, 134, 244, 1);
width: 100%;
word-break: normal;
border-bottom: 1rpx solid rgba(218, 217, 217, 1);
}
.table_Text_last_class{
display: flex;
justify-content: center;
align-items: center;
height: 60rpx;
font-size: 30rpx;
color: rgba(55, 134, 244, 1);
width: 100%;
word-break: normal;
}
.edit-content{
width: 94%;
margin: 0 auto;
font-size: 24rpx;
color: #888888;
margin-top: 20rpx;
}
\ No newline at end of file
// pages/skip/todayData/tadayData.js
var API = require("../../../utils/request.js");
var timeAPI = require("../../../utils/time.js");
var tool = require("../../../utils/util.js");
var timeUtils = require("../../../utils/time.js");
var page = 1;
var size = 30;
var today = "";
var weekDay = [];
Page({
data: {
level: 4,
num:1,
detPage:1,
toView:'',
projectId:1,
startDay:'',
endDay:'',
nowday:0,
week:[],
list:[],
modeList : ["倒计时30秒","自由跳", '倒计时1分钟', '倒计时2分钟', "倒计时3分钟", "倒计时120秒", "倒计时150秒", "倒计时180秒", "倒计时210秒", "倒计时240秒","倒计时270秒", "倒计时300秒", "倒计次300次", "倒计次500次",
"倒计次1000次", "倒计次1500次", "倒计次2000次", "倒计次2500次", "倒计次3000次", "倒计次3500次",
"倒计次4000次", "倒计次4500次", "倒计次5000次"],
dayInfo:{},
maxSkipNum:0,
time:'',
rope:true,
sportType:'',
maxSportTime:0,
sportTimeList:[],
currentDay:'', //当前选中的开始时间
totalTime:'', //当前选中的总运动时间
totalCalorie:'', //当前选中的总卡路里数量
totalNumber:'', //当前选中的总个数
joinDayNum:'', //累计天数
sportRecordList:[], //记录列表
viewData:false,
viewTotal:true,
totalList:[],
nowTime:'',
width:130,
hasDevice:true,
projectList:{1:'跳绳',2:'仰卧起坐',3:'踢毽子',4:'步数',5:'坐位体前屈',6:'50米跑',11:'开合跳',13:'深蹲',14:'俯卧撑',15:'高抬腿',16:'原地臀踢',17:'原地跑'},
type:1,
startDayShow:0,
nowMonth:0
},
onLoad: function (options) {
console.log(options);
var that = this;
page = 1;
if(options.type == 1){
that.setData({
level:4,
viewTotal:true,
viewData:false,
sportType:'',
},()=>{
that.getTotalData();
that.getRecordTotal(that.data.detPage)
})
}else{
that.setData({
level:1,
viewTotal:false,
viewData:true,
sportType:'day',
},()=>{
that.getDataList(page,that.data.sportType);
})
}
},
onReady: function () {
},
onShow: function () {
this.setData({
nowday:0
})
},
//获取运动日周月记录
getDataList(page,dataType){
var that = this;
API.getData('/es/student/report/getDataList', {
dateType:dataType,
page:page,
size:size
}, (res) => {
if(dataType == 'total'){
return false;
}
console.log('我是总运动记录',res);
for(var j = 0; j < res.data.length; j++){
res.data[j].select = 0;
}
that.setData({
toView:'',
detPage:1
})
if(dataType == 'day'){
console.log('进入日')
for(var j = 0; j < res.data.length; j++){
res.data[j].day = res.data[j].recordDate.substr(5,10).replace('-','/');
res.data[j].select = 0;
that.data.sportTimeList.unshift(res.data[j])
}
var currentDay = that.data.sportTimeList[29].recordDate;
console.log('当前选中的日期',currentDay);
for(var k = 0;k < that.data.sportTimeList.length; k++){
if(that.data.sportTimeList[k].recordDate == currentDay){
console.log('当前日期对应的date',that.data.sportTimeList[k]);
that.setData({
totalTime:parseInt(that.data.sportTimeList[k].sportTime / 60),
totalCalorie:that.data.sportTimeList[k].calorie,
totalNumber:that.data.sportTimeList[k].count
})
}
}
that.setData({
startDayShow:currentDay.slice(5,10),
startDay:currentDay,
endDay:currentDay,
currentDay:currentDay,
})
//进入按日查询
that.getRecord(that.data.currentDay,that.data.currentDay)
}
if(dataType == 'week'){
console.log('进入周');
for(var j = 0; j < res.data.length; j++){
res.data[j].day = res.data[j].startDate.substr(5,10).replace('-','/') + '-' + res.data[j].endData.substr(5,10).replace('-','/');
res.data[j].select = 0;
that.data.sportTimeList.unshift(res.data[j])
}
that.data.sportTimeList[29].select = 1;
var currentDay = that.data.sportTimeList[29].recordDate;
console.log('当前选中的日期',currentDay);
for(var k = 0;k < that.data.sportTimeList.length; k++){
if(that.data.sportTimeList[k].recordDate == currentDay){
console.log('当前日期对应的date',that.data.sportTimeList[k]);
that.setData({
nowTime:that.data.sportTimeList[k].startDate.substr(5,10).replace('-','/') + '-' + that.data.sportTimeList[k].endData.substr(5,10).replace('-','/'),
startDay:that.data.sportTimeList[k].startDate,
endDay:that.data.sportTimeList[k].endData,
totalTime:parseInt(that.data.sportTimeList[k].sportTime / 60),
totalCalorie:that.data.sportTimeList[k].calorie,
totalNumber:that.data.sportTimeList[k].count,
joinDayNum:that.data.sportTimeList[k].joinDayNum
})
}
}
that.setData({
currentDay:currentDay,
detPage:1
})
//进入按周查询
that.getRecord(that.data.startDay,that.data.endDay)
}
if(dataType == 'month'){
console.log('进入月');
for(var j = 0; j < res.data.length; j++){
res.data[j].day = res.data[j].recordDate;
res.data[j].select = 0;
that.data.sportTimeList.unshift(res.data[j])
}
that.data.sportTimeList[29].select = 1;
var currentDay = that.data.sportTimeList[29].recordDate;
console.log('当前选中的日期',currentDay);
for(var k = 0;k < that.data.sportTimeList.length; k++){
if(that.data.sportTimeList[k].recordDate == currentDay){
console.log('当前日期对应的date',that.data.sportTimeList[k]);
that.setData({
nowTime:that.data.sportTimeList[k].startDate.substr(5,10).replace('-','/') + '-' + that.data.sportTimeList[k].endData.substr(5,10).replace('-','/'),
startDay:that.data.sportTimeList[k].startDate,
endDay:that.data.sportTimeList[k].endData,
totalTime:parseInt(that.data.sportTimeList[k].sportTime / 60),
totalCalorie:that.data.sportTimeList[k].calorie,
totalNumber:that.data.sportTimeList[k].count,
joinDayNum:that.data.sportTimeList[k].joinDayNum,
})
}
}
that.setData({
nowMonth:currentDay.slice(5,7),
currentDay:currentDay,
detPage:1
})
//进入按月查询
that.getRecord(that.data.sportTimeList[29].startDate,that.data.sportTimeList[29].endData)
}
// that.setData({
// sportTimeList:that.data.sportTimeList,
// toView:'list29'
// })
var timeList = [];
for(var i = 0; i < that.data.sportTimeList.length; i++){
timeList.push(that.data.sportTimeList[i].sportTime);
}
for(var m = 0; m < that.data.sportTimeList.length;m++){
that.data.sportTimeList[m].nowYear = that.data.sportTimeList[m].day.slice(0,4);
that.data.sportTimeList[m].nowMonth = that.data.sportTimeList[m].day.slice(5,7);
}
console.log('我是总运动记录2',that.data.sportTimeList);
that.data.sportTimeList[29].select = 1;
that.setData({
maxSportTime:Math.max(...timeList),
sportTimeList:that.data.sportTimeList,
toView:'list29'
})
}, function () {
wx.hideLoading()
});
},
//获取运动记录汇总
getTotalData(){
var that = this;
API.getData('/es/student/report/getTotalData', {
}, (res) => {
that.setData({
totalTime:parseInt(res.data.sportTime / 60),
totalCalorie:res.data.calorie,
totalNumber:res.data.count,
joinDayNum:res.data.joinDayNum,
})
console.log('我是运动汇总的数据',res)
}, function () {
wx.hideLoading()
});
},
//获取当前选中的运动记录
getRecord(startDate,endDate){
var that = this;
API.getData('/project/record/day/project', {
// page:page,
// size:size,
startDate:startDate,
endDate:endDate
}, (res) => {
console.log('我是当前选中的数据',res);
that.setData({
//totalList:that.data.totalList.concat(res.data),
totalList:res.data
})
console.log('翻页合并后的数据',that.data.totalList);
var arr = []; //存放新数组
for (var i = 0; i < that.data.totalList.length; i++) {
//读取每条数据的日期
var recordDate = that.data.totalList[i].recordDate;
//当日期相同,只要传这个
var valDetailList = {
"id": that.data.totalList[i].id,
"count": that.data.totalList[i].count,
"projectId": that.data.totalList[i].projectId,
"isDevData":that.data.totalList[i].isDevData,
"sportValue": that.data.totalList[i].sportValue,
"sportValueType": that.data.totalList[i].sportValueType,
"recordDate":that.data.totalList[i].recordDate,
"createTime":that.data.totalList[i].createTime,
"classId":that.data.totalList[i].classId,
"sportTime":timeUtils.forTimes(that.data.totalList[i].sportTime),
"calorie":that.data.totalList[i].calorie,
"speed":that.data.totalList[i].speed,
"sportValueTypeName":that.data.totalList[i].sportValueTypeName,
"listIcon":that.data.totalList[i].listIcon
}
//当日期没有相同的,就新建一个Item
var valItem = {
"recordDate": '',
"detailList": []
}
valItem.recordDate = recordDate;
valItem.detailList.push(valDetailList);
//第0个不需要比较
if (i == 0) {
arr.push(valItem);
}
//第1个就要开始找新数组arr相同的日期
else{
var index = -1;
for(var k =0;k<arr.length;k++){
if(recordDate == arr[k].recordDate){
index = k;
break;
}
}
if(index === -1){
arr.push(valItem);
}else{
arr[k].detailList.push(valDetailList);
}
}
}
console.log('我是合并后的数组',arr);
that.setData({
sportRecordList:arr
})
}, function () {
wx.hideLoading()
});
},
//获取汇总的运动记录
getRecordTotal(page){
var that = this;
API.getData('/project/record/day/project', {
// page:page,
// size:size,
}, (res) => {
console.log('我是当前选中的数据',res);
that.setData({
//totalList:that.data.totalList.concat(res.data),
totalList:res.data
})
console.log('翻页合并后的数据',that.data.totalList);
var arr = []; //存放新数组
for (var i = 0; i < that.data.totalList.length; i++) {
//读取每条数据的日期
var recordDate = that.data.totalList[i].recordDate;
//当日期相同,只要传这个
var valDetailList = {
"id": that.data.totalList[i].id,
"count": that.data.totalList[i].count,
"projectId": that.data.totalList[i].projectId,
"isDevData":that.data.totalList[i].isDevData,
"sportValue": that.data.totalList[i].sportValue,
"sportValueType": that.data.totalList[i].sportValueType,
"recordDate":that.data.totalList[i].recordDate,
"createTime":that.data.totalList[i].createTime,
"classId":that.data.totalList[i].classId,
"sportTime":timeUtils.forTimes(that.data.totalList[i].sportTime),
"calorie":that.data.totalList[i].calorie,
"speed":that.data.totalList[i].speed,
"sportValueTypeName":that.data.totalList[i].sportValueTypeName,
"listIcon":that.data.totalList[i].listIcon
}
//当日期没有相同的,就新建一个Item
var valItem = {
"recordDate": '',
"detailList": []
}
valItem.recordDate = recordDate;
valItem.detailList.push(valDetailList);
//第0个不需要比较
if (i == 0) {
arr.push(valItem);
}
//第1个就要开始找新数组arr相同的日期
else{
var index = -1;
for(var k =0;k<arr.length;k++){
if(recordDate == arr[k].recordDate){
index = k;
break;
}
}
if(index === -1){
arr.push(valItem);
}else{
arr[k].detailList.push(valDetailList);
}
}
}
console.log('我是合并后的数组',arr);
that.setData({
sportRecordList:arr
})
}, function () {
wx.hideLoading()
});
},
//选中日期
selectDay(e){
var that = this;
//每次清空数组
that.setData({
totalList:[],
sportRecordList:[],
detPage:1
})
for(var i = 0; i < that.data.sportTimeList.length; i++){
that.data.sportTimeList[i].select = 0
}
console.log(e.currentTarget.dataset.day);
that.setData({
nowMonth:e.currentTarget.dataset.day.slice(5,7),
})
for(var j = 0;j < that.data.sportTimeList.length; j++){
if(that.data.sportTimeList[j].recordDate == e.currentTarget.dataset.day){
console.log('当前日期对应的date',that.data.sportTimeList[j]);
that.setData({
totalTime:parseInt(that.data.sportTimeList[j].sportTime / 60), //timeUtils.formatSeconds(that.data.sportTimeList[j].sportTime),
totalCalorie:that.data.sportTimeList[j].calorie,
totalNumber:that.data.sportTimeList[j].count,
joinDayNum:that.data.sportTimeList[j].joinDayNum
})
}
}
console.log(e.currentTarget.dataset.idx);
var idx = e.currentTarget.dataset.idx;
that.data.sportTimeList[idx].select = 1;
that.setData({
sportTimeList:that.data.sportTimeList
})
if(that.data.sportType == 'day'){
that.setData({
startDayShow:e.currentTarget.dataset.day.slice(5,10),
startDay:e.currentTarget.dataset.day,
endDay:e.currentTarget.dataset.day
})
that.getRecord(e.currentTarget.dataset.day,e.currentTarget.dataset.day)
}else if(that.data.sportType == 'week'){
console.log('当前周的日期',e.currentTarget.dataset.info);
that.setData({
nowTime:e.currentTarget.dataset.info.startDate.substr(5,10).replace('-','/') + '-' + e.currentTarget.dataset.info.endData.substr(5,10).replace('-','/'),
startDay:e.currentTarget.dataset.info.startDate,
endDay:e.currentTarget.dataset.info.endData
})
that.getRecord(e.currentTarget.dataset.info.startDate,e.currentTarget.dataset.info.endData)
}else if(that.data.sportType == 'month'){
console.log('当前月的日期',e.currentTarget.dataset.info);
that.setData({
nowTime:e.currentTarget.dataset.info.startDate.substr(5,10).replace('-','/') + '-' + e.currentTarget.dataset.info.endData.substr(5,10).replace('-','/'),
startDay:e.currentTarget.dataset.info.startDate,
endDay:e.currentTarget.dataset.info.endData
})
that.getRecord(e.currentTarget.dataset.info.startDate,e.currentTarget.dataset.info.endData)
}
},
//选中类型
selectLevel(e) {
var that = this;
that.setData({
totalList:[],
detPage:1
})
if(e.currentTarget.dataset.level){
that.setData({
width:160
})
}
if(e.currentTarget.dataset.level == 'total'){
that.setData({
viewData:false,
viewTotal:true
})
page = 0;
console.log(e.currentTarget.dataset.level);
that.setData({
sportType:e.currentTarget.dataset.level,
num:0,
sportTimeList:[],
sportRecordList:[],
level: e.currentTarget.dataset.lv,
});
that.getTotalData();
//进入按日查询
that.getRecordTotal(that.data.detPage)
return false;
}else{
that.setData({
viewData:true,
viewTotal:false
})
page = 0;
console.log(e.currentTarget.dataset.level);
that.setData({
sportType:e.currentTarget.dataset.level,
num:0,
sportTimeList:[],
sportRecordList:[],
level: e.currentTarget.dataset.lv,
});
that.upper();
}
},
touchStart: function (e) {
if (e.touches.length == 1) {
this.setData({
startX: e.touches[0].clientX
});
}
},
touchMove: function (e) {
var that = this;
if (e.touches.length == 1) {
var moveX = e.touches[0].clientX;
var diffX = this.data.startX - moveX;
if (diffX < 50) {
// that.lastWeek();
// console.log('向左滑动');
} else if (diffX > 0) {
// that.nextWeek();
// console.log('向右滑动');
}
}
},
upper:tool.throttle(function(){
var that = this;
for(var i = 0; i < that.data.sportTimeList.length; i++){
that.data.sportTimeList[i].select = 0
}
console.log('触发页码数+1');
that.setData({
num:that.data.num + 1,
})
that.getDataList(that.data.num,that.data.sportType);
},200),
//向左滑动
// lastWeek:tool.throttle(function(){
// var that = this;
// page = page + 1;
// console.log(page);
// console.log(that.data.sportType);
// that.getDataList(page,that.data.sportType);
// }),
onReachBottom: function () {
// var that = this;
// console.log('触发上拉操作');
// that.data.detPage = that.data.detPage + 1;
// console.log('当前的上拉页码数',that.data.detPage);
// if(that.data.sportType == 'total'){
// that.getRecordTotal(that.data.detPage);
// }else{
// that.getRecord(that.data.detPage,that.data.startDay,that.data.endDay);
// }
},
//查看详情
viewInfo(e){
console.log(e.currentTarget.dataset.info);
var info = e.currentTarget.dataset.info;
if(info.projectId == 1 && info.isDevData == 1){
wx.navigateTo({
url: '../../skip/share/share?id=' + info.id,
})
}else if(info.projectId == 1 && info.isDevData == 0){
wx.navigateTo({
url: '../../skip/share/share?ordin=1&id=' + info.id,
})
}else if(info.projectId != 1){
wx.navigateTo({
url:'../../skip/sportInfo/sportInfo?id=' + info.id,
})
}
},
//智能跳绳购买
buy(){
tool.goBuy();
},
//查看详情
checkInfo(e){
var that = this;
var projectId = e.currentTarget.dataset.info.projectId;
var sportValueTypeName = e.currentTarget.dataset.info.sportValueTypeName;
console.log('当前日期',that.data.startDay,that.data.endDay)
if(that.data.level == 4){
wx.navigateTo({
url: '../myData/myData?projectId=' + projectId
})
}else{
wx.navigateTo({
url: '../myData/myData?projectId=' + projectId + '&startDay=' + that.data.startDay + '&endDay=' + that.data.endDay
})
}
// if (projectId == 1) {
// wx.navigateTo({
// url: '../../../packageA/skip/todayData/todayData?projectId=' + projectId,
// })
// } else if (projectId == 2) {
// wx.navigateTo({
// url: '../../../packageA/skip/sitTodayData/sitTodayData?projectId=' + projectId,
// })
// } else if (projectId == 3) {
// wx.navigateTo({
// url: '../../../packageA/skip/kickTodayData/kickTodayData?projectId=' + projectId,
// })
// } else if (projectId == 4) {
// if (that.data.hasDevice == true) {
// wx.navigateTo({
// url: '../../../packageA/skip/walkTodayData/walkTodayData?projectId=' + projectId,
// })
// } else {
// wx.navigateTo({
// url: '../../../packageB/setting/bindDev/bindDev'
// })
// }
// } else if (projectId > 4) {
// wx.navigateTo({
// url: '../../../packageA/skip/publicTodayData/publicTodayData?projectId=' + projectId + '&unit=' + sportValueTypeName + '&projectName=' + that.data.projectList[projectId],
// })
// }
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTitleText": "运动记录"
}
\ No newline at end of file
<view>
<view class="top">
<view class="top-li">
<view class="type {{level == 1?'active':''}}" bindtap="selectLevel" data-lv="1" data-level="day">
<view class="name">日</view>
</view>
<view class="type {{level == 2?'active':''}}" bindtap="selectLevel" data-lv="2" data-level="week">
<view class="name">周</view>
</view>
<view class="type {{level == 3?'active':''}}" bindtap="selectLevel" data-lv="3" data-level="month">
<view class="name">月</view>
</view>
<view class="type {{level == 4?'active':''}}" bindtap="selectLevel" data-lv="4" data-level="total">
<view class="name">总</view>
</view>
</view>
</view>
<view class="scroll_box">
<scroll-view scroll-x scroll-into-view="{{toView}}" bindscrolltoupper="upper" wx:if="{{viewData}}">
<view class="item_list" style="width:{{width}}rpx" wx:for="{{sportTimeList}}" wx:for-index='idx' wx:for-item="items" bindtap="selectDay" data-info="{{items}}" data-idx="{{idx}}" data-day="{{items.recordDate}}" id="list{{idx}}">
<view class="{{items.select == 1?'item-set item baf':'item baf'}}">
<view wx:if="{{level == 3}}">
<view wx:if="{{items.nowMonth == 01}}">
{{items.nowYear}}年{{items.nowMonth}}月
</view>
<view wx:else>
{{items.nowMonth}}月
</view>
</view>
<view wx:else>
{{items.day}}
</view>
</view>
<view class="data">
<view class="{{items.select == 1?'line sel-line':'line'}}"></view>
<view class="sanjiao" wx:if="{{items.select == 1}}"></view>
<view class="item">
<view class="chart" wx:if="{{items.sportTime}}" >
<view class="{{items.select == 1?'chart-set ':'aa'}}" style="height:{{items.sportTime/maxSportTime*300}}rpx;"></view>
</view>
<!-- <view class="val" wx:if="{{items.sportTime && items.select}}">{{dayInfo.sportValue}}个</view> -->
</view>
</view>
</view>
</scroll-view>
<view class="total" wx:if="{{viewTotal}}">
<view class="totla-number">
<view>{{totalTime}}</view>
<view class="unit">分钟</view>
</view>
<view class="total-type">
<view class="type-item">
<view class="num left">{{joinDayNum || 0}}</view>
<view class="content left">累计(天)</view>
</view>
<view class="type-item">
<view class="num contents">{{totalNumber || 0}}</view>
<view class="content contents">完成(次)</view>
</view>
<view class="type-item">
<view class="num right">{{totalCalorie || 0}}</view>
<view class="content right">消耗(千卡)</view>
</view>
</view>
</view>
</view>
<view class="card" wx:if="{{sportType == 'day'}}">
<view class="selTime">{{startDayShow}},运动数据</view>
<view class="data-wrap pd80">
<view class="item">
<view class="val">{{totalTime || 0}}</view>
<view class="key">用时(分)</view>
</view>
<view class="item">
<view class="val">{{totalNumber || 0}}</view>
<view class="key">完成(次)</view>
</view>
<view class="item">
<view class="val">{{totalCalorie || 0}}</view>
<view class="key">消耗(千卡)</view>
</view>
</view>
</view>
<view class="card" wx:if="{{sportType == 'week'}}">
<view class="selTime">{{nowTime}},运动数据</view>
<view class="data-wrap">
<view class="item item-time">
<view class="val">{{totalTime || 0}}</view>
<view class="key">分钟</view>
</view>
</view>
<view class="data-wrap">
<view class="item">
<view class="val">{{joinDayNum || 0}}</view>
<view class="key">累计(天)</view>
</view>
<view class="item">
<view class="val">{{totalNumber || 0}}</view>
<view class="key">完成(次)</view>
</view>
<view class="item">
<view class="val">{{totalCalorie || 0}}</view>
<view class="key">消耗(千卡)</view>
</view>
</view>
</view>
<view class="card" wx:if="{{sportType == 'month'}}">
<view class="selTime">{{nowMonth}}月,运动数据</view>
<view class="data-wrap">
<view class="item item-time">
<view class="val">{{totalTime || 0}}</view>
<view class="key">分钟</view>
</view>
</view>
<view class="data-wrap">
<view class="item">
<view class="val">{{joinDayNum || 0}}</view>
<view class="key">累计(天)</view>
</view>
<view class="item">
<view class="val">{{totalNumber || 0}}</view>
<view class="key">完成(次)</view>
</view>
<view class="item">
<view class="val">{{totalCalorie || 0}}</view>
<view class="key">消耗(千卡)</view>
</view>
</view>
</view>
<view>
<view class="todayList">
<view class="nodata" wx:if="{{sportRecordList.length == 0}}">
<image src="https://ttxs01-10066525.file.myqcloud.com/sport/miniapp/mobile/skip/nodata.png"></image>
</view>
<view class="selTimeText" wx:else>
<view wx:if="{{sportType == 'day'}}">{{startDayShow}},运动记录</view>
<view wx:elif="{{sportType == 'week'}}">{{nowTime}},运动记录</view>
<view wx:elif="{{sportType == 'month'}}">{{nowMonth}}月,运动记录</view>
<view wx:else>总运动记录</view>
</view>
<view wx:for="{{sportRecordList}}" data-projectid="{{item.projectId}}" data-info="{{item.detailList}}" data-isdevdata="{{item.isDevData}}" data-id="{{item.id}}">
<view class="li" hover-class="after-click-content" wx:for="{{item.detailList}}" wx:for-item="items" data-info="{{items}}" bindtap="checkInfo">
<view class="more">查看详情</view>
<image class="more-img" src="/images/home/next.png"></image>
<!-- <view class="todayTime">{{items.createTime}}</view> -->
<view class="li">
<view class="left">
<image src="{{items.listIcon}}"></image>
</view>
<view class="right">
<view class="num">
<text class="sportType" wx:if="{{items.projectId == 1}}">跳绳</text>
<text class="sportType" wx:if="{{items.projectId == 2}}">仰卧起坐</text>
<text class="sportType" wx:if="{{items.projectId == 3}}">踢毽子</text>
<text class="sportType" wx:if="{{items.projectId == 4}}">步数</text>
<text class="sportType" wx:if="{{items.projectId == 5}}">坐位体前屈</text>
<text class="sportType" wx:if="{{items.projectId == 6}}">50米跑</text>
<text class="sportType" wx:if="{{items.projectId == 11}}">开合跳</text>
<text class="sportType" wx:if="{{items.projectId == 13}}">深蹲</text>
<text class="sportType" wx:if="{{items.projectId == 14}}">俯卧撑</text>
<text class="sportType" wx:if="{{items.projectId == 15}}">高抬腿</text>
<text class="sportType" wx:if="{{items.projectId == 16}}">原地臀踢</text>
<text class="sportType" wx:if="{{items.projectId == 17}}">原地跑</text>
<text class="isSmart" catchtap="buy" wx:if="{{items.isDevData == 1 && items.projectId == 1}}">智能跳绳</text>
</view>
<view class="info" wx:if="{{items.projectId == 1 || items.projectId == 2 || items.projectId == 3 || items.projectId == 4 || items.projectId == 5 || items.projectId == 6 || items.projectId == 11 || items.projectId == 13 || items.projectId == 14 || items.projectId == 15 || items.projectId == 16 || items.projectId == 17}}">
<view class="time" wx:if="{{items.projectId == 1 || items.projectId == 2 || items.projectId == 3 || items.projectId == 4 || items.projectId == 5 || items.projectId == 6 || items.projectId == 11 || items.projectId == 13 || items.projectId == 14 || items.projectId == 15 || items.projectId == 16 || items.projectId == 17}}">{{items.sportValue}} <text>{{items.sportValueTypeName || ''}}</text></view>
<view class="time" wx:else>{{items.count}}<text>次</text></view>
<view>
<view class="time">{{items.sportTime}}</view>
<image src="/images/skip/time_black.png"></image>
</view>
<view>
<view class="qk">{{items.calorie}}</view>
<image src="/images/skip/calorie_black.png"></image>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
page{
background: #f5f5f5;
}
.top-wrap{
background: #fff;
}
.day{display: flex;}
.day view{
width: 160rpx;
height: 100%;
margin-right: 23rpx;
display: inline-block;
margin-left: 10px;
background-color: blue;
text-align: center;
font-size: 24rpx;
color: #333;
height: 70rpx;
line-height: 70rpx;
}
.data{
position: relative;
height: 330rpx;
display: flex;
background: #F8F8F8 !important;
}
.data .line{
position: absolute;
width: 2rpx;
height: 100%;
border:1rpx dashed #E5E5E5;
left: calc(50% - 2rpx);
top: 10rpx;
transform: scaleX(0.5);
}
.data .sel-line{
position: absolute;
width: 0rpx;
height: 100%;
border:1rpx dashed #FF811E;
left: calc(50% - 2rpx);
top: 10rpx;
}
.data .item{
width: 180rpx;
height: 100%;
margin-right: 23rpx;
display: inline-block;
margin-left: 10px;
}
.item_list .item-set{
color: #3FCB7D;
}
.item_list .item .val{
text-align: center;
color: #FFFFFF;
font-size: 26rpx;
position: absolute;
}
.chart{
height: 338rpx;
width: 60rpx;
margin:0 auto;
border-radius: 60rpx 60rpx 0 0;
position: relative;
}
.chart view{
height: 400rpx;
width: 60rpx;
/* background: linear-gradient(180deg, #239E71 0%, #183247 100%); */
background: #FFE8D5;
margin:0 auto;
border-radius: 8rpx 8rpx 0rpx 0rpx;
position: absolute;
bottom: 18rpx;
left: 0;
}
.chart-set{
background: #FF811E !important;
}
.card {
position: relative;
background-color: #fff;
padding-bottom: 30rpx;
padding-top: 0rpx;
border-radius: 24rpx 24rpx 0rpx 0rpx;
margin-top: -48rpx;
}
.data-wrap{
display: flex;
margin-top: 40rpx;
padding-top: 30rpx;
}
.pd80{
padding-top: 80rpx;
}
.data-wrap .item{
flex: 1;
font-family: "Number";
text-align: center
}
.data-wrap .item-time{
margin-top: 60rpx;
}
.data-wrap .key{
font-size: 22rpx;
color: #B2B2B2;
margin-top: 10rpx;
}
.card .number{
font-family: "Number";
width: 100%;
text-align: center;
font-size: 104rpx;
margin-top: 40rpx;
margin-bottom: 60rpx;
padding-top: 40rpx;
}
.data-wrap .val text{
font-size: 18rpx;
font-weight: normal;
}
.data-wrap .val{
font-size: 48rpx;
}
.data-item{
background: #fff;
margin-top: 20rpx;
}
.data-item .top{
width: 654rpx;
height: 100rpx;
line-height: 100rpx;
margin:0 auto;
border-bottom: 1rpx solid #dbdbdb;
}
.data-item .top .val{
float: left;
font-size: 36rpx;
}
.data-item .top .val text{
font-size:16rpx ;
}
.data-item .top .mode{
float: left;
width:120rpx;
height:36rpx;
background:rgba(237,255,244,1);
border:1rpx solid rgba(63,195,121,1);
border-radius:18rpx;
color:rgba(63,195,121,1);
text-align: center;
line-height: 36rpx;
font-size: 20rpx;
margin:32rpx 30rpx 0 30rpx;
}
.data-item .time{
float: right;
font-size: 26rpx;
}
.data-item .bottom{
display: flex;
height: 100rpx;
width: 654rpx;
margin:0 auto;
}
.t-l{
text-align: left;
}
.t-r{
text-align: right;
}
.center{
min-width: 400rpx;
}
.data-item .bottom .li{
flex: 1;
text-align: center;
}
.data-item .bottom .li .key{
font-size: 22rpx;
color: #656565;
}
.data-item .bottom .li .val{
font-size: 26rpx;
margin-top: 10rpx;
}
.last{
float:left;
font-size: 28rpx;
text-align: center;
padding: 10rpx 20rpx;
border-radius: 10rpx;
color: #FFFFFF;
background: #3FCB7D;
margin: 20rpx;
}
.next{
float:right;
font-size: 28rpx;
text-align: center;
padding: 10rpx 20rpx;
border-radius: 10rpx;
color: #FFFFFF;
background: #3FCB7D;
margin: 20rpx;
}
.top{
overflow: hidden;
background: #FFFFFF;
}
.on{
background: #f5f5f5;
color: #000000;
}
.scroll_box{
width: 100%;
height: 410rpx;
/* padding: 20rpx; */
white-space: nowrap;
}
.scroll_box scroll-view{
background: #F8F8F8;
height: 420rpx;
width: auto;
}
.item_list{
position: relative;
top: 0;
text-align: center;
/* width: 130rpx; */
height: 100%;
/* margin-right: 23rpx; */
display: inline-block;
/* margin-left: 10px; */
font-size: 26rpx;
}
.item_list .item{
font-size: 22rpx;
line-height: 80rpx;
color: rgba(0, 0, 0, 0.5);
background: #F8F8F8;
}
.item_list .item-set{
font-weight: bold;
color: #FF811E;
}
::-webkit-scrollbar{
width: 0;
height: 0;
color: transparent;
}
.todayList{
position: relative;
width: 100%;
margin-top: 20rpx;
background: #FFFFFF;
}
.todayList .li{
position: relative;
width: 100%;
/* height: 210rpx; */
display: flex;
}
.todayList .li .left{
text-align: center;
margin-left: 30rpx;
margin-right: 18rpx;
}
.todayList .li .left image{
width: 100rpx;
height: 100rpx;
margin-top: 30rpx;
}
.todayList .li .right{
flex: 1;
border-bottom: 2rpx solid #EEEEEE;
margin-right: 30rpx;
padding-bottom: 14rpx;
}
.todayList .li .alone{
margin-left: 30rpx;
}
.right .type{
height: 30rpx;
margin-top: 30rpx;
font-size: 22rpx;
color: #B2B2B2;
}
.right .num{
font-family: "Number";
color: #353535;
font-size: 48rpx;
margin-top: 20rpx;
margin-bottom: 20rpx;
}
.right .unit{
font-size: 20rpx;
color: #B2B2B2;
margin-left: 6rpx;
}
.right .isSmart{
font-size: 22rpx;
background: #31BBFF;
border-radius: 12rpx;
color: #FFFFFF;
padding: 2rpx 10rpx;
padding-bottom: 10rpx;
margin-left: 20rpx;
}
.right .info{
overflow: hidden;
margin-top: 12rpx;
}
.alone .info{
overflow: hidden;
margin-top: 12rpx;
margin-bottom: 12rpx;
}
.right .info image{
width: 28rpx;
height: 28rpx;
float: left;
margin-top: 2rpx;
margin-left: 8rpx;
}
.right .info .time{
font-family: "Number";
font-size: 28rpx;
float: left;
}
.right .info .qk{
font-family: "Number";
font-size: 28rpx;
float: left;
margin-left: 20rpx;
}
.todayTime{
position: absolute;
right: 30rpx;
top: 40rpx;
font-size: 22rpx;
color: #B2B2B2;
}
.todayList .nodata{
width: 100%;
text-align: center;
}
.todayList .nodata image{
width: 440rpx;
height: 328rpx;
margin-top: 60rpx;
}
.sportTime{
padding-left: 30rpx;
color: #888888;
font-size: 28rpx;
height: 80rpx;
line-height: 80rpx;
}
.top{
background: #FFFFFF;
color: #748490;
width: 100%;
}
.top-li{
display: flex;
height: 78rpx;
line-height: 78rpx;
width: 702rpx;
margin: 0 auto;
background: #F5F5F5;
border-radius:16rpx;
padding: 0rpx 4rpx;
}
.top .type{
flex:1;
text-align: center;
font-size: 28rpx;
color: rgba(0, 0, 0, 0.9);
}
.top .active{
height: 70rpx;
font-weight: bold;
color: #FF811E;
background: #FFFFFF;
/* box-shadow: 0rpx 4rpx 8rpx 2rpx rgba(0, 0, 0, 0.08); */
border-radius: 16rpx;
margin-top: 5rpx;
line-height: 70rpx;
}
.top .type .name{
width: 100%;
text-align: center;
}
.select{
width: 30rpx;
height: 4rpx;
border-radius: 12rpx;
background: #FFFFFF;
margin: 0 auto;
margin-top: -14rpx;
}
.total{
overflow: hidden;
background: #FFFFFF;
height: 420rpx;
width: auto;
}
.totla-number{
font-family: "Number";
width: 100%;
font-weight: bold;
color: rgba(0, 0, 0, 0.9);
font-size: 100rpx;
text-align: center;
padding-top: 70rpx;
}
.totla-number .unit{
font-size: 22rpx;
color: rgba(0, 0, 0, 0.3);
}
.viewToatl{
width: 100%;
height: 420rpx;
}
.total-type{
width: 84%;
display: flex;
margin: 0 auto;
margin-top: 50rpx;
}
.total-type .type-item{
flex: 1;
text-align: center;
color: #FFFFFF;
}
.type-item .num{
font-family: "Number";
color: rgba(0, 0, 0, 0.9);
font-size: 44rpx;
font-weight: bold;
}
.type-item .content{
font-size: 22rpx;
color: #FFFFFF;
margin-top: 8rpx;
color: rgba(0, 0, 0, 0.3);
}
.type-item .left{
text-align: left;
}
.type-item .contents{
text-align: content;
}
.type-item .right{
text-align: right;
}
.selTime{
position: absolute;
width: 90%;
margin: 0 auto;
font-size: 28rpx;
color: #888888;
left: 5%;
top: 20rpx;
}
.time text{
color: #B2B2B2;
margin-left: 6rpx;
margin-right: 40rpx;
font-size: 22rpx;
}
.sportType{
color: #353535;
font-size: 28rpx;
font-weight: bold;
}
.more{
position: absolute;
font-size: 24rpx;
right: 50rpx;
top: 38rpx;
color: rgba(0, 0, 0, 0.5);
}
.more-img{
position: absolute;
width: 24rpx;
height: 24rpx;
right: 22rpx;
top: 44rpx;
}
.baf{
background: #FFFFFF !important;
}
.sanjiao{
position: absolute;
left: calc(50% - 8rpx);
top: 0rpx;
width:0rpx;
height:0rpx;
border:10rpx solid #000;
border-top-color: #FF811E;
border-bottom-color:transparent;
border-left-color:transparent;
border-right-color:transparent;
}
.selTimeText{
font-size: 28rpx;
width: 90%;
margin: 0 auto;
color: rgba(0, 0, 0, 0.5);
padding-top: 20rpx;
}
\ No newline at end of file
var API = require("../../../utils/request.js");
var tool = require("../../../utils/util.js");
var handle = 0;
var sportType = 1;//1跳绳 2 仰卧起坐 3//踢键子
var sportData = 0;
var _this = this;
var sportTime = 60;
var activityId = 0;
var submitFlag = true;
var timeHandle = 0; //定时器句柄
var startSkips = 0;//开始
Page({
data: {
array: ['倒计时1分钟', '倒计时2分钟', '倒计时3分钟'],
index:0,
num: 5,
play: false,
list: [],
flag: false, //数据统计
placeholder: '请输入跳绳个数',
startFlag: false,
delBtnWidth: 260,
startX: "",
inputVal: '',
countdown:60,
time:0,
showTime:'00:00',
is_start:true,
isTs:false,
start:true,
end:false,
sourcesId:0,
mode:2,
startCountdown:0, //开始前倒计时
endCountdown:0, //结束前倒计时
skipJz:1, //背景音乐开关
music:'', //当前的背景音乐
isSz:true, //是否设置
isPicker:false,//是否打开
},
onLoad: function (options) {
var that =this;
that.setData({
index:options.select - 2,
innerAudioContext: wx.createInnerAudioContext(),
},()=>{
console.log('当前模式',that.data.index)
if(that.data.index == 0){
sportTime = 60;
that.setData({
mode:2
})
}else if(that.data.index == 1){
sportTime = 120;
that.setData({
mode:3
})
}else if(that.data.index == 2){
sportTime = 180;
that.setData({
mode:4
})
}
})
wx.setInnerAudioOption({
obeyMuteSwitch: false,
success: function (e) {
console.log(e)
console.log('play success')
},
fail: function (e) {
console.log(e)
console.log('play fail')
}
})
//that.getActivityDetail();
that.getBgMusic();
submitFlag = true;
console.log(options);
this.setType(options); //设置运动类型
activityId = options.activityId;
if(options.sportType == "1"){
sportTime = 60;
wx.setNavigationBarTitle({
title: '跳绳'
})
}else if(options.sportType == "2"){
sportTime = 60;
wx.setNavigationBarTitle({
title: '仰卧起坐'
})
}else if(options.sportType == "3"){
sportTime = 60;
wx.setNavigationBarTitle({
title: '踢毽子'
})
}
if(options.sportType === "1"){
that.setData({
isTs:true
})
}else{
that.setData({
isTs:false
})
}
that.setData({ startFlag: false });
// if (options.hasData == 0) {
// this.amiata(); //开始初始动画
// } else if (options.hasData == 1) {
// this.setData({ startFlag: false });
// }
//this.getSportDataList();//活动运动记录数据
// 背景音乐播放结束监听
wx.onBackgroundAudioStop(()=>{
var that = this;
if(that.data.is_start){
setTimeout(function() {
that.palyVoice(that.data.music);
}, 200);
}
})
},
//获取背景音乐列表
getBgMusic() {
var that = this;
wx.showLoading({
title: '加载中...',
})
API.getData('/config/getBgMusic', {}, function (res) {
var list = res.data;
API.getData('/config/getSkipConfig', {}, function (res) {
console.log('当前的音乐配置',res.data);
console.log('当前的音乐列表',list);
if(res.data == null){
that.setData({
startCountdown:1,
endCountdown:1,
skipJz:1,
music:list[0].musicUrl
})
}else{
if(res.data.skipJz == 1 && res.data.skipBackMusic != null){
for(var i = 0; i < list.length; i++){
if(list[i].id == res.data.skipBackMusic){
console.log(list[i].musicName);
that.setData({
music:list[i].musicUrl
})
}
}
}else if(res.data.skipJz == null && res.data.skipBackMusic != null){
for(var i = 0; i < list.length; i++){
if(list[i].id == res.data.skipBackMusic){
console.log(list[i].musicName);
that.setData({
music:list[i].musicUrl
})
}
}
}else if(res.data.skipJz == 1 && res.data.skipBackMusic == null){
that.setData({
music:list[0].musicUrl
})
}else if(res.data.skipJz == null && res.data.skipBackMusic == null){
that.setData({
music:list[0].musicUrl
})
}
else if(res.data.skipJz == 0){
console.log('当前背景音乐关闭');
that.setData({
music:''
})
}
if(res.data.startCountdown == 0){
that.setData({
startCountdown:0
})
}else{
that.setData({
startCountdown:1
})
}
if(res.data.endCountdown == 0){
that.setData({
endCountdown:0
})
}else{
that.setData({
endCountdown:1
})
}
if(res.data.skipJz == 0){
that.setData({
skipJz:0
})
}else{
that.setData({
skipJz:1
})
}
}
wx.hideLoading();
})
}, function () {
});
},
// 获取当前的活动
// getActivityDetail() {
// var that = this;
// API.getData('/activity/getCur', {}, function (res) {
// console.log('当前活动的id',res);
// if (res.code == 200) {
// wx.setStorageSync('nowSourcesId', res.data.id);
// that.setData({
// sourcesId:res.data.id
// })
// }else{
// wx.showToast({
// icon:'none',
// title: '活动获取失败',
// success:function(){
// wx.switchTab({
// url: '/pages/index/index',
// })
// }
// })
// }
// }, function () {
// });
// },
formatSeconds(value) {
let result = parseInt(value)
let h = Math.floor(result / 3600) < 10 ? Math.floor(result / 3600) : Math.floor(result / 3600);
let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
var time = m + ":" + s
return time;
},
//开始
clickKs(){
this.amiata();
},
clickBc(){
wx.showToast({
title: '计时未结束,无法上传数据哦~再接再厉,突破自己!',
icon: 'none',
duration: 1500
})
},
onReady: function () {
},
onShow: function () {
var that = this;
that.getBgMusic();
console.log(that.data.time);
//that.getActivityDetail();
if(that.data.flag == true && that.data.time > 0){
that.setData({
is_start:false
})
wx.stopBackgroundAudio();
}else if(that.data.flag == false && that.data.time > 0){
//this.palyVoice('http://cdn.xiaobentiyu.cn/video/syjzsp.m4v');
this.palyVoice(this.data.music);
}
wx.setKeepScreenOn({
keepScreenOn: true
})
},
onHide: function () {
console.log("---onHide-----");
this.setData({
is_start:false
})
wx.stopBackgroundAudio();
//clearInterval(handle);
},
onUnload: function () {
console.log("---onUnload-----");
var that = this;
that.setData({
is_start:false
})
wx.stopBackgroundAudio();
clearTimeout(startSkips);//清楚定时任务
clearInterval(handle);
that.data.innerAudioContext.destroy();
},
bindPickerChange: function (e) {
var that = this;
console.log('picker发送选择改变,携带值为', e.detail.value)
that.setData({
index: e.detail.value
})
if(e.detail.value == 0){
sportTime = 60;
that.setData({
mode:2
})
}else if(e.detail.value == 1){
sportTime = 120;
that.setData({
mode:3
})
}else if(e.detail.value == 2){
sportTime = 180;
that.setData({
mode:4
})
}
},
//播放本地音乐组件
palyLocal(url) {
var that = this;
this.data.innerAudioContext.autoplay = true;
this.data.innerAudioContext.src = url;
this.data.innerAudioContext.onPlay(() => {
console.log('开始播放')
})
},
palyVoice(url) {
wx.playBackgroundAudio({
dataUrl: url,
success(e) { console.log(e); },
fail(e) { console.log(e); },
complete() { }
})
},
//设置运动类型
setType(options) {
console.log(options);
if (options.sportType == 1) {
sportType = options.sportType;
this.setData({ placeholder: '请输入跳绳个数' })
this.setData({ sportType: sportType });
} else if (options.sportType == 2) {
sportType = options.sportType;
this.setData({ placeholder: '请输入仰卧起坐个数' })
this.setData({ sportType: sportType });
} else if (options.sportType == 3) {
sportType = options.sportType;
this.setData({ placeholder: '请输入踢键子个数' })
this.setData({ sportType: sportType });
} else {
this.setData({ placeholder: '请输入跳绳个数' })
this.setData({ sportType: sportType });
}
if (sportType == 2) {
}
},
// 初始动画
amiata() {
var _this = this;
_this.setData({
isSz:false,
start:false,
end:true,
startFlag: true,
is_start:false,
isTs:false,
isPicker:true
})
if(this.data.startCountdown == 1){
var num = this.data.num;
var num = 5;
_this.palyLocal('/images/ai/N5.mp3');
setTimeout(function () {
handle = setInterval(function () {
num = num - 1;
// console.log(num);
_this.setData({ num: num })
if(num ===4){
_this.palyLocal('/images/ai/N4.mp3');
_this.setData({
is_start:false
})
}else if(num ===3){
_this.palyLocal('/images/ai/N3.mp3');
_this.setData({
is_start:false
})
}else if(num ===2){
_this.palyLocal('/images/ai/N2.mp3');
_this.setData({
is_start:false
})
}else if(num ===1){
_this.palyLocal('/images/ai/N1.mp3');
_this.setData({
is_start:false
})
}else if (num === 0) {
if (sportType == 1) {
_this.setData({
isTs:true
})
} else{
_this.setData({
isTs:false
})
}
clearInterval(handle);
_this.setData({ num: '开始' });
_this.palyLocal('/images/ai/V_START.mp3')
startSkips = setTimeout(function () {
_this.setData({
startFlag: false,
is_start:true
});
_this.startTime();
}, 1200);
}
}, 1000)
}, 1000)
}else{
console.log('关闭开始前');
_this.setData({ num: '开始' });
_this.palyVoice('/images/ai/V_START.mp3')
setTimeout(function () {
_this.setData({
startFlag: false,
is_start:true
});
_this.startTime();
}, 1200);
}
},
// 最后5秒处理
countdown(_this,totleTime,time){
var index = totleTime -time;
if(_this.data.endCountdown == 1){
if(index ===5){
_this.setData({is_start:false});
wx.stopBackgroundAudio();
_this.palyLocal('/images/ai/N5.mp3');
}else if(index ===4){
_this.palyLocal('/images/ai/N4.mp3');
}else if(index ===3){
_this.palyLocal('/images/ai/N3.mp3');
}else if(index ===2){
_this.palyLocal('/images/ai/N2.mp3');
}else if(index ===1){
_this.palyLocal('/images/ai/N1.mp3');
}else if(index ===0){
}
}else{
console.log('关闭了结束前');
}
},
// 提交运动记录
submits:tool.throttle(function(){
var that = this;
submitFlag = true;
console.log('点击了保存');
console.log('当前的活动id',that.data.sourcesId);
// wx.showLoading({
// title: '保存中...',
// mask:true
// })
// if (submitFlag) {
// submitFlag = false;
if (sportData) {
console.log('进入了保存');
var subData = {
projectId: parseInt(sportType), //项目id 比如跳绳
sportValue: parseInt(sportData),//运动值
sourceType: 1, //1 活动,2课程
sourceId: that.data.sourcesId,//活动id
sportTime: sportTime,//运动时长 单位为s
sportModel:that.data.mode
}
if(!/^\d+$/.test(sportData)){
submitFlag = true;
sportData = 0;
this.setData({
inputVal: ''
})
wx.showToast({
title: '请输入正确的跳绳数',
icon: 'none',
duration: 1000
})
return false;
}
API.requestAll('/project/addReord', subData, (res) => {
submitFlag = true;
console.log("我是上传的数据",subData);
console.log(res);
if (res.code == 200) {
sportData = 0;
this.setData({ flag: false, play: false });
//this.getSportDataList();
var uid = res.data.id;
setTimeout(function(){
wx.hideLoading({
success: (res) => {
if(sportType == 1){
wx.redirectTo({
url: '../share/share?ordin=1&id=' + uid + '&showMedal=1&sportTime=' + that.data.showTime,
})
}else if(sportType == 2){
wx.redirectTo({
url:'../share/share?id=' + uid + '&share=0&isDev=0&sportTime=' + that.data.showTime,
})
}
// else{
// wx.redirectTo({
// url:'../../activity/secondsMark/secondsMark?id=' + uid + '&showMedal=1'
// })
// }
},
})
},2000)
} else {
wx.hideLoading()
submitFlag = true;
sportData = 0;
this.setData({ inputVal: '' })
wx.showToast({ icon: 'none', title: res.message, duration: 2000 })
}
}, function () {
wx.hideLoading()
});
} else {
wx.hideLoading()
wx.showToast({ icon: 'none', title: '请记录运动数据', duration: 2000 })
}
// }
},2000),
getSportDataList() {
var that = this;
var obj = {
projectId: parseInt(sportType), //项目id 比如跳绳
sourceType: 1, //1 活动,2课程
sourceId: that.data.sourceId,//活动id
}
API.getData('/project/todayrecord', obj, (res) =>{
console.log(res);
if (res.code == 200) {
this.setData({ list: res.data })
}
}, function () {
});
},
// 开始运动
startTime() {
this.setData({ time: '0' });
console.log(this.data.time)
var time = parseInt(this.data.time);
var _this = this;
_this.setData({ num: '', play: true });
startSkips = setTimeout(function(){
if (sportType == 1) {
_this.palyVoice(_this.data.music);
}else{
_this.palyVoice('http://cdn.xiaobentiyu.cn/video/syjzsp.m4v')
}
},1000)
handle = setInterval(function () {
time = time + 1;
if (time < 10) {
_this.setData({ time: '0' + time })
} else {
_this.setData({ time: time })
}
var showTime = _this.formatSeconds(time);
_this.setData({ time: time,showTime:showTime});
console.log(time);
_this.countdown(_this,sportTime,time);
if (time == sportTime) {
_this.setData({
is_start:false,
isTs:false
});
if (sportType == 1) {
_this.palyVoice('https://ttxs01-10066525.cos.ap-shanghai.myqcloud.com/youplus/mp3/a_3.mp3');
} else if (sportType == 2) {
_this.palyVoice('https://ttxs01-10066525.cos.ap-shanghai.myqcloud.com/youplus/mp3/a_5.mp3');
} else if (sportType == 3) {
_this.palyVoice('https://ttxs01-10066525.cos.ap-shanghai.myqcloud.com/youplus/mp3/n_5.mp3');
}
_this.setData({ flag: true, time: '00' });
clearInterval(handle);
}
}, 1000)
},
// cancel() {
// clearInterval(handle);
// wx.switchTab({
// url: '/pages/activity/index/index'
// })
// },
getNum(e) {
console.log(e.detail.value);
sportData = e.detail.value;
},
touchS: function (e) {
console.log(e);
if (e.touches.length == 1) {
this.setData({
//设置触摸起始点水平方向位置
startX: e.touches[0].clientX
});
}
},
touchM: function (e) {
if (e.touches.length == 1) {
//手指移动时水平方向位置
var moveX = e.touches[0].clientX;
//手指起始点位置与移动期间的差值
var disX = this.data.startX - moveX;
var delBtnWidth = this.data.delBtnWidth;
var txtStyle = "";
if (disX == 0 || disX < 0) {//如果移动距离小于等于0,说明向右滑动,文本层位置不变
txtStyle = "left:0rpx";
} else if (disX > 0) {//移动距离大于0,文本层left值等于手指移动距离
txtStyle = "left:-" + disX + "rpx";
if (disX >= delBtnWidth) {
//控制手指移动距离最大值为删除按钮的宽度
txtStyle = "left:-" + delBtnWidth + "rpx";
}
}
//获取手指触摸的是哪一项
var index = e.currentTarget.dataset.index;
var list = this.data.list;
list[index].txtStyle = txtStyle;
//更新列表的状态
this.setData({
list: list
});
}
},
touchE: function (e) {
if (e.changedTouches.length == 1) {
//手指移动结束后水平位置
var endX = e.changedTouches[0].clientX;
//触摸开始与结束,手指移动的距离
var disX = this.data.startX - endX;
var delBtnWidth = this.data.delBtnWidth;
//如果距离小于删除按钮的1/2,不显示删除按钮
var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx";
//获取手指触摸的是哪一项
var index = e.currentTarget.dataset.index;
var list = this.data.list;
list[index].txtStyle = txtStyle;
//更新列表的状态
this.setData({
list: list
});
}
},
//设置
goEdit(){
wx.navigateTo({
url:'../skip-edit/skip-edit'
})
}
})
{
"usingComponents": {}
}
\ No newline at end of file
<view class="count" wx:if="{{isTs}}">
<picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}" disabled="{{isPicker}}">
<view class="mode-sel">
{{array[index]}}
<image src="https://cdn.xiaobentiyu.cn/sport_minapp_img/jt3.png" class="jt"></image>
</view>
</picker>
<view class="edit" bindtap="goEdit" wx:if="{{isSz && isTs}}">设置</view>
<view class="edit-no" wx:else>设置</view>
</view>
<view class="daka">
<view class="{{num==='开始'?'go mix':'go '}}" wx:if="{{num && startFlag}}">{{num}}</view>
<view wx:if="{{!startFlag}}" class="daka-wrap">
<!-- <view class="time">00:{{time}}</view> -->
<view class="time">{{showTime}}</view>
<view class="btn" bindtap="clickKs" wx:if="{{start}}">
<image src="../../../images/sport/icon_ks.png"></image>
开始
</view>
<view class="btn" bindtap="clickBc" wx:if="{{end}}">
<image src="../../../images/sport/icon_bc.png"></image>
保存
</view>
<view class="mask" wx:if="{{flag}}"></view>
<view class="layer" wx:if="{{flag}}">
<view class="title">运动数据统计</view>
<view class="content">为确保运动数据更准确,请如实输入个数</view>
<view class="input-wrap">
<input placeholder="{{placeholder}}" type="number" bindinput="getNum" value="{{inputVal}}"></input>
</view>
<view class="btn" hover-class="after-click-btn" bindtap="submits">确定</view>
</view>
</view>
</view>
\ No newline at end of file
.go {
/* font-family: "Number"; */
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: #FF9B4D;
line-height: 800rpx;
text-align: center;
font-size: 300rpx;
color: #fff;
}
.mix {
font-size: 200rpx;
}
page {
background: #41cf7e;
}
.daka-wrap {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: #FFFFFF;
}
.time {
font-family: "Number";
font-size: 120rpx;
text-align: center;
margin-top: 300rpx;
color: #353535;
}
.btn-wrap {
height: 165rpx;
padding: 0 30rpx;
margin-top: 20px;
}
.btn-wrap .btn {
width: 170rpx;
height: 170rpx;
border: 3rpx solid #6f7179;
border-radius: 50%;
}
.btn-wrap .btn view {
width: 160rpx;
height: 160rpx;
margin: 5rpx auto;
background: #6f7179;
border-radius: 50%;
font-size: 32rpx;
}
.btn-right view {
background: #4f6d64 !important;
}
.btn-right {
border: 3rpx solid #4f6d64
}
.btn-left {
line-height: 160rpx;
text-align: center;
color: #fff;
}
.btn-right text {
display: block;
text-align: center;
position: relative;
top: 32rpx;
color: #45b876
}
.keep .btn {
margin: 0 auto;
}
.keep .btn view {
background: #6f7179 !important;
}
.keep .btn text {
color: #fff !important;
}
.list {
height: 300px;
position: fixed;
bottom: 0;
border-top: 1rpx solid #fff;
padding-top: 1rpx;
}
.list .item {
height: 133rpx;
line-height: 133rpx;
padding: 0 0rpx;
color: #fff;
border-bottom: 1rpx solid #fff;
position: relative;
padding-bottom: 1rpx;
}
.list .item .inner {
position: absolute;
top: 0;
}
.list .item .content {
width: 100%;
box-sizing: border-box;
padding: 0 30rpx;
z-index: 200;
background: #52535e
}
.list .item .del {
right: 0;
text-align: center;
width: 260rpx;
background: #ff0000;
}
.list .item .updata {
right: 130rpx;
text-align: center;
width: 130rpx;
background: #41cf7e;
}
.mask {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: #000;
opacity: 0.3;
z-index: 200;
}
.layer {
position: absolute;
width: 90%;
top: 400rpx;
left: 5%;
z-index: 300;
border-radius: 10rpx;
background: #fff;
}
.layer .title {
height: 90rpx;
line-height: 90rpx;
background: #FFFFFF;
color: #353535;
padding: 0 30rpx;
text-align: center;
border-radius: 10rpx 10rpx 0 0;
font-weight: bold;
}
.layer .content{
color: #888888;
font-size: 28rpx;
text-align: center;
}
.layer .input-wrap {
margin: 40rpx auto 40rpx auto;
height: 88rpx;
width: 90%;
border: 2rpx solid #F3F3F3;
border-radius: 50rpx;
}
.layer input {
width: 100%;
height: 88rpx;
color: #888888;
text-align: center;
}
.layer .btn {
width: 90%;
height: 88rpx;
line-height: 88rpx;
background: #FF9B4D;
margin: 10rpx auto 30rpx auto;
text-align: center;
color: #fff;
border-radius: 50rpx;
}
.count{
position: fixed;
z-index: 9;
width: 100%;
top: 50rpx;
overflow: hidden;
height: 60rpx;
}
.mode-sel{
font-size: 26rpx;
color: #353535;
margin:0 auto;
float: left;
position:absolute;
left:50%;
top:50%;
transform:translateX(-50%) translateY(-50%);
background: #F8F8F8;
border:2rpx solid #E8E8E8;
padding: 10rpx 28rpx 10rpx 38rpx;
border-radius:30rpx;
font-weight:bold;
}
.jt {
width: 32rpx;
height: 32rpx;
position: relative;
top: 6rpx;
}
.btn {
position: relative;
width: 178rpx;
height: 178rpx;
border-radius: 50%;
line-height: 220rpx;
background: #FF9B4D;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.06);
color: #fff;
text-align: center;
margin: 160rpx auto 0 auto;
}
.btn image{
position: absolute;
left: 68rpx;
top:32rpx;
width: 48rpx;
height: 48rpx;
}
.edit{
position: absolute;
right: 40rpx;
top: 14rpx;
height: 40rpx;
font-size: 28rpx;
color: #353535;
}
.edit-no{
position: absolute;
right: 40rpx;
top: 14rpx;
height: 40rpx;
font-size: 28rpx;
color: #888888;
}
.edit image{
width: 40rpx;
height: 40rpx;
}
\ No newline at end of file
var app = getApp();
var version = 'v2.0.5'
/**
* POST请求,
* URL:接口
......@@ -7,41 +6,71 @@ var version = 'v2.0.5'
* doSuccess:成功的回调函数
* doFail:失败的回调函数
*/
function requestAll(url, postData, doSuccess) {
// postData.userId = parseInt(wx.getStorageSync('userId'));
function requestAll(url, postData, doSuccess, doFail) {
wx.request({
//项目的真正接口,通过字符串拼接方式实现
url: wx.getStorageSync('host') + url,
header: {
"content-type": "application/json;charset=UTF-8",
"version":version,
token:wx.getStorageSync('token'),
// token: wx.getStorageSync('token'),
"token": 'be3531e49c70444189d7511c7bb9602d',
version: wx.getStorageSync('version'),
pvmodel:wx.getStorageSync('model'),
pvversion: wx.getStorageSync('pvversion'),
route:"xiaobenSport"
},
data: postData,
method: 'POST',
success: function (res) {
if (res.data.code == 200) {
//console.log('发送请求',res)
if(res.data.code == 200){
doSuccess(res.data);
}else if(res.data.code == 401){
wx.reLaunch({
url:'/pages/authorize/authorize'
});
} else {
if (res.data.message){
if (res.data.message && res.data.message.indexOf('token') != -1){
wx.navigateTo({ url: '/pages/authorize/authorize' })
}else{
wx.showToast({ icon: 'none', title: res.data.message, duration: 2000 })
}
url:'/packageB/login/index/index'
})
}else{
wx.showToast({ icon: 'none', title: '服务器开小差了', duration: 2000 })
doSuccess(res.data);
wx.showToast({
title: res.data.message,
duration: 2000,
icon: 'none'
});
}
},
fail: function () {
doFail();
},
})
}
function request(url, postData, doSuccess,doFail) {
wx.request({
//项目的真正接口,通过字符串拼接方式实现
url: wx.getStorageSync('host') + url,
header: {
"content-type": "application/json;charset=UTF-8",
"token":'be3531e49c70444189d7511c7bb9602d'
// token: wx.getStorageSync('token'),
// version: wx.getStorageSync('version'),
// pvmodel:wx.getStorageSync('model'),
// pvversion: wx.getStorageSync('pvversion'),
// route:"xiaobenSport"
},
data: postData,
method: 'POST',
success: function (res) {
if (res.data.code == 200) {
doSuccess(res.data);
} else if (res.data.code == 401) {
wx.reLaunch({
url:'/packageB/login/index/index'
});
}else {
doSuccess(res.data);
}
},
fail: function () {
wx.showToast({ icon: 'none', title: '服务器开小差了', duration: 2000 })
// doFail();
wx.showToast({ icon: 'none', title: '网络异常,请重试', duration: 2000 })
},
})
}
......@@ -52,80 +81,118 @@ function getData(url, data, doSuccess, doFail) {
url: wx.getStorageSync('host') + url,
header: {
"content-type": "application/json;charset=UTF-8",
"version": version,
token: 'a299f858af9d4bcc9f21836e3967f85b',
"token":'be3531e49c70444189d7511c7bb9602d'
// token: wx.getStorageSync('token'),
// version: wx.getStorageSync('version'),
// pvmodel:wx.getStorageSync('model'),
// pvversion: wx.getStorageSync('pvversion'),
// route:"xiaobenSport"
},
data: data,
method: 'GET',
success: function (res) {
if (res.data.code == 200) {
doSuccess(res.data);
}else if(res.data.code == 401){
} else if (res.data.code == 401){
wx.reLaunch({
url:'/pages/authorize/authorize'
url:'/packageB/login/index/index'
});
} else {
if (res.data.message) {
if (res.data.message && res.data.message.indexOf('token') != -1) {
wx.navigateTo({ url: '/pages/authorize/authorize' })
} else {
wx.showToast({ icon: 'none', title: res.data.message, duration: 2000 })
}
} else {
// wx.showToast({ icon: 'none', title: '服务器开小差了', duration: 2000 })
}
}else {
doSuccess(res.data);
}
},
fail: function (res) {
wx.showToast({ icon: 'none', title: '服务器开小差了', duration: 2000 })
doFail();
wx.showToast({ icon: 'none', title: '网络异常,请重试', duration: 2000 })
},
})
}
//GET请求,不需传参,直接URL调用,
function getDataAll(url, data, doSuccess, doFail) {
wx.request({
url: wx.getStorageSync('host') + url,
header: {
"content-type": "application/json;charset=UTF-8",
"version": version,
token: wx.getStorageSync('token'),
"token":'be3531e49c70444189d7511c7bb9602d'
// token: wx.getStorageSync('token'),
// version: wx.getStorageSync('version'),
// pvmodel:wx.getStorageSync('model'),
// pvversion: wx.getStorageSync('pvversion'),
// route:"xiaobenSport"
},
data: data,
method: 'GET',
success: function (res) {
if (res.data.code == 200) {
if(res.data.code == 200){
doSuccess(res.data);
}else if(res.data.code == 401){
wx.reLaunch({
url:'/pages/authorize/authorize'
});
} else {
if (res.data.message) {
if (res.data.message && res.data.message.indexOf('token') != -1) {
wx.navigateTo({ url: '/pages/authorize/authorize' })
} else {
doFail(res);
wx.showToast({ icon: 'none', title: res.data.message, duration: 2000 })
url:'/packageB/login/index/index'
})
}else{
doSuccess(res.data);
}
} else {
},
fail: function (res) {
doFail(res.data);
},
})
}
function del(url, data, doSuccess, doFail) {
wx.request({
url: wx.getStorageSync('host') + url,
header: {
"content-type": "application/json;charset=UTF-8",
"token":'be3531e49c70444189d7511c7bb9602d'
// token: wx.getStorageSync('token'),
// version: wx.getStorageSync('version'),
// pvmodel:wx.getStorageSync('model'),
// pvversion: wx.getStorageSync('pvversion'),
// route:"xiaobenSport"
},
// data: {},
method: 'DELETE',
success: function (res) {
doSuccess(res);
},
fail: function (res) {
doFail(res);
wx.showToast({ icon: 'none', title: '服务器开小差了', duration: 2000 })
}
}
},
})
}
function put(url, data, doSuccess, doFail) {
wx.request({
url: wx.getStorageSync('host') + url,
header: {
"content-type": "application/json;charset=UTF-8",
"token":'be3531e49c70444189d7511c7bb9602d'
// token: wx.getStorageSync('token'),
// version: wx.getStorageSync('version'),
// pvmodel:wx.getStorageSync('model'),
// pvversion: wx.getStorageSync('pvversion'),
// route:"xiaobenSport"
},
data: data,
method: 'PUT',
success: function (res) {
doSuccess(res);
},
fail: function (res) {
wx.showToast({ icon: 'none', title: '服务器开小差了', duration: 2000 })
doFail(res);
},
})
}
function log(val){
function log(val) {
console.log(val);
}
module.exports.requestAll = requestAll;
module.exports.request = request;
module.exports.getData = getData;
module.exports.getDataAll = getDataAll
module.exports.getDataAll = getDataAll;
module.exports.requestAll = requestAll;
module.exports.del = del;
module.exports.put = put;
module.exports.log = log;
/**
* Created by pangwenjian on 16-11-7.
*/
const WEEK_DAY = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
module.exports = {
//根据日期获取当前周列表
getDatesWeek(data) {
var new_Date = new Date(data)
var timesStamp = new_Date.getTime();
var currenDay = new_Date.getDay();
var dates = [];
for(var i = 0; i < 7; i++) {
var dayStamp = new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7));
var mon = dayStamp.getMonth()+1;
var month = mon < 10 ? '0' + mon : mon;
var day = dayStamp.getDate() < 10 ? '0' + dayStamp.getDate() : dayStamp.getDate();
var showData = month + '.' + day;
dates.push({day:showData});
}
return dates;
},
//获取昨天今天和明天、后天
getDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth()+1;//获取当前月份的日期
var d = dd.getDate();
return y+"-"+m+"-"+d;
},
//获取昨天今天和明天、后天
getDateStrs(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = (dd.getMonth()+1)<10?'0'+(dd.getMonth()+1):(dd.getMonth()+1);//获取当前月份的日期
var d = (dd.getDate())<10?'0'+(dd.getDate()):(dd.getDate());
return y+"-"+m+"-"+d;
},
getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
},
//毫秒时间转换
formatSeconds(s) {
//计算分钟
//算法:将秒数除以60,然后下舍入,既得到分钟数
var h;
h = Math.floor(s/60);
//计算秒
//算法:取得秒%60的余数,既得到秒数
s = s%60;
//将变量转换为字符串
h += '';
s += '';
//如果只有一位数,前面增加一个0
h = (h.length==1)?'0'+h:h;
s = (s.length==1)?'0'+s:s;
return h+':'+s;
},
formatTime(time) {
var timeStr = (parseInt(time / 60) < 10 ? '0' + parseInt(time / 60) : parseInt(time / 60)) + ':'
+ (time % 60 < 10 ? '0' + time % 60 : time % 60);
return timeStr;
},
forTimes(data) {
  var time = Number(data);
  var h = Math.floor(time / 3600);
  var m = Math.floor((time % 3600) / 60);
  var s = parseInt(time % 3600) % 60;
  var hh = h < 10 ? "0" + h : h;
  var mm = m < 10 ? "0" + m : m;
  var ss = s < 10 ? "0" + s : s;
  return hh + ":" + mm + ":" + ss;
},
//获取打卡的日历
getCalendarArry(year, month, spotArry, startTime,endTime) {
if (startTime && endTime){
var startTime = startTime.split('-');
var endTime = endTime.split('-');
var startNum = parseInt(startTime[0])*10000 + parseInt(startTime[1])*100 + parseInt(startTime[2]);
var endNum = parseInt(endTime[0])*10000 + parseInt(endTime[1])*100 + parseInt(endTime[2])
}
// console.log("-------------------------------");
// console.log(startNum)
// console.log(year*1000+month*100);
// console.log(endNum);
var _date_array = this.initMonthDayNumber(year); //给月份数组附上每月天数
var lastMonthDays = (new Date(parseInt(year) + '-' + month + '-' + '01' + 'T00:00:00')).getDay();
// console.log('lastMonthDays:' + lastMonthDays);
var dataArry = [];
for (var i = 0; i < lastMonthDays; i++) {
dataArry.push('');
}
for (i = 1; i <= _date_array[month - 1]; i++) {
var item = {
data: i,
selected: false,
color: '#ff0000',
className: '',
spot: false,
taday: false
}
var nowNum = year * 10000 + month * 100 + i
if(startTime && endTime){
// console.log(month);
if (startNum <= nowNum && nowNum <= endNum){
// console.log(i);
item.start = 'color:#000000';
}
}
if (spotArry) {
// console.log(spotArry);
var day =i;
if(i<10){
day = '0'+i
}
for (var k = 0; k < spotArry.length; k++) {
if (spotArry[k] === year+'-'+month+'-'+day) {
item.spot = true;
}
}
}
// if (spotArry) {
// // console.log(spotArry);
// for (var k = 0; k < spotArry.length; k++) {
// if (spotArry[k] === i) {
// item.spot = true;
// }
// }
// }
if (parseInt(year) === parseInt(this.getFullYear())
&& parseInt(month) === parseInt(this.getMonth())
&& parseInt(i) === parseInt(this.getDate())
) {
item.taday = true;
item.className = 'today';
item.start = '';
}
dataArry.push(item)
}
for (i = 0; i < (42 - lastMonthDays - _date_array[month - 1]); i++) {
dataArry.push('');
}
var data = [[], [], [], [], [], []]
for (i = 0; i < 6; i++) {
for (var j = 0; j < 7; j++) {
data[i][j] = dataArry[i * 7 + j];
}
}
console.log('打点后的日历',data);
return data;
},
//测试获取打卡的日历
getCalendarArryTese(year, month, spotArry, startTime,endTime) {
if (startTime && endTime){
var startTime = startTime.split('-');
var endTime = endTime.split('-');
var startNum = parseInt(startTime[0])*10000 + parseInt(startTime[1])*100 + parseInt(startTime[2]);
var endNum = parseInt(endTime[0])*10000 + parseInt(endTime[1])*100 + parseInt(endTime[2])
}
// console.log("-------------------------------");
// console.log(startNum)
// console.log(year*1000+month*100);
// console.log(endNum);
var _date_array = this.initMonthDayNumber(year); //给月份数组附上每月天数
var lastMonthDays = (new Date(parseInt(year) + '-' + month + '-' + '01' + 'T00:00:00')).getDay();
// console.log('lastMonthDays:' + lastMonthDays);
var dataArry = [];
for (var i = 0; i < lastMonthDays; i++) {
dataArry.push('');
}
for (i = 1; i <= _date_array[month - 1]; i++) {
var item = {
data: i,
selected: false,
color: '#ff0000',
className: '',
spots: false,
taday: false
}
var nowNum = year * 10000 + month * 100 + i
if(startTime && endTime){
// console.log(month);
if (startNum <= nowNum && nowNum <= endNum){
// console.log(i);
item.start = 'color:#000000';
}
}
if (spotArry) {
// console.log(spotArry);
var day =i;
if(i<10){
day = '0'+i
}
for (var k = 0; k < spotArry.length; k++) {
if (spotArry[k] === year+'-'+month+'-'+day) {
item.spots = true;
}
}
}
// if (spotArry) {
// // console.log(spotArry);
// for (var k = 0; k < spotArry.length; k++) {
// if (spotArry[k] === i) {
// item.spot = true;
// }
// }
// }
if (parseInt(year) === parseInt(this.getFullYear())
&& parseInt(month) === parseInt(this.getMonth())
&& parseInt(i) === parseInt(this.getDate())
) {
item.taday = true;
item.className = 'today';
item.start = '';
}
dataArry.push(item)
}
for (i = 0; i < (42 - lastMonthDays - _date_array[month - 1]); i++) {
dataArry.push('');
}
var data = [[], [], [], [], [], []]
for (i = 0; i < 6; i++) {
for (var j = 0; j < 7; j++) {
data[i][j] = dataArry[i * 7 + j];
}
}
console.log('打点后的日历',data);
return data;
},
/**
*
* 判断这一年是闰年还是平年
* @param year {String/Number} 年份
* @returns {boolean}
*/
isLeapYear: function (year) {
if (!typeof year === 'number') {
throw new Error("年份格式不正确");
}
if (year < 1790) {
throw new Error("年份不能低于1790年");
}
// 计算闰年方法
// 1.能被4整除而不能被100整除
// 2.能被400整除
return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
},
/**
* 获取当前周从星期一到星期日的日期
* @param {String} dateString 日期。格式:yyyy-MM-dd
* @return {Array} 当前周星期一到星期日的日期
*/
getWeekDay: function(dateString) {
let dateStringReg = /^\d{4}[/-]\d{1,2}[/-]\d{1,2}$/;
if (dateString.match(dateString)) {
let presentDate = new Date(dateString),
today = presentDate.getDay() !== 0 ? presentDate.getDay() : 7;
return Array.from(new Array(7), function(val, index) {
return formatDate(new Date(presentDate.getTime() - (today - index-1) * 24 * 60 * 60 * 1000));
});
} else {
throw new Error('dateString should be like "yyyy-mm-dd"');
}
function formatDate(date) {
return date.getFullYear()+'-'+(date.getMonth() + 1) + '-' + date.getDate();
}
},
/**
* 返回月份中的第一天是星期几
* @returns {number}
* 1 星期一
* 2 星期二
* 3 星期三
* 4 星期四
* 5 星期五
* 6 星期六
* 0 星期天
*/
weekOfMonth: function (date) {
if (!date) date = new Date();
return new Date(this.getFullYear(date), this.getMonth(date), 1).getDay();
},
/**
* 获取月份
* @param date
* @returns {*|number}
*/
getMonth: function (date) {
if (!date) date = new Date();
let res = date.getMonth() + 1
return res > 10 ? res : '0' + res;
},
/**
* 获取完整月份
* @param year month {number}
* @returns {string}
*/
getFullMonth: function (year, month) {
if (month < 10) {
month = '0' + month;
}
return year + '-' + month;
},
/**
* 获取年份
* @param date
* @returns {number}
*/
getFullYear: function (date) {
if (!date) date = new Date();
return date.getFullYear();
},
/**
* 获取完整日期
* @param year date day{number}
* @returns {string}
*/
getFullDate: function (year, month, day) {
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
return year + '-' + month + '-' + day;
},
/**
* 获取一月中的某一天
* @param date
* @returns {number}
*/
getDate: function (date) {
if (!date) date = new Date();
var day = date.getDate();
if (day < 10) {
day = '0' + day;
}
return day;
},
//参数时间格式 yyyy-MM-dd
getWeek: function (date) {
let myDate = new Date(date);
return WEEK_DAY[myDate.getDay()];
},
/**
* 给月份数组附上每月天数
* @param year 年份
* @private
*/
initMonthDayNumber: function (year) {
let _date_array = [];
for (var i = 0; i < 12; i++) {
switch (i + 1) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
_date_array.push(31);
break;
case 4:
case 6:
case 9:
case 11:
_date_array.push(30);
break;
case 2:
if (this.isLeapYear(year)) {
_date_array.push(29);
} else {
_date_array.push(28);
}
break;
default:
break;
}
}
return _date_array;
},
//参数格式 HH:mm
getAmOrPm: function (time) {
if (time) {
return parseInt(time.substring(0, 2)) >= 12 ? '下午' : '上午';
} else {
return null;
}
},
//获取上一个月份
//参数格式 yyyy-MM
getLastMonth: function (date) {
let arr = date.split('-');
if (arr[1] === '01') {
arr[1] = '12';
arr[0] = parseInt(arr[0]) - 1;
} else {
arr[1] = parseInt(arr[1]) - 1;
if (arr[1] < 10) {
arr[1] = '0' + arr[1];
}
}
return arr.join('-');
},
//获取下一个月份
//参数格式 yyyy-MM
getNextMonth: function (date) {
let arr = date.split('-');
if (arr[1] === '12') {
arr[1] = '01';
arr[0] = parseInt(arr[0]) + 1;
} else {
arr[1] = parseInt(arr[1]) + 1;
if (arr[1] < 10) {
arr[1] = '0' + arr[1];
}
}
return arr.join('-');
},
convertToDate: function (str) {
str = str.replace(/-/g, '/');
return new Date(str);
},
convertToLong: function (str) {
return this.convertToDate(str).getTime();
},
format: function (date, fmt) {
if (typeof (date) == 'undefined' || (typeof (date) == 'string' && date == '')) {
return '';
}
if (typeof (date) === 'number') {
if (date <= 0) {
return '';
}
date = new Date(date);
}
var o = {
'M+': date.getMonth() + 1, //月份
'd+': date.getDate(), //日
'h+': date.getHours() % 12 == 0 ? 12 : date.getHours() % 12, //小时
'H+': date.getHours(), //小时
'm+': date.getMinutes(), //分
's+': date.getSeconds(), //秒
'q+': Math.floor((date.getMonth() + 3) / 3), //季度
'S': date.getMilliseconds() //毫秒
};
var week = {
'0': '/u65e5',
'1': '/u4e00',
'2': '/u4e8c',
'3': '/u4e09',
'4': '/u56db',
'5': '/u4e94',
'6': '/u516d'
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
}
if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '/u661f/u671f' : '/u5468') : '') + week[date.getDay() + '']);
}
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
}
}
return fmt;
},
timeline(input, now) {
now = now || new Date().getTime();
var timeSpan = now - input;
var time = 0;
if (timeSpan < 60000) {
return '刚刚';
} else if (timeSpan < 3600000) {
time = Math.floor(timeSpan / 60000);
return time + '分钟前';
} else if (timeSpan < 24 * 3600000) {
time = Math.floor(timeSpan / 3600000);
return time + '小时前';
} else if (timeSpan < 7 * 24 * 3600000) {
time = Math.floor(timeSpan / 24 / 3600000);
return time + '天前';
} else if (timeSpan < 30 * 24 * 3600000) {
time = Math.floor(timeSpan / 7 / 24 / 3600000);
return time + '星期前';
} else if (timeSpan < 365 * 24 * 3600000) {
time = Math.floor(timeSpan / 30 / 24 / 3600000);
return time + '个月前';
} else {
return this.format(input, 'YYYY年MM月DD日');
}
},
//单位秒转分秒 例 sec = 90 return 1分30秒
handleTimeStg (sec){
var theTime = sec //秒
var minute = 0; // 分
if(theTime >= 60){
minute= parseInt(theTime / 60);
theTime = parseInt(theTime % 60);
if(minute> 60){
middle = parseInt(minute% 60);
}
}
var result= "" + (parseInt(theTime) > 0 ? parseInt(theTime) + '秒' : '')
if(minute> 0){
result= "" + parseInt(minute) + (parseInt(theTime) > 0?"分":"分钟") + result;
}
return result
},
formatTimes (date) {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
return `${[year, month, day].map(formatNumber).join('-')} ${[hour, minute].map(formatNumber).join(':')}`
},
};
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment