裂变星小程序-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.

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