裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
3.8 KiB

  1. <template>
  2. <view class="page">
  3. <navbar leftClick @leftClick="$utils.navigateBack" />
  4. <view class="content">
  5. <image class="avatar" :src="detail.headImage"></image>
  6. <text class="nick-name">{{ detail.headTitle || '' }}</text>
  7. <template v-if="isLocked">
  8. <button class="btn" type="success" @click="onAdd">加入</button>
  9. </template>
  10. <view v-else class="group-info flex">
  11. <text>扫一扫加群主审核进群</text>
  12. <image class="qr" :src="detail.wxCodeImage" :show-menu-by-longpress="true"></image>
  13. </view>
  14. </view>
  15. <loginPopup ref="loginPopup" @login="fetchDetails"/>
  16. <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-group.png"></popupUnlock>
  17. </view>
  18. </template>
  19. <script>
  20. import { mapState } from 'vuex'
  21. import loginPopup from '@/components/config/loginPopup.vue'
  22. import popupUnlock from '../components/popupUnlock.vue'
  23. export default {
  24. components: {
  25. loginPopup,
  26. popupUnlock,
  27. },
  28. data() {
  29. return {
  30. id: null,
  31. detail: {
  32. id: null,
  33. avatarUrl: null,
  34. nickName: null,
  35. imageUrl: null,
  36. times: 10,
  37. qrCode: null,
  38. description: null,
  39. },
  40. isLocked: true,
  41. }
  42. },
  43. computed: {
  44. ...mapState(['userInfo']),
  45. },
  46. onLoad(option) {
  47. const { id, state, shareId } = option
  48. if (shareId) {
  49. uni.setStorageSync('shareId', shareId)
  50. }
  51. if (state) {
  52. uni.setStorageSync('state', state)
  53. }
  54. this.id = id
  55. if(uni.getStorageSync('token')){
  56. this.fetchDetails()
  57. }else{
  58. this.$refs.loginPopup.open()
  59. }
  60. },
  61. onShareAppMessage(res) {
  62. const {
  63. headTitle,
  64. indexImage,
  65. } = this.detail
  66. let o = {
  67. title : headTitle,
  68. imageUrl: indexImage,
  69. query: `id=${this.id}&state=2&shareId=${this.userInfo.id}`,
  70. }
  71. // todo: get times and check is unlocked
  72. this.refreshLockStatus()
  73. return o
  74. },
  75. methods: {
  76. async fetchDetails() {
  77. try {
  78. this.detail = await this.$fetch('getGroupShareInfo', { id: this.id })
  79. } catch (err) {
  80. }
  81. },
  82. async fetchCheckShare(id) {
  83. try {
  84. return await this.$fetch('checkGroupShare', { id })
  85. } catch (err) {
  86. return {}
  87. }
  88. },
  89. async refreshLockStatus() {
  90. const result = await this.fetchCheckShare()
  91. const { title, open } = result
  92. if (open) {
  93. this.isLocked = false
  94. this.$refs.popupUnlock.close();
  95. return
  96. }
  97. title && uni.showToast({
  98. title,
  99. icon: 'none',
  100. duration: 3000
  101. })
  102. },
  103. openPopup() {
  104. this.$refs.popupUnlock.open();
  105. },
  106. async onAdd() {
  107. const result = await this.fetchCheckShare()
  108. const { open } = result
  109. // todo: check
  110. if (open) { // 转发已达标
  111. this.isLocked = false
  112. return
  113. }
  114. this.openPopup()
  115. }
  116. },
  117. }
  118. </script>
  119. <style scoped lang="scss">
  120. .page {
  121. position: relative;
  122. height: 100vh;
  123. }
  124. .content {
  125. display: flex;
  126. flex-direction: column;
  127. align-items: center;
  128. }
  129. .avatar {
  130. width: 180rpx;
  131. height: 180rpx;
  132. margin-top: 127rpx;
  133. }
  134. .nick-name {
  135. color: #1B1B1B;
  136. font-size: 32rpx;
  137. margin-top: 30rpx;
  138. }
  139. .btn, .group-info {
  140. position: absolute;
  141. }
  142. .btn {
  143. width: calc(100% - 60rpx*2);
  144. height: auto;
  145. left: 60rpx;
  146. bottom: 292rpx;
  147. background-color: #07C160;
  148. border: none;
  149. color: #FFFFFF;
  150. font-size: 28rpx;
  151. line-height: 1;
  152. border-radius: 45rpx;
  153. padding: 25rpx 0;
  154. box-sizing: border-box;
  155. }
  156. .group-info {
  157. bottom: 269rpx;
  158. flex-direction: column;
  159. color: #1B1B1B;
  160. font-size: 32rpx;
  161. }
  162. .qr {
  163. margin-top: 40rpx;
  164. width: 350rpx;
  165. height: 350rpx;
  166. }
  167. </style>