...
|
...
|
@@ -6,7 +6,6 @@ innerAudioContext.autoplay = true |
|
|
let time = null
|
|
|
let time_num = 0;
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
...
|
...
|
@@ -18,7 +17,7 @@ Page({ |
|
|
http_url:'',
|
|
|
|
|
|
Count:0,//总题数
|
|
|
current:0,//当前题号
|
|
|
current:"0",//当前题号
|
|
|
today_id:'',//今日任务id
|
|
|
match_id:'',//比赛任务id
|
|
|
all_data:[],//全部题目
|
...
|
...
|
@@ -48,7 +47,9 @@ Page({ |
|
|
alterType:false,//弹窗状态
|
|
|
alterData:{},//弹窗数据
|
|
|
taskType:'',//任务类型 比赛任务 今日任务
|
|
|
TodayTaskType:''//1 打卡 0 补卡
|
|
|
TodayTaskType:'',//1 打卡 0 补卡
|
|
|
webImg:'',//第三方链接封面
|
|
|
pages_types:false,//页面加载
|
|
|
},
|
|
|
PlayState(){
|
|
|
this.selectComponent("#audio").changePlayState()
|
...
|
...
|
@@ -98,7 +99,7 @@ Page({ |
|
|
}
|
|
|
}else if(this.data.taskType == "match"){//比赛任务
|
|
|
answer = {
|
|
|
'match_subject_id': res.data.List[0].match_subject_id, //'题目ID',
|
|
|
'match_subject_id': this.data.all_data[index].match_subject_id, //'题目ID',
|
|
|
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
|
|
|
'file_url': [] //'图片/音频 【多张图 , 分割 拼接字符串】'
|
|
|
}
|
...
|
...
|
@@ -134,6 +135,7 @@ Page({ |
|
|
var url = '' //接口地址
|
|
|
//判断任务类型
|
|
|
var temporary = Math.ceil(time_num/60);//学习时间
|
|
|
var all_data = JSON.stringify(this.data.allAnswer)
|
|
|
if(this.data.taskType == "today"){ //今日任务
|
|
|
url = 'today/TodayTask'
|
|
|
data = {today_id:this.data.today_id,json:all_data,learn_time:temporary,type:this.data.TodayTaskType}
|
...
|
...
|
@@ -141,7 +143,6 @@ Page({ |
|
|
url = 'match/MatchTask'
|
|
|
data = {match_id:this.data.match_id,json:all_data,learn_time:temporary}
|
|
|
}
|
|
|
var all_data = JSON.stringify(this.data.allAnswer)
|
|
|
app.post(url,data ).then(res => {
|
|
|
if(res.code == 1){
|
|
|
console.log(res)
|
...
|
...
|
@@ -180,6 +181,7 @@ Page({ |
|
|
http_url:app.globalData.imgBaseUrl,
|
|
|
})
|
|
|
var that = this;
|
|
|
this.WebImage()
|
|
|
time = setInterval(function(){
|
|
|
time_num++
|
|
|
},1000)
|
...
|
...
|
@@ -226,9 +228,13 @@ Page({ |
|
|
},
|
|
|
//获取今日任务列表
|
|
|
TodayQuestion(){
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
})
|
|
|
var that = this;
|
|
|
app.post("today/TodayQuestion", {today_id:this.data.today_id}).then(res => {
|
|
|
if(res.code == 1){
|
|
|
wx.hideLoading()
|
|
|
console.log(res)
|
|
|
|
|
|
let answer = {
|
...
|
...
|
@@ -249,6 +255,7 @@ Page({ |
|
|
Count:res.data.Count,//总题数
|
|
|
current:1,//当前题数
|
|
|
answer,
|
|
|
pages_types:true,
|
|
|
})
|
|
|
}
|
|
|
}).catch(err => {
|
...
|
...
|
@@ -261,10 +268,13 @@ Page({ |
|
|
//比赛任务
|
|
|
MatchQuestion(){
|
|
|
var that = this;
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
})
|
|
|
app.post("match/MatchQuestion", {match_id:this.data.match_id}).then(res => {
|
|
|
if(res.code == 1){
|
|
|
console.log(res)
|
|
|
|
|
|
wx.hideLoading()
|
|
|
let answer = {
|
|
|
'match_subject_id': res.data.List[0].match_subject_id, //'题目ID',
|
|
|
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
|
...
|
...
|
@@ -283,6 +293,7 @@ Page({ |
|
|
Count:res.data.Count,//总题数
|
|
|
current:1,//当前题数
|
|
|
answer,
|
|
|
pages_types:true,
|
|
|
})
|
|
|
}
|
|
|
}).catch(err => {
|
...
|
...
|
@@ -292,6 +303,23 @@ Page({ |
|
|
})
|
|
|
})
|
|
|
},
|
|
|
//答题页外部链接按钮图片
|
|
|
WebImage(){
|
|
|
var that = this;
|
|
|
app.post("index/WebImage", {}).then(res => {
|
|
|
if(res.code == 1){
|
|
|
console.log(res)
|
|
|
this.setData({
|
|
|
webImg: res.data.web_image
|
|
|
})
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
wx.showToast({
|
|
|
title: err.msg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
...
|
...
|
@@ -303,14 +331,18 @@ Page({ |
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
|
|
|
innerAudioContext.onEnded((res)=>{ // 监听音频自然播放至结束的事件
|
|
|
console.log(res)
|
|
|
this.setData({
|
|
|
soundType : 2
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -318,6 +350,10 @@ Page({ |
|
|
*/
|
|
|
onUnload: function () {
|
|
|
clearInterval(time)
|
|
|
innerAudioContext.offEnded((res)=>{//取消监听音频自然播放至结束的事件
|
|
|
console.log(res)
|
|
|
})
|
|
|
this.PlayState()//暂停后台播放的音乐
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -340,6 +376,7 @@ Page({ |
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
//第三方链接
|
|
|
web_url(e){
|
|
|
var webUrl = e.currentTarget.dataset.weburl;
|
...
|
...
|
@@ -377,6 +414,7 @@ Page({ |
|
|
//看原图
|
|
|
showImg: function (e) {
|
|
|
var that = this;
|
|
|
console.log(e.currentTarget.dataset.index)
|
|
|
wx.previewImage({
|
|
|
urls: that.data.uploaderList,
|
|
|
current: that.data.uploaderList[e.currentTarget.dataset.index]
|
...
|
...
|
@@ -509,6 +547,8 @@ Page({ |
|
|
soundType:3,//录音结束
|
|
|
})
|
|
|
innerAudioContext.src = this.data.musicUrl
|
|
|
innerAudioContext.play()
|
|
|
console.log(innerAudioContext.paused)
|
|
|
innerAudioContext.onPlay(() => { // 监听音频播放事件
|
|
|
console.log('开始播放')
|
|
|
})
|
...
|
...
|
@@ -516,13 +556,14 @@ Page({ |
|
|
console.log(res.errMsg)
|
|
|
console.log(res.errCode)
|
|
|
})
|
|
|
|
|
|
},
|
|
|
//录音暂停事件
|
|
|
pause_voice(){
|
|
|
this.setData({
|
|
|
soundType:2,//录音结束
|
|
|
})
|
|
|
console.log("暂停录音")
|
|
|
console.log("暂停播放")
|
|
|
innerAudioContext.pause()
|
|
|
innerAudioContext.onPause(() => { // 监听音频暂停事件
|
|
|
console.log('暂停播放')
|
...
|
...
|
@@ -531,5 +572,8 @@ Page({ |
|
|
console.log(res.errMsg)
|
|
|
console.log(res.errCode)
|
|
|
})
|
|
|
// innerAudioContext.offEnded((res)=>{//取消监听音频自然播放至结束的事件
|
|
|
// console.log(res)
|
|
|
// })
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|