Commit 8066a4a3 by liwk

commit

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