App.vue 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script>
  2. import {
  3. getpayOpenId
  4. } from './utils/api_hotel.js'
  5. // https://chtech.ncjti.edu.cn/hotel/ihotel/auto/appletLogin/login
  6. // https%3A%2F%2Fchtech.ncjti.edu.cn%2Fhotel%2Fh5%2F
  7. export default {
  8. onLaunch: function() {
  9. console.log('App Launch')
  10. // alert(localStorage.getItem('errorMsg')+'token')
  11. if(localStorage.getItem('token')=='null'){
  12. // alert(333)
  13. window.location.href ='https://open.wecard.qq.com/connect/oauth/authorize?app_key=4FD5599032819781&response_type=code&scope=snsapi_userinfo&ocode=1015730314&redirect_uri=https://chtech.ncjti.edu.cn/hotel/ihotel/auto/appletLogin/login&state=https://chtech.ncjti.edu.cn/hotel/ihotel/auto/appletLogin/login';
  14. //// window.location.href ='https://open.wecard.qq.com/connect/oauth/authorize?app_key=4FD5599032819781&response_type=code&scope=snsapi_userinfo&ocode=1015730314&redirect_uri=https://chtech.ncjti.edu.cn/testingServer/ihotel/auto/appletLogin/login&state=https://chtech.ncjti.edu.cn/testingServer/ihotel/auto/appletLogin/login';
  15. }else if(localStorage.getItem('token')=='null' && localStorage.getItem('errorMsg')=='null') {
  16. window.location.href ='https://open.wecard.qq.com/connect/oauth/authorize?app_key=4FD5599032819781&response_type=code&scope=snsapi_userinfo&ocode=1015730314&redirect_uri=https://chtech.ncjti.edu.cn/hotel/ihotel/auto/appletLogin/login&state=https://chtech.ncjti.edu.cn/hotel/ihotel/auto/appletLogin/login';
  17. } else if (localStorage.getItem('token')=='null' && localStorage.getItem('errorMsg')=='获取用户信息失败') {
  18. uni.navigateTo({
  19. url:'pages/huoquanshibai/huoquanshibai'
  20. })
  21. }
  22. // alert((localStorage.getItem('code')=='null'|| localStorage.getItem('code')=='undefined' || localStorage.getItem('code')==null),'2')
  23. if((!localStorage.getItem('openId2')&&localStorage.getItem('code')) || (localStorage.getItem('openId2')=='null'&&localStorage.getItem('code'))){
  24. this.getOpenId()
  25. }else if(localStorage.getItem('code')=='null'|| localStorage.getItem('code')=='undefined' || localStorage.getItem('code')==null){
  26. window.location.href ='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd87cbe1db0437303&redirect_uri=https%3A%2F%2Fchtech.ncjti.edu.cn%2Fhotel%2Fh5%2F&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect';
  27. }
  28. },
  29. methods:{
  30. getOpenId(){
  31. var data='?wxcode='+localStorage.getItem('code')
  32. getpayOpenId(data).then((res) => {
  33. if (res.success) {
  34. localStorage.setItem('openId2',res.message)
  35. } else if(res.code=='500'){
  36. window.location.href ='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd87cbe1db0437303&redirect_uri=https%3A%2F%2Fchtech.ncjti.edu.cn%2Fhotel%2Fh5%2F&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect';
  37. }
  38. }).catch((err) => {
  39. });
  40. }
  41. },
  42. onShow: function() {
  43. console.log('App Show')
  44. },
  45. onHide: function() {
  46. console.log('App Hide')
  47. }
  48. }
  49. </script>
  50. <style lang="scss">
  51. /*每个页面公共css */
  52. @import '@/uni_modules/uni-scss/index.scss';
  53. /* #ifndef APP-NVUE */
  54. @import '@/static/customicons.css';
  55. // 设置整个项目的背景色
  56. page {
  57. background-color: #f5f5f5;
  58. }
  59. /* #endif */
  60. .example-info {
  61. font-size: 14px;
  62. color: #333;
  63. padding: 10px;
  64. }
  65. </style>