-
제목:${res[0].title}
-
-
내용:${res[0].content}
+
+
+
+
+
+
${res[0].title}
+
+ ${res[0].content}
-
+
+
`;
- var html = template.HTML(title, head, body);
+ var html = template.HTML(title, head, body, author.statusUI(request, response));
response.send(html);
});
});
diff --git a/routes/community/page_req.js b/routes/community/page_req.js
index f44292e..b01d18e 100644
--- a/routes/community/page_req.js
+++ b/routes/community/page_req.js
@@ -1,30 +1,57 @@
var express = require('express');
var router = express.Router();
var template = require('../../lib/template.js');
+var author = require('../../lib/author.js');
const db = require('../../db.js');
var path = require('path');
router.get('/community/requirement/page/:pageId', function (request, response) {
var pageId = path.parse(request.params.pageId).base;
- db.query(`SELECT * FROM requirement WHERE id=?`, [pageId], function(err, res){
+ db.query(`SELECT * FROM requirement WHERE id=?`, [pageId], function (err, res) {
var title = '건의글보기';
var head = `
-
+
`;
var body = `
-
-
-
제목:${res[0].title}
+
+
+
`;
- var html = template.HTML(title, head, body);
+ var html = template.HTML(title, head, body, author.statusUI(request, response));
response.send(html);
});
});
diff --git a/routes/login.js b/routes/login.js
index a36667e..6e185f6 100644
--- a/routes/login.js
+++ b/routes/login.js
@@ -1,6 +1,7 @@
var express = require('express');
var router = express.Router();
var template = require('../lib/template.js');
+var author = require('../lib/author.js');
router.get('/login', function (request, response) {
var title = '로그인';
@@ -158,13 +159,12 @@ router.get('/login', function (request, response) {
`;
- var html = template.HTML(title, head, body);
+ var html = template.HTML(title, head, body, author.statusUI(request, response));
response.send(html);
});
diff --git a/routes/login_process.js b/routes/login_process.js
new file mode 100644
index 0000000..2dc707b
--- /dev/null
+++ b/routes/login_process.js
@@ -0,0 +1,34 @@
+var express = require('express');
+var router = express.Router();
+var template = require('../lib/template.js');
+const db = require('../db.js');
+var qs = require('querystring');
+
+router.post('/login_process', function (request, response) {
+ var body = ``;
+ request.on('data', function(data){
+ body = body + data;
+ });
+ request.on('end', function(){
+ var post = qs.parse(body);
+ var email = post.email;
+ var password = post.password;
+ db.query(`SELECT password, nickname FROM user WHERE email=?`, [email], function(err, res){
+ console.log(res[0]);
+ console.log(request.session);
+ if(res[0].password == password){
+ request.session.is_logined = true;
+ request.session.email = email;
+ request.session.nickname = res[0].nickname;
+ request.session.save(function() {
+ response.redirect(`/`);
+ });
+ } else {
+ response.send('Who?');
+ }
+ response.redirect(`/`);
+ });
+ });
+});
+
+module.exports = router;
\ No newline at end of file
diff --git a/routes/logout_process.js b/routes/logout_process.js
new file mode 100644
index 0000000..95dce80
--- /dev/null
+++ b/routes/logout_process.js
@@ -0,0 +1,21 @@
+var express = require('express');
+var router = express.Router();
+var template = require('../lib/template.js');
+const db = require('../db.js');
+var qs = require('querystring');
+
+router.get('/logout_process', function(req,res){
+ if(req.session.user){
+ console.log('logout');
+
+ req.session.destroy(function(err){
+ if(err) throw err;
+ res.redirect('/');
+ });
+ }
+ else{
+ res.redirect('/');
+ }
+});
+
+module.exports = router;
\ No newline at end of file
diff --git a/routes/main.js b/routes/main.js
index 842dda4..df1762e 100644
--- a/routes/main.js
+++ b/routes/main.js
@@ -1,6 +1,7 @@
var express = require('express');
var router = express.Router();
var template = require('../lib/template.js');
+var author = require('../lib/author.js');
router.get('/', function (request, response) {
var title = 'For me 나를 위해';
@@ -318,7 +319,7 @@ router.get('/', function (request, response) {
`;
- var html = template.HTML(title, head, body);
+ var html = template.HTML(title, head, body, author.statusUI(request, response));
response.send(html);
});
diff --git a/routes/mypage/main_mypage.js b/routes/mypage/main_mypage.js
index 3a62063..85fde5b 100644
--- a/routes/mypage/main_mypage.js
+++ b/routes/mypage/main_mypage.js
@@ -1,6 +1,7 @@
var express = require('express');
var router = express.Router();
var template = require('../../lib/template.js');
+var author = require('../../lib/author.js');
const db = require('../../db.js');
router.get('/mypage', function (request, response) {
@@ -11,7 +12,7 @@ router.get('/mypage', function (request, response) {
var head = `
+ `;
+ var body = `
+
+
+
+
+ 나에게 딱맞는 월경용품 찾기
+
+
+
+
+ 시작하기 버튼을 눌러 시작해 주세요.
+
+
+
+
+
+ 나에게 딱맞는 월경용품 찾기 결과는?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `;
+
+ var html = template.HTML(title, head, body, author.statusUI(request, response));
+ response.send(html);
+});
+
+module.exports = router;
diff --git a/routes/prod_rec/question.js b/routes/prod_rec/question.js
new file mode 100644
index 0000000..55b4dc6
--- /dev/null
+++ b/routes/prod_rec/question.js
@@ -0,0 +1,163 @@
+const QnAList = [{
+ q: '월경이 규칙적인가요?',
+ a: [{
+ answer: '예',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '아니오',
+ type: ['pad', 'tampon']
+ },
+ {
+ answer: '잘 모르겠어요',
+ type: ['pad', 'cotton', 'tampon']
+ }
+ ]
+ },
+
+ {
+ q: '월경통이 어느 정도로 심각한가요?',
+ a: [{
+ answer: '거의 없어요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '보통이에요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '심한 편이에요',
+ type: ['cotton', 'tampon']
+ },
+ {
+ answer: '아주 심해요',
+ type: ['cotton', 'cup']
+ }
+ ]
+ },
+
+ {
+ q: '월경시 Y존 민감 증상(쓰라림, 가려움 등)이 있나요?',
+ a: [{
+ answer: '거의 없어요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '보통이에요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '심한 편이에요',
+ type: ['cup', 'cotton', 'tampon']
+ },
+ {
+ answer: '아주 심해요',
+ type: ['cup', 'tampon']
+ }
+ ]
+ },
+
+ {
+ q: '월경시 활동량은 많은 편인가요?',
+ a: [{
+ answer: '거의 움직이지 않는 편이에요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '보통이에요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '매우 활발한 편이에요',
+ type: ['cup', 'tampon']
+ }
+ ]
+ },
+
+ {
+ q: '구매에 대한 생각이 궁금해요!',
+ a: [{
+ answer: '언제 어디서든 쉽게 구할 수 있었으면 좋겠어요',
+ type: ['pad']
+ },
+ {
+ answer: '인터넷에서 사서 상관없어요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '매달 구매하는 과정이 귀찮아요',
+ type: ['cotton', 'cup']
+ }
+ ]
+ },
+
+ {
+ q: '유기농 제품에 대한 생각이 궁금해요',
+ a: [{
+ answer: '잘 모르고 관심없어요',
+ type: ['pad', 'tampon']
+ },
+ {
+ answer: '관심은 있는 데 찾아서 사용하진 않아요',
+ type: ['pad', 'cotton', 'cup', 'tampon']
+ },
+ {
+ answer: '찾아서 사용하고 있어요',
+ type: ['pad', 'cotton', 'cup']
+ }
+ ]
+ },
+
+ {
+ q: '월경용품을 사용하면서 가장 불편한 점은 무엇인가요?',
+ a: [{
+ answer: '쓰레기가 너무 많이 나와요',
+ type: ['cotton', 'cup']
+ },
+ {
+ answer: '장시간 외출 시 사용이 불편해요',
+ type: ['pad', 'tampon']
+ },
+ {
+ answer: '판매하는 제품이 다양하지 않아요',
+ type: ['pad']
+ }
+ ]
+ },
+
+ {
+ q: '삽입형 월경용품에 대한 거부감이 있나요?',
+ a: [{
+ answer: '네 거부감이 있어요',
+ type: ['pad', 'cotton']
+ },
+ {
+ answer: '아뇨 없어요',
+ type: ['cup', 'tampon']
+ },
+ {
+ answer: '잘 모르겠어요',
+ type: ['pad', 'cup', 'cotton', 'tampon']
+ }
+ ]
+ }
+]
+
+
+const infoList = [{
+ name: '클래식 이즈 더 베스트 <일회용 월경대>',
+ desc: '가장 많은 사람들이 사용하고 있는 제품군이예요. 판매하는 제품군이 다양하고 언제 어디서나 쉽게 구할 수 있다는 게 큰 장점이에요.'
+ },
+ {
+ name: ' <면 월경대>',
+ desc: ''
+ },
+ {
+ name: '<월경컵>',
+ desc: '월경계의 신문물 월경컵! 활동이 많은 날도 사용할 수 있어요. 재사용이 가능하고 세척도 쉬운 편 '
+ },
+ {
+ name: ' <탐폰>',
+ desc: '활동이 많은 날에도 샘걱정 없이 사용할 수 있어요! 8시간 이상 사용은 권하지 않아요.'
+ }
+]
\ No newline at end of file
diff --git a/routes/prod_rec/start.js b/routes/prod_rec/start.js
new file mode 100644
index 0000000..523be80
--- /dev/null
+++ b/routes/prod_rec/start.js
@@ -0,0 +1,132 @@
+const main = document.querySelector("#main");
+const qna = document.querySelector("#qna");
+const result = document.querySelector("#result");
+const endPoint = 7;
+const select = [0, 0, 0, 0];
+
+function calResult(){
+ // var pointArray = [
+ // { name: 'pad', value: 0, key: 0 },
+ // { name: 'cotton', value: 0, key: 0},
+ // { name: 'cup', value: 0, key: 0},
+ // { name: 'tampon', value: 0, key: 0}
+ // ]
+ // for(let i = 0; i < endPoint; i++){
+ // var target = QnAList[i].a[select[i]];
+ // for(let j = 0; j < target.type.length; j++){
+ // for(let k = 0; k< pointArray.length; k++){
+ // if(target.type[j] === pointArray[k].name){
+ // pointArray[k].value += 1;
+ // }
+ // }
+ // }
+ // }
+
+ // var resultArray = pointArray.sort(function (a, b){
+ // if(a.value > b.value){
+ // return -1;
+ // }
+ // if(a.value < b.value){
+ // return 1;
+ // }
+ // return 0;
+ // });
+
+ // let resultword = resultArray[0].key;
+ // return resultword;
+
+ console.log(select);
+ var result = select.indexOf(Math.max(...select));
+ return result;
+}
+
+function setResult(){
+ let point = calResult();
+ const resultName = document.querySelector('.resultname');
+ resultName.innerHTML = infoList[point].name;
+
+ var resultImg = document.createElement('img');
+ const imgDiv = document.querySelector('#resultImg');
+ var imgURL = '../../public/images/image-' + point + '.png';
+ resultImg.src = imgURL;
+ resultImg.alt = point;
+ resultImg.classList.add('img-fluid');
+ imgDiv.appendChild(resultImg);
+
+ const resultDesc = document.querySelector('.resultDesc');
+ resultDesc.innerHTML = infoList[point].desc;
+}
+function goResult(){
+ qna.style.WebitAnimation = "fadeOut 1s";
+ qna.style.animation = "fadeOut 1s";
+ setTimeout(() => {
+ result.style.WebitAnimation = "fadeIn 1s";
+ result.style.animation = "fadeIn 1s";
+ setTimeout(() => {
+ qna.style.display = "none";
+ result.style.display = "block";
+ }, 450)})
+ setResult();
+}
+
+function addAnswer(answerText, qIdx, idx) {
+ var a = document.querySelector('.answerBox');
+ var answer = document.createElement('button');
+ answer.classList.add('answerList');
+ answer.classList.add('my-3');
+ answer.classList.add('py-3');
+ answer.classList.add('mx-auto');
+ answer.classList.add('fadeIn');
+
+ a.appendChild(answer);
+ answer.innerHTML = answerText;
+
+ answer.addEventListener("click", function () {
+ var children = document.querySelectorAll('.answerList');
+ for (let i = 0; i < children.length; i++) {
+ children[i].disabled = true;
+ children[i].style.WebitAnimation = "fadeOut 0.3s";
+ children[i].style.animation = "fadeOut 0.3s";
+ }
+ setTimeout(() =>{
+ var target = QnAList[qIdx].a[idx].type;
+ for(let i = 0; i < target.length; i++){
+ select[target[i]] += 1;
+ }
+ for(let i = 0; i < children.length; i++){
+ children[i].style.display = 'none';
+ }
+ goNext(++qIdx);
+ },450)
+ }, false);
+}
+
+function goNext(qIdx) {
+ if (qIdx === endPoint) {
+ goResult()
+ return;
+ }
+ var q = document.querySelector('.qBox');
+ q.innerHTML = QnAList[qIdx].q;
+ for (let i in QnAList[qIdx].a) {
+ addAnswer(QnAList[qIdx].a[i].answer, qIdx, i);
+ }
+ var status = document.querySelector('.statusBar');
+ status.style.width = (100 / endPoint) * (qIdx + 1) + '%';
+}
+
+function begin() {
+ main.style.WebitAnimation = "fadeOut 1s";
+ main.style.animation = "fadeOut 1s";
+ setTimeout(() => {
+
+ qna.style.WebitAnimation = "fadeIn 1s";
+ qna.style.animation = "fadeIn 1s";
+ setTimeout(() => {
+ main.style.display = "none";
+ qna.style.display = "block";
+ }, 450)
+ let qIdx = 0;
+ goNext(qIdx);
+ }, 450);
+}
\ No newline at end of file
diff --git a/routes/recommend.js b/routes/recommend.js
index 954b2b7..4f5386c 100644
--- a/routes/recommend.js
+++ b/routes/recommend.js
@@ -1,6 +1,7 @@
var express = require('express');
var router = express.Router();
var template = require('../lib/template.js');
+var author = require('../lib/author.js');
router.get('/recommend', function (request, response) {
var title = `월경 용품 추천`;
@@ -126,7 +127,7 @@ router.get('/recommend', function (request, response) {