Commit 2ad91cea authored by Facius's avatar Facius

Merge branch 'dev-v1.0.0' of https://git.banshouhui.com/wuzhenzhe/study into dev-v1.0.0

parents 3ce14407 997efc74
...@@ -15256,6 +15256,16 @@ ...@@ -15256,6 +15256,16 @@
"which-boxed-primitive": "^1.0.2" "which-boxed-primitive": "^1.0.2"
} }
}, },
"uni-read-pages": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/uni-read-pages/-/uni-read-pages-1.0.5.tgz",
"integrity": "sha512-GkrrZ0LX0vn9R5k6RKEi0Ez3Q3e2vUpjXQ8Z6/K/d28KudI9ajqgt8WEjQFlG5EPm1K6uTArN8LlqmZTEixDUA=="
},
"uni-simple-router": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/uni-simple-router/-/uni-simple-router-2.0.6.tgz",
"integrity": "sha512-n5gepoT3QcBrvVLeTCY/DjUjC4m1hNzwFlOa1VlCsww/4/34MGfvegpN9OWR8jOxxtUPKGHLAG0yODL/ITCwbw=="
},
"unicode-canonical-property-names-ecmascript": { "unicode-canonical-property-names-ecmascript": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"flyio": "^0.6.2", "flyio": "^0.6.2",
"regenerator-runtime": "^0.12.1", "regenerator-runtime": "^0.12.1",
"uni-read-pages": "^1.0.5",
"uni-simple-router": "^2.0.6",
"vue": "^2.6.11", "vue": "^2.6.11",
"vuex": "^3.2.0" "vuex": "^3.2.0"
}, },
......
...@@ -3,8 +3,6 @@ export default { ...@@ -3,8 +3,6 @@ export default {
onLaunch: function () { onLaunch: function () {
// 版本更新 // 版本更新
this.updateApp() this.updateApp()
// 检查登录是否已过期
this.checkLogin()
}, },
onShow: function () { onShow: function () {
console.log('App Show') console.log('App Show')
...@@ -13,27 +11,6 @@ export default { ...@@ -13,27 +11,6 @@ export default {
console.log('App Hide') console.log('App Hide')
}, },
methods: { methods: {
checkLogin() {
if (this.vuex_token) {
uni.checkSession({
success: (result) => {
//session_key 未过期,并且在本生命周期一直有效
console.log("session未过期", result)
},
fail: (error) => {
// session_key 已经失效,需要重新执行登录流程
console.log("error", error)
this.$u.route({
url: 'pages/login/index'
})
}
})
} else {
this.$u.route({
url: 'pages/login/index'
})
}
},
/* 版本更新 */ /* 版本更新 */
updateApp() { updateApp() {
if (uni.canIUse('getUpdateManager')) { if (uni.canIUse('getUpdateManager')) {
......
...@@ -45,7 +45,7 @@ const install = (Vue, vm) => { ...@@ -45,7 +45,7 @@ const install = (Vue, vm) => {
vm.$u.toast('验证失败,请重新登录'); vm.$u.toast('验证失败,请重新登录');
setTimeout(() => { setTimeout(() => {
// 此为uView的方法,详见路由相关文档 // 此为uView的方法,详见路由相关文档
vm.$u.route('/pages/user/login') vm.$u.route('/pages/login/index')
}, 1500) }, 1500)
return false; return false;
} else { } else {
......
...@@ -2,7 +2,8 @@ import Vue from 'vue' ...@@ -2,7 +2,8 @@ import Vue from 'vue'
import App from './App' import App from './App'
import store from '@/store' import store from '@/store'
import vuexStore from "@/store/$u.mixin.js" import vuexStore from "@/store/$u.mixin.js"
import {router,RouterMount} from './router.js'
Vue.use(router)
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
...@@ -24,4 +25,10 @@ Vue.use(httpInterceptor, app) ...@@ -24,4 +25,10 @@ Vue.use(httpInterceptor, app)
import httpApi from '@/common/http.api.js' import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app) Vue.use(httpApi, app)
// #ifdef H5
RouterMount(app,router,'#app')
// #endif
// #ifndef H5
app.$mount() app.$mount()
// #endif
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/index/index",
"name": "index",
"style": { "style": {
"navigationBarTitleText": "题库", "navigationBarTitleText": "题库",
"navigationStyle": "custom", "navigationStyle": "custom",
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
}, },
{ {
"path": "pages/index/cert", "path": "pages/index/cert",
"name": "cert",
"style": { "style": {
"navigationBarTitleText": "证书", "navigationBarTitleText": "证书",
"navigationStyle": "custom", "navigationStyle": "custom",
...@@ -21,6 +23,7 @@ ...@@ -21,6 +23,7 @@
}, },
{ {
"path": "pages/index/mine", "path": "pages/index/mine",
"name": "mine",
"style": { "style": {
"navigationBarTitleText": "个人中心", "navigationBarTitleText": "个人中心",
"disableScroll": true "disableScroll": true
...@@ -33,6 +36,7 @@ ...@@ -33,6 +36,7 @@
"pages": [ "pages": [
{ {
"path": "index", "path": "index",
"name": "login",
"style": { "style": {
"navigationBarTitleText": "授权登录", "navigationBarTitleText": "授权登录",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
...@@ -46,6 +50,7 @@ ...@@ -46,6 +50,7 @@
"pages": [ "pages": [
{ {
"path": "detail", "path": "detail",
"name": "learnDetail",
"style": { "style": {
"navigationBarTitleText": "题库详情" "navigationBarTitleText": "题库详情"
} }
...@@ -67,6 +72,7 @@ ...@@ -67,6 +72,7 @@
"pages": [ "pages": [
{ {
"path": "detail", "path": "detail",
"name": "certDetail",
"style": { "style": {
"navigationBarTitleText": "证书详情" "navigationBarTitleText": "证书详情"
} }
...@@ -78,8 +84,8 @@ ...@@ -78,8 +84,8 @@
"pages": [ "pages": [
{ {
"path": "customer", "path": "customer",
"name": "mineCustomer",
"style": { "style": {
"navigationStyle": "custom",
"navigationBarTitleText": "联系客服", "navigationBarTitleText": "联系客服",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"disableScroll": true "disableScroll": true
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<u-cell-group> <u-cell-group>
<u-cell-item icon="star" title="个人信息" value="完善度40%"></u-cell-item> <u-cell-item icon="star" title="个人信息" value="完善度40%"></u-cell-item>
<u-cell-item icon="photo" title="我的题库"></u-cell-item> <u-cell-item icon="photo" title="我的题库"></u-cell-item>
<u-cell-item icon="coupon" title="联系客服"></u-cell-item> <u-cell-item icon="coupon" title="联系客服" @tap="toUrl('pages/mine/customer')"></u-cell-item>
<u-cell-item icon="coupon" title="退出登录" @tap="logout"></u-cell-item> <u-cell-item icon="coupon" title="退出登录" @tap="logout"></u-cell-item>
</u-cell-group> </u-cell-group>
</view> </view>
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
url: 'pages/login/index' url: 'pages/login/index'
}) })
}, },
toUrl(url) {
this.$u.route({
url: url
})
},
logout() { logout() {
this.$u.vuex('vuex_token', '') this.$u.vuex('vuex_token', '')
this.$u.vuex('userInfo', {}) this.$u.vuex('userInfo', {})
......
...@@ -18,18 +18,8 @@ export default { ...@@ -18,18 +18,8 @@ export default {
} }
}, },
onShow() { onShow() {
this.checkLogin()
}, },
methods: { methods: {
checkLogin() {
if (this.vuex_token) {
uni.checkSession({
success: (result) => {
this.$u.route({ type: 'back' })
}
})
}
},
wxLogin() { wxLogin() {
// 获取code 小程序专有,用户登录凭证。 // 获取code 小程序专有,用户登录凭证。
uni.getUserProfile({ uni.getUserProfile({
......
<template>
<view class="content">
<view>
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '我的客服'
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin: 200rpx auto 50rpx auto;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
import { RouterMount, createRouter } from 'uni-simple-router'
import store from '@/store/index.js'
const router = createRouter({
platform: process.env.VUE_APP_PLATFORM,
routes: [...ROUTES],
})
// 检测登录白名单,无需登录也可访问的页面
const whiteList = ['index', 'cert', 'mine', 'login']
// 全局路由前置守卫
router.beforeEach((to, from, next) => {
const token = store.state.vuex_token
// 进入需要授权的页面,未登录跳转
if (!whiteList.includes(to.name) && !token) {
next({ name: 'login', NAVTYPE: 'push' })
}
next()
})
// 全局路由后置守卫
router.afterEach((to, from) => {
console.log('跳转结束')
})
export { router, RouterMount }
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
module.exports = {
configureWebpack: {
plugins: [
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true )
})
]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment