diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index c8959a3..03d418c 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -2,6 +2,7 @@ const Hex = require('crypto-js/enc-hex'); const SHA1 = require('crypto-js/sha1'); const MD5 = require('crypto-js/md5'); +const CryptoJS = require('crypto-js'); const moment = require('moment'); const uuid = require('uuid'); @@ -11,10 +12,11 @@ async function login (ctx, next) { const models = ctx.fs.dc.models; const params = ctx.request.body; - let userRes = null if (params.username && params.password) { - const password = Hex.stringify(MD5(params.password)); + const secretKey = 'freesun'; + const decryptedPassword = CryptoJS.AES.decrypt(params.password, secretKey).toString(CryptoJS.enc.Utf8); + const password = Hex.stringify(MD5(decryptedPassword)); userRes = await models.User.findOne({ attributes: { exclude: ['password'] }, where: { diff --git a/api/app/lib/controllers/member/index.js b/api/app/lib/controllers/member/index.js index ed65497..2b0a2af 100644 --- a/api/app/lib/controllers/member/index.js +++ b/api/app/lib/controllers/member/index.js @@ -1,6 +1,7 @@ 'use strict'; const Hex = require('crypto-js/enc-hex'); const MD5 = require('crypto-js/md5'); +const CryptoJS = require('crypto-js'); function getUserList(opts) { return async function (ctx, next) { @@ -83,14 +84,17 @@ function editUser(opts) { const { id } = ctx.params; const body = ctx.request.body; if (body.oldpassword) { - const password = Hex.stringify(MD5(body.oldpassword)); + const secretKey = 'freesun'; + const decryptedOldPassword = CryptoJS.AES.decrypt(body.oldpassword, secretKey).toString(CryptoJS.enc.Utf8); + const decryptedPassword = CryptoJS.AES.decrypt(body.password, secretKey).toString(CryptoJS.enc.Utf8); + const password = Hex.stringify(MD5(decryptedOldPassword)); const checkPwd = await models.User.findOne({ where: { id: id, password } }); if (!checkPwd) { ctx.status = 400; ctx.body = { message: '旧密码错误' } } else { await models.User.update( - { password: Hex.stringify(MD5(body.password)) }, + { password: Hex.stringify(MD5(decryptedPassword)) }, { where: { id: id, } } ) ctx.status = 204; diff --git a/api/app/lib/controllers/superScreen/community.js b/api/app/lib/controllers/superScreen/community.js index 67ff20e..6f54307 100644 --- a/api/app/lib/controllers/superScreen/community.js +++ b/api/app/lib/controllers/superScreen/community.js @@ -1,4 +1,6 @@ 'use strict'; +const request = require("superagent"); +const cheerio = require('cheerio'); function getPersonAge(opts) { return async function (ctx, next) { @@ -145,9 +147,44 @@ function getHomeInfo(opts) { } } +function getFgjvNotice(opts) { + return async function (ctx, next) { + let errMsg = { message: '获取房管局通知失败' } + try { + let rslt = []; + const res = await request.get('https://www.nc.gov.cn/ncszf/fgjv/2021_nav_list.shtml'); + const $ = cheerio.load(res.text); + $('div.pageList-line ul').children('li').each(function (i, elem) { + if (i >= 5) return false; + let obj = {}; + const a = $(this).find('a'); + obj.title = a.text(); + obj.time = $(this).find('span').text(); + obj.link = 'https://www.nc.gov.cn' + a.attr('href'); + rslt.push(obj); + }); + const promistArr = rslt.map(obj => request.get(obj.link)); + const detailRes = await Promise.all(promistArr); + for (let i = 0; i < rslt.length; i++) { + const detail$ = cheerio.load(detailRes[i].text); + const temp = detail$('ucapcontent').text().trim().substring(0, 50).replace(/\n/g, ""); + rslt[i].detail = temp; + } + + ctx.status = 200; + ctx.body = rslt; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = errMsg + } + } +} + module.exports = { getPersonAge, getHomePerson, - getHomeInfo + getHomeInfo, + getFgjvNotice } diff --git a/api/app/lib/middlewares/authenticator.js b/api/app/lib/middlewares/authenticator.js index bf83caa..ac60cfd 100644 --- a/api/app/lib/middlewares/authenticator.js +++ b/api/app/lib/middlewares/authenticator.js @@ -73,6 +73,7 @@ let isPathExcluded = function (opts, path, method) { excludeOpts.push({ p: '/person/age', o: 'GET' }); excludeOpts.push({ p: '/home/person', o: 'GET' }); excludeOpts.push({ p: '/community/info', o: 'GET' }); + excludeOpts.push({ p: '/community/fgjv/notice', o: 'GET' }); excludes = new ExcludesUrls(excludeOpts); } diff --git a/api/app/lib/routes/superScreen/community.js b/api/app/lib/routes/superScreen/community.js index 2ed2eeb..0934dff 100644 --- a/api/app/lib/routes/superScreen/community.js +++ b/api/app/lib/routes/superScreen/community.js @@ -16,4 +16,7 @@ module.exports = function (app, router, opts, AuthCode) { app.fs.api.logAttr['GET/community/info'] = { content: '获取社区房屋统计信息', visible: true }; router.get('/community/info', community.getHomeInfo(opts)); + //获取房管局通知 + app.fs.api.logAttr['GET/community/fgjv/notice'] = { content: '获取房管局通知', visible: true }; + router.get('/community/fgjv/notice', community.getFgjvNotice(opts)); }; diff --git a/api/package.json b/api/package.json index 65da9b7..5e7f62e 100644 --- a/api/package.json +++ b/api/package.json @@ -18,6 +18,7 @@ "ali-oss": "^6.17.1", "args": "^3.0.7", "better-xlsx": "^0.7.6", + "cheerio": "^1.0.0-rc.12", "clickhouse": "^2.6.0", "crypto-js": "^4.0.0", "diskinfo": "0.0.3", diff --git a/super-screen/client/assets/images/homepage/communtity/arrow_right.png b/super-screen/client/assets/images/homepage/communtity/arrow_right.png new file mode 100644 index 0000000..7399c36 Binary files /dev/null and b/super-screen/client/assets/images/homepage/communtity/arrow_right.png differ diff --git a/super-screen/client/assets/images/homepage/communtity/notice.png b/super-screen/client/assets/images/homepage/communtity/notice.png new file mode 100644 index 0000000..0907013 Binary files /dev/null and b/super-screen/client/assets/images/homepage/communtity/notice.png differ diff --git a/super-screen/client/src/sections/community-safty/components/city-safty.js b/super-screen/client/src/sections/community-safty/components/city-safty.js index ba74c68..c451f8f 100644 --- a/super-screen/client/src/sections/community-safty/components/city-safty.js +++ b/super-screen/client/src/sections/community-safty/components/city-safty.js @@ -8,60 +8,88 @@ import './style.less'; function CitySafty(props) { const { waterLevelAlarms } = props; - const { data: fireAlarms = [] } = useFsRequest({ url: ApiTable.getFireAlarmList }); + // const { data: fireAlarms = [] } = useFsRequest({ url: ApiTable.getFireAlarmList }); - const getContent = () => { - return