choosePlatform.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <uni-notice-bar @click="toLogin" v-if="!isLogin" single showIcon text="当前未登录,如需提交问题请点击此处登录~">
  4. </uni-notice-bar>
  5. <view class="mainBox">
  6. <view class="contentBox">
  7. <image src="../../static/image/logo.png" class="logo"></image>
  8. <view class="logoText">
  9. 快报嗨享平台
  10. </view>
  11. <view class="logoTextNext">
  12. 一个好看有用的平台
  13. </view>
  14. <view class="btnBox">
  15. <view class="btn" v-if="isAuth" @click="toManage()">后台管理</view>
  16. <view class="btn" @click="toSquare()">快报帮</view>
  17. <view class="btn" v-if="isLive" @click="tolive()">打开直播</view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. mapMutations,
  26. mapState
  27. } from 'vuex';
  28. import {
  29. findUserAuth
  30. } from '../../network/api'
  31. export default {
  32. data() {
  33. return {
  34. isAuth: false,
  35. isLogin: false,
  36. isLive: false,
  37. liveId: "sph2Kn7SwRTPGaO"
  38. };
  39. },
  40. mounted() {
  41. const _this = this;
  42. uni.getChannelsLiveInfo({
  43. finderUserName: _this.liveId,
  44. success: e => {
  45. _this.isLive = e.status === 2
  46. }
  47. })
  48. },
  49. computed: {
  50. ...mapState(['userInfo'])
  51. },
  52. onShow() {
  53. let user = null;
  54. try {
  55. user = JSON.parse(uni.getStorageSync('userInfo'));
  56. } catch (e) {
  57. //TODO handle the exception
  58. }
  59. if (!user) return
  60. this.isLogin = true
  61. this.setUserInfo(user);
  62. this.findAuth()
  63. },
  64. methods: {
  65. ...mapMutations(['setUserInfo']),
  66. async findAuth() {
  67. let params = {
  68. 'mobile': this.userInfo.phone,
  69. 'departmentId': 1
  70. }
  71. let res = await findUserAuth(params)
  72. console.log(res);
  73. if (res.data === true) this.isAuth = true
  74. // if(res.state == 200) {
  75. // this.isAuth = res.data
  76. // }
  77. },
  78. toLogin() {
  79. uni.navigateTo({
  80. url: '/pages/Login/Login?choose=1'
  81. });
  82. },
  83. toManage() {
  84. uni.navigateTo({
  85. url: `/pages/managePage/managePage?phone=${this.userInfo.phone}`
  86. });
  87. },
  88. tolive() {
  89. uni.openChannelsLive({
  90. finderUserName: this.liveId,
  91. success() {
  92. console.log("success")
  93. },
  94. fail() {
  95. uni.showToast({
  96. title: '已取消跳转视频号',
  97. duration: 2000,
  98. icon: 'none'
  99. })
  100. }
  101. })
  102. },
  103. toSquare() {
  104. uni.navigateTo({
  105. url: '/pages/newsSquare/newsSquare'
  106. });
  107. }
  108. }
  109. };
  110. </script>
  111. <style lang="scss" scoped>
  112. .mainBox {
  113. box-sizing: border-box;
  114. width: 100%;
  115. height: 100vh;
  116. display: flex;
  117. justify-content: center;
  118. align-items: center;
  119. .contentBox {
  120. width: 526rpx;
  121. // height: 770rpx;
  122. display: flex;
  123. flex-direction: column;
  124. align-items: center;
  125. .logo {
  126. width: 150px;
  127. height: 150px;
  128. }
  129. .logoText {
  130. margin-top: 30px;
  131. font-size: 18px;
  132. }
  133. .logoTextNext {
  134. margin-top: 15px;
  135. font-size: 20px;
  136. }
  137. .btnBox {
  138. margin-top: auto;
  139. .btn {
  140. width: 526rpx;
  141. height: 44px;
  142. line-height: 40px;
  143. background-color: #007aff;
  144. color: #ffffff;
  145. text-align: center;
  146. margin-top: 72rpx;
  147. border-radius: 30px;
  148. }
  149. }
  150. }
  151. }
  152. </style>