choosePlatform.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="mainBox">
  3. <view class="contentBox">
  4. <image src="../../static/image/logo.png" class="logo"></image>
  5. <view class="logoText">
  6. 快报嗨享平台
  7. </view>
  8. <view class="logoTextNext">
  9. 一个好看有用的平台
  10. </view>
  11. <view class="btnBox">
  12. <view class="btn" v-if="isAuth" @click="toManage()">后台管理</view>
  13. <view class="btn" @click="toSquare()">快报帮</view>
  14. <view class="btn" v-if="isLive" @click="tolive()">打开直播</view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. mapMutations,
  22. mapState
  23. } from 'vuex';
  24. import {
  25. findUserAuth
  26. } from '../../network/api'
  27. export default {
  28. data() {
  29. return {
  30. isAuth: false,
  31. isLogin: false,
  32. isLive: false,
  33. liveId: "sph2Kn7SwRTPGaO"
  34. };
  35. },
  36. mounted() {
  37. const _this = this;
  38. uni.getChannelsLiveInfo({
  39. finderUserName: this.liveId,
  40. success: e => {
  41. _this.isLive = e.status === 2
  42. }
  43. })
  44. },
  45. computed: {
  46. ...mapState(['userInfo'])
  47. },
  48. onShow() {
  49. let user = null;
  50. try {
  51. user = JSON.parse(uni.getStorageSync('userInfo'));
  52. } catch (e) {
  53. //TODO handle the exception
  54. }
  55. if (user) {
  56. this.isLogin = true
  57. this.setUserInfo(user);
  58. this.findAuth()
  59. }
  60. },
  61. methods: {
  62. ...mapMutations(['setUserInfo']),
  63. async findAuth() {
  64. let params = {
  65. 'mobile': this.userInfo.phone,
  66. 'departmentId': 1
  67. }
  68. let res = await findUserAuth(params)
  69. console.log(res);
  70. if (res.data === true) {
  71. this.isAuth = true
  72. }
  73. // if(res.state == 200) {
  74. // this.isAuth = res.data
  75. // }
  76. },
  77. toManage() {
  78. uni.navigateTo({
  79. url: `/pages/managePage/managePage?phone=${this.userInfo.phone}`
  80. });
  81. },
  82. tolive() {
  83. uni.openChannelsLive({
  84. finderUserName: this.liveId,
  85. success() {
  86. console.log("success")
  87. },
  88. fail() {
  89. uni.showToast({
  90. title: '已取消跳转视频号',
  91. duration: 2000,
  92. icon: 'none'
  93. })
  94. }
  95. })
  96. },
  97. toSquare() {
  98. if (this.isLogin) {
  99. uni.navigateTo({
  100. url: '/pages/newsSquare/newsSquare'
  101. });
  102. } else {
  103. uni.navigateTo({
  104. url: '/pages/Login/Login?choose=1'
  105. });
  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: 14px;
  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>