| | |
| | | /** |
| | | * @description 微信业务请求 原接口 'wxpay/getaccesstoken' |
| | | */ |
| | | wxAccessToken (domain = '') { |
| | | let _url = domain || window.GLOB.baseurl |
| | | // wxAccessToken (appId, domain = '') { |
| | | // let _url = domain || window.GLOB.baseurl |
| | | |
| | | return new Promise(resolve => { |
| | | if (window.GLOB.accessToken.domain === domain && window.GLOB.accessToken.accessTime && (parseInt(new Date().getTime() / 1000) - window.GLOB.accessToken.accessTime < 30)) { |
| | | resolve(window.GLOB.accessToken) |
| | | } else { |
| | | window.GLOB.accessToken = {domain} |
| | | axios({ |
| | | url: _url + 'wechat/getaccesstoken', |
| | | method: 'post', |
| | | data: JSON.stringify({app_id: domain === '' ? window.GLOB.WXAppID : 'wx4d8a34c8d4494872'}) |
| | | }).then(res => { |
| | | if (res.access_token) { |
| | | window.GLOB.accessToken.accessTime = parseInt(new Date().getTime() / 1000) |
| | | window.GLOB.accessToken.access_token = res.access_token |
| | | } |
| | | resolve(res) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | // return axios({ |
| | | // url: _url + 'wechat/getaccesstoken', |
| | | // method: 'post', |
| | | // data: JSON.stringify({app_id: appId}) |
| | | // }) |
| | | // } |
| | | |
| | | /** |
| | | * @description 微信业务请求 |
| | |
| | | if (process.env.NODE_ENV === 'production') { |
| | | _url = document.location.origin + '/' + url |
| | | } |
| | | if (/qingqiumarket.cn|cloud.mk9h.cn/.test(_url)) { |
| | | _url = _url.replace('http://qingqiumarket.cn/', 'http://qingqiumarket.cn:8080/') |
| | | _url = _url.replace('http://cloud.mk9h.cn/', 'http://cloud.mk9h.cn:8080/') |
| | | _url = _url.replace('https://qingqiumarket.cn/', 'https://qingqiumarket.cn:8443/') |
| | | _url = _url.replace('https://cloud.mk9h.cn/', 'https://cloud.mk9h.cn:8443/') |
| | | } |
| | | } |
| | | if (/qingqiumarket.cn|cloud.mk9h.cn/.test(_url)) { |
| | | _url = _url.replace('http://qingqiumarket.cn/', 'http://qingqiumarket.cn:8080/') |
| | | _url = _url.replace('http://cloud.mk9h.cn/', 'http://cloud.mk9h.cn:8080/') |
| | | _url = _url.replace('https://qingqiumarket.cn/', 'https://qingqiumarket.cn:8443/') |
| | | _url = _url.replace('https://cloud.mk9h.cn/', 'https://cloud.mk9h.cn:8443/') |
| | | } |
| | | |
| | | if (param) { |
| | |
| | | /** |
| | | * @description 直接请求 |
| | | */ |
| | | directRequest (params) { |
| | | directRequest (params, script, position) { |
| | | if (script) { |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('axios', 'Api', 'param', 'position', 'systemType', 'notification', script) |
| | | let promise = func(axios, this, params, position, window.GLOB.systemType, notification) |
| | | |
| | | if (promise instanceof Promise) { |
| | | return promise |
| | | } |
| | | } catch (e) { |
| | | console.warn(e) |
| | | } |
| | | |
| | | return Promise.resolve({ |
| | | status: false, |
| | | message: '自定义脚本执行错误', |
| | | ErrCode: 'E' |
| | | }) |
| | | } |
| | | |
| | | return axios(params) |
| | | } |
| | | |
| | |
| | | /** |
| | | * @description 获取或修改系统配置,增加appkey |
| | | */ |
| | | getSystemFuncs (time) { |
| | | let param = { |
| | | func: 's_get_func_base_sso', |
| | | update_date: time, |
| | | userid: sessionStorage.getItem('UserID') || '', |
| | | lang: sessionStorage.getItem('lang') || '', |
| | | SessionUid: localStorage.getItem('SessionUid') || '', |
| | | LoginUID: sessionStorage.getItem('LoginUID') || '', |
| | | appkey: window.GLOB.appkey |
| | | } |
| | | // getSystemFuncs (time) { |
| | | // let param = { |
| | | // func: 's_get_func_base_sso', |
| | | // update_date: time, |
| | | // userid: sessionStorage.getItem('UserID') || '', |
| | | // lang: sessionStorage.getItem('lang') || '', |
| | | // SessionUid: localStorage.getItem('SessionUid') || '', |
| | | // LoginUID: sessionStorage.getItem('LoginUID') || '', |
| | | // appkey: window.GLOB.appkey |
| | | // } |
| | | |
| | | let url = window.GLOB.mainSystemApi || '/webapi/dostars' |
| | | param = this.encryptParam(param) |
| | | // let url = window.GLOB.mainSystemApi || '/webapi/dostars' |
| | | // param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: `${url}/${param.func}`, |
| | | method: 'post', |
| | | data: JSON.stringify(param) |
| | | }) |
| | | } |
| | | // return axios({ |
| | | // url: `${url}/${param.func}`, |
| | | // method: 'post', |
| | | // data: JSON.stringify(param) |
| | | // }) |
| | | // } |
| | | |
| | | /** |
| | | * @description 获取或修改系统配置,增加appkey |
| | |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (param.$backend) { |
| | | delete param.$backend |
| | | |
| | | let id = '' |
| | | if (cache) { |
| | | id = param.data[0].id |
| | | |
| | | if (window.GLOB.CacheMap.has(id)) { |
| | | return Promise.resolve(window.GLOB.CacheMap.get(id)) |
| | | } |
| | | } |
| | | |
| | | param.username = sessionStorage.getItem('User_Name') || '' |
| | | param.fullname = sessionStorage.getItem('Full_Name') || '' |
| | | param.s_debug = window.GLOB.debugger ? 'Y' : '' |
| | | param.data_md5 = param.data_md5 || '' |
| | | param.time_limit = param.time_limit || 0 |
| | | |
| | | let url = '/webapi/exstars' |
| | | if (param.rduri) { |
| | | param.rduri = param.rduri.replace(/dostars/ig, 'exstars') |
| | | if (!window.GLOB.transfer) { |
| | | url = param.rduri |
| | | delete param.rduri |
| | | } |
| | | } |
| | | |
| | | if (param.$type) { |
| | | url += '/' + param.$type |
| | | } |
| | | |
| | | delete param.$type |
| | | |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise((resolve) => { |
| | | axios({ |
| | | url: url, |
| | | method: 'post', |
| | | data: JSON.stringify(param) |
| | | }).then(res => { |
| | | if (res.mksqls) { |
| | | res.mksqls.forEach(n => { |
| | | n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '') |
| | | window.mkInfo(n) |
| | | }) |
| | | } |
| | | if (res.ErrCode === 'version_error') { |
| | | res.ErrCode = '-2' |
| | | MKEmitter.emit('reloadTabs') |
| | | } |
| | | if (res.status) { |
| | | window.GLOB.CacheMap.set(id, res) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | let url = '/webapi/dostars' |
| | | if (param.rduri && !window.GLOB.transfer) { |
| | |
| | | } |
| | | }) |
| | | }) |
| | | } else if (param.$backend) { |
| | | delete param.$backend |
| | | |
| | | let url = '/webapi/exstars' |
| | | if (param.rduri) { |
| | | param.rduri = param.rduri.replace(/dostars/ig, 'exstars') |
| | | if (!window.GLOB.transfer) { |
| | | url = param.rduri |
| | | delete param.rduri |
| | | } |
| | | } |
| | | |
| | | if (param.$type) { |
| | | url += '/' + param.$type |
| | | } |
| | | |
| | | delete param.$type |
| | | |
| | | param.username = sessionStorage.getItem('User_Name') || '' |
| | | param.fullname = sessionStorage.getItem('Full_Name') || '' |
| | | param.s_debug = window.GLOB.debugger ? 'Y' : '' |
| | | param.data_md5 = param.data_md5 || '' |
| | | param.time_limit = param.time_limit || 0 |
| | | |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise((resolve) => { |
| | | axios({ |
| | | url: url, |
| | | method: 'post', |
| | | data: JSON.stringify(param), |
| | | requestId |
| | | }).then(res => { |
| | | if (res.mksqls) { |
| | | res.mksqls.forEach(n => { |
| | | n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '') |
| | | window.mkInfo(n) |
| | | }) |
| | | } |
| | | if (res.ErrCode === 'version_error') { |
| | | res.ErrCode = '-2' |
| | | MKEmitter.emit('reloadTabs') |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | } else { |
| | | let url = '/webapi/dostars' |
| | | if (param.rduri && !window.GLOB.transfer && /\/dostars/.test(param.rduri) && param.func !== 'webapi_ChangeUser') { |
| | | if (param.rduri && (!window.GLOB.transfer || /https:\/\/sso.mk9h.cn/.test(param.rduri)) && /\/dostars/.test(param.rduri) && param.func !== 'webapi_ChangeUser') { |
| | | url = param.rduri |
| | | delete param.rduri |
| | | } |
| | |
| | | requestId |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 清空后端缓存 |
| | | */ |
| | | cacheInterface (param) { |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | let url = '/webapi/excache' |
| | | if (param.rduri && !window.GLOB.transfer) { |
| | | url = param.rduri |
| | | delete param.rduri |
| | | } |
| | | |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: url, |
| | | method: 'post', |
| | | data: JSON.stringify(param), |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * @description 大文件上传 |
| | | */ |
| | | getLargeFileUpload (param) { |
| | | return axios({ |
| | | url: '/webapi/doupload', |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, |
| | | data: param |
| | | getFileUpload (param) { |
| | | param.append('shardingCnt', 1) |
| | | param.append('LoginUID', sessionStorage.getItem('LoginUID') || '') |
| | | param.append('UserID', sessionStorage.getItem('UserID') || '') |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | axios({ |
| | | url: '/webapi/doupload', |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, |
| | | data: param |
| | | }).then(res => { |
| | | if (res.status && res.urlPath) { |
| | | if (!/Content\/images/.test(res.urlPath)) { |
| | | let key = CryptoJS.enc.Utf8.parse('D1185ED7B32568C9') |
| | | let wordArray = CryptoJS.enc.Base64.parse(res.urlPath) |
| | | let decryptedWordArray = CryptoJS.AES.decrypt({ ciphertext: wordArray }, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }) |
| | | res.urlPath = CryptoJS.enc.Utf8.stringify(decryptedWordArray) |
| | | } |
| | | if (!/^http/.test(res.urlPath)) { |
| | | res.urlPath = window.GLOB.baseurl + res.urlPath |
| | | } |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 查询文件是否已上传 |
| | | */ |
| | | getFilePreUpload (param) { |
| | | return axios({ |
| | | url: '/webapi/dopreload', |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, |
| | | data: param |
| | | }) |
| | | } |
| | | // getFilePreUpload (param) { |
| | | // return axios({ |
| | | // url: '/webapi/dopreload', |
| | | // method: 'post', |
| | | // headers: { 'Content-Type': 'multipart/form-data' }, |
| | | // data: param |
| | | // }) |
| | | // } |
| | | |
| | | /** |
| | | * @description oss文件上传 |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取微信支付二维码 |
| | | * @description 获取微信支付二维码 原接口wxpay/wxNativePay |
| | | */ |
| | | getWxNativePay (param) { |
| | | let _url = window.GLOB.baseurl + 'wxpay/wxNativePay' |
| | | |
| | | return axios({ |
| | | url: _url, |
| | | url: window.GLOB.baseurl + 'wechat/native', |
| | | method: 'post', |
| | | data: qs.stringify(param) |
| | | data: JSON.stringify(param) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 微信支付退款 |
| | | * @description 微信支付退款 原接口wxpay/wxRefund |
| | | */ |
| | | setRefund (orderId) { |
| | | let _param = new FormData() |
| | | _param.append('out_biz_no', orderId) |
| | | |
| | | setRefund (param) { |
| | | return axios({ |
| | | url: '/wxpay/wxRefund', |
| | | headers: { 'Content-Type': 'multipart/form-data' }, |
| | | url: window.GLOB.baseurl + 'wechat/wxRefund', |
| | | method: 'post', |
| | | data: _param |
| | | data: JSON.stringify(param) |
| | | }) |
| | | } |
| | | |
| | |
| | | sql = sql.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | console.info(`/* sql 验证 */\n${sql.replace(/\n\s{6,20}/ig, '\n')}`) |
| | | window.mkInfo(`/* sql 验证 */\n${sql.replace(/\n\s{6,20}/ig, '\n')}`) |
| | | |
| | | sql = sql.replace(/\n/ig, ' ') |
| | | |