Commit 1034349b authored by yaobeibei's avatar yaobeibei

creat dev oem

parent 39f0e6d4
......@@ -3,3 +3,4 @@
/dist/
/*.js
/test/unit/coverage/
/src/
\ No newline at end of file
......@@ -16,6 +16,8 @@ RUN npm i --only=production --registry https://registry.npm.taobao.org
ENV SERVICE_PORT=8082
ENV PROJECT_LEVEL=production
ENV MONGO='mongodb://mongo-adpro-ssp-v2-rs-1.localhost:1301/remarketing?replicaSet=adpro_ssp_v2_rs'
ENV MONGO_OEM='mongodb://bjwjh-admin:c9yJ2gBFkp7U6@mongo-bjwjh-rs-1.localhost:1302,mongo-bjwjh-rs-2.localhost:1302,mongo-bjwjh-rs-3.localhost:1302/oem_maitian_remarketingAgent?replicaSet=bjwjh-rs&authSource=admin'
ENV NODE_ENV='production'
EXPOSE 8082
CMD node server.js
......@@ -3,45 +3,126 @@ const mongoClient = mongodb.MongoClient
const app = require('express').Router()
const _ = require('lodash')
const moment = require('moment')
var db = {}
var reg = /@test.com$|@123.com$|@goyoo.com$|@xiaoyun.com$|^@|^test|@dis.com$|time-stone.cn$|^tangyong|^875652541|@1.com$|@xioayun.com$/i
var dbpath = null
// if (process.env.MONGO) {
// adminDBpath = process.env.MONGO || 'mongodb://10.11.3.123:1301/remarketing'
// } else {
// adminDBpath = 'mongodb://localhost:27017/remarketing'
// }
// var adminDBpath = null
if (process.env.MONGO) {
dbpath = process.env.MONGO || 'mongodb://10.11.3.123:1301/remarketing'
} else {
dbpath = 'mongodb://localhost:27017/remarketing'
}
var dbpath_oem = null
if (process.env.MONGO) {
dbpath_oem = 'mongodb://bjwjh-admin:c9yJ2gBFkp7U6@mongo-bjwjh-rs-1.localhost:1302,mongo-bjwjh-rs-2.localhost:1302,mongo-bjwjh-rs-3.localhost:1302/oem_maitian_remarketingAgent?replicaSet=bjwjh-rs&authSource=admin'
} else {
dbpath_oem = 'mongodb://localhost:27017/remarketing2'
}
var db = {}
var db_oem_mtty = {}
mongoClient.connect(dbpath, function (err, res) {
if (err) return console.log(err)
db = res.db('remarketing')
})
mongoClient.connect(dbpath, function (err, res) {
if (err) return console.log(err)
db = res.db('remarketing')
db.collection('msgTemps').find({}).toArray((err, r) => {
console.log('数据库已经连接')
})
})
mongoClient.connect(dbpath_oem, function (err, res) {
if (err) return console.log(err)
if (process.env.MONGO) {
db_oem_mtty = res.db('oem_mtty_remarketing')
} else {
db_oem_mtty = res.db('remarketing2')
}
})
function getSession (sessionID, res) {
if (!sessionID) {
// res.send({status: 500, data: '数据库连接失败'})
} else if (sessionID === 'admin') {
return db
} else {
db = db_oem_mtty
return db
}
}
// 登陆接口
app.post('/login', async function (req, res) {
console.log('进入登陆')
let body = req.body
console.log(body)
if (body.userName === 'admin') {
if (body.password === 'goyooyunying') {
res.send({ status: 230, message: '登陆成功' })
let { userEmail, password } = req.body
console.log(req.body)
if (userEmail === 'admin') {
if (password === 'goyooyunying') {
res.send({status: 230, message: '登陆成功', id: 'admin'})
} else {
res.send({ status: 200, message: '密码错误' })
}
} else {
res.send({ status: 200, message: '账号错误' })
await db.collection('OEM_account').find({OEM_email: userEmail}).toArray( (err, data) => {
console.log(data)
if (data[0].OEM_password === password) {
res.send({status: 230, id: data[0]._id, message: '登陆成功'})
getSession(data[0]._id, res)
} else {
res.send({status: 600, message: '密码错误'})
}
})
}
})
app.post('/creatOEM', async function (req, res) {
console.log(res.body)
// 获取首页数据
let { OEM_email, OEM_account, OEM_password, OEM_company } = req.body
await db.collection('OEM_account').insert({OEM_email: OEM_email, OEM_account: OEM_account, OEM_password: OEM_password, OEM_company: OEM_company})
res.send({status: 200, message: '创建成功'})
})
// 获取登陆账号信息
// app.post('/getAccount', async function (req, res) {
// console.log('获取账号信息')
// console.log(req.body)
// let {sessionID} = req.body
// let oem_account = null
// if (sessionID !== 'admin') {
// console.log(1)
// oem_account = await db.collection('OEM_account').find({_id: mongodb.ObjectId(sessionID)}).toArray()
// console.log(oem_account)
// } else {
// oem_account = [{OEM_email: 'admin', OEM_account: 'admin'}]
// }
//
// console.log(oem_account)
//
// res.send({status: 200, datas: oem_account})
//
// })
// 获取统计数据
app.post('/dataList', async function (req, res) {
console.log('进入了统计')
let body = req.body
......@@ -562,10 +643,13 @@ function getTimeRange({ start, end, key }) {
// 发布公告
app.post('/releaseInfo', async function (req, res) {
console.log('进入更新公告')
let body = req.body
body.time = new Date()
console.log(body)
await db.collection('inform').insertOne(body, function (err, rep) {
let {title, content, releaseMen, sessionID} = req.body
getSession(sessionID, res)
let time = new Date()
await db.collection('inform').insertOne({title: title, content: content, releaseMen: releaseMen, time: time}, function (err, rep) {
if (!err) {
db.collection('account').update({}, { $set: { inform: true } }, { multi: true })
res.send({ status: 200, message: '更新成功' })
......@@ -578,8 +662,15 @@ app.post('/releaseInfo', async function (req, res) {
app.post('/getInfo', async function (req, res) {
console.log('进入公告')
console.log(req.body)
let { currentPage, pageSize } = req.body
let { currentPage, pageSize, sessionID} = req.body
getSession(sessionID, res)
console.log(db)
let info = await db.collection('inform').find().sort({ 'createdAt': -1 }).toArray()
console.log(info)
let dataArr = []
info.forEach(x => {
let item = {}
......@@ -599,7 +690,9 @@ app.post('/checkCall', async function (req, res) {
console.log('进入了审核')
let { startTime, endTime, total, pageSize, currentPage, choose } = req.body
let { startTime, endTime, total, pageSize, currentPage, choose, sessionID} = req.body
getSession(sessionID, res)
console.log(req.body)
......@@ -708,12 +801,13 @@ app.post('/checkCall', async function (req, res) {
res.send({ state: 200, data: dataArr, total: dataTotal })
})
// 云呼审核接口
app.post('/send', async function (req, res) {
console.log('进入send')
console.log(req.body)
let { taskId, groupId, interestlist, hostlist, status } = req.body
let {taskId, groupId, interestlist, hostlist, status, sessionID} = req.body
getSession(sessionID, res)
if (status === 8) {
await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } })
......@@ -736,8 +830,9 @@ app.post('/getCheckNote', async function (req, res) {
console.log('进入了getData')
let { startTime, endTime, total, pageSize, currentPage, chooseId, operatorId } = req.body
let { startTime, endTime, total, pageSize, currentPage, chooseId, operatorId, sessionID} = req.body
getSession(sessionID, res)
console.log(req.body)
console.log(chooseId)
......@@ -873,7 +968,8 @@ app.post('/getCheckNote', async function (req, res) {
app.post('/sendCheckNote', async function (req, res) {
console.log('进入send')
console.log(req.body)
let { taskId, status, sendNum, operatorId } = req.body
let { taskId, status, sendNum, operatorId, sessionID} = req.body
getSession(sessionID, res)
if (status === 8) {
db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 0 } })
......@@ -922,7 +1018,8 @@ app.post('/sendCheckNote', async function (req, res) {
app.post('/getAccount', async function (req, res) {
console.log('进入用户控制')
console.log(req.body)
let { currentPage, pageSize, choose } = req.body
let { currentPage, pageSize, choose, sessionID } = req.body
getSession(sessionID, res)
let accounts = await db.collection('account').find().toArray()
let dataArr = []
let emailArr = []
......@@ -958,12 +1055,12 @@ app.post('/getAccount', async function (req, res) {
res.send({ status: 200, data: dataArr, dataTotal: dataArrTotal, emailArr: emailArr })
})
// 注销接口
app.post('/deleteAccount', async function (req, res) {
console.log('进入用户控制')
console.log(req.body)
let { accountId, status } = req.body
let { accountId, status, sessionID} = req.body
getSession(sessionID, res)
if (status === 0 || status === '0') {
await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isDelete': true } })
res.send({ status: 200, data: '用户注销成功' })
......@@ -978,7 +1075,8 @@ app.post('/deleteAccount', async function (req, res) {
app.post('/closeBtn', async function (req, res) {
console.log('进入自动备案')
console.log(req.body)
let { accountId, status } = req.body
let { accountId, status, sessionID} = req.body
getSession(sessionID, res)
if (status === 0 || status === '0') {
await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isCloseAuto': true } })
res.send({ status: 200, data: '自动备案关闭成功' })
......@@ -994,7 +1092,9 @@ app.post('/getSlot', async function (req, res) {
console.log('进入获取代码位')
console.log(req.body)
let { currentPage, pageSize, choose } = req.body
let { currentPage, pageSize, choose, sessionID} = req.body
getSession(sessionID, res)
let company = await db.collection('account').find({}).toArray()
......@@ -1048,7 +1148,8 @@ app.post('/getSlot', async function (req, res) {
// 代码位备案策略
app.post('/slotAutoRule', async function (req, res) {
console.log(req.body)
let { slotId, autoRule } = req.body
let { slotId, autoRule, sessionID} = req.body
getSession(sessionID, res)
await db.collection('slotTemps').update({ '_id': mongodb.ObjectId(slotId) }, { $set: { 'autoRule': autoRule } })
res.send({ status: 200, message: '备案策略更改成功' })
})
......@@ -1057,7 +1158,8 @@ app.post('/slotAutoRule', async function (req, res) {
app.post('/deleteSlot', async function (req, res) {
console.log('进入代码位控制')
console.log(req.body)
let { slotId, status } = req.body
let { slotId, status, sessionID } = req.body
getSession(sessionID, res)
if (status === 0 || status === '0') {
await db.collection('slotTemps').update({ '_id': mongodb.ObjectId(slotId) }, { $set: { 'isSlotDelete': true } })
res.send({ status: 200, data: '代码位注销成功' })
......
<template>
<el-container>
<el-main>
<div style='width: 50%;'>
<p style='margin: 5px 0'>邮箱:</p>
<el-input
placeholder="请输入邮箱名"
suffix-icon="el-icon-date"
v-model="OEM_email"
style='margin: 10px 0'
>
</el-input>
<p style='margin: 5px 0'>用户名:</p>
<el-input
placeholder="请输入用户名"
suffix-icon="el-icon-date"
v-model="OEM_account"
style='margin: 10px 0'
>
</el-input>
<p style='margin: 5px 0'>密码:</p>
<el-input
placeholder="请输入密码"
style='margin: 10px 0'
type='password'
prefix-icon="el-icon-search"
v-model="OEM_password">
</el-input>
<p style='margin: 5px 0'>重复密码:</p>
<el-input
placeholder="请输入再次密码"
style='margin: 10px 0'
type='password'
prefix-icon="el-icon-search"
v-model="OEM_password2">
</el-input>
<p style='margin: 5px 0'>公司名:</p>
<el-input
placeholder="请输入公司名"
style='margin: 10px 0'
prefix-icon="el-icon-search"
v-model="OEM_company">
</el-input>
</div>
<el-button type='primary' @click='creatOEM'>确定</el-button>
</el-main>
</el-container>
</template>
<script>
export default {
name: 'OEM',
data () {
return {
OEM_email: null,
OEM_account: null,
OEM_password: null,
OEM_password2: null,
OEM_company: null
}
},
methods: {
creatOEM () {
let self = this
let OEM_email = self.OEM_email
let OEM_account = self.OEM_account
let OEM_password = self.OEM_password
let OEM_company = self.OEM_company
if (self.OEM_password !== self.OEM_password2) {
this.$message.error('请确认两次密码输入相同')
} else {
fetch('/api/creatOEM', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({OEM_email, OEM_account, OEM_password, OEM_company})
}).then(res => { return res.json() }).then(data => {
console.log(data)
self.OEM_account = null
self.OEM_password = null
self.OEM_password2 = null
self.OEM_company = null
self.OEM_email = null
if (data.status === 200) {
this.$message({
message: 'OEM运营账号创建成功',
type: 'success'
})
}
})
}
}
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
......@@ -66,10 +66,12 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'account',
data () {
return {
sessionID: null,
datas: null,
isCloseAuto: false,
isAccountDelete: false,
......@@ -80,8 +82,14 @@
}
},
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getData(this.currentPage, this.pageSize, this.inputValue)
},
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: {
AutoChange (row) {
console.log(row.isCloseAuto)
......@@ -114,7 +122,7 @@
fetch('/api/getAccount', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({currentPage: currentPage, pageSize: pageSize, choose: choose})
body: JSON.stringify({currentPage: currentPage, pageSize: pageSize, choose: choose, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
self.datas = data.data
......@@ -131,11 +139,12 @@
this.getData(this.currentPage, this.pageSize, this.inputValue)
},
deleteAccount (row, status) {
let self = this
let accountId = row._id
fetch('/api/deleteAccount', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({accountId: accountId, status: status})
body: JSON.stringify({accountId: accountId, status: status, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
if (status === 0) {
......@@ -153,11 +162,12 @@
})
},
closeAuto (row, status) {
let self = this
let accountId = row._id
fetch('/api/closeBtn', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({accountId: accountId, status: status})
body: JSON.stringify({accountId: accountId, status: status, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
if (status === 0) {
......
......@@ -150,11 +150,13 @@
</template>
<script>
import { mapGetters } from 'vuex'
import moment from 'moment'
export default {
name: 'checkCall',
data () {
return {
sessionID: null,
url: '/api/checkCall',
datas: [],
statue: '未审核',
......@@ -216,11 +218,17 @@
}
},
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getTime()
this.change('POST', this.startTime, this.endTime, this.total, this.pageSize, this.currentPage, this.chooseId)
this.valueRange[0] = this.startTime
this.valueRange[1] = this.endTime
},
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: {
openForm (data, index) {
this.dialogFormVisible = true
......@@ -340,13 +348,14 @@
let interestlist = this.interestlist
let hostlist = this.hostlist
let currentdata = this.currentdata
let sessionID = this.sessionID
let taskId = currentdata ? currentdata.name : row.name
let groupId = currentdata ? currentdata.groupID : row.groupID
this.dialogFormVisible = false
fetch('/api/send', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({taskId, groupId, interestlist, hostlist, status})
body: JSON.stringify({taskId, groupId, interestlist, hostlist, status, sessionID})
}).then(res => {
return res.json()
}).then(data => {
......@@ -383,7 +392,7 @@
fetch(self.url, {
method: type,
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({startTime, endTime, total, pageSize, currentPage, choose})
body: JSON.stringify({startTime, endTime, total, pageSize, currentPage, choose, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
self.datas = []
console.log(data)
......
......@@ -129,10 +129,12 @@
<script>
import moment from 'moment'
import { mapGetters } from 'vuex'
export default {
name: 'checkNote',
data () {
return {
sessionID: null,
datas: [],
url: '/api/getCheckNote',
statue: '未审核',
......@@ -186,11 +188,17 @@
}
},
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getTime()
this.change('POST', this.startTime, this.endTime, this.total, this.pageSize, this.currentPage, this.chooseId, this.operatorId)
this.valueRange[0] = this.startTime
this.valueRange[1] = this.endTime
},
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: {
chooseOperator (command) {
let self = this
......@@ -278,7 +286,7 @@
fetch('/api/sendCheckNote', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({taskId, status, sendNum, operatorId})
body: JSON.stringify({taskId, status, sendNum, operatorId, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
self.$message({
......@@ -312,7 +320,7 @@
fetch('/api/sendCheckNote', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({taskId, status, sendNum, operatorId})
body: JSON.stringify({taskId, status, sendNum, operatorId, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
self.$message({
......@@ -336,7 +344,7 @@
fetch(self.url, {
method: type,
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({startTime, endTime, total, pageSize, currentPage, chooseId, operatorId})
body: JSON.stringify({startTime, endTime, total, pageSize, currentPage, chooseId, operatorId, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
self.datas = []
console.log(data)
......
<template>
<el-container style="height: 100%;">
<el-header style="background-color: #000000c5">
<div style='float: right;margin: 16px 20px'>
<el-dropdown @command="handleCommand">
<span class="el-dropdown-link" style='color: white'>
{{email}}<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<!--<el-dropdown-item command="mine">个人中心</el-dropdown-item>-->
<el-dropdown-item command="exit">退出登陆</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<img src="../assets/logo.png"
style="width: 105px;height: 25px;margin: 16px 0;float: right">
style="width: 105px;height: 25px;margin: 16px 0;float: left">
</el-header>
<el-container style="height: 100%">
<el-aside :style="{width: isCollapse ? '66px' : '160px'}">
......@@ -15,7 +26,7 @@
text-color="#fff"
:collapse="isCollapse"
active-text-color="#ffd04b">
<el-submenu index="1">
<el-submenu index="1" v-if=' sessionID === "admin" '>
<template slot="title">
<i class="el-icon-view"></i>
<span>数据统计</span>
......@@ -30,7 +41,7 @@
</el-menu-item-group>
</el-submenu>
<el-submenu index="2">
<el-submenu index="2" v-if=' sessionID === "admin" '>
<template slot="title">
<i class="el-icon-tickets"></i>
<span>财务中心</span>
......@@ -84,7 +95,7 @@
</el-menu-item>
</el-submenu>
<el-submenu index=6>
<el-submenu index=6 v-if=' sessionID === "admin" '>
<template slot='title'>
<i class='el-icon-setting'></i>
<span>营销任务</span>
......@@ -100,6 +111,16 @@
</el-menu-item>
</el-submenu>
<el-submenu index=7 v-if=' sessionID === "admin" '>
<template slot='title'>
<i class='el-icon-setting'></i>
<span>OEM运营账号</span>
</template>
<el-menu-item index='/OEM' @click="routeTo">
创建OME运营账号
</el-menu-item>
</el-submenu>
<a class="btn-toggle" @click="toggle"><i
:class="[isCollapse? 'el-icon-d-arrow-right' : 'el-icon-d-arrow-left']"></i></a>
</el-menu>
......@@ -116,9 +137,16 @@
name: 'home',
data () {
return {
isCollapse: false
isCollapse: false,
sessionID: null,
email: null
}
},
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.email = sessionStorage.getItem('email')
this.getAccount(this.sessionID)
},
methods: {
toggle () {
this.isCollapse = !this.isCollapse
......@@ -126,6 +154,25 @@
routeTo (item) {
this.$router.push(item.index)
this.header = item.TextNode
},
handleCommand (command) {
console.log(command)
if (command === 'exit') {
console.log('退出登陆')
sessionStorage.setItem('sessionID', null)
sessionStorage.setItem('email', null)
this.$router.push({path: '/login'})
}
},
getAccount () {
let self = this
fetch('/api/getAccount', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
})
}
}
}
......
......@@ -27,17 +27,25 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'info',
data () {
return {
sessionID: null,
datas: [],
currentPage: 1,
pageSize: 10,
total: 100
}
},
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getData(this.currentPage, this.pageSize)
},
methods: {
......@@ -54,7 +62,7 @@
fetch('/api/getInfo', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({currentPage: currentPage, pageSize: pageSize})
body: JSON.stringify({currentPage: currentPage, pageSize: pageSize, sessionID: this.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
self.datas = data.data
......
......@@ -6,12 +6,12 @@
<el-col :span="12">
<el-form label-position="top" :model="from" ref="from">
<el-form-item label="账号" prop="name">
<el-input v-model="from.userName"></el-input>
<el-input v-model="from.userEmail"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model.trim="from.password" type="password" auto-complete="off"></el-input>
</el-form-item>
<el-button type="primary" @click="onSubmit" style="margin: 0 auto">确定登陆</el-button>
<el-button type="primary" @click="login({userEmail: from.userEmail, password: from.password})" style="margin: 0 auto">确定登陆</el-button>
</el-form>
</el-col>
</el-row>
......@@ -21,12 +21,13 @@
</template>
<script>
import { mapActions } from 'vuex'
export default {
name: 'login',
data () {
return {
from: {
userName: '',
userEmail: '',
password: ''
}
}
......@@ -35,40 +36,43 @@
},
mounted () {
const self = this
if (localStorage.getItem('sureLogin')) {
self.onSubmit()
}
// const self = this
// if (localStorage.getItem('sureLogin')) {
// self.onSubmit()
// }
},
methods: {
onSubmit () {
let self = this
if (self.from.userName && self.from.password) {
fetch('/api/login', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify(self.from)
}).then(res => { return res.json() }).then(data => {
console.log(data)
if (data.status === 230) {
sessionStorage.setItem('sureLogin', 'admin')
this.$router.push({path: '/'})
} else {
this.$message({
showClose: true,
message: data.message,
type: 'error'
})
}
})
} else {
this.$message({
showClose: true,
message: '请输入账号密码',
type: 'error'
})
}
}
// onSubmit () {
// let self = this
// if (self.from.userName && self.from.password) {
// fetch('/api/login', {
// method: 'POST',
// headers: {'Content-Type': 'application/json;charset=UTF-8'},
// body: JSON.stringify(self.from)
// }).then(res => { return res.json() }).then(data => {
// console.log(data)
// if (data.status === 230) {
// sessionStorage.setItem('sureLogin', data.id)
// this.$router.push({path: '/'})
// } else {
// this.$message({
// showClose: true,
// message: data.message,
// type: 'error'
// })
// }
// })
// } else {
// this.$message({
// showClose: true,
// message: '请输入账号密码',
// type: 'error'
// })
// }
// },
...mapActions([
'login'
])
}
}
</script>
......
<template>
</template>
<script>
export default {
name: 'mine'
}
</script>
<style scoped>
</style>
\ No newline at end of file
......@@ -22,20 +22,30 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'releaseInfo',
data () {
return {
sessionID: null,
centerDialogVisible: false,
title: '',
content: '',
releaseMen: ''
}
},
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
},
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: {
sure () {
let self = this
let data = {'title': this.title, 'content': this.content, 'releaseMen': this.releaseMen}
let data = {title: this.title, content: this.content, releaseMen: this.releaseMen, sessionID: this.sessionID}
console.log(data)
if (this.title && this.content && this.releaseMen) {
fetch('/api/releaseInfo', {
......
......@@ -71,6 +71,7 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'slot',
data () {
......@@ -91,12 +92,19 @@
autoRule: {
internal: null,
strategy: 'all'
}
},
sessionID: null
}
},
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getData(this.currentPage, this.pageSize, this.inputValue)
},
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: {
getChoose (value) {
console.log(value)
......@@ -126,7 +134,7 @@
fetch('/api/slotAutoRule', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({slotId: slotId, autoRule: autoRule})
body: JSON.stringify({slotId: slotId, autoRule: autoRule, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
this.$message({
......@@ -155,7 +163,7 @@
fetch('/api/getSlot', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({currentPage: currentPage, pageSize: pageSize, choose: choose})
body: JSON.stringify({currentPage: currentPage, pageSize: pageSize, choose: choose, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
self.datas = data.data
......@@ -181,11 +189,12 @@
}
},
deleteSlot (row, status) {
let self = this
let slotId = row.slotId
fetch('/api/deleteSlot', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({slotId: slotId, status: status})
body: JSON.stringify({slotId: slotId, status: status, sessionID: self.sessionID})
}).then(res => { return res.json() }).then(data => {
console.log(data)
if (status === 0) {
......
<template>
<el-container>
<h1>欢迎来到运营平台</h1>
</el-container>
</template>
<script>
export default {
name: "welcome"
}
</script>
<style scoped>
</style>
\ No newline at end of file
......@@ -5,6 +5,7 @@ import App from './App'
import router from './router'
import ElemetnUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import store from './store/index'
Vue.config.productionTip = false
Vue.use(ElemetnUI)
......@@ -12,16 +13,16 @@ Vue.use(ElemetnUI)
router.beforeEach((to, from, next) => {
let sureSession = sessionStorage.getItem('sureLogin')
let sureSession = sessionStorage.getItem('sessionID')
console.log(sureSession)
if (to.matched.some(record => record.meta.requiresId)) {
if (sureSession !== 'admin') {
if (!sureSession) {
next({path: '/login'})
console.log(1)
} else {
next()
}
if (sureSession === 'admin') {
if (sureSession) {
next()
} else {
next({path: '/login'})
......@@ -35,6 +36,7 @@ router.beforeEach((to, from, next) => {
new Vue({
el: '#app',
store,
router,
components: {App},
template: '<App/>'
......
......@@ -16,6 +16,8 @@ import distributor from '@/components/distributor'
import userPool from '@/components/userPool'
import leadPoolTask from '@/components/leadPoolTask'
import exportPoolTask from '@/components/exportPoolTask'
import OEM from '@/components/OEM'
import welcome from '@/components/welcome'
Vue.use(Router)
......@@ -27,7 +29,7 @@ export default new Router({
component: home,
meta: {requiresId: true},
children: [
{name: 'data', path: '', meta: {requiresId: false}, component: dataList},
{name: 'data', path: '', meta: {requiresId: false}, component: welcome},
{name: 'dataList', path: '/dataList', meta: {requiresId: false}, component: dataList},
{name: 'finance', path: '/finance', meta: {requiresId: false}, component: finance},
{name: 'consume', path: '/consume', meta: {requiresId: false}, component: consume},
......@@ -41,7 +43,8 @@ export default new Router({
{name: 'userPool', path: '/userPool', meta: {requiresId: false}, component: userPool},
{name: 'leadPoolTask', path: '/leadPoolTask', meta: {requiresId: false}, component: leadPoolTask},
{name: 'exportPoolTask', path: '/exportPoolTask', meta: {requiresId: false}, component: exportPoolTask},
{name: 'distributor', path: '/distributor', meta: {requiresId: false}, component: distributor}
{name: 'distributor', path: '/distributor', meta: {requiresId: false}, component: distributor},
{name: 'OEM', path: '/OEM', meta: {requiresId: false}, component: OEM}
]
},
{
......
import Vue from 'vue'
import vuex from 'vuex'
import dataList from './dataList';
import dataList from './dataList'
import login from './login'
Vue.use(vuex);
Vue.use(vuex)
export default new vuex.Store({
modules: {
dataList
dataList,
login
}
})
\ No newline at end of file
})
import router from '../router/index'
const type = {
LOGIN: 'LOGIN'
}
const state = {
sessionID: ''
}
const getters = {
getSessionID () {
return state.sessionID
}
}
const mutations = {
[type.LOGIN] (state) {
state.sessionID = sessionStorage.getItem('sessionID')
}
}
const actions = {
login ({commit}, {userEmail, password}) {
console.log(1)
console.log(userEmail, password)
if (userEmail && password) {
fetch('/api/login', {
method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify({userEmail: userEmail, password: password})
}).then(res => { return res.json() }).then(data => {
console.log(data)
if (data.status === 230 || data.message === '登陆成功') {
console.log('进入commit')
console.log(data.id)
sessionStorage.setItem('sessionID', data.id)
sessionStorage.setItem('email', userEmail)
commit(type.LOGIN)
router.push({path: '/'})
}
})
}
}
}
export default {
state,
getters,
mutations,
actions
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment