Commit 6be4bd78e937ce467b76cf8c2b80dbc6d05119a5
1 parent
6efe1a3b
Exists in
master
feat: centerNo获取
Showing
3 changed files
with
52 additions
and
113 deletions
Show diff stats
src/views/PublicHome/HomeKQ.vue
| ... | ... | @@ -77,24 +77,34 @@ export default { |
| 77 | 77 | this.headImgUrl = sessionStorage.getItem('headImgUrl') |
| 78 | 78 | this.nicknameUser = sessionStorage.getItem('nicknameUser') |
| 79 | 79 | |
| 80 | - const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 81 | - alert(sUserAgent) | |
| 82 | - console.log(sUserAgent) | |
| 83 | - const dtdreamweb = sUserAgent.indexOf("dtdreamweb") > -1 | |
| 84 | - const miniprogram = sUserAgent.indexOf("miniprogram") > -1 && sUserAgent.indexOf("alipay") > -1 | |
| 85 | - if (dtdreamweb) { | |
| 86 | - alert('浙里办') | |
| 87 | - // window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=hswsy`; | |
| 88 | - } | |
| 89 | - | |
| 90 | - if (miniprogram) { | |
| 91 | - alert('支付宝') | |
| 92 | - // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`; | |
| 93 | - } | |
| 94 | - sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU') | |
| 95 | - this.getUserInfoXST() | |
| 80 | + alert(location.href) | |
| 81 | + this.checkAuth() | |
| 96 | 82 | }, |
| 97 | 83 | methods: { |
| 84 | + checkAuth () { | |
| 85 | + let centerNo = this.$route.query.center_no || sessionStorage.getItem('centerNo'); | |
| 86 | + if (centerNo) { | |
| 87 | + alert('获取到centerNo,不跳登录') | |
| 88 | + console.log('获取到centerNo,不跳登录') | |
| 89 | + this.centerNo = centerNo | |
| 90 | + sessionStorage.setItem('centerNo', centerNo); | |
| 91 | + } else { | |
| 92 | + const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 93 | + const dtdreamweb = sUserAgent.indexOf("dtdreamweb") > -1 | |
| 94 | + const miniprogram = sUserAgent.indexOf("miniprogram") > -1 && sUserAgent.indexOf("alipay") > -1 | |
| 95 | + if (dtdreamweb) { | |
| 96 | + alert('浙里办') | |
| 97 | + window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=hswsy`; | |
| 98 | + } | |
| 99 | + else if (miniprogram) { | |
| 100 | + alert('支付宝') | |
| 101 | + // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`; | |
| 102 | + } | |
| 103 | + else{ | |
| 104 | + alert('非浙里办或支付宝渠道访问') | |
| 105 | + } | |
| 106 | + } | |
| 107 | + }, | |
| 98 | 108 | // 研学码 |
| 99 | 109 | handleYanxue () { |
| 100 | 110 | let isLogin = this.checkLogin() | ... | ... |
src/views/PublicService/ServiceBaseKQ.vue
| ... | ... | @@ -105,13 +105,6 @@ export default { |
| 105 | 105 | console.log('base activated') |
| 106 | 106 | this.initService() |
| 107 | 107 | }, |
| 108 | - computed: { | |
| 109 | - schoolName() { | |
| 110 | - if(!sessionStorage.getItem('userInfo')) return {schoolName: ''} | |
| 111 | - console.log(JSON.parse(sessionStorage.getItem('userInfo')).schoolName) | |
| 112 | - return JSON.parse(sessionStorage.getItem('userInfo')).schoolName | |
| 113 | - } | |
| 114 | - }, | |
| 115 | 108 | methods: { |
| 116 | 109 | initService(){ |
| 117 | 110 | this.getUniList() |
| ... | ... | @@ -287,32 +280,16 @@ export default { |
| 287 | 280 | }, |
| 288 | 281 | // 我的订单 |
| 289 | 282 | handleMyOrder(){ |
| 290 | - let isLogin = this.checkLogin() | |
| 291 | - if (!isLogin) return; | |
| 292 | 283 | this.$router.push({ name: 'ServiceOrderPublic' }) |
| 293 | 284 | }, |
| 294 | 285 | // 我的优惠券 |
| 295 | 286 | handleMyCard(){ |
| 296 | - let isLogin = this.checkLogin() | |
| 297 | - if (!isLogin) return; | |
| 298 | 287 | this.$router.push({ name: 'ServiceCardBoxPublic' }) |
| 299 | 288 | }, |
| 300 | 289 | // 个人信息 |
| 301 | 290 | handleMyClass(){ |
| 302 | 291 | this.$router.push({ name: 'privateXST' }) |
| 303 | 292 | }, |
| 304 | - // 判断是否已登录 | |
| 305 | - checkLogin () { | |
| 306 | - if (process.env.NODE_ENV != "production") return true; | |
| 307 | - const userInfo = JSON.parse(sessionStorage.getItem('userInfo')) | |
| 308 | - if (!userInfo?.phone) { | |
| 309 | - sessionStorage.setItem('prePage', 'Service' + this.publicName); | |
| 310 | - sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab:this.$route.query.showTab })); | |
| 311 | - this.$router.push({ name: 'LoginPublic', query: { publicName: this.publicName } }) | |
| 312 | - return false; | |
| 313 | - } | |
| 314 | - return true; | |
| 315 | - }, | |
| 316 | 293 | formatWeek(week){ |
| 317 | 294 | return week == 1 ? '周一' : week == 2 ? '周二' : week == 3 ? '周三' : week == 4 ? '周四' : week == 5 ? '周五' : week == 6 ? '周六' : week == 0 ? '周日' : ''; |
| 318 | 295 | }, | ... | ... |
src/views/PublicService/ServiceKQ.vue
| 1 | 1 | <template> |
| 2 | - <service-basekq :centerNo="centerNo" v-if="showData"></service-basekq> | |
| 2 | + <service-basekq :centerNo="centerNo" v-if="centerNo"></service-basekq> | |
| 3 | 3 | </template> |
| 4 | 4 | |
| 5 | 5 | <script> |
| 6 | -// import ServiceBaseKQ from './ServiceBaseKQ.vue' | |
| 7 | 6 | import ServiceBasekq from './ServiceBaseKQ.vue' |
| 8 | -// import vConsole from 'vconsole' | |
| 9 | 7 | export default { |
| 10 | 8 | name: 'ServiceKQ', |
| 11 | 9 | data () { |
| 12 | 10 | return { |
| 13 | 11 | centerNo: '', |
| 14 | - showData: false, | |
| 15 | - publicName: 'KQ', | |
| 16 | - appId: 'wx1305e88d2bc74073', | |
| 17 | 12 | } |
| 18 | 13 | }, |
| 19 | 14 | |
| 20 | 15 | mounted () { |
| 21 | 16 | console.log('xst mounted') |
| 22 | - // sessionStorage.setItem('publicName', this.publicName); | |
| 23 | - // sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab: this.$route.query.showTab })); | |
| 24 | - // sessionStorage.setItem('prePage', 'Service' + this.publicName); | |
| 25 | - // sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU'); | |
| 26 | - const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 27 | - // alert(sUserAgent) | |
| 28 | - console.log(sUserAgent) | |
| 29 | - const dtdreamweb = sUserAgent.indexOf("dtdreamweb") > -1 | |
| 30 | - const miniprogram = sUserAgent.indexOf("miniprogram") > -1 && sUserAgent.indexOf("alipay") > -1 | |
| 31 | - if (dtdreamweb) { | |
| 32 | - alert('浙里办') | |
| 33 | - window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=hswsy`; | |
| 34 | - } | |
| 17 | + this.checkAuth() | |
| 35 | 18 | |
| 36 | - if (miniprogram) { | |
| 37 | - alert('支付宝') | |
| 38 | - // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`; | |
| 39 | - } | |
| 40 | - sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU'); | |
| 41 | - this.$nextTick(() => { | |
| 42 | - this.getUserInfo() | |
| 43 | - }) | |
| 44 | 19 | }, |
| 45 | 20 | activated () { |
| 46 | 21 | console.log('KQ activated') |
| 47 | - sessionStorage.setItem('publicName', this.publicName); | |
| 48 | - sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab: this.$route.query.showTab })); | |
| 49 | - sessionStorage.setItem('prePage', 'Service' + this.publicName); | |
| 50 | - const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 51 | - console.log(sUserAgent) | |
| 52 | - const dtdreamweb = sUserAgent.indexOf("dtdreamweb") > -1 | |
| 53 | - const miniprogram = sUserAgent.indexOf("miniprogram") > -1 && sUserAgent.indexOf("alipay") > -1 | |
| 54 | - if (dtdreamweb) { | |
| 55 | - alert('浙里办') | |
| 56 | - // window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=passp&goto=`; | |
| 57 | - } | |
| 58 | - | |
| 59 | - if (miniprogram) { | |
| 60 | - alert('支付宝') | |
| 61 | - // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`; | |
| 62 | - } | |
| 63 | - sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU'); | |
| 64 | - this.$nextTick(() => { | |
| 65 | - this.getUserInfo() | |
| 66 | - }) | |
| 22 | + this.checkAuth() | |
| 67 | 23 | }, |
| 68 | 24 | methods: { |
| 69 | - // 获取用户信息 | |
| 70 | - getUserInfo () { | |
| 71 | - let userInfo = sessionStorage.getItem('userInfo'); | |
| 72 | - let unionId = sessionStorage.getItem('unionId'); | |
| 73 | - if (userInfo) { | |
| 74 | - userInfo = JSON.parse(userInfo) | |
| 75 | - this.centerNo = userInfo.centerNo | |
| 76 | - this.showData = true; | |
| 25 | + checkAuth () { | |
| 26 | + let centerNo = this.$route.query.center_no || sessionStorage.getItem('centerNo'); | |
| 27 | + if (centerNo) { | |
| 28 | + alert('获取到centerNo,不跳登录') | |
| 29 | + console.log('获取到centerNo,不跳登录') | |
| 30 | + this.centerNo = centerNo | |
| 31 | + sessionStorage.setItem('centerNo', centerNo); | |
| 77 | 32 | } else { |
| 78 | - this.$toast.loading({ | |
| 79 | - message: '加载中...', | |
| 80 | - duration: 0, | |
| 81 | - forbidClick: true | |
| 82 | - }) | |
| 83 | - this.yxAxios.get(`${this.proxyUrl}/prod/api/wx/${this.appId}/getUserInfo?unionId=${unionId}`).then((res) => { | |
| 84 | - this.$toast.clear() | |
| 85 | - if (res.data.code == 200) { | |
| 86 | - this.centerNo = res.data.data.centerNo | |
| 87 | - this.showData = true | |
| 88 | - sessionStorage.setItem('userInfo', JSON.stringify(res.data.data)) | |
| 89 | - } else { | |
| 90 | - console.log('getUserInfo失败') | |
| 91 | - this.showData = true; | |
| 92 | - // this.$router.push({ name: 'LoginPublic', query: { publicName: this.publicName } }) | |
| 93 | - } | |
| 94 | - }) | |
| 33 | + const sUserAgent = window.navigator.userAgent.toLowerCase() | |
| 34 | + const dtdreamweb = sUserAgent.indexOf("dtdreamweb") > -1 | |
| 35 | + const miniprogram = sUserAgent.indexOf("miniprogram") > -1 && sUserAgent.indexOf("alipay") > -1 | |
| 36 | + if (dtdreamweb) { | |
| 37 | + alert('浙里办') | |
| 38 | + window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=hswsy`; | |
| 39 | + } | |
| 40 | + else if (miniprogram) { | |
| 41 | + alert('支付宝') | |
| 42 | + // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`; | |
| 43 | + } | |
| 44 | + else{ | |
| 45 | + alert('非浙里办或支付宝渠道访问') | |
| 46 | + } | |
| 95 | 47 | } |
| 96 | 48 | }, |
| 49 | + | |
| 97 | 50 | }, |
| 98 | 51 | components: { |
| 99 | - ServiceBasekq, | |
| 100 | - // ServiceBaseKQ | |
| 52 | + ServiceBasekq | |
| 101 | 53 | } |
| 102 | 54 | } |
| 103 | 55 | </script> | ... | ... |