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

207 lines
4.0 KiB

4 months ago
4 months ago
  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. if (id) {
  56. uni.setStorageSync('id', id)
  57. }
  58. this.id = id
  59. if(uni.getStorageSync('token')){
  60. this.fetchDetails()
  61. }else{
  62. this.$refs.loginPopup.open()
  63. }
  64. },
  65. onShareAppMessage(res) {
  66. const {
  67. headTitle,
  68. indexImage,
  69. } = this.detail
  70. let o = {
  71. title : headTitle,
  72. imageUrl: indexImage,
  73. query: `id=${this.id}&state=2&shareId=${this.userInfo.id}`,
  74. }
  75. // todo: get times and check is unlocked
  76. this.refreshLockStatus()
  77. return o
  78. },
  79. methods: {
  80. async fetchDetails() {
  81. try {
  82. this.detail = await this.$fetch('getGroupShareInfo', { id: this.id })
  83. } catch (err) {
  84. }
  85. },
  86. async fetchCheckShare(id) {
  87. try {
  88. return await this.$fetch('checkGroupShare', { id })
  89. } catch (err) {
  90. return {}
  91. }
  92. },
  93. async refreshLockStatus() {
  94. const result = await this.fetchCheckShare()
  95. const { title, open } = result
  96. if (open) {
  97. this.isLocked = false
  98. this.$refs.popupUnlock.close();
  99. return
  100. }
  101. title && uni.showToast({
  102. title,
  103. icon: 'none',
  104. duration: 3000
  105. })
  106. },
  107. openPopup() {
  108. this.$refs.popupUnlock.open();
  109. },
  110. async onAdd() {
  111. const result = await this.fetchCheckShare()
  112. const { open } = result
  113. // todo: check
  114. if (open) { // 转发已达标
  115. this.isLocked = false
  116. return
  117. }
  118. this.openPopup()
  119. }
  120. },
  121. }
  122. </script>
  123. <style scoped lang="scss">
  124. .page {
  125. position: relative;
  126. height: 100vh;
  127. }
  128. .content {
  129. display: flex;
  130. flex-direction: column;
  131. align-items: center;
  132. }
  133. .avatar {
  134. width: 180rpx;
  135. height: 180rpx;
  136. margin-top: 127rpx;
  137. }
  138. .nick-name {
  139. color: #1B1B1B;
  140. font-size: 32rpx;
  141. margin-top: 30rpx;
  142. }
  143. .desc {
  144. margin-top: 30rpx;
  145. }
  146. .btn, .group-info {
  147. position: absolute;
  148. }
  149. .btn {
  150. width: calc(100% - 60rpx*2);
  151. height: auto;
  152. left: 60rpx;
  153. bottom: 292rpx;
  154. background-color: #07C160;
  155. border: none;
  156. color: #FFFFFF;
  157. font-size: 28rpx;
  158. line-height: 1;
  159. border-radius: 45rpx;
  160. padding: 25rpx 0;
  161. box-sizing: border-box;
  162. }
  163. .group-info {
  164. bottom: 269rpx;
  165. flex-direction: column;
  166. color: #1B1B1B;
  167. font-size: 32rpx;
  168. }
  169. .qr {
  170. margin-top: 40rpx;
  171. width: 350rpx;
  172. height: 350rpx;
  173. }
  174. </style>