Commit 8066a4a3 by liwk

commit

1 parent 2aa6cc65
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"autoprefixer": "^8.0.0", "autoprefixer": "^8.0.0",
"core-js": "^3.6.4", "core-js": "^3.6.4",
"dayjs": "^1.10.5", "dayjs": "^1.10.5",
"glsx-common": "^1.4.6", "glsx-common": "^1.4.8",
"lib-flexible": "^0.3.2", "lib-flexible": "^0.3.2",
"postcss-loader": "^6.2.0", "postcss-loader": "^6.2.0",
"sha1": "^1.1.1", "sha1": "^1.1.1",
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
"vconsole": "^3.7.0", "vconsole": "^3.7.0",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-router": "^3.2.0", "vue-router": "^3.2.0",
"vuex": "^3.4.0" "vuex": "^3.4.0",
"webpack-spritesmith": "^1.1.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-babel": "~4.5.0",
......
const url = '/rop-scrm-sso/router'
const returnAll = false
export default { export default {
/**OAuth2授权登陆 */ /**OAuth2授权登陆 */
login(data) { login(data) {
data.returnAll = true
data.method = 'scrm.api.sso.ww.oauth.login' data.method = 'scrm.api.sso.ww.oauth.login'
return window.$HTTP({ data }) return window.$HTTP({
url,
data,
returnAll
})
}, },
/** 选择登录账号 */ /** 选择登录账号 */
selectAccount(data) { selectAccount(data) {
data.returnAll = true
data.method = 'scrm.api.sso.user.login.select' data.method = 'scrm.api.sso.user.login.select'
return window.$HTTP({ data }) return window.$HTTP({
url,
data,
returnAll
})
} }
} }
\ No newline at end of file \ No newline at end of file
/** -------slide-left begin**/ /** -------slide-left begin**/
.slide-left-enter { .slide-left-enter {
opacity: 0; opacity: 0;
-webkit-transform: translate($translateLength, 0); -webkit-transform: translate($translateLength, 0);
transform: translate($translateLength, 0); transform: translate($translateLength, 0);
} }
.slide-left-leave-to { .slide-left-leave-to {
opacity: 0; opacity: 0;
-webkit-transform: translate(-$translateLength, 0); -webkit-transform: translate(-$translateLength, 0);
...@@ -14,31 +15,56 @@ ...@@ -14,31 +15,56 @@
.slide-left-enter-active { .slide-left-enter-active {
transition: all $animateDuration ease; transition: all $animateDuration ease;
} }
.slide-left-leave-active { .slide-left-leave-active {
transition: all $animateDuration ease; transition: all $animateDuration ease;
} }
/** -------slide-left end**/ /** -------slide-left end**/
/** -------slide-right begin**/ /** -------slide-right begin**/
.slide-right-enter { .slide-right-enter {
opacity: 0; opacity: 0;
-webkit-transform: translate(-$translateLength, 0); -webkit-transform: translate(-$translateLength, 0);
transform: translate(-$translateLength, 0); transform: translate(-$translateLength, 0);
} }
.slide-right-leave-to { .slide-right-leave-to {
opacity: 0; opacity: 0;
-webkit-transform: translate($translateLength, 0); -webkit-transform: translate($translateLength, 0);
transform: translate($translateLength, 0); transform: translate($translateLength, 0);
} }
.slide-right-enter-active { .slide-right-enter-active {
transition: all $animateDuration ease; transition: all $animateDuration ease;
} }
.slide-right-leave-active { .slide-right-leave-active {
transition: all 0.1s ease; transition: all 0.1s ease;
} }
/** -------slide-right end**/ /** -------slide-right end**/
.flip-list-move { .flip-list-move {
transition: transform $animateDuration; transition: transform $animateDuration;
} }
// 路由淡入淡出
.fade-enter-active,
.fade-leave-active {
transition-property: opacity;
transition-duration: .3s;
}
.fade-enter-active {
transition-delay: .3s;
}
.fade-enter,
.fade-leave-active {
opacity: 0;
}
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
@import './animate.scss'; @import './animate.scss';
@import './iconfont.scss'; @import './iconfont.scss';
@import './vant.scss'; @import './vant.scss';
@import './sprite.scss';
html, html,
body .app { body .app {
color: #333333; color: #333333;
......
.sprite-icon { background-image: url(../images/sprite.png);background-size: 190px 140px;}
.icon-0 { width: 40px; height: 40px; background-position: 0px 0px;}
.icon-1 { width: 40px; height: 40px; background-position: -50px 0px;}
.icon-2 { width: 40px; height: 40px; background-position: 0px -50px;}
.icon-3 { width: 40px; height: 40px; background-position: -50px -50px;}
.icon-4 { width: 40px; height: 40px; background-position: -100px 0px;}
.icon-5 { width: 40px; height: 40px; background-position: -100px -50px;}
.icon-6 { width: 40px; height: 40px; background-position: 0px -100px;}
.icon-7 { width: 40px; height: 40px; background-position: -50px -100px;}
.icon-8 { width: 40px; height: 40px; background-position: -100px -100px;}
.icon-9 { width: 40px; height: 40px; background-position: -150px 0px;}
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
:key="index" :key="index"
replace replace
:to="`/${i.name}`" :to="`/${i.name}`"
:icon="i.icon"
:name="i.name" :name="i.name"
>{{i.title}}</van-tabbar-item> >{{i.title}}</van-tabbar-item>
</template> </template>
...@@ -43,19 +42,27 @@ export default { ...@@ -43,19 +42,27 @@ export default {
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped> <style scoped lang='scss'>
h3 { .van-tabbar {
margin: 40px 0 0; background: linear-gradient(180deg, #ffffff 0%, #ffffff 100%);
} box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.04);
ul { border-radius: 16px 16px 0px 0px;
list-style-type: none; overflow: hidden;
padding: 0; &::after {
} width: 1px;
li { height: 34px;
display: inline-block; background: #e9e9e9;
margin: 0 10px; position: absolute;
} left: 50%;
a { top: 8px;
color: #42b983; transform: translateX(-50%);
content: '';
}
.van-tabbar-item--active {
color: #5850ff;
}
.van-tabbar-item {
font-size: 16px;
}
} }
</style> </style>
...@@ -45,11 +45,17 @@ fetchConfig(!isMock).then(res => { ...@@ -45,11 +45,17 @@ fetchConfig(!isMock).then(res => {
// 从配置服务器获取动态配置 // 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn // 设置 js中可以访问 $cdn
Vue.use(cfg) Vue.use(cfg)
window.$HTTP = new Http({...res }) window.$HTTP = new Http({...res, alert: components.Notify })
/**登录过期 重新登录 */
window.reLogin = () => {
console.log(123)
}
window.vm = new Vue({ window.vm = new Vue({
el: '#app', el: '#app',
router, router,
store, store,
render: h => h(App) render: h => h(App)
}) })
store.dispatch('navigation', router)
}) })
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,6 @@ import Vue from 'vue' ...@@ -10,7 +10,6 @@ import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import routes from './routes' import routes from './routes'
import store from '@/store' import store from '@/store'
import util from '@/utils/util'
// hack router push callback // hack router push callback
const originalPush = Router.prototype.push const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) { Router.prototype.push = function push(location, onResolve, onReject) {
...@@ -34,39 +33,12 @@ function createRouter() { ...@@ -34,39 +33,12 @@ function createRouter() {
} }
// http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main/ // http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main/
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
let loginToken = util.getLocalStorage('dj_scrm_loginToken')
let userInfo = util.getLocalStorage('dj_scrm_userInfo')
let accountList = util.getLocalStorage('dj_scrm_accountList')
if (to.name != 'common.accountList') store.commit('SET_LAST_PATH', to.name) if (to.name != 'common.accountList') store.commit('SET_LAST_PATH', to.name)
/* 路由发生变化修改页面title */ /* 路由发生变化修改页面title */
store.dispatch('setPageMeta', to.meta) store.dispatch('setPageMeta', to.meta)
/* 路由发生变化修改页面背景色 */ /* 路由发生变化修改页面背景色 */
store.dispatch('setPageBackground', to.meta) store.dispatch('setPageBackground', to.meta)
if (to.matched.some(recode => recode.meta.noAuth)) { next()
next()
} else {
if (to.path == '/common/accountList') {
if (!loginToken && !userInfo) {
store.dispatch('login')
return
} else {
next()
}
} else {
if (!userInfo) {
if (loginToken && accountList) {
next({ name: 'accountList', replace: true })
return
} else {
store.dispatch('login')
return
}
} else {
next()
return
}
}
}
}) })
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
import { ssoApi } from '@/api' import { ssoApi } from '@/api'
import { store } from 'utils' import { store } from 'utils'
import util from '@/utils/util' import util from '@/utils/util'
import { Toast } from 'vant'
const state = { const state = {
pageMeta: '', pageMeta: '',
keepAlives: [], keepAlives: [],
...@@ -83,6 +82,7 @@ const actions = { ...@@ -83,6 +82,7 @@ const actions = {
}).then(({ code, data, message }) => { }).then(({ code, data, message }) => {
let url = `${redirectUrl.split('#')[0]}#/` let url = `${redirectUrl.split('#')[0]}#/`
let route = state.lastPath == 'home' ? '' : state.lastPath let route = state.lastPath == 'home' ? '' : state.lastPath
state.appFlag = true
if (code == '0') { if (code == '0') {
console.log(data) console.log(data)
if (data.loginList.length) { if (data.loginList.length) {
...@@ -94,7 +94,7 @@ const actions = { ...@@ -94,7 +94,7 @@ const actions = {
let [userInfo] = data.loginList let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo) util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setLocalStorage('dj_scrm_session_id', userInfo.sessionId) util.setLocalStorage('dj_scrm_session_id', userInfo.sessionId)
// 只有一个账号 // 只有一个账号 history.back()
window.location.replace(`${url}${route}`) window.location.replace(`${url}${route}`)
} }
} else { } else {
...@@ -108,12 +108,7 @@ const actions = { ...@@ -108,12 +108,7 @@ const actions = {
} }
}) })
} else { } else {
Toast({ util.showLoading()
type: 'loading',
message: '加载中...',
forbidClick: true,
duration: 0
})
let corpId = getParams('corpId') //从链接获取 let corpId = getParams('corpId') //从链接获取
if (!corpId) corpId = 'ww7ee69c648ae1b7e6' if (!corpId) corpId = 'ww7ee69c648ae1b7e6'
util.setLocalStorage('dj_scrm_corpId', corpId) util.setLocalStorage('dj_scrm_corpId', corpId)
...@@ -121,8 +116,24 @@ const actions = { ...@@ -121,8 +116,24 @@ const actions = {
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize' const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.replace(`${wxUrl}?appid=${corpId}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`) window.location.replace(`${wxUrl}?appid=${corpId}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`)
} }
},
navigation({ dispatch }, router) {
util.showLoading()
let loginToken = util.getLocalStorage('dj_scrm_loginToken')
let userInfo = util.getLocalStorage('dj_scrm_userInfo')
let accountList = util.getLocalStorage('dj_scrm_accountList')
if (!userInfo) {
if (loginToken && accountList) {
state.appFlag = true
router.replace({ name: 'common.accountList' })
return
} else {
dispatch('login')
return
}
}
state.appFlag = true
} }
} }
const getParams = name => { const getParams = name => {
let [url, paramsList] = window.location.href.split('?') let [url, paramsList] = window.location.href.split('?')
......
...@@ -43,13 +43,17 @@ const throttle = (fn, gapTime) => { ...@@ -43,13 +43,17 @@ const throttle = (fn, gapTime) => {
} }
} }
/**防止重复点击 */ /**防止重复点击 */
const showLoading = (title = '加载中...') => { const showLoading = (title = '加载中...', callBack, custom) => {
Toast({ Toast({
type: 'loading', type: 'loading',
message: title, message: title,
forbidClick: true, forbidClick: true,
duration: 0 duration: 0
}) })
if (callBack && typeof callBack == 'function') {
if (!custom) Toast.clear()
callBack()
}
} }
const hideLoading = () => { const hideLoading = () => {
Toast.clear() Toast.clear()
......
...@@ -45,41 +45,41 @@ export default { ...@@ -45,41 +45,41 @@ export default {
}, },
methods: { methods: {
choose (e) { choose (e) {
this.showLoading() this.showLoading('', () => {
let loginToken = this.getLocalStorage('dj_scrm_loginToken') let loginToken = this.getLocalStorage('dj_scrm_loginToken')
let { merchantId, accountName } = e let { merchantId, accountName } = e
let loginAccount = accountName let loginAccount = accountName
ssoApi.selectAccount({
ssoApi.selectAccount({ loginAccount,
loginAccount, merchantId,
merchantId, loginToken,
loginToken, loginSource: 'WW',
loginSource: 'WW', loginType: 3
loginType: 3 }).then(({ code, data }) => {
}).then(({ code, data }) => { this.hideLoading()
this.hideLoading() this.removeLocalStorage('dj_scrm_loginToken')
this.removeLocalStorage('dj_scrm_loginToken') this.removeLocalStorage('dj_scrm_accountList')
this.removeLocalStorage('dj_scrm_accountList') if (code == '0') {
if (code == '0') { if (data) {
if (data) { let { lastPath } = this.getQuery()
let { lastPath } = this.getQuery() this.setLocalStorage('dj_scrm_userInfo', data)
this.setLocalStorage('dj_scrm_userInfo', data) this.setLocalStorage('dj_scrm_session_id', data.sessionId)
this.setLocalStorage('dj_scrm_session_id', data.sessionId) this.showLoading('登录成功', () => {
this.showToast('登录成功', () => { this.$router.replace({ name: lastPath || 'home' })
this.$router.replace({ name: lastPath || 'home' }) })
}
} else {
Dialog.alert({
title: '温馨提示',
message: '登录失败,请重试',
confirmButtonColor: '#FF7336',
confirmButtonText: '重试'
}).then(() => {
store.dispatch('login')
}) })
} }
} else { })
Dialog.alert({ }, true)
title: '温馨提示',
message: '登录失败,请重试',
confirmButtonColor: '#FF7336',
confirmButtonText: '重试'
}).then(() => {
store.dispatch('login')
})
}
})
} }
} }
} }
......
<!-- home --> <!-- home -->
<template> <template>
<div class="container"> <div class="container">
<keep-alive v-if="$route.meta.keepAlive"> <template v-if="appFlag">
<router-view></router-view> <transition name="fade">
</keep-alive> <keep-alive v-if="$route.meta.keepAlive">
<router-view v-else></router-view> <router-view></router-view>
<template v-if="$route.meta.isTab"> </keep-alive>
<tab-bar :data="tabList"></tab-bar> </transition>
<transition name="fade">
<router-view v-if="!$route.meta.keepAlive"></router-view>
</transition>
<template v-if="$route.meta.isTab">
<tab-bar :data="tabList"></tab-bar>
</template>
</template> </template>
</div> </div>
</template> </template>
...@@ -18,18 +24,29 @@ export default { ...@@ -18,18 +24,29 @@ export default {
{ {
title: '我的待办', title: '我的待办',
name: 'home', name: 'home',
icon: 'home-o'
}, },
{ {
title: '工作台', title: '工作台',
name: 'workbench', name: 'workbench',
icon: 'home-o'
} }
], ],
appFlag: false,
}
},
watch: {
watchFlag: {
immediate: true,
handler (newval) {
this.appFlag = newval
this.hideLoading()
}
}
},
computed: {
watchFlag () {
return this.$store.state.app.appFlag
} }
}, },
computed: {},
mounted () { mounted () {
...@@ -39,10 +56,4 @@ export default { ...@@ -39,10 +56,4 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.van-tabbar {
box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.1), 0px 0px 0px 0px #e5e5e5;
.van-tabbar-item--active {
color: #5850ff;
}
}
</style> </style>
<template> <template>
<div class="layout"> <div class="layout">
<div class="utils-box"> <div class="box">
<template v-for="(i,index) in utilsList">
<div
:key="index"
class="item"
>
<div :class="['sprite-icon',`icon-${index}`]"></div>
{{i.name}}
</div>
</template>
</div>
<div class="title">营销转化</div>
<div class="box">
<template v-for="(i,index) in list"> <template v-for="(i,index) in list">
<div <div
:key="index" :key="index"
class="item" class="item"
> >
<img src="@/assets/images/test.jpg"> <div :class="['sprite-icon',`icon-${index + 4}`]"></div>
{{i.name}} {{i.name}}
</div> </div>
</template> </template>
</div> </div>
<div class="title">引流获客</div>
<div class="box box-half">
<div class="item">
<div class="sprite-icon icon-7"></div>
活码引流
</div>
</div>
<div class="title">留客锁客</div>
<div class="box box-half">
<div class="item">
<div class="sprite-icon icon-8"></div>
门店套餐
</div>
</div>
<div class="title">统计分析</div>
<div class="box box-half">
<div class="item">
<div class="sprite-icon icon-9"></div>
门店报表
</div>
</div>
</div> </div>
</template> </template>
...@@ -19,7 +52,7 @@ export default { ...@@ -19,7 +52,7 @@ export default {
name: '', name: '',
data () { data () {
return { return {
list: [ utilsList: [
{ {
name: '核销卡券' name: '核销卡券'
}, },
...@@ -32,6 +65,17 @@ export default { ...@@ -32,6 +65,17 @@ export default {
{ {
name: '商品中心' name: '商品中心'
} }
],
list: [
{
name: '我要发券'
},
{
name: '秒杀活动'
},
{
name: '直播活动'
}
] ]
} }
}, },
...@@ -44,25 +88,48 @@ export default { ...@@ -44,25 +88,48 @@ export default {
<style scoped lang='scss'> <style scoped lang='scss'>
.layout { .layout {
padding-top: 16px; padding: 16px;
.utils-box { .title {
font-weight: 500;
font-size: 16px;
color: #4a4a4a;
padding: 16px 0 10px;
}
&::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 52px;
background: linear-gradient(180deg, #7069ff 0%, #5850ff 100%);
border-radius: 0px 0px 16px 16px;
content: '';
z-index: -1;
}
.box {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
align-items: center; align-items: center;
height: 100px; min-height: 84px;
border-radius: 20px; background: #ffffff;
background-color: #fff; box-shadow: 0px 2px 4px 0px rgba(206, 209, 222, 0.12), 0px 2px 8px 0px rgba(206, 209, 222, 0.4);
margin: 0 16px; border-radius: 4px;
box-sizing: border-box;
color: #333;
font-size: 12px;
.item { .item {
display: flex; display: flex;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
img { .sprite-icon {
width: 40px; margin-bottom: 7px;
height: 40px;
} }
} }
} }
.box-half {
width: 50%;
justify-content: center;
grid-template-columns: repeat(1, 1fr);
}
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -36,8 +36,22 @@ const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV) ...@@ -36,8 +36,22 @@ const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
// } // }
// } // }
/**
* 雪碧图插件
*/
const SpritesmithPlugin = require('webpack-spritesmith')
const spritesmithFunction = data => {
let { spritesheet, sprites } = data
let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}`
let perSprite = sprites.map(sprite => {
let { name, width, height, offset_x, offset_y } = sprite
return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}`
}).join('\n')
return `${shared}\n${perSprite}`
}
module.exports = { module.exports = {
publicPath: './', // 署应用包时的基本 URL。 vue-router hash 模式使用 publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router history模式使用 微信开发环境需打开 // publicPath: '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router history模式使用 微信开发环境需打开
outputDir: 'dist', // 生产环境构建文件的目录 outputDir: 'dist', // 生产环境构建文件的目录
assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录 assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
...@@ -81,12 +95,43 @@ module.exports = { ...@@ -81,12 +95,43 @@ module.exports = {
}, },
configureWebpack: config => { configureWebpack: config => {
config.name = name config.name = name
config.resolve.modules = ['node_modules', './src/assets/spritesmith']
// 为生产环境修改配置... const Plugins = [
// if (IS_PROD) { new SpritesmithPlugin({
// // externals // 引入图片文件夹
// config.externals = externals src: {
// } cwd: path.resolve(__dirname, './src/assets/spritesmith'),
glob: ['*.png', '*.jpg']
},
// 生成图片的路径
target: {
image: path.resolve(__dirname, './src/assets/images/sprite.png'),
// 生成SCSS
css: [
[path.resolve(__dirname, './src/assets/css/sprite.scss'), {
format: 'function_based_template'
}]
]
},
customTemplates: {
'function_based_template': spritesmithFunction,
},
//background引用路径
apiOptions: {
cssImageRef: '../images/sprite.png'
},
// 每个图片间距
spritesmithOptions: {
padding: 20
}
})
]
config.plugins = [...config.plugins, ...Plugins]
// 为生产环境修改配置...
// if (IS_PROD) {
// // externals
// config.externals = externals
// }
}, },
chainWebpack: config => { chainWebpack: config => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!