裂变星小程序-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.3 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. // todo: get times and check is unlocked
  83. this.refreshLockStatus()
  84. return o
  85. },
  86. methods: {
  87. async fetchDetails() {
  88. try {
  89. this.detail = await this.$fetch('getGroupShareInfo', { id: this.id })
  90. } catch (err) {
  91. }
  92. },
  93. async fetchCheckShare() {
  94. try {
  95. return await this.$fetch('checkGroupShare', { id: this.id })
  96. } catch (err) {
  97. return {}
  98. }
  99. },
  100. async refreshLockStatus() {
  101. const result = await this.fetchCheckShare()
  102. const { title, open } = result
  103. if (open) {
  104. this.isLocked = false
  105. this.$refs.popupUnlock.close();
  106. return
  107. }
  108. title && uni.showToast({
  109. title,
  110. icon: 'none',
  111. duration: 3000
  112. })
  113. },
  114. openPopup() {
  115. this.$refs.popupUnlock.open();
  116. },
  117. async onAdd() {
  118. const result = await this.fetchCheckShare()
  119. const { open, need_num, num } = result
  120. if (open) { // 转发已达标
  121. this.isLocked = false
  122. return
  123. }
  124. uni.showToast({
  125. title: `还需转发${need_num - num}`,
  126. icon: 'none',
  127. })
  128. this.openPopup()
  129. }
  130. },
  131. }
  132. </script>
  133. <style scoped lang="scss">
  134. .page {
  135. position: relative;
  136. height: 100vh;
  137. }
  138. .content {
  139. display: flex;
  140. flex-direction: column;
  141. align-items: center;
  142. }
  143. .avatar {
  144. width: 180rpx;
  145. height: 180rpx;
  146. margin-top: 127rpx;
  147. }
  148. .nick-name {
  149. color: #1B1B1B;
  150. font-size: 32rpx;
  151. margin-top: 30rpx;
  152. }
  153. .desc {
  154. margin-top: 30rpx;
  155. }
  156. .btn, .group-info {
  157. position: absolute;
  158. }
  159. .btn {
  160. width: calc(100% - 60rpx*2);
  161. height: auto;
  162. left: 60rpx;
  163. bottom: 292rpx;
  164. background-color: #07C160;
  165. border: none;
  166. color: #FFFFFF;
  167. font-size: 28rpx;
  168. line-height: 1;
  169. border-radius: 45rpx;
  170. padding: 25rpx 0;
  171. box-sizing: border-box;
  172. }
  173. .group-info {
  174. bottom: 269rpx;
  175. flex-direction: column;
  176. color: #1B1B1B;
  177. font-size: 32rpx;
  178. }
  179. .qr {
  180. margin-top: 40rpx;
  181. width: 350rpx;
  182. height: 350rpx;
  183. }
  184. </style>