장주현

예상 원화 가격 확인 기능 추가

...@@ -26,7 +26,7 @@ var cityE, stateE, streetE; ...@@ -26,7 +26,7 @@ var cityE, stateE, streetE;
26 26
27 app.get('/', function(req, res){ 27 app.get('/', function(req, res){
28 //res.send('hello world'); 28 //res.send('hello world');
29 - res.render('index'); 29 + res.render('index');
30 30
31 }); 31 });
32 32
...@@ -39,66 +39,161 @@ var cityE, stateE, streetE; ...@@ -39,66 +39,161 @@ var cityE, stateE, streetE;
39 //app.use('/', indexRoute); 39 //app.use('/', indexRoute);
40 40
41 app.post('/', async function(req,res){ 41 app.post('/', async function(req,res){
42 - console.log(req.body); 42 + if(req.body.process == "주소 변환"){
43 - zipcode = req.body.zipcode; 43 + console.log(req.body);
44 - addressK = req.body.addressK; 44 + zipcode = req.body.zipcode;
45 - addressE = req.body.addressE; 45 + addressK = req.body.addressK;
46 - detailaddressK = req.body.detailaddressK; 46 + addressE = req.body.addressE;
47 - extraaddressK = req.body.extraaddressK; 47 + detailaddressK = req.body.detailaddressK;
48 - extraaddressK = extraaddressK.replace("(", ""); 48 + extraaddressK = req.body.extraaddressK;
49 - extraaddressK = extraaddressK.replace(")", ""); 49 + extraaddressK = extraaddressK.replace("(", "");
50 - console.log(extraaddressK); 50 + extraaddressK = extraaddressK.replace(")", "");
51 - console.log(addressK); 51 + console.log(extraaddressK);
52 - //trans(detailaddressK, detailaddressE); 52 + console.log(addressK);
53 - //trans(extraaddressK, extraaddressE); 53 + //trans(detailaddressK, detailaddressE);
54 - request.post( 54 + //trans(extraaddressK, extraaddressE);
55 - { 55 + request.post(
56 - url: PAPAGO_URL, 56 + {
57 - headers: { 57 + url: PAPAGO_URL,
58 - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 58 + headers: {
59 - 'X-Naver-Client-Id': `${PAPAGO_ID}`, 59 + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
60 - 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` 60 + 'X-Naver-Client-Id': `${PAPAGO_ID}`,
61 - }, 61 + 'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
62 - body: 'source=ko&target=en&text=' + detailaddressK, 62 + },
63 - json:true 63 + body: 'source=ko&target=en&text=' + detailaddressK,
64 - },(error, response, body) => { 64 + json:true
65 - if(!error && response.statusCode == 200) { 65 + },(error, response, body) => {
66 - console.log(body.message); 66 + if(!error && response.statusCode == 200) {
67 - detailaddressE = body.message.result.translatedText; 67 + console.log(body.message);
68 + detailaddressE = body.message.result.translatedText;
69 + }
70 + });
71 + request.post(
72 + {
73 + url: PAPAGO_URL,
74 + headers: {
75 + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
76 + 'X-Naver-Client-Id': `${PAPAGO_ID}`,
77 + 'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
78 + },
79 + body: 'source=ko&target=en&text=' + extraaddressK,
80 + json:true
81 + },(error, response, body) => {
82 + if(!error && response.statusCode == 200) {
83 + console.log(body.message);
84 + extraaddressE = body.message.result.translatedText;
85 + }
86 + });
87 +
88 + setTimeout(function(){
89 + var splitaddressE = addressE.split(", ");
90 + cityE = splitaddressE[4];
91 + stateE = splitaddressE[3];
92 + streetE = splitaddressE[0] + ", " +splitaddressE[1] + ", " + splitaddressE[2];
93 + },300);
94 + setTimeout(function(){console.log("set2: " +detailaddressE)},300);
95 + setTimeout(function(){console.log("set2: " +extraaddressE)},300);
96 + //var splitaddressE = addressE.split(", ")
97 + console.log("address: " + addressE);
98 + if(req.body.os == "amazon"){
99 + res.render('amazonaddr', { cityE : cityE, stateE : stateE, streetE : streetE, detailaddressE : detailaddressE, extraaddressE : extraaddressE, zipcode : zipcode, os : req.body.os});
100 + }
101 + if(req.body.os == "ebay"){
102 + res.render('ebayaddr', { cityE : cityE, stateE : stateE, streetE : streetE, detailaddressE : detailaddressE, extraaddressE : extraaddressE, zipcode : zipcode, os : req.body.os});
103 + }
104 + }
105 + else if(req.body.process == "환율 계산"){
106 + var card = req.body.card;
107 + var credit = req.body.credit;
108 + var brand = req.body.brand;
109 + var moneyU = Number(req.body.moneyU);
110 + var addmoneyU = 0;
111 + var addpersent = 0;
112 + var exchange;
113 + if(brand == "VISA"){
114 + addpersent += 0.011;
115 + }
116 + else if(brand == "MASTER"){
117 + addpersent += 0.01;
118 + }
119 + else if(brand == "American Express"){
120 + addpersent += 0.01;
121 + }
122 + else if(brand == "JCB"){
123 + }
124 + else if(brand == "UnionPay"){
125 + if(card == "KB국민카드"){
126 + addpersent += 0.008;
68 } 127 }
69 - }); 128 + }
70 - request.post( 129 +
71 - { 130 + if(card =="KB국민카드"){
72 - url: PAPAGO_URL, 131 + addpersent += 0.0025;
73 - headers: { 132 + }
74 - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 133 + else if(card =="NH농협카드"){
75 - 'X-Naver-Client-Id': `${PAPAGO_ID}`, 134 + if(credit == "신용카드"){
76 - 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` 135 + addpersent += 0.0025;
77 - }, 136 + }
78 - body: 'source=ko&target=en&text=' + extraaddressK, 137 + else if(credit == "체크카드"){
79 - json:true 138 + addmoneyU += 0.5;
80 - },(error, response, body) => {
81 - if(!error && response.statusCode == 200) {
82 - console.log(body.message);
83 - extraaddressE = body.message.result.translatedText;
84 } 139 }
85 - }); 140 + }
141 + else if(card =="롯데카드"){
142 + addpersent += 0.002;
143 + }
144 + else if(card =="삼성카드"){
145 + addpersent += 0.002;
146 + }
147 + else if(card =="신한카드"){
148 + if(credit == "신용카드"){
149 + addpersent += 0.0018;
150 + }
151 + else if(credit == "체크카드"){
152 + addpersent += 0.002;
153 + }
154 + }
155 + else if(card =="씨티카드"){
156 + addpersent += 0.0025;
157 + }
158 + else if(card =="우리카드"){
159 + if(credit == "신용카드"){
160 + addpersent += 0.003;
161 + }
162 + else if(credit == "체크카드"){
163 + addmoneyU += 0.5;
164 + }
165 + }
166 + else if(card =="현대카드"){
167 + if(credit == "신용카드"){
168 + addpersent += 0.0018;
169 + }
170 + else if(credit == "체크카드"){
171 + }
172 + }
173 + else if(card =="하나카드"){
174 + if(credit == "신용카드"){
175 + addpersent += 0.002;
176 + }
177 + else if(credit == "체크카드"){
178 + addmoneyU += 0.5;
179 + }
180 + }
181 + else if(card =="BC카드"){
182 + }
183 +
184 + request({
185 + encoding: "utf-8",
186 + method: "GET",
187 + uri : "https://api.exchangeratesapi.io/2020-06-10?base=USD&symbols=KRW"
188 + }, function(err,res,html){
189 + exchange = Number(html.substring(16,23));
190 + })
191 + setTimeout(function(){
192 + var result = (moneyU + addmoneyU) * (1 + addpersent) * exchange;
193 + console.log(result);
194 + res.send("원화: "+ result + "원");
195 + },300);
86 196
87 - setTimeout(function(){
88 - var splitaddressE = addressE.split(", ");
89 - cityE = splitaddressE[4];
90 - stateE = splitaddressE[3];
91 - streetE = splitaddressE[0] + ", " +splitaddressE[1] + ", " + splitaddressE[2];
92 - },300);
93 - setTimeout(function(){console.log("set2: " +detailaddressE)},300);
94 - setTimeout(function(){console.log("set2: " +extraaddressE)},300);
95 - //var splitaddressE = addressE.split(", ")
96 - console.log("address: " + addressE);
97 - if(req.body.os == "amazon"){
98 - res.render('amazonaddr', { cityE : cityE, stateE : stateE, streetE : streetE, detailaddressE : detailaddressE, extraaddressE : extraaddressE, zipcode : zipcode, os : req.body.os});
99 - }
100 - if(req.body.os == "ebay"){
101 - res.render('ebayaddr', { cityE : cityE, stateE : stateE, streetE : streetE, detailaddressE : detailaddressE, extraaddressE : extraaddressE, zipcode : zipcode, os : req.body.os});
102 } 197 }
103 }); 198 });
104 199
......
...@@ -12,7 +12,35 @@ ...@@ -12,7 +12,35 @@
12 <p> 사용할 해외 쇼핑몰 선택 후 변환</p> 12 <p> 사용할 해외 쇼핑몰 선택 후 변환</p>
13 <input type="radio" name="os" value="amazon" checked="checked">Amazon 13 <input type="radio" name="os" value="amazon" checked="checked">Amazon
14 <input type="radio" name="os" value="ebay">Ebay 14 <input type="radio" name="os" value="ebay">Ebay
15 - <input type="submit" value="주소 변환"> 15 + <input type="submit" name="process" value="주소 변환">
16 +
17 + <br><br><br>
18 + <p> 구매할 물품의 달러가격을 적은후 해당 조건에 맞게 설정후 검색</p>
19 + <input type="text" name="moneyU" placeholder="물품 달러 가격">
20 + <select name="card">
21 + <option value="KB국민카드">KB국민카드</option>
22 + <option value="NH농협카드">NH농협카드</option>
23 + <option value="롯데카드">롯데카드</option>
24 + <option value="삼성카드">삼성카드</option>
25 + <option value="신한카드">신한카드</option>
26 + <option value="씨티카드">씨티카드</option>
27 + <option value="우리카드">우리카드</option>
28 + <option value="현대카드">현대카드</option>
29 + <option value="하나카드">하나카드</option>
30 + <option value="BC카드">BC카드</option>
31 + </select>
32 + <select name="credit">
33 + <option value="신용카드">신용카드</option>
34 + <option value="체크카드">체크카드</option>
35 + </select>
36 + <select name="brand">
37 + <option value="VISA">VISA</option>
38 + <option value="MASTER">MASTER</option>
39 + <option value="American Express">American Express</option>
40 + <option value="JCB">JCB</option>
41 + <option value="UnionPay">UnionPay</option>
42 + </select>
43 + <input type="submit" name="process" value="환율 계산">
16 </form> 44 </form>
17 45
18 <div id="wrap" style="display:none;border:1px solid;width:500px;height:300px;margin:5px 0;position:relative"> 46 <div id="wrap" style="display:none;border:1px solid;width:500px;height:300px;margin:5px 0;position:relative">
......