dwbsChat.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view>
  3. <div>
  4. 跳转中...
  5. </div>
  6. <!-- <div>
  7. token: {{ this.$store.state.app.token }}
  8. </div>
  9. <div>
  10. userinfo: {{ this.$store.state.userinfo }}
  11. </div> -->
  12. </view>
  13. </template>
  14. <script>
  15. import { _API_GetUserStatus } from '@/apis/user.js'
  16. export default {
  17. data() {
  18. return {
  19. }
  20. },
  21. onLoad(option) {
  22. const token = this.$store.state.app.token
  23. const userinfo = this.$store.state.userinfo
  24. if (option == 'dwbsChat') { // 从登录页进入
  25. _API_GetUserStatus().then(res => {
  26. if (res.code === 200) {
  27. if (res.data.user_type == 1) {
  28. const that = this
  29. uni.showModal({
  30. content: '抱歉,您没有权限进入系统',
  31. showCancel: false,
  32. success: function(res) {
  33. if (res.confirm) {
  34. that.$store.commit('app/LOGOUT')
  35. that.toWxchatLogin(`/pages/login-reg/login-reg`, null)
  36. }
  37. }
  38. })
  39. return
  40. }
  41. window.location.href = `http://s-chat.cliu.cc?phone=${res.data.mobile}`
  42. // window.location.href = `http://s-chat.cliu.cc?phone=${res.data.mobile}&&openid=${res.data.openid}&&nickname=${res.data.nickname}&&tx=${res.data.headimgurl}`
  43. } else {
  44. uni.showModal({
  45. content: '获取信息失败',
  46. showCancel: false,
  47. success: function(res) {
  48. if (res.confirm) {
  49. uni.reLaunch({
  50. url: '../index/index'
  51. })
  52. }
  53. }
  54. })
  55. }
  56. })
  57. }
  58. if (token && userinfo) {
  59. window.location.href = `http://s-chat.cliu.cc?phone=${userinfo.mobile}`
  60. } else {
  61. this.toWxchatLogin(`/pages/login-reg/login-reg?type=dwbsChat`, null)
  62. }
  63. },
  64. methods: {
  65. // 跳转微信登录
  66. toWxchatLogin(url, state) {
  67. url = url || '/pages/index/index';
  68. state = state || 'cli';
  69. const redirect_uri = encodeURIComponent(`${this.$config.redirect_uri}/api/gzh#${url}`);
  70. const auth = () =>
  71. (window.location.href = `${this.$config.wxURL}?appid=${
  72. this.$config.appid
  73. }&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`);
  74. auth();
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .course {
  81. width: 100%;
  82. margin: 0 auto;
  83. min-height: 100%;
  84. background: #fff;
  85. }
  86. .card {
  87. width: 702rpx;
  88. margin: 30rpx auto 0;
  89. .card_item {
  90. width: 340rpx;
  91. height: 168rpx;
  92. background: url(../../static/course/bg1.png) no-repeat;
  93. background-size: 100% 100%;
  94. view {
  95. font-size: 34rpx;
  96. color: #fff;
  97. margin-left: 16rpx;
  98. margin-top: -10rpx;
  99. }
  100. }
  101. .card_item:last-child {
  102. background: url(../../static/course/bg2.png) no-repeat;
  103. background-size: 100% 100%;
  104. }
  105. }
  106. .list {
  107. width: 702rpx;
  108. margin: 0 auto;
  109. .title {
  110. border-bottom: 2rpx solid #EEEEEE;
  111. padding: 30rpx 0;
  112. view {
  113. font-size: 36rpx;
  114. font-weight: bold;
  115. }
  116. text {
  117. font-size: 32rpx;
  118. }
  119. }
  120. .list_con {
  121. height: 106rpx;
  122. border-bottom: 2rpx solid #eeeeee;
  123. .chat-icon {
  124. color: #FB231F;
  125. margin-left: 28rpx;
  126. }
  127. .name {
  128. font-size: 36rpx;
  129. font-weight: bold;
  130. }
  131. }
  132. }
  133. </style>