Commit 14b78db9 authored by lvtz's avatar lvtz

微官网首页

parents cd9033c3 ceaeef90
......@@ -49,6 +49,10 @@ Component({
showAuthSettingDia: false
},
pageLifetimes: {
// show () {
// console.log(this.data.role, 'role')
// console.log(this.data.sid, 'role')
// },
hide() {
// 如果在录制中停止录制
if (this.data.audioStatus.play == 'play') {
......@@ -57,6 +61,7 @@ Component({
}
},
created () {
},
attached () {
},
......@@ -70,8 +75,8 @@ Component({
recorderManager.onStop((res) => {
const that = this;
const { tempFilePath } = res;
const fileType = tempFilePath.substr(tempFilePath.lastIndexOf('.') + 1);
if (!this.data.audioStatus.upload) {
return;
}
let filename = '';
......@@ -79,21 +84,23 @@ Component({
let mediaAccess;
if (that.data.role == '2c') {
mediaAccess = cMediaOssAccess({
type: 2
type: 2,
school_id:this.data.sid,
ext: fileType
})
} if (that.data.role == '2b') {
mediaAccess = bMediaOssAccess({
type: 2,
school_id:this.data.sid
school_id:this.data.sid,
ext: fileType
})
}
mediaAccess.then((acc) => {
let access = acc.data;
filename = `${access.dir}${getRandomFilename(tempFilePath)}`;
return wxUploadFile({
url: access.host,
formData: {
key: filename,
key: access.path,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
......
......@@ -28,7 +28,8 @@ import {
wxPreviewImage,
wxOpenSetting,
wxLogin,
wxChooseMessageFile
wxChooseMessageFile,
wxGetVideoInfo
} from '../../../utilities/wxApi.js'
import {
mediaTimeFormat,
......@@ -153,7 +154,7 @@ Page({
getmobiledialogshow: false,
uploadVideoTask: {
},
sid: 0,
detailExpand: true,//作业详情 默认收起
},
onLoad: function(options) { // Do some initialize when page load.
......@@ -161,7 +162,7 @@ Page({
const { tid, sid, cid, pagefrom,clockdate,sub} = options;
this.setData({
tid,
sid,
sid: Number(sid),
pagefrom: pagefrom || '',
clockdate: clockdate || '',
sub:sub || ''
......@@ -169,7 +170,7 @@ Page({
wx.showLoading();
app.getCurrentSchoolStudentId({
source_id: this.data.sid,
source_type: 7,
source_type: 10,
}).then(() => {
themeDetail({
subject_id: this.data.sub?this.data.sub:this.data.tid
......@@ -187,7 +188,7 @@ Page({
themeDetail: Object.assign(data, {
content: _content
}),
sid: data.school_id,
sid: Number(data.school_id),
id: data.class_id,
contentLimit: {
text: data.text_require_status == 2 ? 0 : data.text_require_num,
......@@ -196,7 +197,6 @@ Page({
audio: data.audio_require_status == 2 ? 0 : data.audio_require_num,
}
}, () => {
console.log(this.data.themeDetail.content.length,'content')
this.userShow();
this.queryActivtySchoolInfo(this.data.sid);
this.getClockUuid();
......@@ -361,9 +361,13 @@ Page({
'params.location_address': ''
})
},
addImg (tempFiles) { // 添加图片的操作
addImg (e, wxFile) { // 添加图片的操作
let imgCount = this.data.imageBox.filter(ele => ele.type == 'image').length;
if (imgCount >= this.data.maxImgCount) { // 当等于10条了不能继续添加
wx.showToast({
title: `上传图片不能超过${this.data.maxImgCount}张`,
icon: 'none'
})
return
} else {
if (!this.data.imageUploaded) {
......@@ -384,9 +388,17 @@ Page({
this.setData({
imageUploaded: false
})
wxChooseImage({
let myPromise = null;
if (wxFile) {
myPromise = new Promise((resolve) => {
resolve(wxFile);
})
} else {
myPromise = wxChooseImage({
count: this.data.maxImgCount - imgCount
}).then((res) => {
})
}
myPromise.then((res) => {
const {tempFiles} = res;
let imageBox = this.data.imageBox;
this.setData({
......@@ -445,11 +457,8 @@ Page({
school_id: this.data.sid,
ext: fileType
}).then((acc) => {
if (acc.code == 200) {
access = acc.data;
// if(!tempFiles.currentTarget){
// return {tempFiles,};
// }
// imageBox[this.data.currentIndex].src = access.path;
return wxUploadFile({
url: access.host,
formData: {
......@@ -463,6 +472,7 @@ Page({
filePath: imageBox[this.data.currentIndex].src,
name: 'file',
})
}
}).then((res) => {
let data = JSON.parse(res.data);
if (data.status == 'ok') {
......@@ -484,6 +494,7 @@ Page({
this.singleUploadFile();
}
}).catch((e) => {
console.log('ddddddddddddddddddddd失败')
imageBox[this.data.currentIndex].status = 'fail';
let currentIndex = this.data.currentIndex + 1;
this.setData({
......@@ -748,6 +759,10 @@ Page({
addVideo () {
let videoCount = this.data.imageBox.filter(ele => ele.type == 'video').length;
if (videoCount >= this.data.maxVideoCount) {
wx.showToast({
title: `上传视频不能超过${this.data.maxVideoCount}个`,
icon: 'none'
})
return
}
let mySystem = wx.getSystemInfoSync();
......@@ -785,7 +800,7 @@ Page({
})
this.addVideoMethod();
},
addVideoMethod (tempFile) { // 添加视频的操作
addVideoMethod (e, wxFile) { // 添加视频的操作
const that = this;
let access = {};
let filename = '';
......@@ -794,16 +809,20 @@ Page({
let size = 0;
let duration = 0;
let tempFilePath ='';
wxChooseVideo({
}).then((res) => {
// access = res.data;
let myPromise = null;
if (wxFile) {
myPromise = new Promise((resolve) => {
resolve(wxFile);
})
} else {
myPromise = wxChooseVideo({
})
}
myPromise.then((res) => {
console.log(res, 'res');
size = res.size;
duration = res.duration;
if(tempFile){
tempFilePath = res.path;
}else{
tempFilePath = res.tempFilePath;
}
if (duration > constants.videoConf.duration) {
wx.showModal({
title: '提示',
......@@ -823,7 +842,6 @@ Page({
return
}
videoInsertIndex = imageBox.filter(ele => ele.type == 'video').length;
// filename = `${access.dir}${getRandomFilename(tempFilePath)}`;
const path = tempFilePath;
const fileType = path.substr(path.lastIndexOf('.') + 1).toLowerCase();
return cMediaOssAccess({
......@@ -832,6 +850,7 @@ Page({
type: 1
})
}).then((res) => {
if (res.code == 200) {
access = res.data;
imageBox.splice(videoInsertIndex, 0, {
src: access.path,
......@@ -877,18 +896,17 @@ Page({
}
},
fail (e) {
// console.log('失败');
// that.setData({
// [`imageBox[${videoInsertIndex}].status`]: 'fail'
// })
}
})
that.data.uploadVideoTask[`${filename}`].onProgressUpdate((res) => {
if (that.data.uploadVideoTask[`${access.path}`].onProgressUpdate) {
that.data.uploadVideoTask[`${access.path}`].onProgressUpdate((res) => {
imageBox[videoInsertIndex].videoprogress = res.progress > 95 ? 95 : res.progress;
that.setData({
imageBox: imageBox
})
})
}
}
}).catch((err) => {
wx.hideLoading();
});
......@@ -1028,7 +1046,7 @@ Page({
}
} else {
audioStorage[value].currentTime = slide;
audioStorage[value].isWaiting = true;
audioStorage[value].isWaiting = true;
}
this.innerAudioContext.seek(slide);
this.setData({
......@@ -1261,17 +1279,44 @@ audioStorage[value].isWaiting = true;
type: ''
}).then((res)=>{
const { tempFiles } = res;
const imgList = tempFiles.filter((ele)=>{
return ele.type == 'image'
const file = tempFiles[0];
if (file.type == 'video') { // 上传微信文件的图片
let videoCount = this.data.imageBox.filter(ele => ele.type == 'video').length;
if (videoCount >= this.data.maxVideoCount) {
wx.showToast({
title: `上传视频不能超过${this.data.maxVideoCount}个`,
icon: 'none'
})
return
}
this.addVideoMethod('', {
duration: 1,
errMsg: "chooseVideo:ok",
height: 0,
size: file.size,
tempFilePath: file.path,
thumbTempFilePath: '',
width: 0
})
const videoList = tempFiles.filter(ele=>{
return ele.type == 'video'
} else if (file.type == 'image') {// 上传微信文件的视频
let imgCount = this.data.imageBox.filter(ele => ele.type == 'image').length;
if (imgCount >= this.data.maxImgCount) { // 当等于10条了不能继续添加
wx.showToast({
title: `上传图片不能超过${this.data.maxImgCount}张`,
icon: 'none'
})
console.log(imgList, 'tempFilestempFiles');
this.addImg(imgList);
videoList.forEach((ele)=>{
this.addVideoMethod(ele)
return
}
this.addImg('' , {
tempFiles: tempFiles,
errMsg: "chooseImage:ok"
});
} else {
wx.showToast({
title: '请上传图片和视频',
icon: 'none',
})
}
})
} else {
wx.showModal({
......
......@@ -177,7 +177,7 @@
<!-- 打卡出问题,去客服消息跳 H5 -->
<!-- <view class="red-text" wx:if="{{pagefrom!='morethemeindex'}}">一个作业只能打卡一次喔!</view> -->
<view class="" wx:if="{{sid != 0}}">
<sound-recording
show="{{audioStatus.show}}"
bind:addVoice="addVoice"
......@@ -186,8 +186,10 @@
bind:voiceuploadsuccess="voiceuploadsuccess"
bind:voiceuploadfail="voiceuploadfail"
role="{{recordRole}}"
sid="{{sid}}"
>
</sound-recording>
</view>
<view class="getmobiledialog common-dialog" wx:if="{{getmobiledialogshow}}">
<view class="dialog-box">
<view class="warn-text-a">请授权微信手机号,方便加入课程微信群</view>
......
......@@ -297,6 +297,12 @@ page {
/* .clock-editor-box .clock-video-box .media-box-video-item{
width: 100%;
} */
.clock-editor-box .clock-video-box .videostatus {
font-size: 12px;
white-space: nowrap;
line-height: 44rpx;
overflow: hidden;
}
.clock-editor-box .clock-video-box .videostatus.fail {
background-color: #64d3be;
color: #fff;
......@@ -306,6 +312,7 @@ page {
height: 40rpx;
bottom: 0;
z-index: 50;
font-size: 12px;
}
@keyframes progressani {
0% {
......@@ -337,6 +344,7 @@ page {
width: 100%;
text-align: center;
color: #fff;
font-size: 12px;
}
.clock-editor-box
.clock-video-box
......@@ -374,6 +382,7 @@ page {
transparent
);
-webkit-background-size: 40px 40px;
font-size: 24rpx;
background-size: 40px 40px;
float: left;
height: 100%;
......
......@@ -147,10 +147,10 @@ Page({
ext: fileType
})
}).then((data) => {
if (data.code == 200) {
const acc = data.data;
// filename = `${access.dir}${getRandomFilename(tempFiles[0].path)}`;
filename = acc.path;
console.log(filename, 'filename ');
return wxUploadFile({
url: acc.host,
formData: {
......@@ -164,6 +164,7 @@ Page({
filePath: tempFiles[0].path,
name: 'file',
})
}
}).then((res) => {
const {data} = res;
console.log(data, 'data')
......
......@@ -156,6 +156,7 @@ function wxChooseImage (data) {
resolve(res);
},
fail (err) {
console.log('wxChooseVideo错误');
reject(err);
}
})
......@@ -199,6 +200,7 @@ function wxChooseVideo(data) {
resolve(res);
},
fail (e) {
console.log('wxChooseVideo错误');
reject(e);
}
})
......@@ -215,6 +217,7 @@ function wxChooseMessageFile(data) {
resolve(res);
},
fail (e) {
console.log('wxChooseMessageFile错误');
reject(e);
}
})
......@@ -233,6 +236,19 @@ function wxGetImageInfo ({src}) {
})
})
}
function wxGetVideoInfo ({src}) {
return new Promise((resolve, reject) => {
wx.getVideoInfo({
src,
success (res) {
resolve(res)
},
fail (e) {
reject(e)
}
})
})
}
function wxSaveImageToPhotosAlbum ({filePath}) {
return new Promise((resolve, reject) => {
wx.saveImageToPhotosAlbum({
......@@ -335,5 +351,6 @@ export {
wxGetUserInfo,
wxCheckSession,
wxOpenSetting,
wxChooseMessageFile
wxChooseMessageFile,
wxGetVideoInfo
}
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