diff --git a/constant/MappingConstant.js b/constant/MappingConstant.js index 0a623a0..f49754a 100644 --- a/constant/MappingConstant.js +++ b/constant/MappingConstant.js @@ -10,6 +10,9 @@ class MappingConstant{ static TOKEN = "token"; // token 标识 static USER_INFO = "userInfo"; // 用户信息 static AREA_INFO = "areaInfo"; // 地区信息 + static CURRENT_COMMUNITY_INFO = "currentCommunityInfo"; // 小区信息 + static OWNER_INFO = "ownerInfo"; // 当前业主信息 + static CURRENT_COMMUNITY_INFO = "currentCommunityInfo"; //业主当前小区信息 } diff --git a/constant/UrlConstant.js b/constant/UrlConstant.js index 895ff22..c4d2e93 100644 --- a/constant/UrlConstant.js +++ b/constant/UrlConstant.js @@ -21,8 +21,12 @@ const baseUrl = 'https://app.demo.winqi.cn/'; //家庭成员 const saveOwner=baseUrl + 'app/owner.saveOwner'; + //绑定业主 const appUserBindingOwner = baseUrl + 'app/owner.appUserBindingOwner'; + //查询绑定业主 + const queryAppUserBindingOwner = baseUrl + 'app/owner.listAppUserBindingOwners'; + module.exports = { @@ -33,5 +37,6 @@ module.exports = { saveOwnerRepair: saveOwnerRepair, listOwnerRepairs: listOwnerRepairs, saveOwner: saveOwner, - appUserBindingOwner: appUserBindingOwner + appUserBindingOwner: appUserBindingOwner, + queryAppUserBindingOwner: queryAppUserBindingOwner }; \ No newline at end of file diff --git a/context/Java110Context.js b/context/Java110Context.js index 5912ac4..2dbb639 100644 --- a/context/Java110Context.js +++ b/context/Java110Context.js @@ -115,6 +115,56 @@ const _loadArea = function (_level, _parentAreaCode, callBack = (_areaList)=>{}) }) } +const getOwner = function(callBack = (_ownerInfo)=>{}){ + // 从硬盘中获取 业主信息 + let _ownerInfo = wx.getStorageSync(constant.mapping.OWNER_INFO); + if (_ownerInfo){ + callBack(_ownerInfo); + }else{ + wx.request({ + url: constant.url.queryAppUserBindingOwner, + header: getHeaders(), + data: { + + }, + success: function (res) { + console.log('login success'); + let data = res.data; + console.log(res); + if(res.statusCode == 200){ + _ownerInfo = data.auditAppUserBindingOwners[0]; + if (_ownerInfo.state == '12000'){ + wx.setStorageSync(constant.mapping.OWNER_INFO, _ownerInfo); + let _currentCommunityInfo = { + communityId: _ownerInfo.communityId, + communityName: _ownerInfo.communityName + } + wx.setStorageSync(constant.mapping.CURRENT_COMMUNITY_INFO, _currentCommunityInfo); + } + callBack(data.auditAppUserBindingOwners[0]); + } + }, + + fail: function (error) { + // 调用服务端登录接口失败 + wx.showToast({ + title: '调用接口失败', + }); + console.log(error); + } + }) + } + +} + +/** + * 获取当前小区信息 + */ +const getCurrentCommunity = function(){ + let communityInfo = wx.getStorageSync(constant.mapping.CURRENT_COMMUNITY_INFO); + return communityInfo; +} + module.exports = { constant: constant, util: util, @@ -124,5 +174,7 @@ module.exports = { getUserInfo: getUserInfo, getLoginFlag: getLoginFlag, _loadArea: _loadArea, - getCurrentLocation: getCurrentLocation + getCurrentLocation: getCurrentLocation, + getOwner: getOwner, + getCurrentCommunity: getCurrentCommunity }; \ No newline at end of file diff --git a/pages/my/my.js b/pages/my/my.js index b8fe1d4..c87076c 100644 --- a/pages/my/my.js +++ b/pages/my/my.js @@ -7,13 +7,16 @@ const app = getApp(); Page({ data: { userInfo: {}, // 用户信息 + ownerFlag: false // 是否有业主信息 标记 如果有为 true 没有为false }, onLoad: function() { let _that = this; factory.login.checkLoginStatus(function(){ _that.setData({ userInfo: context.getUserInfo() - }); + }); + //查询用户信息 + _that.loadOwenrInfo(); }); }, @@ -27,5 +30,25 @@ Page({ wx.navigateTo({ url: '../bindOwner/bindOwner', }) + }, + viewOwner: function () { + wx.navigateTo({ + url: '../viewBindOwner/viewBindOwner', + }) + }, + loadOwenrInfo:function(){ + let _that = this; + context.getOwner(function(_ownerInfo){ + console.log(_ownerInfo); + if (_ownerInfo){ + _that.setData({ + ownerFlag:true + }) + }else{ + _that.setData({ + ownerFlag: false + }) + } + }); } }) \ No newline at end of file diff --git a/pages/my/my.wxml b/pages/my/my.wxml index df7896b..040499c 100644 --- a/pages/my/my.wxml +++ b/pages/my/my.wxml @@ -25,7 +25,7 @@ - + 绑定业主 @@ -33,6 +33,14 @@ + + + + 业主信息 + + + +