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

175 lines
3.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. <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. <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-group.png"></popupUnlock>
  16. </view>
  17. </template>
  18. <script>
  19. import popupUnlock from '../components/popupUnlock.vue'
  20. export default {
  21. components: {
  22. popupUnlock,
  23. },
  24. data() {
  25. return {
  26. detail: {
  27. id: null,
  28. avatarUrl: null,
  29. nickName: null,
  30. imageUrl: null,
  31. times: 10,
  32. qrCode: null,
  33. description: null,
  34. },
  35. isLocked: true,
  36. }
  37. },
  38. onLoad(option) {
  39. const { id } = option
  40. this.fetchDetails(id)
  41. },
  42. onShareAppMessage(res) {
  43. const {
  44. headTitle,
  45. indexImage,
  46. } = this.detail
  47. let o = {
  48. title : headTitle,
  49. imageUrl: indexImage,
  50. query: `id=${this.id}`,
  51. }
  52. // todo: get times and check is unlocked
  53. this.refreshLockStatus()
  54. return o
  55. },
  56. methods: {
  57. async fetchDetails(id) {
  58. try {
  59. this.detail = await this.$fetch('getGroupShareInfo', { id })
  60. } catch (err) {
  61. }
  62. },
  63. async fetchCheckShare(id) {
  64. try {
  65. return await this.$fetch('checkGroupShare', { id }, false)
  66. } catch (err) {
  67. return {}
  68. }
  69. },
  70. async refreshLockStatus() {
  71. const res = await this.fetchCheckShare()
  72. const { result, message } = res
  73. if (result) {
  74. this.isLocked = false
  75. this.$refs.popupUnlock.close();
  76. return
  77. }
  78. message && uni.showToast({
  79. title: message,
  80. icon: 'none'
  81. })
  82. },
  83. openPopup() {
  84. this.$refs.popupUnlock.open();
  85. },
  86. async onAdd() {
  87. const res = await this.fetchCheckShare()
  88. console.log('--res', res)
  89. const { result, message } = res
  90. // todo: check
  91. if (result) { // 转发已达标
  92. this.isLocked = false
  93. return
  94. }
  95. this.openPopup()
  96. }
  97. },
  98. }
  99. </script>
  100. <style scoped lang="scss">
  101. .page {
  102. position: relative;
  103. height: 100vh;
  104. }
  105. .content {
  106. display: flex;
  107. flex-direction: column;
  108. align-items: center;
  109. }
  110. .avatar {
  111. width: 180rpx;
  112. height: 180rpx;
  113. margin-top: 127rpx;
  114. }
  115. .nick-name {
  116. color: #1B1B1B;
  117. font-size: 32rpx;
  118. margin-top: 30rpx;
  119. }
  120. .btn, .group-info {
  121. position: absolute;
  122. }
  123. .btn {
  124. width: calc(100% - 60rpx*2);
  125. height: auto;
  126. left: 60rpx;
  127. bottom: 292rpx;
  128. background-color: #07C160;
  129. border: none;
  130. color: #FFFFFF;
  131. font-size: 28rpx;
  132. line-height: 1;
  133. border-radius: 45rpx;
  134. padding: 25rpx 0;
  135. box-sizing: border-box;
  136. }
  137. .group-info {
  138. bottom: 269rpx;
  139. flex-direction: column;
  140. color: #1B1B1B;
  141. font-size: 32rpx;
  142. }
  143. .qr {
  144. margin-top: 40rpx;
  145. width: 350rpx;
  146. height: 350rpx;
  147. }
  148. </style>