Commit e448ec25 authored by lvtz's avatar lvtz

fix

parent b73648a5
......@@ -313,7 +313,8 @@ Page({
school_id: this.data.sid,
sort: 0,
course_id: this.data.courseSelect.id,
teacher_id: this.data.teacher_id
teacher_id: this.data.teacher_id,
imageBox: JSON.stringify(this.data.imageBox)
})).then((res) => {
wx.hideLoading();
if (res.code == 200) {
......@@ -774,6 +775,10 @@ Page({
addImg () { // 添加图片的操作
let imgCount = this.data.imageBox.filter(ele => ele.type == 'image').length;
if (imgCount >= this.data.maxImgCount) { // 当等于10条了不能继续添加
wx.showToast({
title: `上传图片不能超过${this.data.maxImgBoxLength}张`,
icon: 'none'
})
return
} else {
if (!this.data.imageUploaded) {
......@@ -789,19 +794,12 @@ Page({
return;
}
}
let access = {};
let filenameArr = [];
this.setData({
imageUploaded: false
})
bOssAccess({
school_id: this.data.sid
}).then((acc) => {
access = acc.data;
return wxChooseImage({
count: this.data.maxImgCount - imgCount
})
}).then((res) => {
wxChooseImage({
count: this.data.maxImgBoxLength - imgCount
}).then(res=>{
const {tempFiles} = res;
let imageBox = this.data.imageBox;
this.setData({
......@@ -828,47 +826,64 @@ Page({
this.setData({
imageBox: res.imageBox,
})
this.singleUploadFile(access)
this.singleUploadFile()
}).catch((e) => {
wx.hideLoading()
})
},
singleUploadFile(access) {
singleUploadFile() {
console.log(333)
wx.showLoading({
title: `图片上传中`,
mask: true
})
let currentIndex = this.data.currentIndex;
let imageBox = this.data.imageBox;
if (this.data.currentIndex == (imageBox.length)) {
if (currentIndex >= imageBox.length) {
this.setData({
imageUploaded: true
currentIndex: 0,
imageUploaded: true,
})
wx.showToast({
title: `上传成功`
})
return;
}
let filename = `${access.dir}${getRandomFilename(imageBox[this.data.currentIndex].src)}`;
let access = {};
imageBox[this.data.currentIndex].status = 'resolving';
this.setData({
imageBox
})
wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: imageBox[this.data.currentIndex].src,
name: 'file',
const path = imageBox[this.data.currentIndex].src;
const fileType = path.substr(path.lastIndexOf('.') + 1);
bOssAccess({
school_id: this.data.sid,
ext: fileType
}).then((acc) => {
this.imageUploaded = true
access = acc.data;
return wxUploadFile({
url: access.host,
formData: {
key: access.path,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: imageBox[this.data.currentIndex].src,
name: 'file',
})
}).then((res) => {
let data = JSON.parse(res.data);
if (data.status == 'ok') {
imageBox[this.data.currentIndex].status = 'fullfilled';
imageBox[this.data.currentIndex].src = filename;
imageBox[this.data.currentIndex].src = access.path;
let currentIndex = this.data.currentIndex + 1;
this.setData({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
console.log(this.data.imageBox,'数据')
} else {
imageBox[this.data.currentIndex].status = 'fail';
let currentIndex = this.data.currentIndex + 1;
......@@ -876,7 +891,7 @@ Page({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
}
}).catch(() => {
imageBox[this.data.currentIndex].status = 'fail';
......@@ -885,7 +900,7 @@ Page({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
})
},
// 视频播放相关代码
......
......@@ -86,7 +86,9 @@ Component({
return new Promise((resolve, reject) => {
let query = wx.createSelectorQuery().in(this)
query.select('#card-' + card_id +'-type'+type).boundingClientRect(res => {
resolve({card_id, height: res.height})
if(res){
resolve({card_id, height: res.height})
}
})
query.exec()
})
......@@ -169,7 +171,7 @@ Component({
// 由于需要 renderList 先去前台渲染完已有 dom 节点之后再来这边计算每个卡片的高度
if (shouleRecomputeHeight) {
this.setData({renderList}, this._computeCardHeight)
return
// return
} else {
this.setData({renderList})
}
......@@ -179,7 +181,6 @@ Component({
// 暴露点击卡片事件给用户
onBrickItemTap(e){
const {cardId} = e.currentTarget.dataset;
// console.log(cardId,this.properties.type)
this.triggerEvent('tapCard',{cardId,type: this.properties.type})
},
}
......
......@@ -39,7 +39,7 @@
<image
class="video-poster"
src="{{filter.jpgvideoPoster(playitem.content, 'image/resize,w_400/format,jpg')}}"
mode="widthFix"
mode="aspectFit"
lazy-load="false"
binderror=""
bindload=""
......@@ -58,7 +58,7 @@
<image class="video-play-icon" src="{{imageRoot}}2c/websiteindex/bigplay.png?{{imageVersion}}" ></image>
</view>
</view>
<image src="{{filter.imagify(playitem.content)}}" mode="aspeptFit" class="slide-image" style="height:100vh; width: 100%" wx:if="{{playitem.type=='1'}}"></image>
<image src="{{filter.imagify(playitem.content)}}" mode="aspectFit" class="slide-image" style="height:100vh; width: 100%" wx:if="{{playitem.type=='1'}}"></image>
</swiper-item>
</block>
</swiper>
......
......@@ -620,37 +620,25 @@ Page({
const _currentIndex = this.data.currentIndex;
const _innerCurrent = this.data.innerCurrent
this.data.preVideoId = this.data.currentVideoId;
if (_playList[current].type == 2) {
// wx.showLoading({
// title: '加载中',
// })
// setTimeout(()=>{wx.hideLoading()}, 3000);
}
if( this.data.preVideoId ){
this.videoContext = wx.createVideoContext(this.data.preVideoId);
this.videoContext.stop();
}
this.data.currentVideoId = "video" + current;
this.videoContext = wx.createVideoContext(this.data.currentVideoId);
this.videoContext.play();
if (current + 1 == this.data.playList.length) {
this.data.preLoadVideoSrc = this.data.playList[0].type == 2 ? JSON.parse(this.data.playList[0].content)[0]: '';
const currentPlayItemContent = JSON.parse(this.data.playList[current].content);
if (currentPlayItemContent[this.data.innerCurrent[`${current}`] || 0].type == 'video') {
this.data.currentVideoId = `video_${current}_${this.data.innerCurrent[`${current}`] || 0}`;
this.videoContext = wx.createVideoContext(this.data.currentVideoId);
this.videoContext.play();
} else {
this.data.preLoadVideoSrc = this.data.playList[current + 1].type == 2 ? JSON.parse(this.data.playList[current + 1].content)[0] : '';
this.data.currentVideoId = '';
}
this.setData({
[`innerCurrent[${current}]`]:_innerCurrent[current]?_innerCurrent[current]:0,
currentIndex: current,
currentPlayItem: _playList[current],
emptyPage:true,
preLoadVideoSrc: this.data.preLoadVideoSrc
})
const visitor = LocalStorage.getItem('visitor');
// currentIndex
// let
// if (current + 1 < playList) {
// }
dataconsumer({
type: 3,
source_type: 2,
......@@ -685,25 +673,25 @@ Page({
if(this.data.crt){
_currentInit = Number(this.data.crt)
}
if (_currentInit + 1 == data.list.length) {
this.data.preLoadVideoSrc = data.list[0].type == 2 ? JSON.parse(data.list[0].content)[0]: '';
} else {
this.data.preLoadVideoSrc = data.list[_currentInit + 1].type == 2 ? JSON.parse(data.list[_currentInit + 1].content)[0] : '';
}
// if (_currentInit + 1 == data.list.length) {
// this.data.preLoadVideoSrc = data.list[0].type == 2 ? JSON.parse(data.list[0].content)[0]: '';
// } else {
// this.data.preLoadVideoSrc = data.list[_currentInit + 1].type == 2 ? JSON.parse(data.list[_currentInit + 1].content)[0] : '';
// }
this.setData({
playList: data.list,
currentInit:_currentInit,
currentIndex:_currentInit,
currentPlayItem: data.list[_currentInit],
preLoadVideoSrc: this.data.preLoadVideoSrc,
// preLoadVideoSrc: this.data.preLoadVideoSrc,
}, () => {
console.log(this.data.playList,'playList')
if(this.data.currentPlayItem.type==2){
const currentPlayItemContent = JSON.parse(this.data.currentPlayItem.content);
if(currentPlayItemContent[0] && currentPlayItemContent[0].type == 'video'){
wx.showLoading({
title: '加载中',
})
setTimeout(()=>{wx.hideLoading()}, 3000);
this.data.currentVideoId = "video" + _currentInit;
this.data.currentVideoId = `video_${_currentInit}_0`;
this.videoContext = wx.createVideoContext(this.data.currentVideoId);
this.videoContext.play();
}
......@@ -793,14 +781,21 @@ Page({
clickVideo(e){
const id = e.currentTarget.dataset.id;
var videoContext = wx.createVideoContext(this.data.currentVideoId);
this.data.videoStatus[id] = {
isplay: this.data.videoStatus[id].isplay || false,
isClick:true
if (this.data.videoStatus[this.data.currentVideoId]){
this.data.videoStatus[this.data.currentVideoId] = {
isplay: this.data.videoStatus[this.data.currentVideoId].isplay || false,
isClick:true
}
} else {
this.data.videoStatus[this.data.currentVideoId] = {
isplay: true,
isClick: true
}
}
this.setData({
videoStatus:this.data.videoStatus
})
if(this.data.videoStatus[id].isplay){
if(this.data.videoStatus[this.data.currentVideoId].isplay){
videoContext.pause();
}else{
videoContext.play()
......@@ -810,9 +805,9 @@ Page({
const id = e.currentTarget.dataset.id;
const _id = 'video'+this.data.currentIndex;
if(id==_id){
this.data.videoStatus[id] = {
this.data.videoStatus[this.data.currentVideoId] = {
isplay:true,
isClick: this.data.videoStatus[id] ? (this.data.videoStatus[id].isClick || false) : false
isClick: this.data.videoStatus[this.data.currentVideoId] ? (this.data.videoStatus[this.data.currentVideoId].isClick || false) : false
}
this.setData({
videoStatus:this.data.videoStatus
......@@ -820,9 +815,9 @@ Page({
}else{
var videoContext = wx.createVideoContext(id);
videoContext.stop();
this.data.videoStatus[id] = {
this.data.videoStatus[this.data.currentVideoId] = {
isplay:false,
isClick: this.data.videoStatus[id] ? (this.data.videoStatus[id].isClick || false) : false
isClick: this.data.videoStatus[this.data.currentVideoId] ? (this.data.videoStatus[this.data.currentVideoId].isClick || false) : false
}
this.setData({
videoStatus:this.data.videoStatus
......@@ -832,9 +827,9 @@ Page({
},
bindpause(e){
const id = e.currentTarget.dataset.id;
this.data.videoStatus[id] = {
this.data.videoStatus[this.data.currentVideoId] = {
isplay:false,
isClick: this.data.videoStatus[id] ? (this.data.videoStatus[id].isClick || false) : false
isClick: this.data.videoStatus[this.data.currentVideoId] ? (this.data.videoStatus[this.data.currentVideoId].isClick || false) : false
}
this.setData({
videoStatus:this.data.videoStatus
......@@ -884,10 +879,28 @@ Page({
current,
source
} = e.detail;
this.data.preVideoId = this.data.currentVideoId;
const playList = this.data.playList;
const currentPlayItemContent = JSON.parse(playList[this.data.currentIndex].content);
const index = e.currentTarget.dataset.index
const innerCurrent = {};
if( this.data.preVideoId ){
console.log(this.data.preVideoId, 'this.data.preVideoId');
this.videoContext = wx.createVideoContext(this.data.preVideoId);
this.videoContext.stop();
}
if (currentPlayItemContent[current].type == 'video') {
this.data.currentVideoId = `video_${this.data.currentIndex}_${current}`;
console.log(this.data.currentVideoId, 'this.data.currentVideoId');
this.videoContext = wx.createVideoContext(this.data.currentVideoId);
this.videoContext.play();
} else {
this.data.currentVideoId = '';
}
this.setData({
[`innerCurrent[${index}]`]:current,
currentVideoId: this.data.currentVideoId,
preVideoId: this.data.preVideoId
})
},
})
\ No newline at end of file
......@@ -137,17 +137,17 @@
show-center-play-btn="{{false}}"
controls="{{false}}"
data-type="{{playitem.type}}"
data-id="video{{playindex}}"
id="video{{playindex}}"
id="video_{{playindex}}_{{index}}"
autoplay="{{false}}"
poster="{{filter.videoPoster(item.value, 'image/resize,w_400/format,jpg')}}"
wx-if="{{playindex == currentIndex || (playindex == currentIndex + 1)}}"
data-id="video{{playindex}}"
>
</video>
<image
class="video-poster"
src="{{filter.jpgvideoPoster(item.value, 'image/resize,w_400/format,jpg')}}"
mode="widthFix"
mode="aspectFit"
lazy-load="false"
binderror=""
bindload=""
......@@ -161,12 +161,12 @@
data-id="video{{playindex}}"
id="video{{playindex}}"
poster="{{filter.videoPoster(item.value)}}"
wx:if="{{item.type=='video' &&!videoStatus['video'+playindex].isplay}}"
wx:if="{{item.type=='video' &&!videoStatus['video_'+playindex + '_' + index].isplay}}"
>
<image class="video-play-icon" src="{{imageRoot}}2c/websiteindex/bigplay.png?{{imageVersion}}" ></image>
</view>
</view>
<image src="{{filter.imagify(item.value)}}" mode="aspeptFit" class="slide-image" style="height:100vh; width: 100%" wx:if="{{item.type=='img'}}"></image>
<image src="{{filter.imagify(item.value)}}" mode="aspectFit" class="slide-image" style="height:100vh; width: 100%" wx:if="{{item.type=='img'}}"></image>
</swiper-item>
</swiper>
</swiper-item>
......
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