choosePlatform.vue 2.8 KB

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