This commit is contained in:
yulixing 2019-08-01 13:43:03 +08:00
parent 2327f9ef5a
commit c85839e311
8 changed files with 157 additions and 14 deletions

View File

@ -13,6 +13,9 @@ VUE_APP_LDAP_PWD = 'hhsxafTuUtVV'
# upload
VUE_APP_UPLOAD = '/upload/cos'
# area api
VUE_APP_MP = '/mp'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().

View File

@ -12,4 +12,7 @@ VUE_APP_LDAP_PWD = 'hhsxafTuUtVV'
# upload
VUE_APP_UPLOAD = 'http://ad.kingsome.cn/interface/cos_upload'
VUE_APP_UPLOAD = 'http://ad.kingsome.cn/interface/cos_upload'
# area api
VUE_APP_MP = 'http://mp.kingsome.cn/api/open'

View File

@ -1,6 +1,7 @@
// api文档 http://git.kingsome.cn/ops/promotion
import request from '@/utils/request'
import requestMp from '@/utils/request-mp'
// 获取广告位置信息
export function getAdPos(params) {
@ -48,3 +49,10 @@ export function delAd(data) {
}
export function getAdAreaList() {
return requestMp({
url: '/ad/get-area',
method: 'get',
})
}

74
src/utils/request-mp.js Normal file
View File

@ -0,0 +1,74 @@
import axios from 'axios'
import {MessageBox, Message} from 'element-ui'
import store from '@/store'
import {getToken} from '@/utils/auth'
import {encoded, decoded} from '@/utils/cryptor'
// create an axios instance
const service = axios.create({
baseURL: process.env.VUE_APP_MP, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 5000, // request timeout
})
// request interceptor
service.interceptors.request.use(
config => {
// do something before request is sent
const token = store.getters.token
const username = store.getters.username
// if (decoded(token) !== username) {
// let each request carry token
// ['X-Token'] is a custom headers key
// please modify it according to the actual situation
// config.headers['X-Token'] = getToken()
// return Promise.reject('permission denied!')
// }
return config
},
error => {
// do something with request error
console.log(error) // for debug
return Promise.reject(error)
}
)
// response interceptor
service.interceptors.response.use(
/**
* If you want to get http information such as headers or status
* Please return response => response
*/
/**
* Determine the request status by custom code
* Here is just an example
* You can also judge the status by HTTP Status Code
*/
response => {
const {data} = response
if (data.errcode !== 0) {
Message({
message: data.errmsg || 'error',
type: 'error',
duration: 5 * 1000,
})
return Promise.reject(data.errmsg || 'error')
} else {
return response
}
},
error => {
console.log('err' + error) // for debug
Message({
message: error.message,
type: 'error',
duration: 5 * 1000,
})
return Promise.reject(error)
}
)
export default service

View File

@ -219,9 +219,9 @@
</template>
<script>
import { getAdPos, getAd, addAd, updateAd } from '@/api/ad'
import { getAdPos, getAd, addAd, updateAd, getAdAreaList } from '@/api/ad'
import { getGameList } from '@/api/game'
import { areaList, typeList, modeList } from '@/utils/ad-data'
import { typeList, modeList } from '@/utils/ad-data'
import moment from 'moment'
export default {
@ -292,10 +292,14 @@ export default {
},
async mounted() {
//
this.areaList = areaList
this.modeList = modeList
this.typeList = typeList
const areaListRes = await this.getAdAreaList()
areaListRes.adAreaList.map(item => {
this.areaList[item.area_id] = item.name
})
//
const allGame = await this.getGameList()
this.allGame = allGame
@ -348,7 +352,6 @@ export default {
},
methods: {
// common
getGameList(params) {
return new Promise((resolve, reject) => {
getGameList(params)
@ -362,6 +365,19 @@ export default {
})
})
},
getAdAreaList(params) {
return new Promise((resolve, reject) => {
getAdAreaList(params)
.then(res => {
const data = res.data
resolve(data)
})
.catch(err => {
reject(err)
console.log(err)
})
})
},
resetForm(formName) {
this.$refs[formName].resetFields()
},

View File

@ -190,9 +190,9 @@
</template>
<script>
import { getAd, updateAd, delAd, getAdPos } from '@/api/ad'
import { getAd, updateAd, delAd, getAdPos, getAdAreaList } from '@/api/ad'
import { getGameList } from '@/api/game'
import { areaList, typeList, modeList } from '@/utils/ad-data'
import { typeList, modeList } from '@/utils/ad-data'
import { Promise, reject } from 'q'
import moment from 'moment'
@ -235,10 +235,14 @@ export default {
},
async mounted() {
//
this.areaList = areaList
this.modeList = modeList
this.typeList = typeList
const areaListRes = await this.getAdAreaList()
areaListRes.adAreaList.map(item => {
this.areaList[item.area_id] = item.name
})
const gameList = await this.getGameList()
gameList.map(item => {
const gameKey = `${item.game_id}`
@ -265,6 +269,19 @@ export default {
})
})
},
getAdAreaList(params) {
return new Promise((resolve, reject) => {
getAdAreaList(params)
.then(res => {
const data = res.data
resolve(data)
})
.catch(err => {
reject(err)
console.log(err)
})
})
},
getAdPos(params) {
return new Promise((resolve, reject) => {
getAdPos(params)
@ -364,7 +381,7 @@ export default {
return cellValue
? moment(cellValue)
.utc()
.zone(+0)
.utcOffset(+0)
.format('YYYY-MM-DD HH:mm:ss')
: '-'
},

View File

@ -219,7 +219,7 @@
</template>
<script>
import { getAd, updateAd, delAd, getAdPos } from '@/api/ad'
import { getAd, updateAd, delAd, getAdPos, getAdAreaList } from '@/api/ad'
import { getGameList } from '@/api/game'
import { areaList, typeList, modeList } from '@/utils/ad-data'
import { Promise, reject } from 'q'
@ -264,10 +264,14 @@ export default {
},
async mounted() {
//
this.areaList = areaList
this.modeList = modeList
this.typeList = typeList
const areaListRes = await this.getAdAreaList()
areaListRes.adAreaList.map(item => {
this.areaList[item.area_id] = item.name
})
const gameList = await this.getGameList()
gameList.map(item => {
@ -295,6 +299,19 @@ export default {
})
})
},
getAdAreaList(params) {
return new Promise((resolve, reject) => {
getAdAreaList(params)
.then(res => {
const data = res.data
resolve(data)
})
.catch(err => {
reject(err)
console.log(err)
})
})
},
getGameList(params) {
return new Promise((resolve, reject) => {
getGameList(params)
@ -488,7 +505,7 @@ export default {
return cellValue
? moment(cellValue)
.utc()
.zone(+0)
.utcOffset(+0)
.format('YYYY-MM-DD HH:mm:ss')
: '-'
},
@ -503,8 +520,6 @@ export default {
},
formLocation(row, column, cellValue, index) {
const area = cellValue.split(',')
console.log(this.areaList)
return `${this.areaList[area[0]]}-(${area[1]},${area[2]})-${
this.modeList[row.mode]
}`

View File

@ -60,6 +60,13 @@ module.exports = {
'/upload': '',
},
},
[process.env.VUE_APP_MP]: {
target: `http://192.168.100.90:2333/api/open`,
changeOrigin: true,
pathRewrite: {
'/mp': '',
},
},
},
},
configureWebpack: {