Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-05-26 10:47:35 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ec511d6c06ce68d49e789b1ddb875247f9aa4328
ec511d6c
1 parent
0c37a027
调整push,replace跳转函数,按钮颜色配置调整
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
84 deletions
src/hooks/useGo.js
src/settings/componentSetting.js
src/settings/designSetting.js
src/store/index.js
src/views/client/index.vue
src/hooks/useGo.js
View file @
ec511d6
...
...
@@ -10,3 +10,14 @@ export function useGo () {
}
return
go
}
export
function
useReplace
()
{
let
router
=
useRouter
()
function
replace
(
path
,
query
)
{
router
.
replace
({
path
:
path
,
query
:
query
})
}
return
replace
}
...
...
src/settings/componentSetting.js
0 → 100644
View file @
ec511d6
export
default
{
defaultPageSize
:
10
,
}
src/settings/designSetting.js
0 → 100644
View file @
ec511d6
import
{
ref
}
from
'vue'
;
export
const
styleObject1
=
ref
({
backgroundColor
:
'#FFFFFF'
,
color
:
'#0B3A72'
,
borderColor
:
'#0B3A72'
})
export
const
styleObject2
=
ref
({
backgroundColor
:
'#F9D95C'
,
color
:
'#0B3A72'
,
borderColor
:
'#F9D95C'
})
src/store/index.js
View file @
ec511d6
import
{
defineStore
}
from
'pinia'
;
// import { testStore } from './test'; // 另一个store
import
_
from
'lodash'
;
import
{
useRoute
,
useRouter
}
from
'vue-router'
const
$route
=
useRoute
();
export
const
mainStore
=
defineStore
(
'main'
,
{
state
:
()
=>
{
...
...
@@ -17,9 +20,12 @@ export const mainStore = defineStore('main', {
};
},
getters
:
{
getKeepPages
(
state
)
{
return
state
.
keepPages
}
getKeepPages
()
{
return
this
.
keepPages
},
// getTestStoreList () {
// return testStore().list // 返回另一个store的值
// }
},
actions
:
{
changeState
(
state
)
{
...
...
@@ -46,7 +52,9 @@ export const mainStore = defineStore('main', {
changeKeepPages
()
{
// 清空所有缓存,用一个不存在的值覆盖
this
.
keepPages
=
[
'default'
];
},
keepThisPage
(
page
)
{
// 新增缓存页
keepThisPage
()
{
// 新增缓存页
const
$router
=
useRouter
();
const
page
=
$router
.
currentRoute
.
value
.
meta
.
name
;
this
.
keepPages
.
push
(
page
);
},
removeThisPage
(
page
)
{
// 删除缓存页
...
...
src/views/client/index.vue
View file @
ec511d6
...
...
@@ -20,70 +20,36 @@
<script setup>
import { mainStore } from '@/store'
import Cookies from 'js-cookie'
import 'animate.css';
import icon_subscribed from '@images/icon-dingyue01@2x.png'
import MyButton from '@/components/MyButton/index.vue'
import { onMounted } from 'vue'
import { useGo, useReplace } from '@/hooks/useGo'
// 自定义按钮颜色样式
import { styleObject1, styleObject2 } from '@/settings/designSetting.js'
import $ from 'jquery';
import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router'
import { Toast } from 'vant';
import { nextTick, onMounted, reactive, ref, watch } from 'vue'
import axios from '@/utils/axios';
import { wxInfo } from '@/utils/tools';
const $route = useRoute();
const $router = useRouter();
const go = useGo();
const replace = useReplace();
// TAG: keepAlive 缓存页面
const store = mainStore();
store.keepThisPage($route.meta.name);
// 滚动条判断
function hasScrollbar() {
return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight);
}
store.keepThisPage();
onMounted(() => {
// 判断微信授权状态,进入页面时未授权需要授权跳转
if (!Cookies.get('PHPSESSID')) {
$router.replace({
path: '/auth',
query: {
href: location.hash,
userType: 'c'
}
});
replace('/auth', { href: location.hash, userType: 'c' })
}
// 进入项目自动打开导航栏 微信浏览器 避免样式错位
window.history.pushState({}, "title", "#")
})
// 自定义按钮颜色样式
const styleObject1 = reactive({
backgroundColor: '#FFFFFF',
color: '#0B3A72',
borderColor: '#0B3A72'
})
const styleObject2 = reactive({
backgroundColor: '#F9D95C',
color: '#0B3A72',
borderColor: '#F9D95C'
})
const goVisit = () => { // 跳转爱心书籍页面
$router.push({
path: '/client/chooseBook'
});
go('/client/chooseBook')
Cookies.set('userType', 'visitor'); // 访客标识
}
const goSchool = () => { // 跳转选择幼儿园页面
$router.push({
path: '/client/chooseSchool'
});
go('/client/chooseSchool')
Cookies.set('userType', 'client'); // 客户标识
}
...
...
@@ -95,47 +61,11 @@ const goSchool = () => { // 跳转选择幼儿园页面
// onBeforeRouteLeave(() => {
// clearInterval(interval); // 清除调用
// })
const cancelAuth = () => {
axios.get('/srv/?a=cancel_wx_auth', {
params: {
type: 'cancel'
}
})
.then(res => {
if (res.data.code === 1) {
Toast.success('操作成功')
} else {
console.warn(res);
if (!res.data.show) return false;
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
}
</script>
<script>
import mixin from 'common/mixin'
import { mainStore } from '@/store'
import { storeToRefs } from 'pinia'
export default {
name: 'index',
mixins: [mixin.init],
data() {
return {
}
},
mounted() {
},
methods: {
}
}
</script>
...
...
Please
register
or
login
to post a comment