Commit b966d2bc17e80f7516e76040439de45fefffbe93
1 parent
f596a961
Exists in
master
fix:二次回退问题修复
Showing
3 changed files
with
59 additions
and
46 deletions
Show diff stats
src/views/Home/Home.vue
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | {{ schoolNamesChoose.schoolName }}<img src="@/assets/Travel/change.png" /> |
| 13 | 13 | </div> |
| 14 | 14 | </div> |
| 15 | - <p class="phone">{{ phoneDesensitization(userInfo.phone,'*') }}</p> | |
| 15 | + <p class="phone">{{ phoneDesensitization(userInfo.phone, '*') }}</p> | |
| 16 | 16 | </div> |
| 17 | 17 | </div> |
| 18 | 18 | <HomeScan v-if="!isWechat"></HomeScan> |
| ... | ... | @@ -91,7 +91,7 @@ export default { |
| 91 | 91 | showChildList: false, |
| 92 | 92 | showSchool: false, |
| 93 | 93 | schoolNamesChoose: '', |
| 94 | - isWechat:false | |
| 94 | + isWechat: false, | |
| 95 | 95 | } |
| 96 | 96 | }, |
| 97 | 97 | |
| ... | ... | @@ -106,9 +106,9 @@ export default { |
| 106 | 106 | this.schoolNamesChoose = JSON.parse(schoolNamesChoose) |
| 107 | 107 | } |
| 108 | 108 | let isWechat = localStorage.getItem('isWechat') |
| 109 | - if(isWechat==1){ | |
| 110 | - this.isWechat = true | |
| 111 | - } | |
| 109 | + if (isWechat == 1) { | |
| 110 | + this.isWechat = true | |
| 111 | + } | |
| 112 | 112 | this.centerNo = localStorage.getItem('centerNo') |
| 113 | 113 | this.getUserInfo() |
| 114 | 114 | this.againRZ() |
| ... | ... | @@ -183,20 +183,20 @@ export default { |
| 183 | 183 | }, |
| 184 | 184 | //五星少年 |
| 185 | 185 | handleStars() { |
| 186 | - this.$router.push({name: 'stars'}) | |
| 186 | + this.$router.push({ name: 'stars' }) | |
| 187 | 187 | }, |
| 188 | 188 | // 清除缓存 |
| 189 | 189 | handleClearCache() { |
| 190 | 190 | this.$toast.loading({ |
| 191 | - message: '正在清除', | |
| 191 | + message: '清除成功,正在重新登录', | |
| 192 | 192 | duration: 1000, |
| 193 | 193 | forbidClick: true, |
| 194 | 194 | }) |
| 195 | + localStorage.removeItem('schoolNamesChoose') | |
| 196 | + localStorage.removeItem('schoolNames') | |
| 197 | + localStorage.removeItem('centerNo') | |
| 195 | 198 | setTimeout(() => { |
| 196 | - this.$toast('清除成功') | |
| 197 | - localStorage.removeItem('schoolNamesChoose') | |
| 198 | - localStorage.removeItem('schoolNames') | |
| 199 | - this.getUserInfo() | |
| 199 | + this.$router.replace({ path: '/' }) | |
| 200 | 200 | }, 1000) |
| 201 | 201 | }, |
| 202 | 202 | // 获取用户信息 | ... | ... |
src/views/Service/ServiceBaseKQ.vue
| ... | ... | @@ -98,20 +98,6 @@ export default { |
| 98 | 98 | loading: false, |
| 99 | 99 | } |
| 100 | 100 | }, |
| 101 | - watch: { | |
| 102 | - $route: { | |
| 103 | - immediate: true, | |
| 104 | - handler() { | |
| 105 | - // 设置tabbar状态 | |
| 106 | - let showTab = this.$route.query.showTab | |
| 107 | - this.tabName = showTab || 'KQ' | |
| 108 | - // document.title = showTab == 'ZZY' ? '周周营' : '红色网上游——柯桥研学' | |
| 109 | - this.$nextTick(() => { | |
| 110 | - this.$refs.tabs.resize() | |
| 111 | - }) | |
| 112 | - }, | |
| 113 | - }, | |
| 114 | - }, | |
| 115 | 101 | mounted() { |
| 116 | 102 | console.log('base mounted') |
| 117 | 103 | // alert('servicebase show') | ... | ... |
src/views/Service/ServiceKQ.vue
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | <script> |
| 6 | 6 | import ServiceBasekq from './ServiceBaseKQ.vue' |
| 7 | -const userData = require('@/views/answerRank/data.json'); | |
| 7 | +const userData = require('@/views/answerRank/data.json') | |
| 8 | 8 | export default { |
| 9 | 9 | name: 'ServiceKQ', |
| 10 | 10 | data() { |
| ... | ... | @@ -16,29 +16,44 @@ export default { |
| 16 | 16 | mounted() { |
| 17 | 17 | console.log('xst mounted') |
| 18 | 18 | this.checkAuth() |
| 19 | + //二次回退 | |
| 20 | + const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 21 | + const bIsAlipayMini = sUserAgent.indexOf('miniprogram') > -1 && sUserAgent.indexOf('alipay') > -1 | |
| 22 | + if (bIsAlipayMini) { | |
| 23 | + console.log('我来自支付宝,popstate') | |
| 24 | + window.addEventListener('popstate', this.listenerPopstate, true) | |
| 25 | + } else { | |
| 26 | + console.log('我来自浙里办,popstate') | |
| 27 | + window.addEventListener('popstate', this.listenerPopstate, true) | |
| 28 | + } | |
| 19 | 29 | }, |
| 20 | - activated() { | |
| 21 | - console.log('KQ activated') | |
| 22 | - this.checkAuth() | |
| 30 | + //销毁监听 | |
| 31 | + destroyed() { | |
| 32 | + console.log('销毁支付宝监听') | |
| 33 | + window.removeEventListener('popstate', this.listenerPopstate, true) | |
| 23 | 34 | }, |
| 24 | 35 | methods: { |
| 36 | + //支付宝二次回退方法,addEventListener和removeEventListener一定要调用方法,不然无效 | |
| 37 | + listenerPopstate() { | |
| 38 | + ZWJSBridge.close() | |
| 39 | + }, | |
| 25 | 40 | checkAuth() { |
| 26 | 41 | let centerNo = localStorage.getItem('centerNo') |
| 27 | 42 | let ticket = this.common.getUrlParam('ticket') //浙里办app访问 |
| 28 | 43 | let ticketId = this.common.getUrlParam('ticketId') //浙里办微信小程序访问 |
| 29 | 44 | // alert(location.href) |
| 30 | 45 | // alert(ticketId) |
| 31 | - if (ticket) { | |
| 32 | - this.getCenterByTicket(ticket) | |
| 33 | - } else if (ticketId) { | |
| 34 | - // alert('getCenterByTicketId') | |
| 35 | - this.getCenterByTicketId(ticketId) | |
| 36 | - localStorage.setItem('isWechat',1) | |
| 37 | - } else if (centerNo) { | |
| 46 | + if (centerNo) { | |
| 38 | 47 | // alert('有中台编号:' + centerNo) |
| 39 | 48 | this.centerNo = centerNo |
| 40 | 49 | localStorage.setItem('centerNo', centerNo) |
| 41 | 50 | this.getUserInfo() |
| 51 | + } else if (ticket) { | |
| 52 | + this.getCenterByTicket(ticket) | |
| 53 | + } else if (ticketId) { | |
| 54 | + // alert('getCenterByTicketId') | |
| 55 | + this.getCenterByTicketId(ticketId) | |
| 56 | + localStorage.setItem('isWechat', 1) | |
| 42 | 57 | } else { |
| 43 | 58 | const sUserAgent = window.navigator.userAgent.toLowerCase() |
| 44 | 59 | const dtdreamweb = sUserAgent.indexOf('dtdreamweb') > -1 |
| ... | ... | @@ -51,7 +66,7 @@ export default { |
| 51 | 66 | window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` |
| 52 | 67 | } else { |
| 53 | 68 | alert('非浙里办渠道访问,显示测试用户数据') |
| 54 | - console.log('非浙里办渠道访问,显示测试用户数据',userData) | |
| 69 | + console.log('非浙里办渠道访问,显示测试用户数据', userData) | |
| 55 | 70 | this.centerNo = '2022031508525674030748540013076' |
| 56 | 71 | localStorage.setItem('centerNo', '2022031508525674030748540013076') |
| 57 | 72 | let userInfo = JSON.stringify(userData) |
| ... | ... | @@ -125,14 +140,26 @@ export default { |
| 125 | 140 | }, |
| 126 | 141 | reLoad() { |
| 127 | 142 | console.log('reload') |
| 128 | - ZWJSBridge.confirm({ | |
| 129 | - title: '警告', | |
| 130 | - buttonLabels: ['重新载入'], | |
| 131 | - message: '用户身份验证失败,请重新加载', | |
| 132 | - }).then((res) => { | |
| 133 | - const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 134 | - const dtdreamweb = sUserAgent.indexOf('dtdreamweb') > -1 | |
| 135 | - const miniprogram = sUserAgent.indexOf('miniprogram') > -1 && sUserAgent.indexOf('alipay') > -1 | |
| 143 | + const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 144 | + const dtdreamweb = sUserAgent.indexOf('dtdreamweb') > -1 | |
| 145 | + const miniprogram = sUserAgent.indexOf('miniprogram') > -1 && sUserAgent.indexOf('alipay') > -1 | |
| 146 | + if (localStorage.getItem('reloadCount') == 2) { | |
| 147 | + localStorage.setItem('reloadCount', 1) | |
| 148 | + ZWJSBridge.confirm({ | |
| 149 | + title: '警告', | |
| 150 | + buttonLabels: ['重新载入'], | |
| 151 | + message: '用户身份验证失败,请重新加载', | |
| 152 | + }).then((res) => { | |
| 153 | + if (dtdreamweb) { | |
| 154 | + // alert('浙里办') | |
| 155 | + window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
| 156 | + } else if (miniprogram) { | |
| 157 | + // alert('支付宝') | |
| 158 | + window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
| 159 | + } | |
| 160 | + }) | |
| 161 | + } else { | |
| 162 | + localStorage.setItem('reloadCount', 2) | |
| 136 | 163 | if (dtdreamweb) { |
| 137 | 164 | // alert('浙里办') |
| 138 | 165 | window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` |
| ... | ... | @@ -140,7 +167,7 @@ export default { |
| 140 | 167 | // alert('支付宝') |
| 141 | 168 | window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` |
| 142 | 169 | } |
| 143 | - }) | |
| 170 | + } | |
| 144 | 171 | }, |
| 145 | 172 | // 获取用户信息 |
| 146 | 173 | getUserInfo: function() { | ... | ... |