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

统一处理

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