| | |
| | | import moment from 'moment' |
| | | import md5 from 'md5' |
| | | |
| | | const service = window.GLOB.service ? (/\/$/.test(window.GLOB.service) ? window.GLOB.service : window.GLOB.service + '/') : '' |
| | | |
| | | export default class Utils { |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description md5加密 |
| | | * @return {String} str 加密串 |
| | | * @return {String} timestamp 时间戳 |
| | | */ |
| | | static encrypt (str, timestamp) { |
| | | let salt = 'mingke' // 盐值 |
| | | return md5(str + salt + timestamp) |
| | | } |
| | | |
| | | /** |
| | | * @description sql加密 |
| | | * @return {String} value |
| | | */ |
| | | static formatOptions (value) { |
| | | // 产生一个新的GUID值 |
| | | if (!value) return '' |
| | | |
| | | let salt = 'minKe' // 盐值 |
| | | // 关键字转换规则 |
| | | let format = [{ |
| | | key: 'select', |
| | | value: ' msltk ' |
| | |
| | | key: 'ROLLBACK', |
| | | value: ' mrlbkk ' |
| | | }] |
| | | |
| | | // 替换关键字 |
| | | format.forEach(item => { |
| | | let reg = new RegExp('(^|\\s)' + item.key + '(\\s|$)', 'ig') |
| | | value = value.replace(reg, item.value) |
| | | }) |
| | | |
| | | // 1、替换%符(数据库中解析后sql报错),2、去除收尾多余空格 |
| | | value = value.replace(/%/ig, 'mpercent') |
| | | value = value.replace(/(^\s|\s$)/ig, '') |
| | | value = window.btoa(window.encodeURIComponent(value)) |
| | | let index = Math.floor(Math.random() * value.length) |
| | | value = value.slice(0, index) + 'minKe' + value.slice(index) |
| | | value = window.btoa(value) |
| | | // value = value.replace(/%/ig, 'mpercent') |
| | | // .replace(/>/ig, 'greateror') |
| | | |
| | | // value = value.replace(/>/ig, 'greateror') |
| | | // .replace(/</ig, 'lessor') |
| | | // .replace(/!=/ig, 'noequal') |
| | | // .replace(/=/ig, 'equal') |
| | |
| | | // .replace(/\*/ig, 'mastrsk') |
| | | // .replace(/'/ig, 'mqotek') |
| | | // .replace(/\s/ig, 'mspace') |
| | | |
| | | // 1、encode编码(中文字符超出base64加密范围),2、base64加密 |
| | | value = window.btoa(window.encodeURIComponent(value)) |
| | | |
| | | // 随机插入字符 |
| | | let index = Math.floor(Math.random() * value.length) |
| | | value = value.slice(0, index) + salt + value.slice(index) |
| | | |
| | | // base64加密 |
| | | value = window.btoa(value) |
| | | |
| | | return value |
| | | } |
| | | |
| | |
| | | if (!url) return '' |
| | | let baseurl = '' |
| | | if (process.env.NODE_ENV === 'production') { |
| | | baseurl = document.location.origin + '/' |
| | | baseurl = document.location.origin + '/' + service |
| | | } else { |
| | | baseurl = 'http://qingqiumarket.cn/MKWMS/' |
| | | baseurl = 'http://qingqiumarket.cn/' + service |
| | | } |
| | | let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url |
| | | return realurl |