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

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