mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-06-11 14:17:25 +08:00
添加小区成功
This commit is contained in:
parent
7779ddb995
commit
9f62a856ba
@ -2,20 +2,33 @@ import coreUtil from './utils/CoreUtil.js'
|
||||
|
||||
import app from '../../constant/AppConstant.js'
|
||||
|
||||
import {getDateYYYYMMDDHHMISS} from './utils/DateUtil.js'
|
||||
import {
|
||||
getDateYYYYMMDDHHMISS
|
||||
} from './utils/DateUtil.js'
|
||||
|
||||
import url from '../../constant/url.js'
|
||||
|
||||
import mapping from '../../constant/MappingConstant.js'
|
||||
|
||||
import {checkSession} from './page/Page.js'
|
||||
import {
|
||||
checkSession
|
||||
} from './page/Page.js'
|
||||
|
||||
import {getToken} from './utils/StorageUtil.js';
|
||||
import {
|
||||
getToken
|
||||
} from './utils/StorageUtil.js';
|
||||
|
||||
import {hasLogin} from '../../api/user/sessionApi.js';
|
||||
import {
|
||||
hasLogin
|
||||
} from '../../api/user/sessionApi.js';
|
||||
|
||||
|
||||
import {debug,warn,info,error} from './utils/LogUtil.js';
|
||||
import {
|
||||
debug,
|
||||
warn,
|
||||
info,
|
||||
error
|
||||
} from './utils/LogUtil.js';
|
||||
import md5 from './utils/md5Util.js'
|
||||
/**
|
||||
* 获取请求头信息
|
||||
@ -24,7 +37,7 @@ import md5 from './utils/md5Util.js'
|
||||
export function getHeaders() {
|
||||
let _wAppId = uni.getStorageSync(mapping.W_APP_ID);
|
||||
let _token = getToken();
|
||||
if(!_token){
|
||||
if (!_token) {
|
||||
_token = "no login";
|
||||
}
|
||||
return {
|
||||
@ -36,47 +49,51 @@ export function getHeaders() {
|
||||
//"cookie": '_java110_token_=' + getToken(),
|
||||
"Accept": '*/*',
|
||||
"w-app-id": _wAppId,
|
||||
"Authorization":"Bearer "+_token
|
||||
"Authorization": "Bearer " + _token
|
||||
};
|
||||
}
|
||||
|
||||
export function createSign(_reqObj){
|
||||
|
||||
export function createSign(_reqObj) {
|
||||
|
||||
let _header = _reqObj.header;
|
||||
let _transactionId = _header["transaction-id"];
|
||||
let _reqTime = _header["req-time"];
|
||||
let _appId = _header["app-id"];
|
||||
let reqInfo = _transactionId+_reqTime+_appId;
|
||||
|
||||
if(_reqObj.method == 'GET'){
|
||||
let reqInfo = _transactionId + _reqTime + _appId;
|
||||
|
||||
if (_reqObj.method == 'GET') {
|
||||
reqInfo += '?';
|
||||
for (let key in _reqObj.data) {
|
||||
if(_reqObj.data[key]){
|
||||
reqInfo += (key+'='+_reqObj.data[key]+'&');
|
||||
}else{
|
||||
reqInfo += (key+'='+'&');
|
||||
if (_reqObj.data[key]) {
|
||||
reqInfo += (key + '=' + _reqObj.data[key] + '&');
|
||||
} else {
|
||||
reqInfo += (key + '=' + '&');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(reqInfo.endsWith('&')){
|
||||
reqInfo = reqInfo.substr(0,reqInfo.length-1);
|
||||
if (reqInfo.endsWith('&')) {
|
||||
reqInfo = reqInfo.substr(0, reqInfo.length - 1);
|
||||
}
|
||||
} else {
|
||||
if (typeof _reqObj.data === "object") {
|
||||
reqInfo += JSON.stringify(_reqObj.data);
|
||||
} else {
|
||||
reqInfo += _reqObj.data;
|
||||
}
|
||||
}else{
|
||||
reqInfo += JSON.stringify(_reqObj.data);
|
||||
}
|
||||
reqInfo += "whoisyoudad!!!"
|
||||
let _sign = md5(reqInfo);
|
||||
_reqObj.header.sign = _sign;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* http 请求 加入是否登录判断
|
||||
*/
|
||||
export function request(_reqObj) {
|
||||
|
||||
debug('java110Request','request',_reqObj);
|
||||
|
||||
|
||||
debug('java110Request', 'request', _reqObj);
|
||||
|
||||
//这里判断只有在 post 方式时 放加载框
|
||||
if (_reqObj.hasOwnProperty("method") && "POST" == _reqObj.method) {
|
||||
uni.showLoading({
|
||||
@ -106,18 +123,18 @@ export function request(_reqObj) {
|
||||
uni.request(_reqObj);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!hasLogin()){
|
||||
|
||||
if (!hasLogin()) {
|
||||
//todo 这里延迟跳转,等待如果界面又自登陆的话 自登陆完成
|
||||
setTimeout(function(){
|
||||
setTimeout(function() {
|
||||
uni.navigateTo({
|
||||
url:'/pages/login/showlogin'
|
||||
url: '/pages/login/showlogin'
|
||||
})
|
||||
},1500);
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
createSign(_reqObj);
|
||||
|
||||
|
||||
uni.request(_reqObj);
|
||||
}
|
||||
|
||||
@ -127,7 +144,7 @@ export function request(_reqObj) {
|
||||
* @param {Object} _reqObj 请求参数
|
||||
*/
|
||||
export function requestNoAuth(_reqObj) {
|
||||
debug('java110Request','requestNoAuth',_reqObj);
|
||||
debug('java110Request', 'requestNoAuth', _reqObj);
|
||||
//这里判断只有在 post 方式时 放加载框
|
||||
if (_reqObj.hasOwnProperty("method") && "POST" == _reqObj.method) {
|
||||
uni.showLoading({
|
||||
@ -148,6 +165,6 @@ export function requestNoAuth(_reqObj) {
|
||||
_reqObj.header = _headers;
|
||||
}
|
||||
createSign(_reqObj);
|
||||
|
||||
|
||||
uni.request(_reqObj);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user