diff --git a/api/booking/bookingApi.js b/api/booking/bookingApi.js
index 2fa6c11..1f06a28 100644
--- a/api/booking/bookingApi.js
+++ b/api/booking/bookingApi.js
@@ -17,48 +17,43 @@ mapping
from '../../constant/MappingConstant.js'
import {
- getCurOwner
-} from '../owner/ownerApi.js'
+ getOwnerTel
+} from '../owner/ownerApi.js';
+
+import {getCommunityId} from '../community/communityApi.js'
/**
* 查询订场记录
*/
export function getBooks(_objData) {
return new Promise((resolve, reject) => {
- getCurOwner()
- .then(function(_owner) {
- let d = {
- page: "1",
- row: "1000",
- communityId: _owner.communityId,
-
- }
-
- if (_objData ==0){
- // debugger
- d['personTel']=_owner.link;
- }
+ let d = {
+ page: "1",
+ row: "1000",
+ communityId: getCommunityId(),
+ }
+ if (_objData == 0) {
+ d['personTel'] = getOwnerTel();
+ }
+ request({
+ url: url.querySpacePerson,
+ method: "GET",
+ data: d,
+ success: function(res) {
// debugger
- request({
- url: url.querySpacePerson,
- method: "GET",
- data: d,
- success: function(res) {
- // debugger
- if (res.statusCode == 200) {
- //将业主信息和房屋信息一起返回
- res.data['owner'] = _owner;
- resolve(res.data);
- return;
- } else {
- reject("查询订场信息失败");
- }
- },
- fail: function(res) {
- reject(res);
- }
- });
- });
+ if (res.statusCode == 200) {
+ //将业主信息和房屋信息一起返回
+ //res.data['owner'] = _owner;
+ resolve(res.data);
+ return;
+ } else {
+ reject("查询订场信息失败");
+ }
+ },
+ fail: function(res) {
+ reject(res);
+ }
+ });
});
};
diff --git a/api/community/communityApi.js b/api/community/communityApi.js
index cf139fc..a0142e5 100644
--- a/api/community/communityApi.js
+++ b/api/community/communityApi.js
@@ -98,40 +98,14 @@ export function getCommunityName(){
*/
export function getCurCommunity() {
return new Promise((resolve, reject) => {
- if (hasLogin()) { // 判断是否已经登录
- //已经登录 去后台查询
- getCurOwner()
- .then(function(_ownerInfo) {
- let _currentCommunityInfo = {
- communityId: _ownerInfo.communityId,
- communityName: _ownerInfo.communityName,
- tel:_ownerInfo.sCommunityTel
- };
- resolve(_currentCommunityInfo);
- },function() {
- let _currentCommunityInfo = {
- communityId: mapping.HC_TEST_COMMUNITY_ID,
- communityName: mapping.HC_TEST_COMMUNITY_NAME,
- tel:''
- };
- resolve(_currentCommunityInfo);
- })
- } else {
- //没有登录直接写演示小区信息
- getCommunitys({
- communityId:mapping.HC_TEST_COMMUNITY_ID,
- page:1,
- row:1
- }).then(function(_communitys){
- let _currentCommunityInfo = {
- communityId: _communitys[0].communityId,
- communityName: _communitys[0].name,
- tel:_communitys[0].tel
- };
- resolve(_currentCommunityInfo);
- })
-
+ let _currentCommunityInfo = uni.getStorageSync("currentCommunityInfo");
+ if(!_currentCommunityInfo){
+ _currentCommunityInfo = {
+ communityId:conf.DEFAULT_COMMUNITY_ID,
+ communityName: conf.DEFAULT_COMMUNITY_NAME
+ }
}
+ resolve(_currentCommunityInfo);
})
}
diff --git a/api/owner/ownerApi.js b/api/owner/ownerApi.js
index cab862f..fc876d9 100644
--- a/api/owner/ownerApi.js
+++ b/api/owner/ownerApi.js
@@ -1,5 +1,5 @@
/**
- * 首页相关 数据封装API
+ * 业主相关 数据封装API
* add by 吴学文 2020-09-07
* QQ 92825595
*
@@ -22,55 +22,45 @@ export function getOwnerId() {
return "-1"
}
+export function getOwnerName() {
+ let _ownerInfo = wx.getStorageSync(mapping.OWNER_INFO);
+ if (_ownerInfo) {
+ return _ownerInfo.ownerName;
+ }
+ return "-1"
+}
+
+export function getOwnerTel() {
+ let _ownerInfo = wx.getStorageSync(mapping.OWNER_INFO);
+ if (_ownerInfo) {
+ return _ownerInfo.ownerTel;
+ }
+ return "-1"
+}
+
+export function getMemberId() {
+ let _ownerInfo = wx.getStorageSync(mapping.OWNER_INFO);
+ if (_ownerInfo) {
+ return _ownerInfo.memberId;
+ }
+ return "-1"
+}
+
/**
* 查询当前业主信息
+ *
+ * return {
+ memberId:'',
+ ownerName:'',
+ ownerId:'',
+ ownerTel:''
+ }
*/
export function getCurOwner() {
- return new Promise(
- (resolve, reject) => {
- let _ownerInfo = wx.getStorageSync(mapping.OWNER_INFO);
- if (_ownerInfo) {
- resolve(_ownerInfo);
- } else {
- //查询用户信息
- let _userInfo = wx.getStorageSync(mapping.USER_INFO);
- if (!_userInfo) {
- reject();
- return;
- }
- request({
- url: url.queryAppUserBindingOwner,
- data: {
- openId: JSON.parse(_userInfo).openId
- },
- success: function(res) {
- let _json = res.data;
- if (_json.code == 0) {
- _ownerInfo = _json.data[0];
- if (_ownerInfo == null || _ownerInfo == undefined) {
- //没有业主信息
- reject();
- return;
- }
- if (_ownerInfo.state == '12000') {
- wx.setStorageSync(mapping.OWNER_INFO, _ownerInfo);
- let _currentCommunityInfo = {
- communityId: _ownerInfo.communityId,
- communityName: _ownerInfo.communityName
- };
- wx.setStorageSync(mapping.CURRENT_COMMUNITY_INFO,
- _currentCommunityInfo);
- }
- resolve(_json.data[0]);
- }
- },
- fail: function(error) {
- // 查询失败
- reject();
- }
- });
- }
- });
+ return new Promise((resolve, reject) => {
+ let _ownerInfo = uni.getStorageSync(mapping.OWNER_INFO);
+ resolve(_ownerInfo);
+ });
}
/**
diff --git a/api/user/sessionApi.js b/api/user/sessionApi.js
new file mode 100644
index 0000000..5c3580c
--- /dev/null
+++ b/api/user/sessionApi.js
@@ -0,0 +1,181 @@
+/**
+ * 自登陆处理js
+ *
+ */
+import {
+ refreshUserOpenId,
+ getWechatMiniOpenId,
+ getCommunityWechatAppId,
+} from '../../api/user/userApi.js';
+
+import {
+ getCommunityId
+} from '../../api/community/communityApi.js';
+
+import {
+ saveOwnerStorage,
+ saveUserLoginInfo,
+ removeUserLoginInfo,
+ getWAppId,
+ saveWAppId,
+ getLoginFlag
+ } from '@/lib/java110/utils/StorageUtil.js';
+
+import {
+ isWxOrAli
+ } from '../../lib/java110/utils/EnvUtil.js';
+
+const LOGIN_FLAG = 'loginFlag'; //登录标识
+
+/**
+ * 是否 登录
+ */
+export function hasLogin() {
+ let loginFlag = wx.getStorageSync(LOGIN_FLAG);
+ let nowDate = new Date();
+ if (loginFlag && loginFlag.expireTime > nowDate.getTime()) {
+ return true;
+ } else {
+ return false;
+ }
+};
+
+
+/**
+ * 自登陆
+ * @param {Object} _objData
+ */
+export function autoLogin(options) {
+ //todo 检查登录信息是否过期
+ if (hasLogin()) {
+ return;
+ }
+ //todo 如果是 h5 或者 微信小程序 ,检查是否做了配置,如果没有做配置不做自登陆
+ // #ifdef H5 || MP-MP-WEIXIN
+ autoLoginWechat(options);
+ // #endif
+
+}
+
+/**
+ * 主要完成 appId 查询
+ * @param {Object} options
+ */
+export function autoLoginWechat(options) {
+ let _openId = options.openId;
+ if(_openId){ //h5 自登陆的情况
+ loginByOpenId(_openId);
+ return;
+ }
+
+ let _objType = "1100"; // todo public
+ // #ifdef MP-WEIXIN
+ _objType = "1000";
+ // #endif
+ getCommunityWechatAppId({
+ communityId: getCommunityId(),
+ objType: _objType
+ }).then(_data => {
+ if (!_data.data || _data.data.indexOf('wx') < 0) {
+ return;
+ }
+ _generatorOpenId(options, _data.data);
+ })
+}
+
+export function _generatorOpenId(options, appId) {
+ // #ifdef H5
+ //todo h5 情况
+ _refreshWechatOpenId(options, appId);
+ return;
+ // #endif
+
+ // #ifdef MP-WEIXIN
+ _refreshWechatMiniOpenId(options, appId);
+ // #endif
+}
+
+export function _refreshWechatOpenId(options, appId) {
+ //todo 不是微信环境 直接进入
+ if (isWxOrAli() != 'WECHAT') {
+ return;
+ }
+ let _redirectUrl = window.location.href;
+ refreshUserOpenId({
+ redirectUrl: _redirectUrl,
+ wAppId: appId,
+ }).then(_data => {
+ if (_data.code == 0) {
+ window.location.href = _data.data.openUrl;
+ return;
+ }
+ });
+}
+export function _refreshWechatMiniOpenId() {
+ let _that = this;
+ wx.login({
+ success: function(loginRes) {
+ if (!loginRes.code) {
+ return;
+ }
+ let accountInfo = uni.getAccountInfoSync();
+ let appId = accountInfo.miniProgram.appId;
+ getWechatMiniOpenId({
+ code: loginRes.code,
+ appId: appId,
+ }).then(_data => {
+ if (_data.code != 0) {
+ uni.showToast({
+ icon: 'none',
+ title: _data.msg
+ })
+ return;
+ }
+ let openId = _data.data;
+ loginByOpenId(openId);
+ })
+ },
+ fail: function(error) {
+ // 调用 wx.login 接口失败
+ console.log('调用wx.login获取code失败');
+ console.log(error);
+ }
+ });
+}
+
+export function loginByOpenId(openId){
+ requestNoAuth({
+ url: url.ownerUserLoginByOpenId,
+ method: "POST",
+ data: {
+ openId:openId
+ },
+ //动态数据
+ success: function(res) {
+ let _json = res.data;
+ if (_json.code != 0) {
+ return;
+ }
+ //todo 保存业主信息
+ uni.setStorageSync("userInfo",_json.data);
+ uni.setStorageSync("currentCommunityInfo",{
+ communityId:_json.data.communityId,
+ communityName:_json.data.communityName,
+ });
+ uni.setStorageSync("ownerInfo",{
+ memberId:_json.data.memberId,
+ ownerName:_json.data.ownerName,
+ ownerId:_json.data.ownerId,
+ ownerTel:_json.data.ownerTel,
+ communityId:_json.data.communityId,
+ link:_json.data.ownerTel
+ });
+ saveUserLoginInfo(_json.data.userId, _json.data.token, _json.data.key);
+ },
+ fail: function(e) {
+ uni.hideLoading();
+ reject(e);
+ }
+ });
+
+}
diff --git a/api/user/userApi.js b/api/user/userApi.js
index 42c442b..82df0df 100644
--- a/api/user/userApi.js
+++ b/api/user/userApi.js
@@ -284,13 +284,83 @@ export function getCommunityWechatAppId(_objData){
})
}
+export function ownerLogin(_that, _data) {
+ uni.showLoading({
+ title: '加载中',
+ mask: true
+ });
+ return new Promise(
+ (resolve, reject) => {
+ requestNoAuth({
+ url: url.ownerUserLogin,
+ method: "POST",
+ data: _data,
+ //动态数据
+ success: function(res) {
+ uni.hideLoading();
+ let _json = res.data;
+ if (_json.code != 0) {
+ reject(_json.msg);
+ return;
+ }
+ //todo 保存业主信息
+ uni.setStorageSync("userInfo",_json.data);
+ uni.setStorageSync("currentCommunityInfo",{
+ communityId:_json.data.communityId,
+ communityName:_json.data.communityName,
+ });
+ uni.setStorageSync("ownerInfo",{
+ memberId:_json.data.memberId,
+ ownerName:_json.data.ownerName,
+ ownerId:_json.data.ownerId,
+ ownerTel:_json.data.ownerTel,
+ communityId:_json.data.communityId,
+ link:_json.data.ownerTel
+ })
+ resolve(_json.data);
+ },
+ fail: function(e) {
+ uni.hideLoading();
+ reject(e);
+ }
+ });
+ })
+}
+
+export function refreshAppUserBindingOwnerOpenId(_that, _data) {
+ uni.showLoading({
+ title: '加载中',
+ mask: true
+ });
+ return new Promise(
+ (resolve, reject) => {
+ requestNoAuth({
+ url: url.refreshAppUserBindingOwnerOpenId,
+ method: "POST",
+ data: _data,
+ //动态数据
+ success: function(res) {
+ uni.hideLoading();
+ let _json = res.data;
+ if (_json.code != 0) {
+ reject(_json.msg);
+ return;
+ }
+ resolve(_json);
+ },
+ fail: function(e) {
+ uni.hideLoading();
+ reject(e);
+ }
+ });
+ })
+}
+
export function getUserId(){
let _userInfo = uni.getStorageSync("userInfo");
- console.log('_userInfo',_userInfo)
-
if(!_userInfo){
return null;
}
- return JSON.parse(_userInfo).userId;
+ return _userInfo.userId;
}
diff --git a/components/my/my-person.vue b/components/my/my-person.vue
index a3d8d7b..5fd1aa2 100644
--- a/components/my/my-person.vue
+++ b/components/my/my-person.vue
@@ -58,6 +58,10 @@
import {
getCouponUsers
} from '../../api/fee/feeApi.js';
+
+ import {getCommunityId,getCommunityName} from '../../api/community/communityApi.js';
+
+ import {loadLoginOwner,getMemberId} from '../../api/owner/ownerApi.js';
export default {
name: "my-person",
data() {
@@ -91,6 +95,7 @@
_that.login = false;
return;
}
+ _that.communityName = getCommunityName();
_that.login = true;
_that.loadOwenrInfo();
_that.userInfo = context.getUserInfo();
@@ -104,7 +109,6 @@
loadOwenrInfo: function() {
let _that = this;
context.getOwner(function(_ownerInfo) {
- console.log('_ownerInfo', _ownerInfo);
if (_ownerInfo) {
_that.ownerFlag = true;
} else {
@@ -117,17 +121,20 @@
*/
loadOwnerHeaderImg: function() {
let _that = this;
- context.getOwner(function(_owner) {
- if(_owner.headImgUrl){
- _that.headerImg = _owner.headImgUrl;
+
+ loadLoginOwner({
+ memberId:getMemberId(),
+ communityId:getCommunityId()
+ }).then(_data=>{
+ //console.log(_data);
+ if(_data.url){
+ _that.headerImg = _data.url;
}else{
_that.headerImg =conf.imgUrl+'/h5/images/serve/head.png';
}
- _that.userName = _owner.appUserName;
- _that.userPhone = _owner.link;
- _that.communityName = _owner.communityName;
-
- });
+ _that.userName = _data.name;
+ _that.userPhone = _data.link;
+ })
},
// 余额
loadOwnerAccount: function() {
diff --git a/constant/MappingConstant.js b/constant/MappingConstant.js
index 19dddc0..c0e1410 100644
--- a/constant/MappingConstant.js
+++ b/constant/MappingConstant.js
@@ -20,8 +20,6 @@ class MappingConstant {
static OWNER_INFO = "ownerInfo"; // 当前业主信息
-
- static CURRENT_COMMUNITY_INFO = "currentCommunityInfo"; //业主当前小区信息
static CURRENT_OPEN_ID = "openId";
diff --git a/constant/url.js b/constant/url.js
index df6aec5..584c544 100644
--- a/constant/url.js
+++ b/constant/url.js
@@ -217,6 +217,10 @@ export default {
getWechatMiniOpenId: baseUrl + "app/wechat.getWechatMiniOpenId",
getCommunityWechatAppId: baseUrl + "app/wechat.getCommunityWechatAppId",
cashier: baseUrl + "app/payment.cashier",
+ ownerUserLogin: baseUrl+"app/user.ownerUserLogin",
+ refreshAppUserBindingOwnerOpenId: baseUrl+"app/owner.refreshAppUserBindingOwnerOpenId",
+ ownerUserLoginByOpenId: baseUrl+"app/user.ownerUserLoginByOpenId",
+
diff --git a/core/vcRoute.js b/core/vcRoute.js
index 74ef3d1..d741de9 100644
--- a/core/vcRoute.js
+++ b/core/vcRoute.js
@@ -37,7 +37,6 @@ import {
export function navigateH5(_url) {
-
if (_url.indexOf("http") < 0 && _url.indexOf("https") < 0) {
_url = conf.mallUrl + '#' + _url;
}
@@ -111,11 +110,12 @@ export function navigateTo(_param, callback = () => {}) {
return;
}
debug('vcRoute', 'navigateTo', _param);
+ uni.navigateTo(_param);
//校验是否登录,如果没有登录跳转至温馨提示页面
- checkSession(_param.url, function() {
- //有回话 跳转至相应页面
- uni.navigateTo(_param);
- })
+ // checkSession(_param.url, function() {
+ // //有回话 跳转至相应页面
+ // uni.navigateTo(_param);
+ // })
};
/*
diff --git a/lib/java110/java110Request.js b/lib/java110/java110Request.js
index 3e1b4fe..7530843 100644
--- a/lib/java110/java110Request.js
+++ b/lib/java110/java110Request.js
@@ -10,7 +10,9 @@ import mapping from '../../constant/MappingConstant.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 {debug,warn,info,error} from './utils/LogUtil.js'
@@ -20,15 +22,20 @@ import {debug,warn,info,error} from './utils/LogUtil.js'
**/
export function getHeaders() {
let _wAppId = uni.getStorageSync(mapping.W_APP_ID);
+ let _token = getToken();
+ if(!_token){
+ _token = "no login";
+ }
return {
"app-id": app.appId,
"transaction-id": coreUtil.wxuuid(),
"req-time": getDateYYYYMMDDHHMISS(),
"sign": '1234567',
"user-id": '-1',
- "cookie": '_java110_token_=' + getToken(),
+ //"cookie": '_java110_token_=' + getToken(),
"Accept": '*/*',
- "w-app-id": _wAppId
+ "w-app-id": _wAppId,
+ "Authorization":"Bearer "+_token
};
}
/**
@@ -66,13 +73,17 @@ export function request(_reqObj) {
uni.request(_reqObj);
return;
}
- //校验是否登录
- checkSession(null,function() {
- //有回话 跳转至相应页面
- //重写token
- _reqObj.header.cookie = '_java110_token_=' + wx.getStorageSync('token');
- uni.request(_reqObj);
- })
+
+ if(!hasLogin()){
+ //todo 这里延迟跳转,等待如果界面又自登陆的话 自登陆完成
+ setTimeout(function(){
+ uni.navigateTo({
+ url:'/pages/login/showlogin'
+ })
+ },1500);
+ return;
+ }
+ uni.request(_reqObj);
}
/**
@@ -101,6 +112,6 @@ export function requestNoAuth(_reqObj) {
} else {
_reqObj.header = _headers;
}
- _reqObj.header.cookie = '_java110_token_=' + wx.getStorageSync('token');
+
uni.request(_reqObj);
}
diff --git a/lib/java110/page/Page.js b/lib/java110/page/Page.js
index 6cb9c88..f1485f9 100644
--- a/lib/java110/page/Page.js
+++ b/lib/java110/page/Page.js
@@ -41,28 +41,29 @@ import url from '../../../constant/url.js'
* @param {Object} options 页面参数
*/
export function onLoad(options) {
- pageOnLoad(options);
- let pages = getCurrentPages() // 获取栈实例
- let currentRoute = pages[pages.length - 1].route;
- let _key = options.key;
- if (isNotNull(_key)) {
- //根据key 去做登录
- return ;
- }
+ //pageOnLoad(options);
+ // let pages = getCurrentPages() // 获取栈实例
+ // let currentRoute = pages[pages.length - 1].route;
+ // let _key = options.key;
+ // if (isNotNull(_key)) {
+ // //根据key 去做登录
+ // return;
+ // }
//白名单直接跳过检查登录
// if (!url.NEED_NOT_LOGIN_PAGE.includes(currentRoute)) {
// console.log('NEED_NOT_LOGIN_PAGE')
// checkSession(null,function() {
// })
// }
+
}
/**
* 检查会话是否 存在
* add by 吴学文 QQ:928255095
*/
-export function checkSession(_pageUrl,_call) {
- pageCheckSession(_pageUrl,_call)
+export function checkSession(_pageUrl, _call) {
+ pageCheckSession(_pageUrl, _call)
}
/**
* 是否登录 不跳转 只是判断是否登录
@@ -90,6 +91,6 @@ export function userLogin(_obj) {
* 登录页面 查询code
* @param {Object} options 页面数据
*/
-export function getLoginCode(options){
+export function getLoginCode(options) {
return getPageLoginCode(options)
}
diff --git a/lib/java110/page/PageH5.js b/lib/java110/page/PageH5.js
index caa6f2a..27ed10c 100644
--- a/lib/java110/page/PageH5.js
+++ b/lib/java110/page/PageH5.js
@@ -27,7 +27,7 @@ export function pageOnLoad(options) {
});
}
- getPageWAppId(options);
+ //getPageWAppId(options);
if (isNull(_key)) {
onLoadHasAuth();
@@ -199,7 +199,7 @@ export function pageUserLogin(_obj) {
let _ownerInfo = _data.owner;
saveOwnerStorage(_ownerInfo);
saveUserLoginInfo(_ownerInfo.userId, _data.token, _data.key)
- resolve();
+ resolve(_ownerInfo);
},
fail: function(e) {
uni.hideLoading();
diff --git a/lib/java110/utils/StorageUtil.js b/lib/java110/utils/StorageUtil.js
index 3f98d09..c819c2b 100644
--- a/lib/java110/utils/StorageUtil.js
+++ b/lib/java110/utils/StorageUtil.js
@@ -73,6 +73,12 @@ export function saveUserLoginInfo(_userId,_token,_key){
}
}
+export function removeUserLoginInfo(){
+ wx.removeStorageSync(LOGIN_FLAG);
+ wx.removeStorageSync(TOKEN);
+ wx.removeStorageSync(OWNER_KEY);
+}
+
/**
* 获取用户信息
*
@@ -80,7 +86,7 @@ export function saveUserLoginInfo(_userId,_token,_key){
*/
export function getUserInfo() {
let _userInfo = wx.getStorageSync(USER_INFO);
- return JSON.parse(_userInfo);
+ return _userInfo;
};
export function getToken(){
diff --git a/pages.json b/pages.json
index f434912..e8aedc7 100644
--- a/pages.json
+++ b/pages.json
@@ -943,6 +943,15 @@
}
}
+ ,{
+ "path" : "pages/login/loginInitWechat",
+ "style" :
+ {
+ "navigationBarTitleText": "微信登录中",
+ "enablePullDownRefresh": false
+ }
+
+ }
],
"tabBar": {
"color": "#272636",
diff --git a/pages/fee/oweFee.vue b/pages/fee/oweFee.vue
index 46c51f7..1e55215 100644
--- a/pages/fee/oweFee.vue
+++ b/pages/fee/oweFee.vue
@@ -92,7 +92,8 @@
import {
getRoomFees
- } from '../../api/fee/feeApi.js'
+ } from '../../api/fee/feeApi.js';
+ import {autoLogin} from '../../api/user/sessionApi.js';
export default {
@@ -118,6 +119,7 @@
onLoad: function(options) {
context.onLoad(options);
+ autoLogin(options);
},
onShow() {
let _that = this;
diff --git a/pages/fee/payParkingFeeList.vue b/pages/fee/payParkingFeeList.vue
index 4bb3500..69154cf 100644
--- a/pages/fee/payParkingFeeList.vue
+++ b/pages/fee/payParkingFeeList.vue
@@ -56,7 +56,8 @@
//const util = context.util;
import {formatDate} from '../../lib/java110/utils/DateUtil.js'
- import noDataPage from '@/components/no-data-page/no-data-page.vue'
+ import noDataPage from '@/components/no-data-page/no-data-page.vue';
+ import {autoLogin} from '../../api/user/sessionApi.js';
export default {
data() {
@@ -78,6 +79,7 @@
*/
onLoad: function(options) {
context.onLoad(options);
+ autoLogin(options);
this.appId = options.wAppId;
},
/**
diff --git a/pages/fee/roomFeeListNew.vue b/pages/fee/roomFeeListNew.vue
index a26c0b4..9e0ade6 100644
--- a/pages/fee/roomFeeListNew.vue
+++ b/pages/fee/roomFeeListNew.vue
@@ -47,8 +47,8 @@
import {
getRoomFees
- } from '../../api/fee/feeApi.js'
-
+ } from '../../api/fee/feeApi.js';
+ import {autoLogin} from '../../api/user/sessionApi.js';
export default {
data() {
@@ -70,6 +70,7 @@
*/
onLoad: function(options) {
context.onLoad(options);
+ autoLogin(options);
},
/**
* 生命周期函数--监听页面显示
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 55a8b9a..a0a4f57 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -41,7 +41,8 @@
hasOwner
} from '../../api/owner/ownerApi.js';
- import conf from '@/conf/config.js'
+ import conf from '@/conf/config.js';
+ import {autoLogin} from '../../api/user/sessionApi.js';
export default {
data() {
return {
@@ -74,13 +75,10 @@
title:conf.systemName
})
this.vc.onLoad(options);
+ autoLogin(options);
//查询目录
},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {},
onShareAppMessage: function() {
return {
title: '首页',
diff --git a/pages/login/login.vue b/pages/login/login.vue
index 429aba8..1121c1c 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -43,14 +43,24 @@
import wInput from '../../components/watch-input.vue' //input
import wButton from '../../components/watch-button.vue' //button
import {
- sendSmsCode
+ sendSmsCode,
+ ownerLogin,
} from '../../api/user/userApi.js'
import context from '../../lib/java110/Java110Context.js';
import {
- userLogin,
+
getLoginCode
- } from '../../lib/java110/page/Page.js'
+ } from '../../lib/java110/page/Page.js';
+
+ import {
+ saveOwnerStorage,
+ saveUserLoginInfo,
+ removeUserLoginInfo,
+ getWAppId,
+ saveWAppId,
+ getLoginFlag
+ } from '@/lib/java110/utils/StorageUtil.js'
const constant = context.constant;
const factory = context.factory;
@@ -60,9 +70,8 @@
data() {
return {
logoUrl: '',
- username: '',
- password: '',
- appId: "",
+ username: '18909752222',
+ password: '381309',
code: "",
loginByPhone: false,
msgCode: '',
@@ -74,11 +83,12 @@
},
onLoad(option) {
let that = this;
- getLoginCode(option)
- .then((_code) => {
- that.code = _code
- });
this.logoUrl = constant.url.baseUrl + 'logo.png';
+ //todo 清除缓存内容,以防 业主后退,然后还显示他的东西
+ uni.removeStorageSync("JAVA110_USER_INFO");
+ uni.removeStorageSync("currentCommunityInfo");
+ uni.removeStorageSync("ownerInfo");
+ removeUserLoginInfo();
},
methods: {
_doLogin: function() {
@@ -104,19 +114,23 @@
appId: this.vc.getWAppId(),
loginByPhone: this.loginByPhone
};
- userLogin(_obj)
- .then(() => {
- wx.switchTab({
- url: "/pages/index/index?wAppId=" + _that.vc.getWAppId()
- });
+ ownerLogin(this,_obj)
+ .then((_user) => {
+ //todo 保存登录信息
+ saveUserLoginInfo(_user.userId, _user.token, _user.key);
+ uni.navigateTo({
+ url:'/pages/login/loginInitWechat?communityId='+_user.communityId+"&appUserId="+_user.appUserId
+ })
+ },err=>{
+ uni.showToast({
+ icon:'none',
+ title:err
+ })
});
},
_doRegister: function() {
//let _url = '/pages/login/registerByWechat';
let _url = '/pages/login/register';
- // #ifdef H5
- _url += ('?code=' + this.code);
- // #endif
this.vc.navigateTo({
url: _url
})
diff --git a/pages/login/loginInitWechat.vue b/pages/login/loginInitWechat.vue
new file mode 100644
index 0000000..8d844d4
--- /dev/null
+++ b/pages/login/loginInitWechat.vue
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
+
diff --git a/pages/my/changeOwnerCommunity.vue b/pages/my/changeOwnerCommunity.vue
index 526f75f..d8696b4 100644
--- a/pages/my/changeOwnerCommunity.vue
+++ b/pages/my/changeOwnerCommunity.vue
@@ -61,7 +61,14 @@
},
_doChangeCommunity: function(_community) {
uni.setStorageSync(mapping.CURRENT_COMMUNITY_INFO, _community);
- wx.setStorageSync(mapping.OWNER_INFO, _community);
+ uni.setStorageSync("ownerInfo",{
+ memberId:_community.memberId,
+ ownerName:_community.name,
+ ownerId:_community.ownerId,
+ ownerTel:_community.link,
+ communityId:_community.communityId,
+ link:_community.link
+ })
uni.navigateBack({
delta: 1
})