Commit e761f67792c9925e6ec576c1194c1c1de5ea28d8
1 parent
408fe40f
Exists in
master
fix:存在健壮性不足,如链接地址后面加上特殊参数
Showing
3 changed files
with
45 additions
and
36 deletions
Show diff stats
src/common/index.js
... | ... | @@ -2,10 +2,8 @@ var common = function() { |
2 | 2 | return { |
3 | 3 | //取地址参数方法 |
4 | 4 | getUrlParam: function(name) { |
5 | - console.log(name) | |
6 | 5 | var url = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); |
7 | 6 | var newUrl = window.location.search.substr(1).match(url); |
8 | - console.log(window.location) | |
9 | 7 | if (newUrl != null) { |
10 | 8 | return unescape(newUrl[2]); |
11 | 9 | } else { | ... | ... |
src/views/Home/Home.vue
... | ... | @@ -192,7 +192,16 @@ export default { |
192 | 192 | localStorage.removeItem('schoolNames') |
193 | 193 | localStorage.removeItem('centerNo') |
194 | 194 | setTimeout(() => { |
195 | - this.$router.replace({ path: '/' }) | |
195 | + const sUserAgent = window.navigator.userAgent.toLowerCase() | |
196 | + const dtdreamweb = sUserAgent.indexOf('dtdreamweb') > -1 | |
197 | + const miniprogram = sUserAgent.indexOf('miniprogram') > -1 && sUserAgent.indexOf('alipay') > -1 | |
198 | + if (miniprogram) { | |
199 | + // alert('支付宝') | |
200 | + window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
201 | + } else { | |
202 | + // alert('浙里办') | |
203 | + window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
204 | + } | |
196 | 205 | }, 1000) |
197 | 206 | }, |
198 | 207 | // 获取用户信息 | ... | ... |
src/views/Service/ServiceKQ.vue
... | ... | @@ -41,14 +41,12 @@ export default { |
41 | 41 | let centerNo = localStorage.getItem('centerNo') |
42 | 42 | let ticket = this.common.getUrlParam('ticket') //浙里办app访问 |
43 | 43 | let ticketId = this.common.getUrlParam('ticketId') //浙里办微信小程序访问 |
44 | - console.log(ticket,ticketId) | |
45 | - // if (centerNo) { | |
46 | - // // alert('有中台编号:' + centerNo) | |
47 | - // this.centerNo = centerNo | |
48 | - // localStorage.setItem('centerNo', centerNo) | |
49 | - // this.getUserInfo() | |
50 | - // } else | |
51 | - if (ticket) { | |
44 | + if (centerNo) { | |
45 | + // alert('有中台编号:' + centerNo) | |
46 | + this.centerNo = centerNo | |
47 | + localStorage.setItem('centerNo', centerNo) | |
48 | + this.getUserInfo() | |
49 | + } else if (ticket) { | |
52 | 50 | this.getCenterByTicket(ticket) |
53 | 51 | } else if (ticketId) { |
54 | 52 | // alert('getCenterByTicketId') |
... | ... | @@ -78,12 +76,13 @@ export default { |
78 | 76 | // 通过ticket获取centerNo |
79 | 77 | getCenterByTicket(ticket) { |
80 | 78 | this.yxAxios.get(`${this.proxyUrl}/api/third/getCenterNo?ticket=${ticket}`).then((res) => { |
81 | - console.log('通过ticket获取centerNo成功:', res) | |
82 | 79 | if (res.data.code == 200) { |
80 | + console.log('通过ticket获取centerNo成功:', res.data) | |
83 | 81 | this.centerNo = res.data.message |
84 | 82 | localStorage.setItem('centerNo', res.data.message) |
85 | 83 | this.getUserInfo() |
86 | 84 | } else { |
85 | + console.log('通过ticket获取centerNo失败:', res.data.code) | |
87 | 86 | this.reLoad() |
88 | 87 | } |
89 | 88 | }) |
... | ... | @@ -92,12 +91,13 @@ export default { |
92 | 91 | getCenterByTicketId(ticketId) { |
93 | 92 | // alert(ticketId) |
94 | 93 | this.yxAxios.get(`${this.proxyUrl}/api/third/getCenterNoWx?ticket=${ticketId}`).then((res) => { |
95 | - console.log('通过ticket获取centerNo成功:', res) | |
96 | 94 | if (res.data.code == 200) { |
95 | + console.log('通过ticketId获取centerNo成功:', res.data) | |
97 | 96 | this.centerNo = res.data.message |
98 | 97 | localStorage.setItem('centerNo', res.data.message) |
99 | 98 | this.getUserInfo() |
100 | 99 | } else { |
100 | + console.log('通过ticketId获取centerNo失败:', res.data.code) | |
101 | 101 | this.reLoad() |
102 | 102 | } |
103 | 103 | }) |
... | ... | @@ -107,31 +107,34 @@ export default { |
107 | 107 | const sUserAgent = window.navigator.userAgent.toLowerCase() |
108 | 108 | const dtdreamweb = sUserAgent.indexOf('dtdreamweb') > -1 |
109 | 109 | const miniprogram = sUserAgent.indexOf('miniprogram') > -1 && sUserAgent.indexOf('alipay') > -1 |
110 | - if (localStorage.getItem('reloadCount') == 2) { | |
111 | - localStorage.setItem('reloadCount', 1) | |
112 | - ZWJSBridge.confirm({ | |
113 | - title: '警告', | |
114 | - buttonLabels: ['重新载入'], | |
115 | - message: '用户身份验证失败,请重新加载', | |
116 | - }).then((res) => { | |
117 | - if (dtdreamweb) { | |
118 | - // alert('浙里办') | |
119 | - window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
120 | - } else if (miniprogram) { | |
121 | - // alert('支付宝') | |
122 | - window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
123 | - } | |
124 | - }) | |
125 | - } else { | |
126 | - localStorage.setItem('reloadCount', 2) | |
127 | - if (dtdreamweb) { | |
128 | - // alert('浙里办') | |
129 | - window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
130 | - } else if (miniprogram) { | |
110 | + // if (localStorage.getItem('reloadCount') == 2) { | |
111 | + // localStorage.setItem('reloadCount', 1) | |
112 | + // ZWJSBridge.confirm({ | |
113 | + // title: '警告', | |
114 | + // buttonLabels: ['重新载入'], | |
115 | + // message: '用户身份验证失败,请重新加载', | |
116 | + // }).then((res) => { | |
117 | + // if (dtdreamweb) { | |
118 | + // // alert('浙里办') | |
119 | + // window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
120 | + // } else if (miniprogram) { | |
121 | + // // alert('支付宝') | |
122 | + // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
123 | + // } else { | |
124 | + // // alert('浙里办') | |
125 | + // window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
126 | + // } | |
127 | + // }) | |
128 | + // } else { | |
129 | + // localStorage.setItem('reloadCount', 2) | |
130 | + if (miniprogram) { | |
131 | 131 | // alert('支付宝') |
132 | 132 | window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=82a7a71edb794fc285895f9e33290ddc` |
133 | + } else { | |
134 | + // alert('浙里办') | |
135 | + window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=82a7a71edb794fc285895f9e33290ddc` | |
133 | 136 | } |
134 | - } | |
137 | + // } | |
135 | 138 | }, |
136 | 139 | // 获取用户信息 |
137 | 140 | getUserInfo() { |
... | ... | @@ -142,7 +145,6 @@ export default { |
142 | 145 | if (res.data.code == 200) { |
143 | 146 | localStorage.setItem('userInfo', JSON.stringify(res.data.data.userInfo)) |
144 | 147 | this.userInfo = res.data.data.userInfo |
145 | - | |
146 | 148 | } |
147 | 149 | }) |
148 | 150 | }, | ... | ... |