Skip to content

Commit

Permalink
更改线上请求地址
Browse files Browse the repository at this point in the history
  • Loading branch information
wwenj committed Nov 17, 2019
1 parent f616c33 commit fe925b3
Show file tree
Hide file tree
Showing 103 changed files with 186 additions and 147 deletions.
22 changes: 22 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.DS_Store
node_modules
# /dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
account.js
3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
"start": "node ./bin/www",
"pub":"export PORT=80 && npm run start"
},
"dependencies": {
"cookie-parser": "~1.4.4",
Expand Down
51 changes: 27 additions & 24 deletions server/routes/trip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var express = require('express');
var router = express.Router();
var mysql = require('mysql');

var ACC = require('../account');

var data = {
code: 200,
Expand All @@ -16,12 +16,15 @@ var allDistanceData = {
allTaxi: 0,
allWalk: 0
}
var pool = mysql.createPool({
host: '39.106.8.114',
user: '**',
password: '**',
database: 'trip'
});
var pool = mysql.createPool(
ACC.mysql
// {
// host: '39.**.*.114',
// user: '**',
// password: '**',
// database: '**'
// }
);
/* GET users listing. */
// 历史列表接口
router.get('/historyList', function (req, res, next) {
Expand Down Expand Up @@ -73,17 +76,17 @@ router.get('/allDistance', function (req, res, next) {
router.get('/addTrip', function (req, res, next) {
let query = req.query
if (query.tripType === '徒步出行') {
allDistanceData.allWalk = (Number(allDistanceData.allWalk)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allWalk',allDistanceData.allWalk,query.userId)
allDistanceData.allWalk = (Number(allDistanceData.allWalk) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allWalk', allDistanceData.allWalk, query.userId)
} else if (query.tripType === '跑步出行') {
allDistanceData.allRun = (Number(allDistanceData.allRun)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allRun',allDistanceData.allRun,query.userId)
allDistanceData.allRun = (Number(allDistanceData.allRun) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allRun', allDistanceData.allRun, query.userId)
} else if (query.tripType === '骑车出行') {
allDistanceData.allCycle = (Number(allDistanceData.allCycle)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allCycle',allDistanceData.allCycle,query.userId)
allDistanceData.allCycle = (Number(allDistanceData.allCycle) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allCycle', allDistanceData.allCycle, query.userId)
} else if (query.tripType === '自驾出行') {
allDistanceData.allDrive = (Number(allDistanceData.allDrive)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allDrive',allDistanceData.allDrive,query.userId)
allDistanceData.allDrive = (Number(allDistanceData.allDrive) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allDrive', allDistanceData.allDrive, query.userId)
}
//增删改查之后查询,并把查询的最终数据返回前端
pool.query(`INSERT INTO trip_data ( userId, type,tripType,distance,date,time,trajectory,Calorie,speed,mark) VALUES ('${query.userId}','${query.type}','${query.tripType}','${query.distance}','${query.date}','${query.time}','${query.trajectory}','${query.Calorie}','${query.speed}','${query.mark}')`, function (err, results, fields) {
Expand All @@ -106,17 +109,17 @@ router.get('/addTrip', function (req, res, next) {
router.get('/addTraffic', function (req, res, next) {
let query = req.query
if (query.tripType === '步行') {
allDistanceData.allWalk = (Number(allDistanceData.allWalk)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allWalk',allDistanceData.allWalk,query.userId)
allDistanceData.allWalk = (Number(allDistanceData.allWalk) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allWalk', allDistanceData.allWalk, query.userId)
} else if (query.tripType === '出租车') {
allDistanceData.allTaxi = (Number(allDistanceData.allTaxi)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allTaxi',allDistanceData.allTaxi,query.userId)
allDistanceData.allTaxi = (Number(allDistanceData.allTaxi) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allTaxi', allDistanceData.allTaxi, query.userId)
} else if (query.tripType === '单车/电车') {
allDistanceData.allCycle = (Number(allDistanceData.allCycle)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allCycle',allDistanceData.allCycle,query.userId)
allDistanceData.allCycle = (Number(allDistanceData.allCycle) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allCycle', allDistanceData.allCycle, query.userId)
} else if (query.tripType === '公交/地铁') {
allDistanceData.allBus = (Number(allDistanceData.allBus)+Number(query.distance)).toFixed(2)
allDistanceUpdate('allBus',allDistanceData.allBus,query.userId)
allDistanceData.allBus = (Number(allDistanceData.allBus) + Number(query.distance)).toFixed(2)
allDistanceUpdate('allBus', allDistanceData.allBus, query.userId)
}
//增删改查之后查询,并把查询的最终数据返回前端
pool.query(`INSERT INTO trip_data ( userId, type, tripType, distance, date, time, price, startPlace, endPlace, startCode, endCode, mark) VALUES ('${query.userId}','${query.type}','${query.tripType}','${query.distance}','${query.date}','${query.time}','${query.price}','${query.startPlace}','${query.endPlace}','${query.startCode}','${query.endCode}','${query.mark}')`, function (err, results, fields) {
Expand All @@ -136,7 +139,7 @@ router.get('/addTraffic', function (req, res, next) {
})

// 更新里程
function allDistanceUpdate(key,value,userId){
function allDistanceUpdate(key, value, userId) {
console.log(`${key}出行里程更新`)
console.log(allDistanceData)
data.data = allDistanceData
Expand Down
17 changes: 10 additions & 7 deletions server/routes/user.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
var express = require('express');
var router = express.Router();
var mysql = require('mysql');

var ACC = require('../account');

var data = {
code: 200,
msg: 'success'
}; //最后返回的json对象

var pool = mysql.createPool({
host: '39.106.8.114',
user: '**',
password: '**',
database: 'trip'
});
var pool = mysql.createPool(
ACC.mysql
// {
// host: '39.**.*.114',
// user: '**',
// password: '**',
// database: '**'
// }
);
router.post('/', function (req, res, next) {
let userName = req.body.userName
let passWord = req.body.passWord
Expand Down
1 change: 1 addition & 0 deletions view/dist/css/app.292f0060.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion view/dist/css/app.882fb230.css

This file was deleted.

1 change: 0 additions & 1 deletion view/dist/css/chunk-06198ff6.2d45934e.css

This file was deleted.

1 change: 1 addition & 0 deletions view/dist/css/chunk-08d6af33.39536fcd.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions view/dist/css/chunk-16b48e83.6730537f.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
1 change: 0 additions & 1 deletion view/dist/css/chunk-284328ac.5b3d2c9e.css

This file was deleted.

1 change: 0 additions & 1 deletion view/dist/css/chunk-2b97a3ce.6a357af6.css

This file was deleted.

Loading

0 comments on commit fe925b3

Please sign in to comment.