Commit ff9914fa authored by 罗超's avatar 罗超

新增预览返佣

parent 33a8acdb
...@@ -15,10 +15,12 @@ ...@@ -15,10 +15,12 @@
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.19.2",
"cos-js-sdk-v5": "^0.5.26", "cos-js-sdk-v5": "^0.5.26",
"echarts": "^4.8.0",
"element-ui": "^2.13.1", "element-ui": "^2.13.1",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-router": "^3.0.1" "vue-router": "^3.0.1",
"vuedraggable": "^2.23.2"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import md5 from 'js-md5' import md5 from 'js-md5'
export default { export default {
install(Vue, options) { install(Vue, options) {
Vue.prototype.md5 = md5; Vue.prototype.md5 = md5;
//消息成功提示 //消息成功提示
Vue.prototype.Success = function (msg) { Vue.prototype.Success = function(msg) {
this.$message({ this.$message({
message: msg, message: msg,
duration: 2000, duration: 2000,
type: "success" type: "success"
}); });
}, },
//错误提示 //错误提示
Vue.prototype.Error = function (msg) { Vue.prototype.Error = function(msg) {
this.$message({ this.$message({
message: msg, message: msg,
duration: 2000, duration: 2000,
type: "error" type: "error"
}); });
}, },
//一般提示 //一般提示
Vue.prototype.Info = function (msg) { Vue.prototype.Info = function(msg) {
this.$message({ this.$message({
message: msg, message: msg,
duration: 2000, duration: 2000,
type: "info" type: "info"
}); });
}, },
//警告提示 //警告提示
Vue.prototype.Warning = function (msg) { Vue.prototype.Warning = function(msg) {
this.$message({ this.$message({
message: msg, message: msg,
duration: 2000, duration: 2000,
type: "warning" type: "warning"
}); });
}, },
//Confirm //Confirm
Vue.prototype.Confirm = function (msg, callback) { Vue.prototype.Confirm = function(msg, callback) {
this.$confirm(msg, "提示", { this.$confirm(msg, "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}) })
.then(() => { .then(() => {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(); callback();
}
})
.catch(() => {
this.Info("已取消操作");
});
},
//域名管理对象
Vue.prototype.domainManager = function() {
let domainUrl = '';
domainUrl = "https://mallapi.oytour.com";
//domainUrl = "https://localhost:5001";
let locationName = window.location.hostname;
if (locationName.indexOf('testmall.oytour') !== -1) {
domainUrl = "https://mallapi.oytour.com";
} else if (locationName.indexOf('oytour') !== -1) {
domainUrl = "https://mallapi.oytour.com";
}
var obj = {
//主地址npm
DomainUrl: domainUrl,
//常用提交数据URL
PostUrl: domainUrl + "/api/common/post",
ImageUrl: 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com',
UploadFileUrl: domainUrl + '/api/File/LocalFileUploadImport',
UploadBlob: domainUrl + '/api/File/UploadBlob',
};
return obj;
},
//浏览器缓存
Vue.prototype.getLocalStorage = function() {
var localStorageData = window.localStorage["mall_userInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData);
} else {
return null;
}
},
//验证只能输入2位小数【负数:isMinus传true】
Vue.prototype.checkPrice = function(item, filed, isMinus) {
var value = "" + item[filed]; //转字符串
var t = value.charAt(0);
value = value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
value = value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
value = value
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", ".");
value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
//如果第一位是负号,则允许添加 如果不允许添加负号 可以把这块注释掉
//是否允许负数
if (isMinus && t == '-') {
value = '-' + value;
}
item[filed] = value;
} }
}) //验证只能输入整数【负数:isMinus传true】
.catch(() => { Vue.prototype.checkInteger = function(item, filed, isMinus) {
this.Info("已取消操作"); var value = "" + item[filed]; //转字符串
}); var t = value.charAt(0);
}, value = value.replace(this.$commonUtils.Regex.isInteger, "");
//域名管理对象 //是否允许负数
Vue.prototype.domainManager = function () { if (isMinus && t == '-') {
let domainUrl = ''; value = '-' + value;
domainUrl = "http://192.168.2.214:8200"; }
//domainUrl = "https://localhost:5001"; item[filed] = value;
let locationName = window.location.hostname; },
if (locationName.indexOf('testmall.oytour') !== -1) { //是否是线上环境【发布时修改为true】
domainUrl = "https://mallapi.oytour.com"; Vue.prototype.isOnline = function() {
} else if (locationName.indexOf('oytour') !== -1) { return process.env.NODE_ENV !== 'development';
domainUrl = "https://mallapi.oytour.com"; },
} //文件类型数组
var obj = { Vue.prototype.FileType = function() {
//主地址npm var fileTypeJson = {
DomainUrl: domainUrl, //主地址npm
//常用提交数据URL UserImg: "User", //用户相图片
PostUrl: domainUrl + "/api/common/post", //常用提交数据URL
ImageUrl: 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com', GoodsImg: "Goods", //素材相关文件
UploadFileUrl: domainUrl + '/api/File/LocalFileUploadImport', SetImg: "Set", //用户相图片
UploadBlob: domainUrl + '/api/File/UploadBlob', };
}; return fileTypeJson;
return obj; },
}, //上传文件到云存储
//浏览器缓存 Vue.prototype.UploadFileToTencent = function(path, fileObj, callback) {
Vue.prototype.getLocalStorage = function () { //获取文件扩展名
var localStorageData = window.localStorage["mall_userInfo"]; var filename = fileObj.name;
if (localStorageData !== undefined && localStorageData != 'undefined') { var index = filename.lastIndexOf(".");
return JSON.parse(localStorageData); var suffix = filename.substr(index);
} else { var timestamp1 = Date.parse(new Date());
return null; let str = '';
} if (this.isOnline()) {
}, str = "/Test"
//验证只能输入2位小数【负数:isMinus传true】 }
Vue.prototype.checkPrice = function (item, filed, isMinus) { var newFileName = str + '/Upload/' + path + "/" + timestamp1 + "" + suffix;
var value = "" + item[filed]; //转字符串 var uploadMsg = {
var t = value.charAt(0); Bucket: "viitto-1301420277",
value = value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符 Region: "ap-chengdu",
value = value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的 /* 存储桶所在地域,必须字段 */
value = value SecretId: "AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd",
.replace(".", "$#$") SecretKey: "PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob",
.replace(/\./g, "") };
.replace("$#$", "."); var COS = require('cos-js-sdk-v5');
value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数 var cos = new COS({
//如果第一位是负号,则允许添加 如果不允许添加负号 可以把这块注释掉 SecretId: uploadMsg.SecretId,
//是否允许负数 SecretKey: uploadMsg.SecretKey,
if (isMinus && t == '-') { });
value = '-' + value; cos.putObject({
} Bucket: uploadMsg.Bucket,
item[filed] = value; Region: uploadMsg.Region, //存储桶所在地域,必须字段
} Key: newFileName, //文件名
//验证只能输入整数【负数:isMinus传true】 StorageClass: 'STANDARD',
Vue.prototype.checkInteger = function (item, filed, isMinus) { Body: fileObj, // 上传文件对象
var value = "" + item[filed]; //转字符串 onProgress: function(progressData) {}
var t = value.charAt(0); }, function(err, data) {
value = value.replace(this.$commonUtils.Regex.isInteger, ""); if (data && data.statusCode == 200) {
//是否允许负数 var uploadResult = {
if (isMinus && t == '-') { resultCode: 1,
value = '-' + value; FileName: fileObj.name,
} FileUrl: "http://" + data.Location
item[filed] = value; }
}, if (callback) {
//是否是线上环境【发布时修改为true】 callback(uploadResult);
Vue.prototype.isOnline = function () { }
return process.env.NODE_ENV !== 'development'; } else {
}, /*上传文件异常*/
//文件类型数组 console.log(err || data);
Vue.prototype.FileType = function () { }
var fileTypeJson = { });
//主地址npm },
UserImg: "User", //用户相图片 //公用跳转
//常用提交数据URL Vue.prototype.CommonJump = function(path, obj) {
GoodsImg: "Goods", //素材相关文件 this.$router.push({
SetImg: "Set", //用户相图片 name: path,
}; query: obj
return fileTypeJson; });
},
//上传文件到云存储
Vue.prototype.UploadFileToTencent = function (path, fileObj, callback) {
//获取文件扩展名
var filename = fileObj.name;
var index = filename.lastIndexOf(".");
var suffix = filename.substr(index);
var timestamp1 = Date.parse(new Date());
let str = '';
if (this.isOnline()) {
str = "/Test"
}
var newFileName = str + '/Upload/' + path + "/" + timestamp1 + "" + suffix;
var uploadMsg = {
Bucket: "viitto-1301420277",
Region: "ap-chengdu",
/* 存储桶所在地域,必须字段 */
SecretId: "AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd",
SecretKey: "PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob",
};
var COS = require('cos-js-sdk-v5');
var cos = new COS({
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) {
if (data && data.statusCode == 200) {
var uploadResult = {
resultCode: 1,
FileName: fileObj.name,
FileUrl: "http://" + data.Location
} }
if (callback) { //公用判断图片地址 判断是否包含http
callback(uploadResult); Vue.prototype.getIconLink = function(url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
str = url
} else {
str = this.domainManager().ImageUrl + url;
}
return str;
}
}
//HTTP提交数据
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, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
this.$router.push({
path: '/login'
});
} else if (res.resultCode == 10005) {
this.$router.go(-1);
} else {
successCall(res);
}
}, faildCall)
}
//获取请求参数
Vue.prototype.GetPostData = function(cmd, msg, newCmd) {
if (msg == null || msg == "") {
msg = {}
}
var timestamp = (new Date()).valueOf();
if (!localStorage.mall_userInfo && localStorage.mall_userInfo != "" &&
this.$route.path.toLowerCase() != "/login" &&
this.$route.path.toLowerCase() != "/register" &&
this.$route.path.toLowerCase() != "/forgetpassword"
) {
this.$router.push({
path: '/login'
})
}
var token = "";
var key = "";
var MallBaseId = "0"; //小程序ID
var TenantId = "0"; //商户Id
var EmpId = 0; //员工编号【员工登录时使用】
if (this.getLocalStorage() != null) {
token = this.getLocalStorage().Token;
key = this.getLocalStorage().SecretKey;
MallBaseId = this.getLocalStorage().MallBaseId;
TenantId = this.getLocalStorage().TenantId;
EmpId = this.getLocalStorage().EmpId;
}
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
let tempLanguage = 0;
if (localStorage.language && localStorage.language != '') {
if (localStorage.language == "zh-TW") {
tempLanguage = 1;
} else if (localStorage.language == "Japanese") {
tempLanguage = 2;
}
}
var cmdStr = "";
if (newCmd) {
cmdStr = newCmd;
}
var postData = {
msg: msg,
timestamp: timestamp,
token: token,
sign: md5Str,
languageId: tempLanguage,
cmd: cmdStr,
MallBaseId: MallBaseId,
TenantId: TenantId,
EmpId: EmpId,
}
return postData
},
//文件下载
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, {
responseType: 'arraybuffer'
}).then((res) => {
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel"
})
let url = URL.createObjectURL(blob);
let link = document.createElement('a');
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
successCall(res);
}).catch(function(res) {});
} }
} else {
/*上传文件异常*/
console.log(err || data);
}
});
},
//公用跳转
Vue.prototype.CommonJump = function (path, obj) {
this.$router.push({
name: path,
query: obj
});
}
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function (url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
str = url
} else {
str = this.domainManager().ImageUrl + url;
}
return str;
}
}
//HTTP提交数据
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, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
this.$router.push({
path: '/login'
});
} else if (res.resultCode == 10005) {
this.$router.go(-1);
} else {
successCall(res);
}
}, faildCall)
} }
//获取请求参数 }
Vue.prototype.GetPostData = function (cmd, msg, newCmd) { \ No newline at end of file
if (msg == null || msg == "") {
msg = {}
}
var timestamp = (new Date()).valueOf();
if (!localStorage.mall_userInfo && localStorage.mall_userInfo != "" &&
this.$route.path.toLowerCase() != "/login" &&
this.$route.path.toLowerCase() != "/register" &&
this.$route.path.toLowerCase() != "/forgetpassword"
) {
this.$router.push({
path: '/login'
})
}
var token = "";
var key = "";
var MallBaseId = "0"; //小程序ID
var TenantId = "0"; //商户Id
var EmpId = 0; //员工编号【员工登录时使用】
if (this.getLocalStorage() != null) {
token = this.getLocalStorage().Token;
key = this.getLocalStorage().SecretKey;
MallBaseId = this.getLocalStorage().MallBaseId;
TenantId = this.getLocalStorage().TenantId;
EmpId = this.getLocalStorage().EmpId;
}
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
let tempLanguage = 0;
if (localStorage.language && localStorage.language != '') {
if (localStorage.language == "zh-TW") {
tempLanguage = 1;
} else if (localStorage.language == "Japanese") {
tempLanguage = 2;
}
}
var cmdStr = "";
if (newCmd) {
cmdStr = newCmd;
}
var postData = {
msg: msg,
timestamp: timestamp,
token: token,
sign: md5Str,
languageId: tempLanguage,
cmd: cmdStr,
MallBaseId: MallBaseId,
TenantId: TenantId,
EmpId: EmpId,
}
return postData
},
//文件下载
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, {
responseType: 'arraybuffer'
}).then((res) => {
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel"
})
let url = URL.createObjectURL(blob);
let link = document.createElement('a');
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
successCall(res);
}).catch(function (res) {});
}
}
}
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