提交 1d2f85fa 编写于 作者: guangjun.yang's avatar guangjun.yang

统一处理

上级 fdc289c5
......@@ -8,12 +8,12 @@ module.exports = {
}
},
created: function () {
// let query = this.$router.query
// let query = this.$router.query
// this.token = this.getUrlSearch(location.href, 'token') || (query && query.token) || null
// this.token = this.getUrlKey('token') || (query && query.token) || null
// this.token = this.getUrlKey('token') || (query && query.token) || null
},
mounted: function() {
mounted: function () {
},
methods: {
getUrlPara(obj) {
......@@ -31,12 +31,12 @@ module.exports = {
return ''
},
setRouterParm(paramList){
setRouterParm(paramList) {
let parm = {};
if(paramList.length<=1){
if (paramList.length <= 1) {
return '';
}
for(let i=1;i<paramList.length;i++){
for (let i = 1; i < paramList.length; i++) {
parm[paramList[i].key] = paramList[i].value;
}
return parm;
......@@ -44,12 +44,12 @@ module.exports = {
// 拼接多个参数
getUrlParmByCode(paramList) {
if ( paramList.length <= 1) {
if (paramList.length <= 1) {
return ''
}
let dataStr = ''
let list = [];
for( let i = 1; i < paramList.length; i ++) {
for (let i = 1; i < paramList.length; i++) {
list.push(paramList[i].key + '=' + paramList[i].value)
}
dataStr = list.join('&')
......@@ -68,7 +68,7 @@ module.exports = {
// 根据条件排序
async searchForOrder(searchCategory = '1', searchValue = '', sortItem = 1, pageSize = 10, sourceData = []) {
if(pageSize <=0 ) return;
if (pageSize <= 0) return;
let str2 = (searchValue || '').replace(/[\-\_\,\!\|\~\`\(\)\#\$\%\^\&\*\{\}\:\;\"\L\<\>\?]/g, '');// 去掉特殊字符
let _this = this,
para = {
......@@ -82,22 +82,22 @@ module.exports = {
setEntry: 'headers',
}
let url = 'contents/searchKeyword/searchContent'
let csourceData = await this.GET(url, para).then(res => {
// _this.searchText = ''
if (res.code == '000000') {
// 课程
if(searchCategory.indexOf('1') >= 0) {
if (searchCategory.indexOf('1') >= 0) {
sourceData = (res.data && res.data.contentAppModels) || []
}
if(searchCategory.indexOf('2') >= 0) {
if (searchCategory.indexOf('2') >= 0) {
// sourceData = []
sourceData = this.handelFive(res.data.fiveMinutesMedicalContentList || [])
}
if(searchCategory.indexOf('3') >= 0) {
if (searchCategory.indexOf('3') >= 0) {
sourceData = (res.data && res.data.pCourseDoctorModels) || []
}
if(searchCategory.indexOf('4') >= 0) {
if (searchCategory.indexOf('4') >= 0) {
sourceData = res.data.educationContents
}
}
......@@ -105,18 +105,18 @@ module.exports = {
})
return csourceData
},
setEventByModuleCode(itemData){
setEventByModuleCode(itemData) {
let modeCode = itemData.appModuleInfo.code || '';
let paramList = itemData.appModuleInfo.paramList ? itemData.appModuleInfo.paramList : ''
if( modeCode === 'M001' || modeCode === 'M002' || modeCode === 'M003') {
if (modeCode === 'M001' || modeCode === 'M002' || modeCode === 'M003') {
paramList = ''
}else if( modeCode === 'M100' || modeCode === 'M300' ) {
} else if (modeCode === 'M100' || modeCode === 'M300') {
// 支持多个参数
let urlPara = this.getUrlParmByCode(paramList);
if(paramList[0]){
if( paramList[0].value.indexOf("?") == -1){
if (paramList[0]) {
if (paramList[0].value.indexOf("?") == -1) {
paramList[0].value += urlPara
}
}
......@@ -126,25 +126,25 @@ module.exports = {
let v = paramList[0]['value'];
let query = this.setRouterParm(paramList);
paramList = [{
url:v,
query:query
url: v,
query: query
}]
this.$router.push({
path: v,
query: query
})
//alert(this.token);
return 'NO'
return 'NO'
}
if(typeof paramList === 'string' && !paramList){
if (typeof paramList === 'string' && !paramList) {
paramList = []
}
return paramList;
},
// 通用GET请求
GET(api, para, callback,str) {
// para.token = para.token || this.token || "343BCABC890349ACAF357FA79122F9FE"
GET(api, para, callback, str) {
// para.token = para.token || this.token || "343BCABC890349ACAF357FA79122F9FE"
let url = api + this.getUrlPara(para)
url = encodeURI(url);
return fetch({
......@@ -155,7 +155,7 @@ module.exports = {
},
// 通用DELETE请求
DELETE(api, para, callback,str) {
DELETE(api, para, callback, str) {
// para.token = para.token || this.token || "343BCABC890349ACAF357FA79122F9FE"
let url = api + this.getUrlPara(para)
return fetch({
......@@ -174,17 +174,17 @@ module.exports = {
data: para
})
},
// 通用POST请求
PUT(api, para, callback) {
// para.token = para.token || this.token || "343BCABC890349ACAF357FA79122F9FE"
return fetch({
url: getBaseUrl(api),
method: 'put',
data: para
})
},
// 通用POST请求
PUT(api, para, callback) {
// para.token = para.token || this.token || "343BCABC890349ACAF357FA79122F9FE"
return fetch({
url: getBaseUrl(api),
method: 'put',
data: para
})
},
// 从html参数
getUrlKey(name) {
if (decodeURIComponent && location.href) {
......@@ -208,7 +208,48 @@ module.exports = {
}
}
return null
}
},
// 图片处理-新
imgSizeHandleNew(item, imgWidth, imgHeight) {
let lw, lh, newW, newH, imgProportion = (imgWidth / imgHeight).toFixed(1);
if (imgProportion > 0.6) {
if (imgWidth > 192) {
lw = 192;
lh = (imgHeight * lw) / imgWidth;
} else if (imgWidth <= 192) {
lw = imgWidth;
lh = imgHeight;
}
} else if (imgProportion == 0.6) {
if (imgHeight > 320) {
lh = 320;
} else {
lh = imgHeight;
}
lw = lh * 0.6;
} else {
if (imgHeight > 320) {
lh = 320;
lw = (imgWidth * lh) / imgHeight;
} else if (imgHeight <= 320) {
lh = imgHeight;
lw = imgWidth;
}
}
if (lh < 32 && lh < lw) {
newH = 32;
newW = (lw * 32) / lh;
} else if (lw < 32 && lw < lh) {
newW = 32;
newH = (lh * 32) / lw;
} else {
newH = lh;
newW = lw;
}
item.newW = newW;
item.newH = newH;
},
}
}
......@@ -17,12 +17,6 @@
alt
/>
</div>
<!-- <img-size
:imgUrl="item.url"
:imgData="item"
:index="index"
@imgHandle="imgHandle"></img-size> -->
</div>
<div v-if="item.type == 2" class="file-content">
<div class="file-con" @click="openPDF(item.url)">
......@@ -101,49 +95,6 @@ export default {
this.$set(this.detailData.contentModelList[data.index], 'newH', data.height)
},
// 图片处理-新
imgSizeHandleNew(item, imgWidth, imgHeight) {
let lw, lh, newW, newH, imgProportion = (imgWidth / imgHeight).toFixed(1);
if (imgProportion > 0.6) {
if (imgWidth > 192) {
lw = 192;
lh = (imgHeight * lw) / imgWidth;
} else if (imgWidth <= 192) {
lw = imgWidth;
lh = imgHeight;
}
} else if (imgProportion == 0.6) {
if (imgHeight > 320) {
lh = 320;
} else {
lh = imgHeight;
}
lw = lh * 0.6;
} else {
if (imgHeight > 320) {
lh = 320;
lw = (imgWidth * lh) / imgHeight;
} else if (imgHeight <= 320) {
lh = imgHeight;
lw = imgWidth;
}
}
if (lh < 32 && lh < lw) {
newH = 32;
newW = (lw * 32) / lh;
} else if (lw < 32 && lw < lh) {
newW = 32;
newH = (lh * 32) / lw;
} else {
newH = lh;
newW = lw;
}
item.newW = newW;
item.newH = newH;
// this.$set(item, "newW", newW);
// this.$set(item, "newH", newH);
},
// 下载目标文件
downFile() {
let a = document.createElement('a');
......@@ -192,18 +143,6 @@ export default {
max-height: 320px;
overflow: hidden;
}
// .img-box {
// max-width: 192px;
// max-height: 320px;
// overflow: hidden;
// // & > img {
// // // width: 170px;
// // // height: 108px;
// // border-radius: 8px;
// // }
// }
}
.file-content {
padding: 16px 0;
......
......@@ -103,13 +103,7 @@
alt
/>
</div>
<!-- <img-size
:imgUrl="item.url"
:imgData="item"
:index="index"
@imgHandle="imgHandle"
></img-size>-->
</div>
</div>
<div v-if="item.showType == 3" class="mid-pdf" @click="openPDF(item)">
<div class="midp-left">
<span class="name">{{item.text | shortName(23)}}</span>
......@@ -1111,49 +1105,6 @@ export default {
this.$set(item, "newW", newW);
this.$set(item, "newH", newH);
},
// 图片处理-新
imgSizeHandleNew(item, imgWidth, imgHeight) {
let lw, lh, newW, newH, imgProportion = (imgWidth / imgHeight).toFixed(1);
if (imgProportion > 0.6) {
if (imgWidth > 192) {
lw = 192;
lh = (imgHeight * lw) / imgWidth;
} else if (imgWidth <= 192) {
lw = imgWidth;
lh = imgHeight;
}
} else if (imgProportion == 0.6) {
if (imgHeight > 320) {
lh = 320;
} else {
lh = imgHeight;
}
lw = lh * 0.6;
} else {
if (imgHeight > 320) {
lh = 320;
lw = (imgWidth * lh) / imgHeight;
} else if (imgHeight <= 320) {
lh = imgHeight;
lw = imgWidth;
}
}
if (lh < 32 && lh < lw) {
newH = 32;
newW = (lw * 32) / lh;
} else if (lw < 32 && lw < lh) {
newW = 32;
newH = (lh * 32) / lw;
} else {
newH = lh;
newW = lw;
}
item.newW = newW;
item.newH = newH;
// this.$set(item, "newW", newW);
// this.$set(item, "newH", newH);
}
},
beforeDestroy() {
......
......@@ -21,15 +21,9 @@
<div>{{item.content}}</div>
</div>
<div v-if="item.type == 'PICTURE'" class="img-content" v-viewer>
<!-- <img :src="item.content.url" /> -->
<div class="img-box">
<img :src="item.content.url" :style="{width: item.newW + 'px', height: item.newH + 'px'}"/>
</div>
<!-- <img-size
:imgUrl="item.content.url"
:imgData="item"
:index="index"
@imgHandle="imgHandle"></img-size> -->
</div>
<div v-if="item.type == 'CUSTOM'">
<div v-if="item.content.bizType == 18" class="file-content">
......@@ -231,48 +225,6 @@ export default {
});
return data;
},
// 图片处理-新
imgSizeHandleNew(item, imgWidth, imgHeight) {
let lw, lh, newW, newH, imgProportion = (imgWidth / imgHeight).toFixed(1);
if (imgProportion > 0.6) {
if (imgWidth > 192) {
lw = 192;
lh = (imgHeight * lw) / imgWidth;
} else if (imgWidth <= 192) {
lw = imgWidth;
lh = imgHeight;
}
} else if (imgProportion == 0.6) {
if (imgHeight > 320) {
lh = 320;
} else {
lh = imgHeight;
}
lw = lh * 0.6;
} else {
if (imgHeight > 320) {
lh = 320;
lw = (imgWidth * lh) / imgHeight;
} else if (imgHeight <= 320) {
lh = imgHeight;
lw = imgWidth;
}
}
if (lh < 32 && lh < lw) {
newH = 32;
newW = (lw * 32) / lh;
} else if (lw < 32 && lw < lh) {
newW = 32;
newH = (lh * 32) / lw;
} else {
newH = lh;
newW = lw;
}
item.newW = newW;
item.newH = newH;
// this.$set(item, "newW", newW);
// this.$set(item, "newH", newH);
},
// 时间格式转换
timeChange(data) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册