Commit cd9033c3 authored by lvtz's avatar lvtz

微官网首页

parent 80a0d76d
......@@ -165,37 +165,35 @@ Page({
// })
// },
updateAvatar(e) {
let access = {};
let tempFiles = null;
let filename = '';
bOssAccess({
school_id: this.data.sid != 0 ? this.data.sid : this.data.school_id
}).then((acc) => {
access = acc.data;
return wxChooseImage({})
}).then((res) => {
const { tempFiles } = res;
filename = `${access.dir}${getRandomFilename(tempFiles[0].path)}`;
wx.showLoading({
title: '图片上传中'
wxChooseImage({}).then((res) => {
tempFiles = res.tempFiles;
const path = tempFiles[0].path;
const fileType = path.substr(path.lastIndexOf('.') + 1);
return bOssAccess({
school_id: this.data.sid != 0 ? this.data.sid : this.data.school_id,
ext: fileType
})
}).then((data) => {
const acc = data.data;
filename = acc.path;
return wxUploadFile({
url: "https://cdn.s.shangjiadao.cn",
url: acc.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
policy: acc.policy,
OSSAccessKeyId: acc.accessid,
signature: acc.signature,
callback: acc.callback,
success_action_status: '200'
},
filePath: tempFiles[0].path,
name: 'file',
})
}).then((res) => {
const { data } = res;
const {data} = res;
if (data == '{"status":"ok"}') {
// wx.showToast({
// title: '上传成功'
// })
this.setData({
'avatarUrl': filename
},()=>{
......@@ -221,10 +219,9 @@ Page({
})
}
}).catch((err) => {
});
},
//选择学科
selectSubject(event) {
const subject = event.currentTarget.dataset.activeItem;
......@@ -261,54 +258,57 @@ Page({
.catch(e => {});
},
proMainImgUpload(e) {
let access = {};
let filename = "";
let tempFiles = null;
let filename = '';
const { type } = e.currentTarget.dataset;
bOssAccess({
school_id: this.data.sid
})
.then(acc => {
access = acc.data;
return wxChooseImage({});
wxChooseImage({}).then((res) => {
tempFiles = res.tempFiles;
const path = tempFiles[0].path;
const fileType = path.substr(path.lastIndexOf('.') + 1);
return bOssAccess({
school_id: this.data.sid,
ext: fileType
})
.then(res => {
const { tempFiles } = res;
filename = `${access.dir}${getRandomFilename(tempFiles[0].path)}`;
return wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: "200"
},
filePath: tempFiles[0].path,
name: "file"
});
})
.then(res => {
const { data } = res;
if (data == '{"status":"ok"}') {
this.setData({
uploadType: type,
cropperSrc: imagify(filename, "image/resize,w_1280/format,jpg"),
"cropperOpt.width": 300,
"cropperOpt.height": 300,
showCropper: true,
containerheight: "100vh"
});
} else {
wx.hideLoading();
wx.showModal({
title: "提示",
content: "上传失败",
showCancel: false
});
}
}).then((data) => {
const acc = data.data;
filename = acc.path;
return wxUploadFile({
url: acc.host,
formData: {
key: filename,
policy: acc.policy,
OSSAccessKeyId: acc.accessid,
signature: acc.signature,
callback: acc.callback,
success_action_status: '200'
},
filePath: tempFiles[0].path,
name: 'file',
})
.catch(err => {});
}).then((res) => {
const {data} = res;
console.log(data, 'data')
if (data == '{"status":"ok"}') {
this.setData({
// uploadType: type,
cropperSrc: imagify(filename, 'image/resize,w_1280/format,jpg'),
showCropper: true,
"cropperOpt.width": 300,
"cropperOpt.height": 300,
containerheight: "100vh"
})
} else {
wx.hideLoading();
wx.showModal({
title: '提示',
content: '上传失败',
showCancel: false
})
}
}).catch((err) => {
});
},
surecropper() {
this.cropper = this.selectComponent("#image-cropper");
......@@ -323,60 +323,57 @@ Page({
},
clickcut(e) {
let filepath = e.detail.url;
const fileType = filepath.substr(filepath.lastIndexOf('.') + 1);
let fileName = '';
this.setData({
showCropper: false,
cropperSrc: "",
containerheight: ""
});
let filename = "";
bOssAccess({
school_id: this.data.sid
})
.then(acc => {
return acc.data;
school_id: this.data.sid,
ext: fileType
}).then((res) => {
const access = res.data;
wx.showLoading({
title: '图片上传中'
})
.then(access => {
filename = `${access.dir}${getRandomFilename(filepath)}`;
wx.showLoading({
title: "图片上传中"
fileName = access.path;
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: filepath,
name: "file"
});
}).then(res => {
const { data } = res;
if (data == '{"status":"ok"}') {
wx.showToast({
title: "上传成功"
});
return wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: "200"
},
filePath: filepath,
name: "file"
this.setData({
showCropper: false
});
})
.then(res => {
const { data } = res;
if (data == '{"status":"ok"}') {
wx.showToast({
title: "上传成功"
});
this.setData({
showCropper: false
});
this.mycropper = null;
this.setData({
"params.logo": filename
});
} else {
wx.hideLoading();
wx.showModal({
title: "提示",
content: "上传失败",
showCancel: false
});
}
})
.catch(err => {});
this.mycropper = null;
this.setData({
"params.logo": fileName
});
} else {
wx.hideLoading();
wx.showModal({
title: "提示",
content: "上传失败",
showCancel: false
});
}
}).catch(err => {});
},
titleInput(e) {
const { value } = e.detail;
......
......@@ -89,6 +89,7 @@ Component({
uploadingIndex: 0,
imageArrBox: [],
iosPhoneWarn: false,
imageUploaded: true,
},
created () {
console.log(this.data.content, 'this.data.content')
......@@ -132,86 +133,153 @@ Component({
})
})
},
addImg (tempFiles) { // 添加图片的操作
if (this.data.maxImgBoxLength == this.data.imgBoxLength) { // 当等于10条了不能继续添加
addImg (tempFiles1) { // 添加图片的操作
// let imgCount = this.data.imageArrBox.filter(ele => ele.type == 'img').length;
let imgCount = this.data.imageArrBox.length;
console.log(imgCount ,this.data.imageArrBox,this.data.maxImgBoxLength,this.data.imageUploaded)
if (imgCount >= this.data.maxImgBoxLength) { // 当等于10条了不能继续添加
return
} else {
if (!this.data.imageUploaded) {
this.setData({
showtip: true
}, () => {
setTimeout(() => {
this.setData({
showtip: false
})
}, 500)
})
return;
}
}
// if (this.data.maxImgBoxLength == this.data.imgBoxLength) { // 当等于10条了不能继续添加
// return
// }
let access = {};
let filename = '';
let fileNameArr = [];
bOssAccess({
school_id:this.data.sid
}).then((acc) => {
access = acc.data;
if(!tempFiles.currentTarget){
return {tempFiles,};
}
return wxChooseImage({
count: this.data.maxImgBoxLength - this.data.imgBoxLength > 9 ? 9 : this.data.maxImgBoxLength - this.data.imgBoxLength
})
this.setData({
imageUploaded: false
})
wxChooseImage({
count: this.data.maxImgBoxLength - this.data.imgBoxLength > 9 ? 9 : this.data.maxImgBoxLength - this.data.imgBoxLength
}).then((res) => {
const {tempFiles} = res;
let imageArrBox = this.data.imageArrBox;
tempFiles.forEach((ele, index) => {
imageArrBox.push(ele.path)
this.setData({
uploadingIndex: imageArrBox.length
})
tempFiles.forEach((ele) => {
console.log(ele,'元素')
if (this.data.imgBoxLength <= this.data.maxImgBoxLength) {
imageArrBox.push(ele.path)
}
})
console.log(imageArrBox,'imageArrBox')
return {
imageArrBox
}
}, () => {
this.setData({
imageUploaded: true
})
return imageArrBox;
}).then((res) => {
this.setData({
imageArrBox: res,
})
this.singleUploadFile(access);
}).catch((err) => {
this.setData({
imageArrBox: res.imageArrBox,
})
this.singleUploadFile()
}).catch((e) => {
wx.hideLoading()
})
// bOssAccess({
// school_id:this.data.sid
// }).then((acc) => {
// access = acc.data;
// if(!tempFiles.currentTarget){
// return {tempFiles,};
// }
// return wxChooseImage({
// count: this.data.maxImgBoxLength - this.data.imgBoxLength > 9 ? 9 : this.data.maxImgBoxLength - this.data.imgBoxLength
// })
// }).then((res) => {
// const {tempFiles} = res;
// let imageArrBox = this.data.imageArrBox;
// tempFiles.forEach((ele, index) => {
// imageArrBox.push(ele.path)
// })
// return imageArrBox;
// }).then((res) => {
// this.setData({
// imageArrBox: res,
// })
// this.singleUploadFile(access);
// }).catch((err) => {
});
// });
},
singleUploadFile(access) {
singleUploadFile() {
wx.showLoading({
title: `图片上传中`,
mask: true
})
let uploadingIndex = this.data.uploadingIndex;
if (uploadingIndex == this.data.imageArrBox.length) {
if (uploadingIndex >= this.data.imageArrBox.length) {
this.setData({
uploadingIndex: 0,
imageArrBox: []
imageArrBox: [],
imageUploaded: true
})
wx.showToast({
title: `上传成功`
})
return;
}
wx.showLoading({
title: `图片上传中`,
mask: true
})
let access = {};
let imageArrBox = JSON.parse(JSON.stringify(this.data.imageArrBox));
let filename = `${access.dir}${getRandomFilename(imageArrBox[uploadingIndex])}`;
wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: imageArrBox[uploadingIndex],
name: 'file',
}).then((res) => {
const path = imageArrBox[this.data.uploadingIndex];
// console.log(imageArrBox,path,'path',this.data.uploadingIndex)
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: imageArrBox[this.data.uploadingIndex],
name: 'file',
})
}).then((res) =>{
let data = JSON.parse(res.data);
console.log(res,'结果')
if (data.status == 'ok') { // 成功的处理
wx.showToast({
title: `上传成功`
})
let uploadingIndex = this.data.uploadingIndex + 1;
// wx.showToast({
// title: `上传成功`
// })
console.log(res,'resasasasdasdadsasd')
let content = JSON.parse(JSON.stringify(this.data.content));
let uploadingIndex = this.data.uploadingIndex + 1;
content.push({
type: 'img',
value: filename
value: access.path
})
console.log(content,'content')
this.setData({
content,
uploadingIndex,
}, () => {
this.setData({
imgBoxLength: this.countCaculate('img', this.data.content),
......@@ -238,6 +306,7 @@ Component({
})
this.singleUploadFile(access);
})
},
addVoice () { // 添加录音的操作
if (this.data.maxVoiceBoxLength == this.data.voiceBoxLength) { // 当等于10条了不能继续添加
......
......@@ -335,9 +335,8 @@ const apis = {
verifyCode: `${constants.host2}/v2/api/service/user/verify_code`,
resetPassword: `${constants.host2}/v2/api/service/user/reset_password`,
register: `${apiv2}member/register`,
memberOssAccess: `${api}member/oss/access`,
bOssAccess: `${api}member/clock/oss/access`,
bMediaOssAccess: `${api}member/media_access`,
bOssAccess: `${apiv4}member/oss/access`,
bMediaOssAccess: `${apiv4}member/media_access`,
generateBusinessQrcode: `${api}common/qr_code_unlimit`,
generateCustomerQrcode: `${api}common/qr_code_unlimit`,
updateUserinfo: `${api}member/clock/userinfo/edit`,
......
......@@ -8,7 +8,7 @@ import apis from '../../constants/api.js';
function bOssAccess (data) {
return wxRequest({
role: '2b',
url: apis.business.common.memberOssAccess,
url: apis.business.common.bOssAccess,
data,
method: 'GET',
errorresolve: 1,
......
......@@ -95,10 +95,11 @@ function lastReply({class_id}) {
function bOssAccess (data) {
return wxRequest({
role: '2b',
url: apis.business.common.memberOssAccess,
url: apis.business.common.bOssAccess,
data,
method: 'GET',
errorresolve: 1,
needToken: true
})
}
function bMediaOssAccess (data) {
......
......@@ -46,7 +46,6 @@ Component({
if (!Array.isArray(newVal)) {
throw new Error('BrickLayout : dataSet is expecting a Array.')
}
newVal.forEach(item => {
if (!item['id']) {
throw new Error('BrickLayout : 错误的唯一索引。请检查数组中是否含有 id 作为唯一记录标识。')
......
......@@ -5,13 +5,13 @@
<view wx:for="{{renderList}}" wx:key="index" wx:for-item="column" class="list-side-box">
<view wx:for="{{column}}" wx:key="item" class="list-item" id="card-{{item}}-type{{type}}">
<view class="list-item-inner" data-card-id="{{rawData[item].id}}" bindtap="onBrickItemTap">
<image class="video-image" src="{{filter.imagify(filter.jsonParse(rawData[item].content)[0])}}" wx:if="{{rawData[item].type==1}}" mode="widthFix"></image>
<image class="video-image" src="{{filter.gifvideoPoster(filter.jsonParse(rawData[item].content)[0])}}" wx:else mode="widthFix"></image>
<view class="top-fix" wx:if="{{rawData[item].type==1}}">
<image class="video-image" src="{{filter.gifvideoPoster(filter.jsonParse(rawData[item].content)[0].value)}}" wx:if="{{filter.jsonParse(rawData[item].content)[0].type=='video'}}" mode="widthFix"></image>
<image class="video-image" src="{{filter.imagify(filter.jsonParse(rawData[item].content)[0].value)}}" wx:else mode="widthFix" ></image>
<!-- <view class="top-fix" wx:if="{{rawData[item].type==1}}">
<image class="icon-imglabel" src="{{imageRoot}}2c/websiteindex/img.png?{{imageVersion}}"></image>
</view>
</view> -->
<view class="item-content">
<view class="item-title">{{rawData[item].title}}</view>
<view class="item-title">{{rawData[item].title}} {{filter.jsonParse(rawData[item].content)[0].type}}</view>
<view class="item-info" wx:if="{{type!=1}}">
<image class="avatar" src="{{filter.imagify(rawData[item].school_teacher.avatar, 'image/resize,w_160/format,jpg')}}" wx:if="{{rawData[item].school_teacher.avatar}}"></image>
<image class="avatar" src="https://cdn.img.shangjiadao.cn/qingxiao/biz/image/defaultavatar.png" wx:else></image>
......
......@@ -14,18 +14,15 @@
.list-item {
break-inside: avoid;
box-sizing: border-box;
padding-bottom: 28rpx;
padding-bottom: 26rpx;
}
.list-item-inner {
position: relative;
border-radius: 10px;
box-shadow: 0 2rpx 20rpx 0 rgba(34,34,34,0.2);
background: #fff;
}
.list-item .video-image{
width: 100%;
border-radius: 10rpx 10rpx 0 0;
border-radius: 20rpx;
display: block;
}
.list-item .top-fix{
......@@ -45,36 +42,31 @@
height: 25rpx;
}
.list-item .item-content{
padding: 14rpx 19rpx 13rpx 15rpx;
}
.list-item .item-content .item-title{
font-size: 24rpx;
color: #333;
font-weight: 700;
line-height: 30rpx;
letter-spacing: 2rpx;
font-size: 26rpx;
color: #666;
line-height: 40rpx;
word-break: break-all;
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
padding: 16rpx 0 10rpx;
}
.list-item .item-content .item-info{
display: flex;
align-items: center;
margin-top: 8rpx;
}
.list-item .item-content .item-info .avatar {
width: 54rpx;
height: 54rpx;
border-radius: 50%;
margin-right: 11rpx;
border: 4rpx solid orange;
margin-right: 9rpx;
}
.list-item .item-content .item-info .name {
font-size: 22rpx;
font-weight: 400;
color: #333;
color: #666;
}
\ No newline at end of file
......@@ -214,7 +214,6 @@ Page({
cropperSrc: '',
containerheight: ''
})
let filename = '';
cOssAccess({
school_id: this.data.sid,
ext: fileType
......
......@@ -460,6 +460,7 @@ Page({
this.setData({
schoolInfoList: [data.list]
})
console.log(this.data.schoolInfoList,'schoolInfoList')
}
})
},
......
This diff is collapsed.
This diff is collapsed.
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