Browse Source

如果是通过小程序嵌入页面并且token不存在就跳转至二维码识别页面

feature
mk 8 months ago
parent
commit
c6922afef0
  1. 2
      README.md
  2. BIN
      src/assets/images/home/qrcode.jpg
  3. 15
      src/router/index.js
  4. 5
      src/router/router.config.js
  5. 26
      src/views/scanQrCode/index.vue

2
README.md

@ -6,7 +6,7 @@
然后跑起来之后你本地的域名就会变成epmet-cloud.elinkservice.cn 然后跑起来之后你本地的域名就会变成epmet-cloud.elinkservice.cn
↓↓↓↓ ↓↓↓↓
在你小程序的公众号开发中输入以下网址就能够访问了 在你小程序的公众号开发中输入以下网址就能够访问了
http://epmet-cloud.elinkservice.cn:80/?appId=wx1078fa1e99424de9&redirect=epmet-cloud.elinkservice.cn&houseId=1640692803448688642 http://epmet-test.elinkservice.cn:80/?appId=wx1078fa1e99424de9&redirect=epmet-test.elinkservice.cn&houseId=1640692803448688642
### Node 版本要求 ### Node 版本要求

BIN
src/assets/images/home/qrcode.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

15
src/router/index.js

@ -5,7 +5,7 @@ import { constantRouterMap } from './router.config.js'
import { checkWxmpRegister, login } from '@/api/user' import { checkWxmpRegister, login } from '@/api/user'
import { title } from '@/config' import { title } from '@/config'
const whiteList = ['/login', '/register', '/errorPage','/selectAgency','/houseQR','/event'] const whiteList = ['/login', '/register', '/errorPage','/selectAgency','/houseQR','/event','/scanQrCode']
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) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
@ -57,10 +57,9 @@ router.beforeEach((to, from, next) => {
}else{ }else{
store.commit('SET_HOUSE_ID', null) store.commit('SET_HOUSE_ID', null)
} }
if(urlParams.type && !localStorage.getItem('token') ){ if(urlParams.type && !localStorage.getItem('token')&&to.path !=='/scanQrCode' ){
location.href = 'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzkxNzQ5MzUzNg==&scene=110#wechat_redirect' next('/scanQrCode')
return }else{
}
if (urlParams.appId) { if (urlParams.appId) {
if (localStorage.getItem('appId') && urlParams.appId !== localStorage.getItem('appId')) { if (localStorage.getItem('appId') && urlParams.appId !== localStorage.getItem('appId')) {
localStorage.removeItem('token') localStorage.removeItem('token')
@ -71,7 +70,7 @@ router.beforeEach((to, from, next) => {
} else { } else {
store.commit('SET_APP_ID', localStorage.getItem('appId')) store.commit('SET_APP_ID', localStorage.getItem('appId'))
} }
if (!localStorage.getItem('appId') && to.path !== '/errorPage'&& to.path != '/houseQR') { if (!localStorage.getItem('appId') && to.path !== '/errorPage'&& to.path != '/houseQR' && to.path != '/scanQrCode') {
if(to.path === '/errorPage'){ if(to.path === '/errorPage'){
next('/errorPage') next('/errorPage')
}else{ }else{
@ -99,7 +98,7 @@ router.beforeEach((to, from, next) => {
next({ path: '/login'}) next({ path: '/login'})
}) })
} else { } else {
if (getQueryStringByName('code') && to.path != '/houseQR') { if (getQueryStringByName('code') && to.path != '/houseQR' && to.path != '/scanQrCode') {
login({ wxCode: getQueryStringByName('code'),appId:'wx1078fa1e99424de9'}).then(res => { login({ wxCode: getQueryStringByName('code'),appId:'wx1078fa1e99424de9'}).then(res => {
localStorage.setItem('token', res.data.token) localStorage.setItem('token', res.data.token)
localStorage.setItem('userId', res.data.userH5DTO.id) localStorage.setItem('userId', res.data.userH5DTO.id)
@ -134,6 +133,8 @@ router.beforeEach((to, from, next) => {
} }
} }
} }
}
}) })
function getQueryParams() { function getQueryParams() {

5
src/router/router.config.js

@ -219,6 +219,11 @@ export const constantRouterMap = [
name: 'topicListDetail', name: 'topicListDetail',
component: () => import('@/views/peoSuggestion/topicListDetail.vue'), component: () => import('@/views/peoSuggestion/topicListDetail.vue'),
meta: { title: '专题详情', keepAlive: false } meta: { title: '专题详情', keepAlive: false }
},{
path: '/scanQrCode',
name: 'scanQrCode',
component: () => import('@/views/scanQrCode/index.vue'),
meta: { title: '我的社区', keepAlive: false }
}, },
] ]

26
src/views/scanQrCode/index.vue

@ -0,0 +1,26 @@
<template>
<div class='flex flex-y flex-center2 flex-center1'>
<img src="@/assets/images/home/qrcode.jpg" show-menu-by-longpress="true" style="width: 160px;height: 160px;" alt="">
<h3>长按识别二维码跳转公众号...</h3>
</div>
</template>
<script>
export default {
data() {
return {};
},
created() {},
methods: {},
components:{},
computed:{},
watch: {},
}
</script>
<style lang='less' scoped>
.flex{
height: 100vh;
background: #fff;
}
</style>
Loading…
Cancel
Save