choosePlatform.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. uni.getChannelsLiveInfo({
  38. finderUserName: this.liveId,
  39. success: e => {
  40. console.log(e.status)
  41. this.setDate({
  42. isLive: e.status === 2
  43. })
  44. }
  45. })
  46. },
  47. computed: {
  48. ...mapState(['userInfo'])
  49. },
  50. onShow() {
  51. let user = null;
  52. try {
  53. user = JSON.parse(uni.getStorageSync('userInfo'));
  54. } catch (e) {
  55. //TODO handle the exception
  56. }
  57. if (user) {
  58. this.isLogin = true
  59. this.setUserInfo(user);
  60. this.findAuth()
  61. }
  62. },
  63. methods: {
  64. ...mapMutations(['setUserInfo']),
  65. async findAuth() {
  66. let params = {
  67. 'mobile': this.userInfo.phone,
  68. 'departmentId': 1
  69. }
  70. let res = await findUserAuth(params)
  71. console.log(res);
  72. if (res.data === true) {
  73. this.isAuth = true
  74. }
  75. // if(res.state == 200) {
  76. // this.isAuth = res.data
  77. // }
  78. },
  79. toManage() {
  80. uni.navigateTo({
  81. url: `/pages/managePage/managePage?phone=${this.userInfo.phone}`
  82. });
  83. },
  84. tolive() {
  85. uni.openChannelsLive({
  86. finderUserName:this.liveId,
  87. success(){
  88. console.log("success")
  89. },
  90. fail() {
  91. uni.showToast({
  92. title: '已取消跳转视频号',
  93. duration: 2000,
  94. icon: 'none'
  95. })
  96. }
  97. })
  98. },
  99. toSquare() {
  100. if (this.isLogin) {
  101. uni.navigateTo({
  102. url: '/pages/newsSquare/newsSquare'
  103. });
  104. } else {
  105. uni.navigateTo({
  106. url: '/pages/Login/Login?choose=1'
  107. });
  108. }
  109. }
  110. }
  111. };
  112. </script>
  113. <style lang="scss" scoped>
  114. .mainBox {
  115. box-sizing: border-box;
  116. width: 100%;
  117. height: 100vh;
  118. display: flex;
  119. justify-content: center;
  120. align-items: center;
  121. .contentBox {
  122. width: 526rpx;
  123. // height: 770rpx;
  124. display: flex;
  125. flex-direction: column;
  126. align-items: center;
  127. .logo {
  128. width: 150px;
  129. height: 150px;
  130. }
  131. .logoText {
  132. margin-top: 30px;
  133. font-size: 18px;
  134. }
  135. .logoTextNext {
  136. margin-top: 15px;
  137. font-size: 14px;
  138. }
  139. .btnBox {
  140. margin-top: auto;
  141. .btn {
  142. width: 526rpx;
  143. height: 44px;
  144. line-height: 40px;
  145. background-color: #007aff;
  146. color: #ffffff;
  147. text-align: center;
  148. margin-top: 72rpx;
  149. border-radius: 30px;
  150. }
  151. }
  152. }
  153. }
  154. </style>