App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <script>
  2. export default {
  3. onLaunch: function(options) {
  4. // console.log('App Launch')
  5. this.accredit(options)
  6. },
  7. onShow: function() {
  8. console.log('App Show')
  9. },
  10. onHide: function() {
  11. console.log('App Hide')
  12. },
  13. methods: {
  14. accredit(options) {
  15. // console.log('\'' + this.$utils.getEncryptedData('token') + '\'')
  16. // console.log('\'' + this.$utils.getEncryptedData('cardNumber') + '\'')
  17. // console.log('\'' + this.$utils.getEncryptedData('errorMsg') + '\'')
  18. var cardNumber = options.query.card_number;
  19. if (!this.$utils.isEmpty(cardNumber)) {
  20. this.$utils.storeEncryptedData('cardNumber', cardNumber);
  21. } else {
  22. cardNumber = this.$utils.getEncryptedData('cardNumber');
  23. if (this.$utils.isEmpty(cardNumber)) {
  24. uni.showToast({
  25. title: '未获得用户信息',
  26. duration: 3000
  27. })
  28. }
  29. }
  30. var token = this.$utils.getEncryptedData('token');
  31. var errorMsg = this.$utils.getEncryptedData('errorMsg');
  32. if (this.$utils.isEmpty(cardNumber) && this.$utils.isEmpty(token) && this.$utils.isEmpty(errorMsg)) {
  33. var url = 'https://chtech.ncjti.edu.cn/hotelReservation/zhotel/appopenid.action';
  34. var encodedUrl = encodeURIComponent(url);
  35. window.location.href = 'https://open.wecard.qq.com/connect/oauth/authorize' +
  36. '?app_key=9FFFACD6D09F15D2' +
  37. '&response_type=code' +
  38. '&scope=snsapi_userinfo' +
  39. '&ocode=1015730314' +
  40. '&redirect_uri=' + encodedUrl +
  41. '&state=' + url;
  42. } else if (this.$utils.isEmpty(cardNumber) && this.$utils.isEmpty(token) && this.$utils.containsString(errorMsg, '失败')) {
  43. uni.navigateTo({
  44. url: '/pages/p404/p404'
  45. })
  46. }
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss">
  52. /*每个页面公共css */
  53. @import '@/uni_modules/uni-scss/index.scss';
  54. /* #ifndef APP-NVUE */
  55. @import '@/static/customicons.css';
  56. // 设置整个项目的背景色
  57. page {
  58. background-color: #f5f5f5;
  59. }
  60. /* #endif */
  61. .example-info {
  62. font-size: 14px;
  63. color: #333;
  64. padding: 10px;
  65. }
  66. </style>