|
|
@ -22,10 +22,10 @@ const NODE_ENV = 'development'; |
|
|
|
// const NODE_ENV = 'production';
|
|
|
|
if(NODE_ENV == 'development'){ |
|
|
|
Vue.prototype.cssUrl = '/static/images/frontend/'; |
|
|
|
Vue.prototype.request_domain = "http://xmztest.yitongtang66.com/"; |
|
|
|
Vue.prototype.request_domain = "http://apizj.checkcopy.com/"; |
|
|
|
}else{ |
|
|
|
Vue.prototype.cssUrl = 'https://xmz.yitongtang66.com/assets/img/new/'; |
|
|
|
Vue.prototype.request_domain = "https://xmz.yitongtang66.com/"; |
|
|
|
Vue.prototype.cssUrl = '/static/images/frontend/'; |
|
|
|
Vue.prototype.request_domain = "http://apizj.checkcopy.com/"; |
|
|
|
} |
|
|
|
|
|
|
|
try{ |
|
|
@ -173,9 +173,9 @@ if(Vue.prototype.provider == Vue.prototype.provider_weixin) { |
|
|
|
Vue.prototype.View = currentPageView+'New'; |
|
|
|
} |
|
|
|
|
|
|
|
const CODE_SUCCESS = 200; |
|
|
|
const CODE_SUCCESS = 2000; |
|
|
|
const CODE_ERROR = 40001; |
|
|
|
const CODE_LOGIN_EXIPRE = 40002; |
|
|
|
const CODE_LOGIN_EXIPRE = 4000; |
|
|
|
|
|
|
|
Vue.prototype.user_preview = 1; |
|
|
|
Vue.prototype.edit_preview = 2; |
|
|
@ -184,49 +184,34 @@ Vue.prototype.edit_album = 4; |
|
|
|
|
|
|
|
function removeLogin() { |
|
|
|
uni.removeStorageSync('token'); |
|
|
|
uni.removeStorageSync('uuid'); |
|
|
|
uni.removeStorageSync('nickname'); |
|
|
|
uni.removeStorageSync('avatar'); |
|
|
|
uni.removeStorageSync('level_id'); |
|
|
|
uni.removeStorageSync('level_name'); |
|
|
|
uni.removeStorageSync('is_admin'); |
|
|
|
uni.removeStorageSync('avatar_full'); |
|
|
|
uni.removeStorageSync('create'); |
|
|
|
uni.removeStorageSync('uuid_str'); |
|
|
|
} |
|
|
|
|
|
|
|
function req(url, data={}, method = 'POST') { |
|
|
|
var domain = Vue.prototype.request_domain; |
|
|
|
data.xcxtype = 3; |
|
|
|
if(Vue.prototype.appid != '') { |
|
|
|
data.appid = Vue.prototype.appid; |
|
|
|
data.xcx_scource = Vue.prototype.USER_SOURCE_WX_XCX; |
|
|
|
function req(url, data={}, method = 'POST', header={}) { |
|
|
|
var domain = Vue.prototype.request_domain; |
|
|
|
if(Vue.prototype.appid != '') { |
|
|
|
data.appid = Vue.prototype.appid; |
|
|
|
data.xcx_scource = Vue.prototype.USER_SOURCE_WX_XCX; |
|
|
|
}else{ |
|
|
|
domain = '/api/'; |
|
|
|
if(Vue.prototype.isMobile){ |
|
|
|
data.xcx_scource = Vue.prototype.USER_SOURCE_H5; |
|
|
|
domain = '/api/'; |
|
|
|
if(Vue.prototype.isMobile){ |
|
|
|
data.xcx_scource = Vue.prototype.USER_SOURCE_H5; |
|
|
|
if(Vue.prototype.env_val.indexOf('weixin') > -1) data.xcx_scource = Vue.prototype.USER_SOURCE_WX_H5; |
|
|
|
data.host = location.host; |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
data.xcx_scource = Vue.prototype.USER_SOURCE_PC; |
|
|
|
data.host = location.host; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(NODE_ENV == 'development') data.env = 'dev'; |
|
|
|
|
|
|
|
var headerObj = {'content-type': 'application/x-www-form-urlencoded'}; |
|
|
|
var token = uni.getStorageSync('token'); |
|
|
|
var uuid = uni.getStorageSync('uuid'); |
|
|
|
|
|
|
|
var loginFunc = ''; |
|
|
|
if(data.xcx_scource == Vue.prototype.USER_SOURCE_WX_XCX) loginFunc = 'ai_xcx_login'; |
|
|
|
data.submit_source = data.xcx_scource; |
|
|
|
data.is_ai = 1; |
|
|
|
if(token && uuid && url != loginFunc){ |
|
|
|
data.token = token; |
|
|
|
data.user_id = uuid; |
|
|
|
} |
|
|
|
var noNeedLoginFunc = [ |
|
|
|
'client/common/mp/config', |
|
|
|
'client/user/login' |
|
|
|
] |
|
|
|
var isNeedLogin = !noNeedLoginFunc.includes(url); |
|
|
|
|
|
|
|
var headerObj = {'content-type': 'application/x-www-form-urlencoded'}; |
|
|
|
var token = uni.getStorageSync('token'); |
|
|
|
if(token) headerObj.Authorization = token |
|
|
|
|
|
|
|
var getWxH5LoginConfigUri = 'client/common/mp/config' |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
uni.request({ |
|
|
@ -239,30 +224,22 @@ function req(url, data={}, method = 'POST') { |
|
|
|
try{ |
|
|
|
var rdata = res.data; |
|
|
|
if(rdata.code != CODE_SUCCESS) { |
|
|
|
if(data.xcx_scource == Vue.prototype.USER_SOURCE_WX_XCX && !data.repeat && rdata.code==CODE_LOGIN_EXIPRE && url != 'userapi/login2/weChatLogin'){ |
|
|
|
if(rdata.code==CODE_LOGIN_EXIPRE && data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5 && url != getWxH5LoginConfigUri && data.repeat != 1){ |
|
|
|
if(headerObj.Authorization) { |
|
|
|
console.log(headerObj.Authorization, url) |
|
|
|
return |
|
|
|
} |
|
|
|
removeLogin(); |
|
|
|
xcx_login(url, data, method).then(data=>{ |
|
|
|
return resolve(data); |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if(data.xcx_scource == Vue.prototype.USER_SOURCE_H5 && res.data.info.indexOf('请先登录')>-1){ |
|
|
|
location.href="/pages/jumpxcx/jumpxcx"; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if(rdata.code==CODE_LOGIN_EXIPRE && data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5 && url != 'ai_get_mplogin_url'){ |
|
|
|
var logindatac = new Object(); |
|
|
|
logindatac.host = location.host; |
|
|
|
|
|
|
|
const pagesc = getCurrentPages(); |
|
|
|
const currentPagec = pagesc[pagesc.length - 1]; |
|
|
|
var pageUrlc = '/'+currentPagec.route; |
|
|
|
logindatac.state = encodeURIComponent(pageUrlc); |
|
|
|
req('ai_get_mplogin_url', logindatac).then(data=>{ |
|
|
|
if(data == -1 || !data.login_link) return; |
|
|
|
location.href = data.login_link; |
|
|
|
var pageUrlc = '/'+currentPagec.route; |
|
|
|
uni.setStorageSync('rebackPagePath', pageUrlc); |
|
|
|
req(getWxH5LoginConfigUri, logindatac, 'GET').then(data=>{ |
|
|
|
if(data == -1 || !data.user_authorize_url) return; |
|
|
|
location.href = data.user_authorize_url; |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
@ -325,18 +302,8 @@ function xcx_login(url, eqdata={}, method = 'POST') { |
|
|
|
if (res.code) { |
|
|
|
var pdata = new Object(); |
|
|
|
pdata.code = res.code; |
|
|
|
req('userapi/login2/weChatLogin', pdata).then(data=>{ |
|
|
|
req('client/user/login', pdata, 'POST').then(data=>{ |
|
|
|
uni.setStorageSync('token', data.token); |
|
|
|
uni.setStorageSync('uuid', data.userId); |
|
|
|
uni.setStorageSync('uuid_str', data.userIdStr); |
|
|
|
uni.setStorageSync('nickname', data.nickname); |
|
|
|
uni.setStorageSync('avatar', data.avatar); |
|
|
|
uni.setStorageSync('level_id', data.level_id); |
|
|
|
uni.setStorageSync('level_name', data.level_name); |
|
|
|
uni.setStorageSync('avatar_full', data.avatar_full); |
|
|
|
uni.setStorageSync('create', data.create); |
|
|
|
if(data.is_admin) uni.setStorageSync('is_admin', data.is_admin); |
|
|
|
|
|
|
|
eqdata.repeat = 1; |
|
|
|
req(url, eqdata, method).then(data=>{ |
|
|
|
return resolve(data); |
|
|
|