Showing
5 changed files
with
49 additions
and
84 deletions
| ... | @@ -10,3 +10,14 @@ export function useGo () { | ... | @@ -10,3 +10,14 @@ export function useGo () { |
| 10 | } | 10 | } |
| 11 | return go | 11 | return go |
| 12 | } | 12 | } |
| 13 | + | ||
| 14 | +export function useReplace () { | ||
| 15 | + let router = useRouter() | ||
| 16 | + function replace (path, query) { | ||
| 17 | + router.replace({ | ||
| 18 | + path: path, | ||
| 19 | + query: query | ||
| 20 | + }) | ||
| 21 | + } | ||
| 22 | + return replace | ||
| 23 | +} | ... | ... |
src/settings/componentSetting.js
0 → 100644
src/settings/designSetting.js
0 → 100644
| 1 | import { defineStore } from 'pinia'; | 1 | import { defineStore } from 'pinia'; |
| 2 | +// import { testStore } from './test'; // 另一个store | ||
| 2 | import _ from 'lodash'; | 3 | import _ from 'lodash'; |
| 4 | +import { useRoute, useRouter } from 'vue-router' | ||
| 5 | +const $route = useRoute(); | ||
| 3 | 6 | ||
| 4 | export const mainStore = defineStore('main', { | 7 | export const mainStore = defineStore('main', { |
| 5 | state: () => { | 8 | state: () => { |
| ... | @@ -17,9 +20,12 @@ export const mainStore = defineStore('main', { | ... | @@ -17,9 +20,12 @@ export const mainStore = defineStore('main', { |
| 17 | }; | 20 | }; |
| 18 | }, | 21 | }, |
| 19 | getters: { | 22 | getters: { |
| 20 | - getKeepPages (state) { | 23 | + getKeepPages () { |
| 21 | - return state.keepPages | 24 | + return this.keepPages |
| 22 | - } | 25 | + }, |
| 26 | + // getTestStoreList () { | ||
| 27 | + // return testStore().list // 返回另一个store的值 | ||
| 28 | + // } | ||
| 23 | }, | 29 | }, |
| 24 | actions: { | 30 | actions: { |
| 25 | changeState (state) { | 31 | changeState (state) { |
| ... | @@ -46,7 +52,9 @@ export const mainStore = defineStore('main', { | ... | @@ -46,7 +52,9 @@ export const mainStore = defineStore('main', { |
| 46 | changeKeepPages () { // 清空所有缓存,用一个不存在的值覆盖 | 52 | changeKeepPages () { // 清空所有缓存,用一个不存在的值覆盖 |
| 47 | this.keepPages = ['default']; | 53 | this.keepPages = ['default']; |
| 48 | }, | 54 | }, |
| 49 | - keepThisPage (page) { // 新增缓存页 | 55 | + keepThisPage () { // 新增缓存页 |
| 56 | + const $router = useRouter(); | ||
| 57 | + const page = $router.currentRoute.value.meta.name; | ||
| 50 | this.keepPages.push(page); | 58 | this.keepPages.push(page); |
| 51 | }, | 59 | }, |
| 52 | removeThisPage (page) { // 删除缓存页 | 60 | removeThisPage (page) { // 删除缓存页 | ... | ... |
| ... | @@ -20,70 +20,36 @@ | ... | @@ -20,70 +20,36 @@ |
| 20 | 20 | ||
| 21 | <script setup> | 21 | <script setup> |
| 22 | import { mainStore } from '@/store' | 22 | import { mainStore } from '@/store' |
| 23 | - | ||
| 24 | import Cookies from 'js-cookie' | 23 | import Cookies from 'js-cookie' |
| 25 | import 'animate.css'; | 24 | import 'animate.css'; |
| 26 | -import icon_subscribed from '@images/icon-dingyue01@2x.png' | ||
| 27 | - | ||
| 28 | import MyButton from '@/components/MyButton/index.vue' | 25 | import MyButton from '@/components/MyButton/index.vue' |
| 26 | +import { onMounted } from 'vue' | ||
| 27 | +import { useGo, useReplace } from '@/hooks/useGo' | ||
| 28 | +// 自定义按钮颜色样式 | ||
| 29 | +import { styleObject1, styleObject2 } from '@/settings/designSetting.js' | ||
| 29 | 30 | ||
| 30 | -import $ from 'jquery'; | 31 | +const go = useGo(); |
| 31 | -import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router' | 32 | +const replace = useReplace(); |
| 32 | -import { Toast } from 'vant'; | ||
| 33 | -import { nextTick, onMounted, reactive, ref, watch } from 'vue' | ||
| 34 | -import axios from '@/utils/axios'; | ||
| 35 | - | ||
| 36 | -import { wxInfo } from '@/utils/tools'; | ||
| 37 | - | ||
| 38 | -const $route = useRoute(); | ||
| 39 | -const $router = useRouter(); | ||
| 40 | 33 | ||
| 41 | // TAG: keepAlive 缓存页面 | 34 | // TAG: keepAlive 缓存页面 |
| 42 | const store = mainStore(); | 35 | const store = mainStore(); |
| 43 | -store.keepThisPage($route.meta.name); | 36 | +store.keepThisPage(); |
| 44 | - | ||
| 45 | -// 滚动条判断 | ||
| 46 | -function hasScrollbar() { | ||
| 47 | - return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight); | ||
| 48 | -} | ||
| 49 | 37 | ||
| 50 | onMounted(() => { | 38 | onMounted(() => { |
| 51 | // 判断微信授权状态,进入页面时未授权需要授权跳转 | 39 | // 判断微信授权状态,进入页面时未授权需要授权跳转 |
| 52 | if (!Cookies.get('PHPSESSID')) { | 40 | if (!Cookies.get('PHPSESSID')) { |
| 53 | - $router.replace({ | 41 | + replace('/auth', { href: location.hash, userType: 'c' }) |
| 54 | - path: '/auth', | ||
| 55 | - query: { | ||
| 56 | - href: location.hash, | ||
| 57 | - userType: 'c' | ||
| 58 | - } | ||
| 59 | - }); | ||
| 60 | } | 42 | } |
| 61 | // 进入项目自动打开导航栏 微信浏览器 避免样式错位 | 43 | // 进入项目自动打开导航栏 微信浏览器 避免样式错位 |
| 62 | window.history.pushState({}, "title", "#") | 44 | window.history.pushState({}, "title", "#") |
| 63 | }) | 45 | }) |
| 64 | 46 | ||
| 65 | -// 自定义按钮颜色样式 | ||
| 66 | -const styleObject1 = reactive({ | ||
| 67 | - backgroundColor: '#FFFFFF', | ||
| 68 | - color: '#0B3A72', | ||
| 69 | - borderColor: '#0B3A72' | ||
| 70 | -}) | ||
| 71 | -const styleObject2 = reactive({ | ||
| 72 | - backgroundColor: '#F9D95C', | ||
| 73 | - color: '#0B3A72', | ||
| 74 | - borderColor: '#F9D95C' | ||
| 75 | -}) | ||
| 76 | - | ||
| 77 | const goVisit = () => { // 跳转爱心书籍页面 | 47 | const goVisit = () => { // 跳转爱心书籍页面 |
| 78 | - $router.push({ | 48 | + go('/client/chooseBook') |
| 79 | - path: '/client/chooseBook' | ||
| 80 | - }); | ||
| 81 | Cookies.set('userType', 'visitor'); // 访客标识 | 49 | Cookies.set('userType', 'visitor'); // 访客标识 |
| 82 | } | 50 | } |
| 83 | const goSchool = () => { // 跳转选择幼儿园页面 | 51 | const goSchool = () => { // 跳转选择幼儿园页面 |
| 84 | - $router.push({ | 52 | + go('/client/chooseSchool') |
| 85 | - path: '/client/chooseSchool' | ||
| 86 | - }); | ||
| 87 | Cookies.set('userType', 'client'); // 客户标识 | 53 | Cookies.set('userType', 'client'); // 客户标识 |
| 88 | } | 54 | } |
| 89 | 55 | ||
| ... | @@ -95,47 +61,11 @@ const goSchool = () => { // 跳转选择幼儿园页面 | ... | @@ -95,47 +61,11 @@ const goSchool = () => { // 跳转选择幼儿园页面 |
| 95 | // onBeforeRouteLeave(() => { | 61 | // onBeforeRouteLeave(() => { |
| 96 | // clearInterval(interval); // 清除调用 | 62 | // clearInterval(interval); // 清除调用 |
| 97 | // }) | 63 | // }) |
| 98 | - | ||
| 99 | -const cancelAuth = () => { | ||
| 100 | - axios.get('/srv/?a=cancel_wx_auth', { | ||
| 101 | - params: { | ||
| 102 | - type: 'cancel' | ||
| 103 | - } | ||
| 104 | - }) | ||
| 105 | - .then(res => { | ||
| 106 | - if (res.data.code === 1) { | ||
| 107 | - Toast.success('操作成功') | ||
| 108 | - } else { | ||
| 109 | - console.warn(res); | ||
| 110 | - if (!res.data.show) return false; | ||
| 111 | - Toast({ | ||
| 112 | - icon: 'close', | ||
| 113 | - message: res.data.msg | ||
| 114 | - }); | ||
| 115 | - } | ||
| 116 | - }) | ||
| 117 | - .catch(err => { | ||
| 118 | - console.error(err); | ||
| 119 | - }) | ||
| 120 | -} | ||
| 121 | </script> | 64 | </script> |
| 122 | 65 | ||
| 123 | <script> | 66 | <script> |
| 124 | -import mixin from 'common/mixin' | ||
| 125 | -import { mainStore } from '@/store' | ||
| 126 | -import { storeToRefs } from 'pinia' | ||
| 127 | export default { | 67 | export default { |
| 128 | name: 'index', | 68 | name: 'index', |
| 129 | - mixins: [mixin.init], | ||
| 130 | - data() { | ||
| 131 | - return { | ||
| 132 | - } | ||
| 133 | - }, | ||
| 134 | - mounted() { | ||
| 135 | - }, | ||
| 136 | - methods: { | ||
| 137 | - | ||
| 138 | - } | ||
| 139 | } | 69 | } |
| 140 | </script> | 70 | </script> |
| 141 | 71 | ... | ... |
-
Please register or login to post a comment