Commit 1034349b authored by yaobeibei's avatar yaobeibei

creat dev oem

parent 39f0e6d4
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
/dist/ /dist/
/*.js /*.js
/test/unit/coverage/ /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 ...@@ -16,6 +16,8 @@ RUN npm i --only=production --registry https://registry.npm.taobao.org
ENV SERVICE_PORT=8082 ENV SERVICE_PORT=8082
ENV PROJECT_LEVEL=production ENV PROJECT_LEVEL=production
ENV MONGO='mongodb://mongo-adpro-ssp-v2-rs-1.localhost:1301/remarketing?replicaSet=adpro_ssp_v2_rs' 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' ENV NODE_ENV='production'
EXPOSE 8082 EXPOSE 8082
CMD node server.js CMD node server.js
...@@ -3,45 +3,126 @@ const mongoClient = mongodb.MongoClient ...@@ -3,45 +3,126 @@ const mongoClient = mongodb.MongoClient
const app = require('express').Router() const app = require('express').Router()
const _ = require('lodash') const _ = require('lodash')
const moment = require('moment') 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 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 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) { if (process.env.MONGO) {
dbpath = process.env.MONGO || 'mongodb://10.11.3.123:1301/remarketing' dbpath = process.env.MONGO || 'mongodb://10.11.3.123:1301/remarketing'
} else { } else {
dbpath = 'mongodb://localhost:27017/remarketing' 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) { mongoClient.connect(dbpath, function (err, res) {
if (err) return console.log(err) if (err) return console.log(err)
db = res.db('remarketing') 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) { app.post('/login', async function (req, res) {
console.log('进入登陆') console.log('进入登陆')
let body = req.body let { userEmail, password } = req.body
console.log(body) console.log(req.body)
if (body.userName === 'admin') { if (userEmail === 'admin') {
if (body.password === 'goyooyunying') { if (password === 'goyooyunying') {
res.send({ status: 230, message: '登陆成功' }) res.send({status: 230, message: '登陆成功', id: 'admin'})
} else { } else {
res.send({ status: 200, message: '密码错误' }) res.send({ status: 200, message: '密码错误' })
} }
} else { } 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) { app.post('/dataList', async function (req, res) {
console.log('进入了统计') console.log('进入了统计')
let body = req.body let body = req.body
...@@ -562,10 +643,13 @@ function getTimeRange({ start, end, key }) { ...@@ -562,10 +643,13 @@ function getTimeRange({ start, end, key }) {
// 发布公告 // 发布公告
app.post('/releaseInfo', async function (req, res) { app.post('/releaseInfo', async function (req, res) {
console.log('进入更新公告') console.log('进入更新公告')
let body = req.body let {title, content, releaseMen, sessionID} = req.body
body.time = new Date()
console.log(body) getSession(sessionID, res)
await db.collection('inform').insertOne(body, function (err, rep) {
let time = new Date()
await db.collection('inform').insertOne({title: title, content: content, releaseMen: releaseMen, time: time}, function (err, rep) {
if (!err) { if (!err) {
db.collection('account').update({}, { $set: { inform: true } }, { multi: true }) db.collection('account').update({}, { $set: { inform: true } }, { multi: true })
res.send({ status: 200, message: '更新成功' }) res.send({ status: 200, message: '更新成功' })
...@@ -578,8 +662,15 @@ app.post('/releaseInfo', async function (req, res) { ...@@ -578,8 +662,15 @@ app.post('/releaseInfo', async function (req, res) {
app.post('/getInfo', async function (req, res) { app.post('/getInfo', async function (req, res) {
console.log('进入公告') console.log('进入公告')
console.log(req.body) 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() let info = await db.collection('inform').find().sort({ 'createdAt': -1 }).toArray()
console.log(info)
let dataArr = [] let dataArr = []
info.forEach(x => { info.forEach(x => {
let item = {} let item = {}
...@@ -599,7 +690,9 @@ app.post('/checkCall', async function (req, res) { ...@@ -599,7 +690,9 @@ app.post('/checkCall', async function (req, res) {
console.log('进入了审核') 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) console.log(req.body)
...@@ -708,12 +801,13 @@ app.post('/checkCall', async function (req, res) { ...@@ -708,12 +801,13 @@ app.post('/checkCall', async function (req, res) {
res.send({ state: 200, data: dataArr, total: dataTotal }) res.send({ state: 200, data: dataArr, total: dataTotal })
}) })
// 云呼审核接口 // 云呼审核接口
app.post('/send', async function (req, res) { app.post('/send', async function (req, res) {
console.log('进入send') console.log('进入send')
console.log(req.body) 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) { if (status === 8) {
await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } }) await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } })
...@@ -736,8 +830,9 @@ app.post('/getCheckNote', async function (req, res) { ...@@ -736,8 +830,9 @@ app.post('/getCheckNote', async function (req, res) {
console.log('进入了getData') 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(req.body)
console.log(chooseId) console.log(chooseId)
...@@ -873,7 +968,8 @@ app.post('/getCheckNote', async function (req, res) { ...@@ -873,7 +968,8 @@ app.post('/getCheckNote', async function (req, res) {
app.post('/sendCheckNote', async function (req, res) { app.post('/sendCheckNote', async function (req, res) {
console.log('进入send') console.log('进入send')
console.log(req.body) 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) { if (status === 8) {
db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 0 } }) db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 0 } })
...@@ -922,7 +1018,8 @@ app.post('/sendCheckNote', async function (req, res) { ...@@ -922,7 +1018,8 @@ app.post('/sendCheckNote', async function (req, res) {
app.post('/getAccount', async function (req, res) { app.post('/getAccount', async function (req, res) {
console.log('进入用户控制') console.log('进入用户控制')
console.log(req.body) 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 accounts = await db.collection('account').find().toArray()
let dataArr = [] let dataArr = []
let emailArr = [] let emailArr = []
...@@ -958,12 +1055,12 @@ app.post('/getAccount', async function (req, res) { ...@@ -958,12 +1055,12 @@ app.post('/getAccount', async function (req, res) {
res.send({ status: 200, data: dataArr, dataTotal: dataArrTotal, emailArr: emailArr }) res.send({ status: 200, data: dataArr, dataTotal: dataArrTotal, emailArr: emailArr })
}) })
// 注销接口 // 注销接口
app.post('/deleteAccount', async function (req, res) { app.post('/deleteAccount', async function (req, res) {
console.log('进入用户控制') console.log('进入用户控制')
console.log(req.body) console.log(req.body)
let { accountId, status } = req.body let { accountId, status, sessionID} = req.body
getSession(sessionID, res)
if (status === 0 || status === '0') { if (status === 0 || status === '0') {
await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isDelete': true } }) await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isDelete': true } })
res.send({ status: 200, data: '用户注销成功' }) res.send({ status: 200, data: '用户注销成功' })
...@@ -978,7 +1075,8 @@ app.post('/deleteAccount', async function (req, res) { ...@@ -978,7 +1075,8 @@ app.post('/deleteAccount', async function (req, res) {
app.post('/closeBtn', async function (req, res) { app.post('/closeBtn', async function (req, res) {
console.log('进入自动备案') console.log('进入自动备案')
console.log(req.body) console.log(req.body)
let { accountId, status } = req.body let { accountId, status, sessionID} = req.body
getSession(sessionID, res)
if (status === 0 || status === '0') { if (status === 0 || status === '0') {
await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isCloseAuto': true } }) await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isCloseAuto': true } })
res.send({ status: 200, data: '自动备案关闭成功' }) res.send({ status: 200, data: '自动备案关闭成功' })
...@@ -994,7 +1092,9 @@ app.post('/getSlot', async function (req, res) { ...@@ -994,7 +1092,9 @@ app.post('/getSlot', async function (req, res) {
console.log('进入获取代码位') console.log('进入获取代码位')
console.log(req.body) 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() let company = await db.collection('account').find({}).toArray()
...@@ -1048,7 +1148,8 @@ app.post('/getSlot', async function (req, res) { ...@@ -1048,7 +1148,8 @@ app.post('/getSlot', async function (req, res) {
// 代码位备案策略 // 代码位备案策略
app.post('/slotAutoRule', async function (req, res) { app.post('/slotAutoRule', async function (req, res) {
console.log(req.body) 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 } }) await db.collection('slotTemps').update({ '_id': mongodb.ObjectId(slotId) }, { $set: { 'autoRule': autoRule } })
res.send({ status: 200, message: '备案策略更改成功' }) res.send({ status: 200, message: '备案策略更改成功' })
}) })
...@@ -1057,7 +1158,8 @@ app.post('/slotAutoRule', async function (req, res) { ...@@ -1057,7 +1158,8 @@ app.post('/slotAutoRule', async function (req, res) {
app.post('/deleteSlot', async function (req, res) { app.post('/deleteSlot', async function (req, res) {
console.log('进入代码位控制') console.log('进入代码位控制')
console.log(req.body) console.log(req.body)
let { slotId, status } = req.body let { slotId, status, sessionID } = req.body
getSession(sessionID, res)
if (status === 0 || status === '0') { if (status === 0 || status === '0') {
await db.collection('slotTemps').update({ '_id': mongodb.ObjectId(slotId) }, { $set: { 'isSlotDelete': true } }) await db.collection('slotTemps').update({ '_id': mongodb.ObjectId(slotId) }, { $set: { 'isSlotDelete': true } })
res.send({ status: 200, data: '代码位注销成功' }) 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 @@ ...@@ -66,10 +66,12 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
export default { export default {
name: 'account', name: 'account',
data () { data () {
return { return {
sessionID: null,
datas: null, datas: null,
isCloseAuto: false, isCloseAuto: false,
isAccountDelete: false, isAccountDelete: false,
...@@ -80,8 +82,14 @@ ...@@ -80,8 +82,14 @@
} }
}, },
mounted () { mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getData(this.currentPage, this.pageSize, this.inputValue) this.getData(this.currentPage, this.pageSize, this.inputValue)
}, },
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: { methods: {
AutoChange (row) { AutoChange (row) {
console.log(row.isCloseAuto) console.log(row.isCloseAuto)
...@@ -114,7 +122,7 @@ ...@@ -114,7 +122,7 @@
fetch('/api/getAccount', { fetch('/api/getAccount', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
self.datas = data.data self.datas = data.data
...@@ -131,11 +139,12 @@ ...@@ -131,11 +139,12 @@
this.getData(this.currentPage, this.pageSize, this.inputValue) this.getData(this.currentPage, this.pageSize, this.inputValue)
}, },
deleteAccount (row, status) { deleteAccount (row, status) {
let self = this
let accountId = row._id let accountId = row._id
fetch('/api/deleteAccount', { fetch('/api/deleteAccount', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
if (status === 0) { if (status === 0) {
...@@ -153,11 +162,12 @@ ...@@ -153,11 +162,12 @@
}) })
}, },
closeAuto (row, status) { closeAuto (row, status) {
let self = this
let accountId = row._id let accountId = row._id
fetch('/api/closeBtn', { fetch('/api/closeBtn', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
if (status === 0) { if (status === 0) {
......
...@@ -150,11 +150,13 @@ ...@@ -150,11 +150,13 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import moment from 'moment' import moment from 'moment'
export default { export default {
name: 'checkCall', name: 'checkCall',
data () { data () {
return { return {
sessionID: null,
url: '/api/checkCall', url: '/api/checkCall',
datas: [], datas: [],
statue: '未审核', statue: '未审核',
...@@ -216,11 +218,17 @@ ...@@ -216,11 +218,17 @@
} }
}, },
mounted () { mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getTime() this.getTime()
this.change('POST', this.startTime, this.endTime, this.total, this.pageSize, this.currentPage, this.chooseId) this.change('POST', this.startTime, this.endTime, this.total, this.pageSize, this.currentPage, this.chooseId)
this.valueRange[0] = this.startTime this.valueRange[0] = this.startTime
this.valueRange[1] = this.endTime this.valueRange[1] = this.endTime
}, },
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: { methods: {
openForm (data, index) { openForm (data, index) {
this.dialogFormVisible = true this.dialogFormVisible = true
...@@ -340,13 +348,14 @@ ...@@ -340,13 +348,14 @@
let interestlist = this.interestlist let interestlist = this.interestlist
let hostlist = this.hostlist let hostlist = this.hostlist
let currentdata = this.currentdata let currentdata = this.currentdata
let sessionID = this.sessionID
let taskId = currentdata ? currentdata.name : row.name let taskId = currentdata ? currentdata.name : row.name
let groupId = currentdata ? currentdata.groupID : row.groupID let groupId = currentdata ? currentdata.groupID : row.groupID
this.dialogFormVisible = false this.dialogFormVisible = false
fetch('/api/send', { fetch('/api/send', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => {
return res.json() return res.json()
}).then(data => { }).then(data => {
...@@ -383,7 +392,7 @@ ...@@ -383,7 +392,7 @@
fetch(self.url, { fetch(self.url, {
method: type, method: type,
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
self.datas = [] self.datas = []
console.log(data) console.log(data)
......
...@@ -129,10 +129,12 @@ ...@@ -129,10 +129,12 @@
<script> <script>
import moment from 'moment' import moment from 'moment'
import { mapGetters } from 'vuex'
export default { export default {
name: 'checkNote', name: 'checkNote',
data () { data () {
return { return {
sessionID: null,
datas: [], datas: [],
url: '/api/getCheckNote', url: '/api/getCheckNote',
statue: '未审核', statue: '未审核',
...@@ -186,11 +188,17 @@ ...@@ -186,11 +188,17 @@
} }
}, },
mounted () { mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getTime() this.getTime()
this.change('POST', this.startTime, this.endTime, this.total, this.pageSize, this.currentPage, this.chooseId, this.operatorId) this.change('POST', this.startTime, this.endTime, this.total, this.pageSize, this.currentPage, this.chooseId, this.operatorId)
this.valueRange[0] = this.startTime this.valueRange[0] = this.startTime
this.valueRange[1] = this.endTime this.valueRange[1] = this.endTime
}, },
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: { methods: {
chooseOperator (command) { chooseOperator (command) {
let self = this let self = this
...@@ -278,7 +286,7 @@ ...@@ -278,7 +286,7 @@
fetch('/api/sendCheckNote', { fetch('/api/sendCheckNote', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
self.$message({ self.$message({
...@@ -312,7 +320,7 @@ ...@@ -312,7 +320,7 @@
fetch('/api/sendCheckNote', { fetch('/api/sendCheckNote', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
self.$message({ self.$message({
...@@ -336,7 +344,7 @@ ...@@ -336,7 +344,7 @@
fetch(self.url, { fetch(self.url, {
method: type, method: type,
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
self.datas = [] self.datas = []
console.log(data) console.log(data)
......
<template> <template>
<el-container style="height: 100%;"> <el-container style="height: 100%;">
<el-header style="background-color: #000000c5"> <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" <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-header>
<el-container style="height: 100%"> <el-container style="height: 100%">
<el-aside :style="{width: isCollapse ? '66px' : '160px'}"> <el-aside :style="{width: isCollapse ? '66px' : '160px'}">
...@@ -15,7 +26,7 @@ ...@@ -15,7 +26,7 @@
text-color="#fff" text-color="#fff"
:collapse="isCollapse" :collapse="isCollapse"
active-text-color="#ffd04b"> active-text-color="#ffd04b">
<el-submenu index="1"> <el-submenu index="1" v-if=' sessionID === "admin" '>
<template slot="title"> <template slot="title">
<i class="el-icon-view"></i> <i class="el-icon-view"></i>
<span>数据统计</span> <span>数据统计</span>
...@@ -30,7 +41,7 @@ ...@@ -30,7 +41,7 @@
</el-menu-item-group> </el-menu-item-group>
</el-submenu> </el-submenu>
<el-submenu index="2"> <el-submenu index="2" v-if=' sessionID === "admin" '>
<template slot="title"> <template slot="title">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>财务中心</span> <span>财务中心</span>
...@@ -84,7 +95,7 @@ ...@@ -84,7 +95,7 @@
</el-menu-item> </el-menu-item>
</el-submenu> </el-submenu>
<el-submenu index=6> <el-submenu index=6 v-if=' sessionID === "admin" '>
<template slot='title'> <template slot='title'>
<i class='el-icon-setting'></i> <i class='el-icon-setting'></i>
<span>营销任务</span> <span>营销任务</span>
...@@ -100,6 +111,16 @@ ...@@ -100,6 +111,16 @@
</el-menu-item> </el-menu-item>
</el-submenu> </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 <a class="btn-toggle" @click="toggle"><i
:class="[isCollapse? 'el-icon-d-arrow-right' : 'el-icon-d-arrow-left']"></i></a> :class="[isCollapse? 'el-icon-d-arrow-right' : 'el-icon-d-arrow-left']"></i></a>
</el-menu> </el-menu>
...@@ -116,9 +137,16 @@ ...@@ -116,9 +137,16 @@
name: 'home', name: 'home',
data () { data () {
return { 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: { methods: {
toggle () { toggle () {
this.isCollapse = !this.isCollapse this.isCollapse = !this.isCollapse
...@@ -126,6 +154,25 @@ ...@@ -126,6 +154,25 @@
routeTo (item) { routeTo (item) {
this.$router.push(item.index) this.$router.push(item.index)
this.header = item.TextNode 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 @@ ...@@ -27,17 +27,25 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
export default { export default {
name: 'info', name: 'info',
data () { data () {
return { return {
sessionID: null,
datas: [], datas: [],
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 100 total: 100
} }
}, },
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
mounted () { mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getData(this.currentPage, this.pageSize) this.getData(this.currentPage, this.pageSize)
}, },
methods: { methods: {
...@@ -54,7 +62,7 @@ ...@@ -54,7 +62,7 @@
fetch('/api/getInfo', { fetch('/api/getInfo', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
self.datas = data.data self.datas = data.data
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<el-col :span="12"> <el-col :span="12">
<el-form label-position="top" :model="from" ref="from"> <el-form label-position="top" :model="from" ref="from">
<el-form-item label="账号" prop="name"> <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>
<el-form-item label="密码" prop="password"> <el-form-item label="密码" prop="password">
<el-input v-model.trim="from.password" type="password" auto-complete="off"></el-input> <el-input v-model.trim="from.password" type="password" auto-complete="off"></el-input>
</el-form-item> </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-form>
</el-col> </el-col>
</el-row> </el-row>
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
</template> </template>
<script> <script>
import { mapActions } from 'vuex'
export default { export default {
name: 'login', name: 'login',
data () { data () {
return { return {
from: { from: {
userName: '', userEmail: '',
password: '' password: ''
} }
} }
...@@ -35,40 +36,43 @@ ...@@ -35,40 +36,43 @@
}, },
mounted () { mounted () {
const self = this // const self = this
if (localStorage.getItem('sureLogin')) { // if (localStorage.getItem('sureLogin')) {
self.onSubmit() // self.onSubmit()
} // }
}, },
methods: { methods: {
onSubmit () { // onSubmit () {
let self = this // let self = this
if (self.from.userName && self.from.password) { // if (self.from.userName && self.from.password) {
fetch('/api/login', { // fetch('/api/login', {
method: 'POST', // method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, // headers: {'Content-Type': 'application/json;charset=UTF-8'},
body: JSON.stringify(self.from) // body: JSON.stringify(self.from)
}).then(res => { return res.json() }).then(data => { // }).then(res => { return res.json() }).then(data => {
console.log(data) // console.log(data)
if (data.status === 230) { // if (data.status === 230) {
sessionStorage.setItem('sureLogin', 'admin') // sessionStorage.setItem('sureLogin', data.id)
this.$router.push({path: '/'}) // this.$router.push({path: '/'})
} else { // } else {
this.$message({ // this.$message({
showClose: true, // showClose: true,
message: data.message, // message: data.message,
type: 'error' // type: 'error'
}) // })
} // }
}) // })
} else { // } else {
this.$message({ // this.$message({
showClose: true, // showClose: true,
message: '请输入账号密码', // message: '请输入账号密码',
type: 'error' // type: 'error'
}) // })
} // }
} // },
...mapActions([
'login'
])
} }
} }
</script> </script>
......
<template>
</template>
<script>
export default {
name: 'mine'
}
</script>
<style scoped>
</style>
\ No newline at end of file
...@@ -22,20 +22,30 @@ ...@@ -22,20 +22,30 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
export default { export default {
name: 'releaseInfo', name: 'releaseInfo',
data () { data () {
return { return {
sessionID: null,
centerDialogVisible: false, centerDialogVisible: false,
title: '', title: '',
content: '', content: '',
releaseMen: '' releaseMen: ''
} }
}, },
mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
},
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: { methods: {
sure () { sure () {
let self = this 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) console.log(data)
if (this.title && this.content && this.releaseMen) { if (this.title && this.content && this.releaseMen) {
fetch('/api/releaseInfo', { fetch('/api/releaseInfo', {
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
export default { export default {
name: 'slot', name: 'slot',
data () { data () {
...@@ -91,12 +92,19 @@ ...@@ -91,12 +92,19 @@
autoRule: { autoRule: {
internal: null, internal: null,
strategy: 'all' strategy: 'all'
} },
sessionID: null
} }
}, },
mounted () { mounted () {
this.sessionID = sessionStorage.getItem('sessionID')
this.getData(this.currentPage, this.pageSize, this.inputValue) this.getData(this.currentPage, this.pageSize, this.inputValue)
}, },
computed: {
...mapGetters({
sessionID: 'getSessionID'
})
},
methods: { methods: {
getChoose (value) { getChoose (value) {
console.log(value) console.log(value)
...@@ -126,7 +134,7 @@ ...@@ -126,7 +134,7 @@
fetch('/api/slotAutoRule', { fetch('/api/slotAutoRule', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
this.$message({ this.$message({
...@@ -155,7 +163,7 @@ ...@@ -155,7 +163,7 @@
fetch('/api/getSlot', { fetch('/api/getSlot', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
self.datas = data.data self.datas = data.data
...@@ -181,11 +189,12 @@ ...@@ -181,11 +189,12 @@
} }
}, },
deleteSlot (row, status) { deleteSlot (row, status) {
let self = this
let slotId = row.slotId let slotId = row.slotId
fetch('/api/deleteSlot', { fetch('/api/deleteSlot', {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, 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 => { }).then(res => { return res.json() }).then(data => {
console.log(data) console.log(data)
if (status === 0) { 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' ...@@ -5,6 +5,7 @@ import App from './App'
import router from './router' import router from './router'
import ElemetnUI from 'element-ui' import ElemetnUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
import store from './store/index'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(ElemetnUI) Vue.use(ElemetnUI)
...@@ -12,16 +13,16 @@ Vue.use(ElemetnUI) ...@@ -12,16 +13,16 @@ Vue.use(ElemetnUI)
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
let sureSession = sessionStorage.getItem('sureLogin') let sureSession = sessionStorage.getItem('sessionID')
console.log(sureSession) console.log(sureSession)
if (to.matched.some(record => record.meta.requiresId)) { if (to.matched.some(record => record.meta.requiresId)) {
if (sureSession !== 'admin') { if (!sureSession) {
next({path: '/login'}) next({path: '/login'})
console.log(1) console.log(1)
} else { } else {
next() next()
} }
if (sureSession === 'admin') { if (sureSession) {
next() next()
} else { } else {
next({path: '/login'}) next({path: '/login'})
...@@ -35,6 +36,7 @@ router.beforeEach((to, from, next) => { ...@@ -35,6 +36,7 @@ router.beforeEach((to, from, next) => {
new Vue({ new Vue({
el: '#app', el: '#app',
store,
router, router,
components: {App}, components: {App},
template: '<App/>' template: '<App/>'
......
...@@ -16,6 +16,8 @@ import distributor from '@/components/distributor' ...@@ -16,6 +16,8 @@ import distributor from '@/components/distributor'
import userPool from '@/components/userPool' import userPool from '@/components/userPool'
import leadPoolTask from '@/components/leadPoolTask' import leadPoolTask from '@/components/leadPoolTask'
import exportPoolTask from '@/components/exportPoolTask' import exportPoolTask from '@/components/exportPoolTask'
import OEM from '@/components/OEM'
import welcome from '@/components/welcome'
Vue.use(Router) Vue.use(Router)
...@@ -27,7 +29,7 @@ export default new Router({ ...@@ -27,7 +29,7 @@ export default new Router({
component: home, component: home,
meta: {requiresId: true}, meta: {requiresId: true},
children: [ 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: 'dataList', path: '/dataList', meta: {requiresId: false}, component: dataList},
{name: 'finance', path: '/finance', meta: {requiresId: false}, component: finance}, {name: 'finance', path: '/finance', meta: {requiresId: false}, component: finance},
{name: 'consume', path: '/consume', meta: {requiresId: false}, component: consume}, {name: 'consume', path: '/consume', meta: {requiresId: false}, component: consume},
...@@ -41,7 +43,8 @@ export default new Router({ ...@@ -41,7 +43,8 @@ export default new Router({
{name: 'userPool', path: '/userPool', meta: {requiresId: false}, component: userPool}, {name: 'userPool', path: '/userPool', meta: {requiresId: false}, component: userPool},
{name: 'leadPoolTask', path: '/leadPoolTask', meta: {requiresId: false}, component: leadPoolTask}, {name: 'leadPoolTask', path: '/leadPoolTask', meta: {requiresId: false}, component: leadPoolTask},
{name: 'exportPoolTask', path: '/exportPoolTask', meta: {requiresId: false}, component: exportPoolTask}, {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 Vue from 'vue'
import vuex from 'vuex' 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({ export default new vuex.Store({
modules: { 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