Commit 299775af authored by 罗超's avatar 罗超

处理上传图片压缩

parent 2db9c308
......@@ -17,3 +17,4 @@ package-lock.json
*.njsproj
*.sln
yarn.lock
{
......@@ -4,7 +4,7 @@ const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
......@@ -18,9 +18,8 @@ module.exports = {
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
publicPath: process.env.NODE_ENV === 'production' ?
config.build.assetsPublicPath : config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
......@@ -30,8 +29,7 @@ module.exports = {
}
},
module: {
rules: [
{
rules: [{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
......
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>微途超级商城</title>
</head>
<body>
</head>
<body>
<div id="app"></div>
</body>
</body>
</html>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=OV7BZ-ZT3HP-6W3DE-LKHM3-RSYRV-ULFZV"></script>
\ No newline at end of file
......@@ -18,6 +18,7 @@
"echarts": "^4.8.0",
"element-ui": "^2.13.1",
"js-md5": "^0.7.3",
"lrz": "^4.9.40",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vuedraggable": "^2.23.2"
......
......@@ -8,6 +8,7 @@ import ajaxPlug from './plug/index'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import echarts from 'echarts'
import lrz from 'lrz'
import '../static/UE/ueditor.config.js'
import '../static/UE/ueditor.all.js'
......@@ -17,14 +18,14 @@ import '../static/UE/ueditor.parse.min.js'
Vue.use(ElementUI);
import commonUtils from './assets/utils/commonUtils'
Vue.commonUtils = Vue.prototype.$commonUtils=commonUtils
Vue.commonUtils = Vue.prototype.$commonUtils = commonUtils
Vue.config.productionTip = false
Vue.http = Vue.prototype.$http = axios
Vue.prototype.$echarts = echarts
Vue.use(ajaxPlug)
/* eslint-disable no-new */
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
......
......@@ -3,7 +3,7 @@ export default {
install(Vue, options) {
Vue.prototype.md5 = md5;
//消息成功提示
Vue.prototype.Success = function (msg) {
Vue.prototype.Success = function(msg) {
this.$message({
message: msg,
duration: 2000,
......@@ -11,7 +11,7 @@ export default {
});
},
//错误提示
Vue.prototype.Error = function (msg) {
Vue.prototype.Error = function(msg) {
this.$message({
message: msg,
duration: 2000,
......@@ -20,7 +20,7 @@ export default {
},
//一般提示
Vue.prototype.Info = function (msg) {
Vue.prototype.Info = function(msg) {
this.$message({
message: msg,
duration: 2000,
......@@ -28,7 +28,7 @@ export default {
});
},
//警告提示
Vue.prototype.Warning = function (msg) {
Vue.prototype.Warning = function(msg) {
this.$message({
message: msg,
duration: 2000,
......@@ -36,7 +36,7 @@ export default {
});
},
//Confirm
Vue.prototype.Confirm = function (msg, callback) {
Vue.prototype.Confirm = function(msg, callback) {
this.$confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
......@@ -52,20 +52,20 @@ export default {
});
},
//域名管理对象
Vue.prototype.domainManager = function () {
Vue.prototype.domainManager = function() {
let domainUrl = '';
let javaUrl='http://192.168.2.65:8018';
let javaUrl = 'http://192.168.2.65:8018';
domainUrl = "http://192.168.2.214:8200";
domainUrl = "http://192.168.2.65";
//domainUrl = "https://localhost:5001";
let locationName = window.location.hostname;
if (locationName.indexOf('testmall.oytour') !== -1) {
domainUrl = "https://mallapi.oytour.com";
javaUrl="http://property.oytour.com";
javaUrl = "http://property.oytour.com";
} else if (locationName.indexOf('oytour') !== -1) {
domainUrl = "https://mallapi.oytour.com";
javaUrl="http://property.oytour.com";
javaUrl = "http://property.oytour.com";
}
var obj = {
//主地址npm
......@@ -81,7 +81,7 @@ export default {
return obj;
},
//浏览器缓存
Vue.prototype.getLocalStorage = function () {
Vue.prototype.getLocalStorage = function() {
var localStorageData = window.localStorage["mall_userInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData);
......@@ -90,7 +90,7 @@ export default {
}
},
//验证只能输入2位小数【负数:isMinus传true】
Vue.prototype.checkPrice = function (item, filed, isMinus) {
Vue.prototype.checkPrice = function(item, filed, isMinus) {
var value = "" + item[filed]; //转字符串
var t = value.charAt(0);
value = value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
......@@ -108,7 +108,7 @@ export default {
item[filed] = value;
}
//验证只能输入整数【负数:isMinus传true】
Vue.prototype.checkInteger = function (item, filed, isMinus) {
Vue.prototype.checkInteger = function(item, filed, isMinus) {
var value = "" + item[filed]; //转字符串
var t = value.charAt(0);
value = value.replace(this.$commonUtils.Regex.isInteger, "");
......@@ -119,11 +119,11 @@ export default {
item[filed] = value;
},
//是否是线上环境【发布时修改为true】
Vue.prototype.isOnline = function () {
Vue.prototype.isOnline = function() {
return process.env.NODE_ENV !== 'development';
},
//文件类型数组
Vue.prototype.FileType = function () {
Vue.prototype.FileType = function() {
var fileTypeJson = {
//主地址npm
UserImg: "User", //用户相图片
......@@ -134,7 +134,26 @@ export default {
return fileTypeJson;
},
//上传文件到云存储
Vue.prototype.UploadFileToTencent = function (path, fileObj, callback) {
Vue.prototype.UploadFileToTencent = function(path, fileObj, callback) {
// debugger;
console.log('filein...')
if (fileObj.type == "image/png" || fileObj.type == "image/jpeg") {
lrz(fileObj, {
width: 750,
quality: 0.8
})
.then(function(rst) {
//成功时执行
console.log(rst)
}).catch(function(error) {
this.uploadStart(path, fileObj, callback)
}).always(function() {
//不管成功或失败,都会执行
})
}
},
Vue.prototype.uploadStart = function(path, fileObj, callback) {
//获取文件扩展名
var filename = fileObj.name;
var index = filename.lastIndexOf(".");
......@@ -157,14 +176,15 @@ export default {
SecretId: uploadMsg.SecretId,
SecretKey: uploadMsg.SecretKey,
});
cos.putObject({
Bucket: uploadMsg.Bucket,
Region: uploadMsg.Region, //存储桶所在地域,必须字段
Key: newFileName, //文件名
StorageClass: 'STANDARD',
Body: fileObj, // 上传文件对象
onProgress: function (progressData) {}
}, function (err, data) {
onProgress: function(progressData) {}
}, function(err, data) {
if (data && data.statusCode == 200) {
var uploadResult = {
resultCode: 1,
......@@ -181,14 +201,14 @@ export default {
});
},
//公用跳转
Vue.prototype.CommonJump = function (path, obj) {
Vue.prototype.CommonJump = function(path, obj) {
this.$router.push({
name: path,
query: obj
});
}
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function (url) {
Vue.prototype.getIconLink = function(url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
......@@ -200,7 +220,7 @@ export default {
}
}
//HTTP提交数据
Vue.prototype.apipost = function (cmd, msg, successCall, faildCall, isOnline) {
Vue.prototype.apipost = function(cmd, msg, successCall, faildCall, isOnline) {
var apiurl = this.domainManager().DomainUrl + cmd;
var postData = this.GetPostData(cmd, msg, "");
this.$http.post(apiurl, postData, {
......@@ -222,7 +242,7 @@ export default {
}, faildCall)
}
//获取请求参数
Vue.prototype.GetPostData = function (cmd, msg, newCmd) {
Vue.prototype.GetPostData = function(cmd, msg, newCmd) {
if (msg == null || msg == "") {
msg = {}
}
......@@ -279,7 +299,7 @@ export default {
return postData
},
//HTTP提交数据资产
Vue.prototype.assetsApipost = function (cmd, msg, successCall, faildCall, isOnline) {
Vue.prototype.assetsApipost = function(cmd, msg, successCall, faildCall, isOnline) {
var apiurl = this.domainManager().DomainUrl + cmd;
var postData = this.GetAssetsPostData(cmd, msg, "");
this.$http.post(apiurl, postData, {
......@@ -302,7 +322,7 @@ export default {
}
//获取请求参数
Vue.prototype.GetAssetsPostData = function (cmd, msg, newCmd) {
Vue.prototype.GetAssetsPostData = function(cmd, msg, newCmd) {
if (msg == null || msg == "") {
msg = {}
}
......@@ -369,7 +389,7 @@ export default {
},
//文件下载
Vue.prototype.GetLocalFile = function (cmd, msg, fileName, newCmd, successCall) {
Vue.prototype.GetLocalFile = function(cmd, msg, fileName, newCmd, successCall) {
var apiurl = this.domainManager().DomainUrl + cmd;
var postData = this.GetPostData(cmd, msg, newCmd);
this.$http.post(apiurl, postData, {
......@@ -385,11 +405,11 @@ export default {
document.body.appendChild(link);
link.click();
successCall(res);
}).catch(function (res) {});
}).catch(function(res) {});
},
//调用资产的接口
Vue.prototype.apiJavaPost = function (cmd, msg, successCall, faildCall) {
Vue.prototype.apiJavaPost = function(cmd, msg, successCall, faildCall) {
if (msg == null || msg == "") {
msg = {}
}
......
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