dwbsChat.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.level == 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://192.168.2.118:8088?phone=${res.data.mobile}&&openid=${res.data.openid}&&nickname=${res.data.nickname}&&tx=${res.data.headimgurl}`
  42. } else {
  43. uni.showModal({
  44. content: '获取信息失败',
  45. showCancel: false,
  46. success: function(res) {
  47. if (res.confirm) {
  48. uni.reLaunch({
  49. url: '../index/index'
  50. })
  51. }
  52. }
  53. })
  54. }
  55. })
  56. }
  57. if (token && userinfo) {
  58. window.location.href = `http://192.168.2.118:8088?phone=${userinfo.mobile}&&openid=${userinfo.openid}&&nickname=${userinfo.nickname}&&tx=${userinfo.headimgurl}`
  59. } else {
  60. this.toWxchatLogin(`/pages/login-reg/login-reg?type=dwbsChat`, null)
  61. }
  62. },
  63. methods: {
  64. // 跳转微信登录
  65. toWxchatLogin(url, state) {
  66. url = url || '/pages/index/index';
  67. state = state || 'cli';
  68. const redirect_uri = encodeURIComponent(`${this.$config.redirect_uri}/api/gzh#${url}`);
  69. const auth = () =>
  70. (window.location.href = `${this.$config.wxURL}?appid=${
  71. this.$config.appid
  72. }&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`);
  73. auth();
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .course {
  80. width: 100%;
  81. margin: 0 auto;
  82. min-height: 100%;
  83. background: #fff;
  84. }
  85. .card {
  86. width: 702rpx;
  87. margin: 30rpx auto 0;
  88. .card_item {
  89. width: 340rpx;
  90. height: 168rpx;
  91. background: url(../../static/course/bg1.png) no-repeat;
  92. background-size: 100% 100%;
  93. view {
  94. font-size: 34rpx;
  95. color: #fff;
  96. margin-left: 16rpx;
  97. margin-top: -10rpx;
  98. }
  99. }
  100. .card_item:last-child {
  101. background: url(../../static/course/bg2.png) no-repeat;
  102. background-size: 100% 100%;
  103. }
  104. }
  105. .list {
  106. width: 702rpx;
  107. margin: 0 auto;
  108. .title {
  109. border-bottom: 2rpx solid #EEEEEE;
  110. padding: 30rpx 0;
  111. view {
  112. font-size: 36rpx;
  113. font-weight: bold;
  114. }
  115. text {
  116. font-size: 32rpx;
  117. }
  118. }
  119. .list_con {
  120. height: 106rpx;
  121. border-bottom: 2rpx solid #eeeeee;
  122. .chat-icon {
  123. color: #FB231F;
  124. margin-left: 28rpx;
  125. }
  126. .name {
  127. font-size: 36rpx;
  128. font-weight: bold;
  129. }
  130. }
  131. }
  132. </style>