//logs.js
var util = require('../../utils/util.js')
Page({
progressTimer: null,
data: {
cs_id: 0,
sub_cs_id: 0,
readingInfo: [],
'---音频相关---': '----',
JFAudio: [],
recording: false,
currentProgress: 0
},
onPullDownRefresh: function () {
wx.stopPullDownRefresh();
},
onLoad: function (obj) {
//接收上一个页面传过来的参数
if (obj && obj.sub_cs_id) {
this.setData({
cs_id: obj.cs_id,
sub_cs_id: obj.sub_cs_id
})
}
},
onShow: function () {
var that = this;
that.getReadingInfo(function (data) {
that.setData({
readingInfo: data.readingInfo
})
})
},
getReadingInfo: function (cal) {
var that = this;
util.JFrequest({
url: 'https://t.superabc.cn/c/os/reading/getreadinginfo',
param : {
'sub_cs_id': that.data.sub_cs_id,
'cs_id': that.data.cs_id
},
success: function (res) {
if (res && res.statusCode == 200 && res.data && res.data.code == 0) {
if (typeof cal == 'function') {
cal(res.data.data);
}
} else {
console.log("请求数据失败,读取缓存");
//
}
}
});
},
//点击提交作业
tapSubmitReadingResult: function (e) {
var that = this;
var jfAudio = that.data.JFAudio;
var audioUrlList = [];
var len = jfAudio.length, successNum = 0;
//如果音频数目不够,不让提交
if (len < that.data.readingInfo.length) {
wx.showToast({
title: '请完成所有跟读再提交作业!',
icon: 'success',
duration: 1000
});
return false;
}
wx.showToast({
title: '正在提交作业……',
icon: 'loading',
duration: 5000
});
for (var i = 0; i < len; i++) {
(function (i) {
console.log(jfAudio[i].tempFilePath);
util.JFuploadfile({
url: 'https://t.superabc.cn/c/s/uploadwxappfile',
filePath: jfAudio[i].tempFilePath || '',
name: 'wx_file_' + i,
formData: {
'part_index': i,
'file_type': 3,
'file_prefix': 'wx_file_'
},
success: function (res) {
console.log(res);
var retData = JSON.parse(res.data);
if (retData && retData.code == 0) {
audioUrlList[i] = retData.data.url;
successNum++;
} else {
console.warn("上传失败!");
}
if (successNum == len) {
//加入跟读(报名 + 提交作业)
that.joinReading(audioUrlList, function (data) {
//提交作业成功,跳转到结果页
var record_id = data.joinRes.record_id;
wx.hideToast();
setTimeout(function () {
wx.redirectTo({
url: '../result/result?record_id=' + record_id
});
},300);
});
}
}
})
})(i);
}
},
//加入跟读
joinReading: function (audioUrlList, cal) {
var that = this;
console.log(that.data.JFAudio);
console.log(audioUrlList);
util.JFrequest({
url: 'https://t.superabc.cn/c/os/reading/joinreading',
param: {
'cs_id': that.data.cs_id,
'sub_cs_id': that.data.sub_cs_id,
'audio_list': audioUrlList
},
success: function (res) {
if (res && res.statusCode == 200 && res.data && res.data.code == 0) {
if (typeof cal == 'function') {
cal(res.data.data);
}
}else {
if(res.data.code == 600004){
wx.showToast({
title: res.data.err_msg,
icon: 'success',
duration: 500
});
setTimeout(function () {
wx.redirectTo({
url: '../course/course?cs_id=' + that.data.cs_id
});
},800);
}
}
},
complete: function (res) {
console.log(res);
}
});
},
//播放标准片段音
tapPlayPartAudio: function (e) {
var thisAudioId = 'partaudio-' + e.currentTarget.id;
var thisAudioCtx = wx.createAudioContext(thisAudioId);
thisAudioCtx.play();
},
emptyAudio: {
'recording': null,
'playing': null,
'hasRecord': false,
'tempFilePath': ''
},
//录音
tapCompleteUserAudio: function (e, itemIndex) {
var that = this;
var readingItem;
if (itemIndex) {
readingItem = itemIndex;
} else {
readingItem = e.currentTarget.dataset.reading_item;
}
wx.stopRecord();
that.updateJFAudio(readingItem, 'recording', false);
that.setData({
recording: false
});
clearInterval(that.progressTimer);
},
tapRecordUserAudio: function (e) {
var that = this;
var readingItem = e.currentTarget.dataset.reading_item;
//当前所在页面
var jfAudio = that.data.JFAudio;
var curAudioModel = that.updateJFAudioModel(readingItem, jfAudio[readingItem]);
//
wx.showToast({
title: '开始录音',
icon: 'success',
duration: 500
});
that.updateJFAudio(readingItem, 'recording', true);
that.setData({
recording: true
});
//更新进度条
var size = 100;
that.setData({
currentProgress: 0
});
that.progressTimer = setInterval(function () {
var num = Math.ceil(parseFloat(that.data.readingInfo[readingItem]['audio_duration']) * 1000);
var newPro = that.data.currentProgress;
newPro += size / num * 100;
if (newPro >= 100) {
that.setData({
currentProgress: 100
});
that.tapCompleteUserAudio(null, readingItem);
} else {
that.setData({
currentProgress: newPro
});
}
}, size);
//
wx.startRecord({
success: function (res) {
that.updateJFAudio(readingItem, 'tempFilePath', res.tempFilePath);
that.updateJFAudio(readingItem, 'hasRecord', true);
//
that.setData({
recording: false
});
},
complete: function () {
that.updateJFAudio(readin
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序开发-绘本跟读案例源码.zip (100个子文件)
reading.js 9KB
login.js 7KB
util.js 6KB
course.js 3KB
courseintro.js 2KB
my.js 2KB
result.js 2KB
index.js 2KB
app.js 958B
logs.js 280B
material.json 2KB
app.json 959B
reading.json 87B
logs.json 56B
courseintro.json 56B
jsconfig.json 55B
result.json 54B
index.json 46B
my.json 46B
login.json 46B
course.json 6B
QQ截图20170605134749.png 107KB
QQ截图20170605134803.png 83KB
img_login_swbg.png 44KB
img_read_taskBg.png 22KB
img_read_taskBg.png 22KB
img_read_taskBg.png 22KB
img_login_bg.png 14KB
btn_read_command.png 8KB
btn_read_command(1).png 8KB
btn_read_homework.png 8KB
btn_read_homework.png 8KB
btn_read_homework.png 8KB
btn_read_homework.png 8KB
img_read_flower_pink.png 8KB
btn_read_listenB.png 8KB
btn_read_listenB.png 8KB
btn_read_listenB.png 8KB
img_read_flower_white.png 8KB
img_read_flower_red.png 7KB
btn_read_voicePlay.png 7KB
btn_read_voicePlay.png 7KB
btn_read_voicePlay.png 7KB
btn_read_videoPlay.png 6KB
btn_read_videoPlay.png 6KB
btn_read_videoPlay.png 6KB
btn_read_teach.png 6KB
btn_read_teach.png 6KB
btn_read_teach.png 6KB
btn_read_record_stop.png 6KB
btn_read_record.png 5KB
btn_read_record.png 5KB
btn_read_record.png 5KB
btn_read_listenS.png 5KB
btn_read_listenS.png 5KB
btn_read_listenS.png 5KB
img_read_wordBg.png 4KB
img_read_wordBg.png 4KB
img_read_wordBg.png 4KB
btn_read_go.png 4KB
btn_read_go.png 4KB
btn_read_go(1).png 4KB
img_login_wechat.png 3KB
btn_read_undone.png 3KB
btn_read_undone.png 3KB
btn_read_undone.png 3KB
img_read_voiceBg.png 3KB
img_read_voiceBg.png 3KB
img_read_voiceBg.png 3KB
img_read_flowerTag.png 1KB
btn_read_wordVoice.png 1KB
btn_read_wordVoice.png 1KB
btn_read_wordVoice.png 1KB
btn_read_voice.png 803B
btn_read_voice.png 803B
btn_read_voice.png 803B
btn_read_voice.png 803B
wechat.png 795B
wechat.png 795B
wechatHL.png 786B
wechatHL.png 786B
weapp.d.ts 42KB
result.wxml 4KB
courseintro.wxml 4KB
course.wxml 3KB
reading.wxml 3KB
login.wxml 3KB
index.wxml 1KB
my.wxml 444B
logs.wxml 194B
courseintro.wxss 13KB
result.wxss 8KB
index.wxss 3KB
login.wxss 3KB
course.wxss 2KB
reading.wxss 2KB
my.wxss 752B
app.wxss 244B
logs.wxss 114B
临时资源.zip 1.27MB
共 100 条
- 1
芝麻粒儿
- 粉丝: 5w+
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页