Commit cd9033c3 authored by lvtz's avatar lvtz

微官网首页

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