Commit 7a6d2201 by wangzhihui

Merge branch 'SAAS+V5.7.4' of http://192.168.3.233:8090/saas/wx-notification into SAAS+V5.7.4

2 parents 8596cc26 16c4ce38
<template>
<div id="app">
<template v-if="showWindow">
<div v-show="isShowWindow">
<transition name="fade">
<keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
......@@ -9,7 +9,10 @@
<transition name="fade">
<router-view v-if="!$route.meta.keepAlive"></router-view>
</transition>
</template>
</div>
<div v-show="!isShowWindow">
<div style="text-align: center;font-size: 14px;height: 48px;line-height: 48px;">无权限访问</div>
</div>
</div>
</template>
<script>
......@@ -17,14 +20,14 @@ export default {
name: 'App',
data() {
return {
isShowWindow: false,
}
},
watch: {
watchFlag: {
immediate: true,
handler(newval) {
this.showWindow = newval
this.hideLoading()
this.isShowWindow = newval
}
}
},
......@@ -33,11 +36,10 @@ export default {
return this.$store.state.app.showWindow
}
},
mounted() {
},
mounted() {},
methods: {}
}
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
<style lang="scss" scoped></style>
\ No newline at end of file
......@@ -7,6 +7,8 @@
* @LastEditTime: 2021-06-17 18:23:27
*/
import indexApi from './indexApi'
import ssoApi from './ssoApi'
export {
indexApi,
ssoApi,
}
\ No newline at end of file
const ssoUrl = '/rop-scrm-sso/router',
biUrl = 'rop-dj-pe-analysis/router'
export default {
login (data = {}) {
data.method = 'scrm.api.sso.ww.bioauth.login'
data.productCode = 'PC00025'
return window.$SCRM_HTTP({
url: ssoUrl,
data,
returnAll: true
})
},
loginByPhone(data = {}){
data.method = 'dj.api.smartcarlife.peAnalysis.loginByPhone'
return window.$DJ_HTTP({
url: biUrl,
data,
// returnAll: true
})
},
}
......@@ -29,13 +29,14 @@ function createRouter () {
routes
})
}
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
store.dispatch('setPageMeta', to.meta)
/* 路由发生变化修改页面背景色 */
document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff'
to.matched.forEach(recode => {
console.log(recode)
// store.dispatch('login')
})
if (to.matched.some(recode => recode.meta.noAuth)) {
console.log('noAuth')
......
......@@ -98,6 +98,16 @@ const pages = {
showAction: true
}
},
{
name: 'authorize',
meta: {
keepAlive: true,
title: '登录授权',
noAuth: true,
backgroundColor: '#f7f8fa',
showAction: true
}
},
]
}
let routes = [
......
......@@ -7,38 +7,130 @@
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { util } from 'utils'
import { util } from 'utils'
import { Http } from 'glsx-common'
import { Notify } from 'vant'
import { ssoApi } from '@/api'
import store from '@/store'
const state = {
showWindow: false
showWindow: false,
lastPath: '',
authorizePage: false,
}
import router from '@/router'
const mutations = {
SET_PAGE_META (state, meta) {
SET_PAGE_META(state, meta) {
state.pageMeta = meta
},
SET_LAST_PATH(state, path) {
state.lastPath = path
},
SET_SHOW_WINDOW(state, showWindow) {
state.showWindow = showWindow
},
SET_AUTHORIZE_PAGE(state, authorizePage) {
state.authorizePage = authorizePage
}
}
const actions = {
setPageMeta ({ commit }, meta) {
setPageMeta({ commit }, meta) {
document.title = meta.title || '企微通知模板'
commit('SET_PAGE_META', meta)
},
registerHttp ({ }, sessionId = '') {
let { scrmRequest, djRequest } = window.$fetchConfig
registerHttp({ }, sessionId = '') {
let { scrmRequest, djRequest } = window.$fetchConfig
window.$SCRM_HTTP = new Http({ ...scrmRequest, alert: Notify })
window.$HTTP = new Http({ ...djRequest, alert: Notify, headers: { token: sessionId } })
window.$HTTP = new Http({ ...djRequest, alert: Notify, headers: { token: sessionId } })
// window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
},
login ({ dispatch }) {
const { corpId, agentId } = util.getLocalStorage('ww_storage_info'),
{ loginUrl } = window.$fetchConfig
window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(window.location.href)}&corpId=${corpId}&agentId=${agentId}`
login({ dispatch, commit, state }) {
//获取当前路由路径
const currentPath = window.location.href;
const pathKeywords = ['/department', '/personage', '/company'];
const isTargetPath = pathKeywords.some(keyword => currentPath.includes(keyword));
// const pathTitleMap = {
// '/department': '美团消费部门月度总结',
// '/personage': '美团消费个人月度总结',
// '/company': '美团消费公司月度总结'
// };
// const matchedPath = Object.keys(pathTitleMap).find(path => currentPath.includes(path));
// if (matchedPath) {
// document.title = pathTitleMap[matchedPath];
// }
const pushId = util.getQuery('pushId');
if (isTargetPath && (pushId && (pushId * 1) > 744)) {
try {
let { corpId, agentId } = util.getQuery();
const wwCode = util.getQuery('code');
let { loginUrl } = window.$fetchConfig;
let userInfo = util.getLocalStorage('ww_userInfo') || '';
if (userInfo && userInfo.timestamp) {
//判断用户时间戳是否过期12小时
if (userInfo.timestamp && (Date.now() - userInfo.timestamp) > (1000 * 60 * 1440)) {
console.log('用户登录过期');
} else {
console.log('用户已经登录');
commit('SET_AUTHORIZE_PAGE', true);
return commit('SET_SHOW_WINDOW', true);
}
}
if (wwCode) {
ssoApi.login({ code: wwCode, corpId, getUserInfoFlag: false }).then(res => {
const { code, data, message } = res;
if (code == "0") {
commit('SET_AUTHORIZE_PAGE', true);
commit('SET_SHOW_WINDOW', true);
const hrefUrl = window.location.href;
const newUrl = hrefUrl.replace(/([?&])code=[^&]*/, (match, prefix) => { return prefix === '?' ? '?' : ''; });
window.history.replaceState({}, '', newUrl);
if (data.loginList && data.loginList.length) {
let [item] = data.loginList
if (item.loginList && item.loginList.length) {
let [userInfo] = item.loginList,
{ phone } = userInfo
if (phone) util.setLocalStorage('ww_params_phone', phone)
//获取当前时间戳
userInfo.timestamp = Date.now();
util.setLocalStorage('ww_userInfo', userInfo);
} else throw ''
} else throw ''
} else {
Notify({ message: message })
commit('SET_SHOW_WINDOW', false);
commit('SET_AUTHORIZE_PAGE', false);
}
})
} else {
commit('SET_AUTHORIZE_PAGE', false);
//是否企微环境
const ua = navigator.userAgent.toLowerCase()
if (Boolean(ua.match(/MicroMessenger/i)) && Boolean(ua.match(/wxwork/i))) {
window.location.href = `${loginUrl}?redirect_uri=${encodeURIComponent(window.location.href)}&corpId=${corpId}&agentId=${agentId}&backLoginCode=BACKCODE`
} else {
Notify({ message: '请使用企业微信打开', duration: 72000000 })
}
}
} catch (error) {
if (!error) error = '登录失败或无权限'
if (error) Notify(typeof error === 'string' ? error : error.toString())
}
} else {
commit('SET_AUTHORIZE_PAGE', true);
commit('SET_SHOW_WINDOW', true);
}
},
navigation ({ dispatch }, to) {
let { corpId, agentId } = getParams()
let userInfo = util.getLocalStorage('ww_userInfo')
navigation({ dispatch, commit }, to) {
let { corpId, agentId, phone, name, id } = util.getQuery(),
userInfo = util.getLocalStorage('ww_userInfo')
if (phone) util.setLocalStorage('ww_params_phone', phone)
if (name) util.setLocalStorage('ww_params_name', name)
if (id) util.setLocalStorage('ww_params_id', id)
dispatch('registerHttp')
if (corpId) {
let ww_storage_info = {}
......@@ -47,23 +139,12 @@ const actions = {
util.setLocalStorage('ww_storage_info', ww_storage_info)
}
if (userInfo) {
state.showWindow = true
commit('SET_SHOW_WINDOW', true)
} else {
util.showLoading()
dispatch('login')
}
},
}
const getParams = name => {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
let obj = {}
param.map(e => {
let [key, value] = e.split('=')
obj[key] = value
})
return name ? obj[name] : obj
}
}
export default {
state,
......
<!-- 公司月度总结 -->
<template>
<div>
<div class="pageBox">{{ pageTitle }}</div>
</div>
</template>
<script>
import { util } from 'utils'
export default {
data() {
return {
pageTitle: '正在登录授权中...',
}
},
mounted() {
const code = this.getParams('code');
if (code) {
this.pageTitle = '授权成功';
const authorizeUrl = util.getLocalStorage('authorizeUrl');
window.location.href = authorizeUrl + '&code=' + code;
} else {
this.pageTitle = '正在登录授权中...'
}
},
methods: {
getParams(name) {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
let obj = {}
param.map(e => {
let [key, value] = e.split('=')
obj[key] = value
})
return name ? obj[name] : obj
}
}
}
</script>
<style lang="scss" scoped>
.pageBox {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<!-- 公司月度总结 -->
<template>
<div class="evection-wrapper">
<div>
<div v-show="$store.state.app.authorizePage" class="evection-wrapper">
<div class="container">
<div class="header">
<div class="title">{{ infoData.monthValue }}月美团线上消费分析报告</div>
......@@ -132,6 +133,8 @@
</div>
</div>
</div>
<div v-show="!$store.state.app.authorizePage" class="loadingBox" ></div>
</div>
</template>
<script>
......@@ -142,6 +145,8 @@ import DataItem from './components/DataItem.vue'
import pieChart from './components/pieChart.vue'
import evectionApi from '@/api/evection'
import { formatNum, formatRatio, formatIsRatio, getIconSrc, getRatioColor } from '@/utils/tools.js'
import store from '@/store'
export default {
components: { StatisticCard, SectionTitle, DataItem, pieChart },
data() {
......@@ -269,6 +274,7 @@ export default {
},
created() {
this.getData()
store.dispatch('login')
},
methods: {
insertBurialPointRecordBatch() {
......@@ -546,4 +552,11 @@ $boxWidth: 351;
// width: formatWidth(145, $boxWidth);
// }
}
.loadingBox{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<!-- 部门月度总结 -->
<template>
<div class="evection-wrapper">
<div>
<div v-show="$store.state.app.authorizePage" class="evection-wrapper">
<div class="container">
<div class="header">
<div class="title">{{ infoData.directOrgName }}{{ infoData.reportDetail && infoData.reportDetail.monthValue }}月美团线上消费分析报告</div>
......@@ -115,6 +116,8 @@
</div>
</div>
</div>
<div v-show="!$store.state.app.authorizePage" class="loadingBox" ></div>
</div>
</template>
<script>
......@@ -125,6 +128,8 @@ import DataItem from './components/DataItem.vue'
import pieChart from './components/pieChart.vue'
import evectionApi from '@/api/evection'
import { formatNum, formatRatio, formatIsRatio, getIconSrc, getRatioColor } from '@/utils/tools.js'
import store from '@/store'
export default {
components: { StatisticCard, SectionTitle, DataItem, pieChart },
data() {
......@@ -258,6 +263,7 @@ export default {
},
created() {
this.getData()
store.dispatch('login')
},
methods: {
......@@ -523,4 +529,11 @@ $boxWidth: 351;
}
}
}
.loadingBox{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<!--个人月度总结 -->
<template>
<div class="evection-wrapper">
<div>
<div v-show="$store.state.app.authorizePage" class="evection-wrapper">
<div class="header">
<div class="title">【{{ infoData.reportDetail.monthValue }}月线上消费明细】您的专属账单已生成</div>
<div class="sub-title">尊敬的{{ infoData.staffName }},您上月美团线上消费情况如下:</div>
......@@ -69,6 +70,8 @@
<div class="tip" style="color: #ff8d1a" v-if="infoData.reportDetail.exceedCount > 0">温馨提示:您本月已超标1次,当月超标3次将有可能暂停招待权!</div>
</div>
</div>
<div v-show="!$store.state.app.authorizePage" class="loadingBox" ></div>
</div>
</template>
<script>
......@@ -77,6 +80,7 @@ import SectionTitle from './components/SectionTitle.vue'
import DataItem from './components/DataItem.vue'
import evectionApi from '@/api/evection'
import { parseTime } from '@/utils/tools.js'
import store from '@/store'
export default {
components: { StatisticCard, SectionTitle, DataItem },
data() {
......@@ -159,6 +163,7 @@ export default {
},
created() {
this.getData()
store.dispatch('login')
},
methods: {
getData() {
......@@ -309,4 +314,11 @@ $boxWidth: 351;
text-align: center;
}
}
.loadingBox{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!